diff --git a/kura/org.eclipse.kura.nm/src/main/java/org/eclipse/kura/nm/NMDbusConnector.java b/kura/org.eclipse.kura.nm/src/main/java/org/eclipse/kura/nm/NMDbusConnector.java index cf3a4fa1ad5..23a365abebb 100644 --- a/kura/org.eclipse.kura.nm/src/main/java/org/eclipse/kura/nm/NMDbusConnector.java +++ b/kura/org.eclipse.kura.nm/src/main/java/org/eclipse/kura/nm/NMDbusConnector.java @@ -449,10 +449,22 @@ private void handleModemManagerGPSSetup(Device device, Optional enableG Properties modemLocationProperties = this.dbusConnection.getRemoteObject(MM_BUS_NAME, modemLocation.getObjectPath(), Properties.class); - Set availableLocationSources = MMModemLocationSource - .toMMModemLocationSourceFromBitMask(modemLocationProperties.Get(MM_LOCATION_BUS_NAME, "Capabilities")); - Set currentLocationSources = MMModemLocationSource - .toMMModemLocationSourceFromBitMask(modemLocationProperties.Get(MM_LOCATION_BUS_NAME, "Enabled")); + Set availableLocationSources = EnumSet + .of(MMModemLocationSource.MM_MODEM_LOCATION_SOURCE_NONE); + Set currentLocationSources = EnumSet + .of(MMModemLocationSource.MM_MODEM_LOCATION_SOURCE_NONE); + + try { + availableLocationSources = MMModemLocationSource.toMMModemLocationSourceFromBitMask( + modemLocationProperties.Get(MM_LOCATION_BUS_NAME, "Capabilities")); + currentLocationSources = MMModemLocationSource + .toMMModemLocationSourceFromBitMask(modemLocationProperties.Get(MM_LOCATION_BUS_NAME, "Enabled")); + } catch (DBusExecutionException e) { + logger.warn("Cannot retrive Modem.Location capabilities for {}. Caused by: ", + modemLocationProperties.getObjectPath(), e); + return; + } + EnumSet managedLocationSources = EnumSet.of( MMModemLocationSource.MM_MODEM_LOCATION_SOURCE_GPS_RAW, MMModemLocationSource.MM_MODEM_LOCATION_SOURCE_GPS_NMEA); @@ -467,7 +479,10 @@ private void handleModemManagerGPSSetup(Device device, Optional enableG logger.debug("Modem location setup {} for modem {}", currentLocationSources, modemDevicePath.get()); - modemLocation.Setup(MMModemLocationSource.toBitMaskFromMMModemLocationSource(currentLocationSources), false); + if (!currentLocationSources.contains(MMModemLocationSource.MM_MODEM_LOCATION_SOURCE_NONE)) { + modemLocation.Setup(MMModemLocationSource.toBitMaskFromMMModemLocationSource(currentLocationSources), + false); + } } private String getDeviceId(Device device) throws DBusException {