Loading src/sunrise6g_opensdk/network/adapters/oai/client.py +10 −25 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ import requests from sunrise6g_opensdk import logger from sunrise6g_opensdk.network.adapters.errors import NetworkPlatformError from sunrise6g_opensdk.network.core import common, schemas from sunrise6g_opensdk.network.core import schemas from sunrise6g_opensdk.network.core.base_network_client import BaseNetworkClient from sunrise6g_opensdk.network.core.schemas import ( AsSessionWithQoSSubscription, Loading Loading @@ -306,9 +306,7 @@ class NetworkManager(BaseNetworkClient): ) # Extract location info (handle both key names) location_info = report_data.get("locationInfo") or report_data.get( "locationInformation" ) location_info = report_data.get("locationInfo") or report_data.get("locationInformation") if not location_info: raise NetworkPlatformError( "Location information not found in OAI NEF monitoring event report" Loading @@ -318,9 +316,7 @@ class NetworkManager(BaseNetworkClient): event_time_raw = report_data.get("eventTime") or report_data.get("timeStamp") if event_time_raw: if isinstance(event_time_raw, str): event_time = datetime.fromisoformat( event_time_raw.replace("Z", "+00:00") ) event_time = datetime.fromisoformat(event_time_raw.replace("Z", "+00:00")) else: event_time = event_time_raw else: Loading @@ -345,9 +341,7 @@ class NetworkManager(BaseNetworkClient): if isinstance(nr_age, (int, float)): age_minutes = int(nr_age) last_location_time = self._compute_camara_last_location_time( event_time, age_minutes ) last_location_time = self._compute_camara_last_location_time(event_time, age_minutes) log.debug(f"OAI Last Location time is {last_location_time}") # --- Build CAMARA area from available location data --- Loading Loading @@ -379,8 +373,7 @@ class NetworkManager(BaseNetworkClient): return schemas.Location(area=area, lastLocationTime=last_location_time) raise NetworkPlatformError( f"No usable location data in OAI NEF response. " f"locationInfo: {location_info}" f"No usable location data in OAI NEF response. " f"locationInfo: {location_info}" ) @staticmethod Loading @@ -391,12 +384,8 @@ class NetworkManager(BaseNetworkClient): Supports both 3GPP standard keys (lat/lon) and verbose keys (latitude/longitude) for forward-compatibility. """ lat = float( point_data.get("lat", point_data.get("latitude", 0)) ) lon = float( point_data.get("lon", point_data.get("longitude", 0)) ) lat = float(point_data.get("lat", point_data.get("latitude", 0))) lon = float(point_data.get("lon", point_data.get("longitude", 0))) return lat, lon @staticmethod Loading Loading @@ -455,9 +444,7 @@ class NetworkManager(BaseNetworkClient): elif "uncertaintyEllipse" in geo_area: # POINT_UNCERTAINTY_ELLIPSE – use the semi-major axis ellipse = geo_area["uncertaintyEllipse"] uncertainty = float( ellipse.get("semiMajor", ellipse.get("uncertainty", 0)) ) uncertainty = float(ellipse.get("semiMajor", ellipse.get("uncertainty", 0))) elif "uncertaintyAltitude" in geo_area: # POINT_ALTITUDE_UNCERTAINTY – horizontal uncertainty uncertainty = float(geo_area.get("uncertainty", 0)) Loading Loading @@ -488,9 +475,7 @@ class NetworkManager(BaseNetworkClient): for c in coords ] if len(camara_points) < 3: raise NetworkPlatformError( "Polygon geographic area requires at least 3 points" ) raise NetworkPlatformError("Polygon geographic area requires at least 3 points") return schemas.Polygon( areaType=schemas.AreaType.polygon, boundary=schemas.PointList(camara_points), Loading src/sunrise6g_opensdk/network/core/base_network_client.py +1 −3 Original line number Diff line number Diff line Loading @@ -248,9 +248,7 @@ class BaseNetworkClient: subscription_3gpp.ipv4Addr = ( device.ipv4Address.root.publicAddress.root if device.ipv4Address else None ) subscription_3gpp.ipv6Addr = ( device.ipv6Address.root if device.ipv6Address else None ) subscription_3gpp.ipv6Addr = device.ipv6Address.root if device.ipv6Address else None return subscription_3gpp Loading tests/network/aoi_location_retrieval_test.py +5 −4 Original line number Diff line number Diff line Loading @@ -48,9 +48,7 @@ camara_payload_by_ip = RetrievalLocationRequest( ) # Identify by phone number (valid E.164 MSISDN format) camara_payload_by_phone = RetrievalLocationRequest( device=Device(phoneNumber="+10010100002") ) camara_payload_by_phone = RetrievalLocationRequest(device=Device(phoneNumber="+10010100002")) # ============================================================ Loading Loading @@ -330,7 +328,10 @@ class TestParseLocationResponseRealCoordinates: "cellId": "cell-001", "userLocation": { "nrLocation": { "ncgi": {"nrCellId": "000000001", "plmnId": {"mcc": "001", "mnc": "01"}}, "ncgi": { "nrCellId": "000000001", "plmnId": {"mcc": "001", "mnc": "01"}, }, "tai": {"tac": "0001", "plmnId": {"mcc": "001", "mnc": "01"}}, } }, Loading Loading
src/sunrise6g_opensdk/network/adapters/oai/client.py +10 −25 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ import requests from sunrise6g_opensdk import logger from sunrise6g_opensdk.network.adapters.errors import NetworkPlatformError from sunrise6g_opensdk.network.core import common, schemas from sunrise6g_opensdk.network.core import schemas from sunrise6g_opensdk.network.core.base_network_client import BaseNetworkClient from sunrise6g_opensdk.network.core.schemas import ( AsSessionWithQoSSubscription, Loading Loading @@ -306,9 +306,7 @@ class NetworkManager(BaseNetworkClient): ) # Extract location info (handle both key names) location_info = report_data.get("locationInfo") or report_data.get( "locationInformation" ) location_info = report_data.get("locationInfo") or report_data.get("locationInformation") if not location_info: raise NetworkPlatformError( "Location information not found in OAI NEF monitoring event report" Loading @@ -318,9 +316,7 @@ class NetworkManager(BaseNetworkClient): event_time_raw = report_data.get("eventTime") or report_data.get("timeStamp") if event_time_raw: if isinstance(event_time_raw, str): event_time = datetime.fromisoformat( event_time_raw.replace("Z", "+00:00") ) event_time = datetime.fromisoformat(event_time_raw.replace("Z", "+00:00")) else: event_time = event_time_raw else: Loading @@ -345,9 +341,7 @@ class NetworkManager(BaseNetworkClient): if isinstance(nr_age, (int, float)): age_minutes = int(nr_age) last_location_time = self._compute_camara_last_location_time( event_time, age_minutes ) last_location_time = self._compute_camara_last_location_time(event_time, age_minutes) log.debug(f"OAI Last Location time is {last_location_time}") # --- Build CAMARA area from available location data --- Loading Loading @@ -379,8 +373,7 @@ class NetworkManager(BaseNetworkClient): return schemas.Location(area=area, lastLocationTime=last_location_time) raise NetworkPlatformError( f"No usable location data in OAI NEF response. " f"locationInfo: {location_info}" f"No usable location data in OAI NEF response. " f"locationInfo: {location_info}" ) @staticmethod Loading @@ -391,12 +384,8 @@ class NetworkManager(BaseNetworkClient): Supports both 3GPP standard keys (lat/lon) and verbose keys (latitude/longitude) for forward-compatibility. """ lat = float( point_data.get("lat", point_data.get("latitude", 0)) ) lon = float( point_data.get("lon", point_data.get("longitude", 0)) ) lat = float(point_data.get("lat", point_data.get("latitude", 0))) lon = float(point_data.get("lon", point_data.get("longitude", 0))) return lat, lon @staticmethod Loading Loading @@ -455,9 +444,7 @@ class NetworkManager(BaseNetworkClient): elif "uncertaintyEllipse" in geo_area: # POINT_UNCERTAINTY_ELLIPSE – use the semi-major axis ellipse = geo_area["uncertaintyEllipse"] uncertainty = float( ellipse.get("semiMajor", ellipse.get("uncertainty", 0)) ) uncertainty = float(ellipse.get("semiMajor", ellipse.get("uncertainty", 0))) elif "uncertaintyAltitude" in geo_area: # POINT_ALTITUDE_UNCERTAINTY – horizontal uncertainty uncertainty = float(geo_area.get("uncertainty", 0)) Loading Loading @@ -488,9 +475,7 @@ class NetworkManager(BaseNetworkClient): for c in coords ] if len(camara_points) < 3: raise NetworkPlatformError( "Polygon geographic area requires at least 3 points" ) raise NetworkPlatformError("Polygon geographic area requires at least 3 points") return schemas.Polygon( areaType=schemas.AreaType.polygon, boundary=schemas.PointList(camara_points), Loading
src/sunrise6g_opensdk/network/core/base_network_client.py +1 −3 Original line number Diff line number Diff line Loading @@ -248,9 +248,7 @@ class BaseNetworkClient: subscription_3gpp.ipv4Addr = ( device.ipv4Address.root.publicAddress.root if device.ipv4Address else None ) subscription_3gpp.ipv6Addr = ( device.ipv6Address.root if device.ipv6Address else None ) subscription_3gpp.ipv6Addr = device.ipv6Address.root if device.ipv6Address else None return subscription_3gpp Loading
tests/network/aoi_location_retrieval_test.py +5 −4 Original line number Diff line number Diff line Loading @@ -48,9 +48,7 @@ camara_payload_by_ip = RetrievalLocationRequest( ) # Identify by phone number (valid E.164 MSISDN format) camara_payload_by_phone = RetrievalLocationRequest( device=Device(phoneNumber="+10010100002") ) camara_payload_by_phone = RetrievalLocationRequest(device=Device(phoneNumber="+10010100002")) # ============================================================ Loading Loading @@ -330,7 +328,10 @@ class TestParseLocationResponseRealCoordinates: "cellId": "cell-001", "userLocation": { "nrLocation": { "ncgi": {"nrCellId": "000000001", "plmnId": {"mcc": "001", "mnc": "01"}}, "ncgi": { "nrCellId": "000000001", "plmnId": {"mcc": "001", "mnc": "01"}, }, "tai": {"tac": "0001", "plmnId": {"mcc": "001", "mnc": "01"}}, } }, Loading