diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RileyLinkBLE.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RileyLinkBLE.java index 05744e1845..e922bd990c 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RileyLinkBLE.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RileyLinkBLE.java @@ -396,10 +396,16 @@ public class RileyLinkBLE { } rileyLinkServiceData.rileyLinkAddress = bluetoothConnectionGatt.getDevice().getAddress(); - rileyLinkServiceData.rileyLinkName = bluetoothConnectionGatt.getDevice().getName(); - // Update stored name upon connecting (also for backwards compatibility for device where a name was not yet stored) - sp.putString(RileyLinkConst.Prefs.RileyLinkName, rileyLinkServiceData.rileyLinkName); + String deviceName = bluetoothConnectionGatt.getDevice().getName(); + if (StringUtils.isNotEmpty(deviceName)) { + // Update stored name upon connecting (also for backwards compatibility for device where a name was not yet stored) + sp.putString(RileyLinkConst.Prefs.RileyLinkName, rileyLinkServiceData.rileyLinkName); + rileyLinkServiceData.rileyLinkName = deviceName; + } else { + sp.remove(RileyLinkConst.Prefs.RileyLinkName); + rileyLinkServiceData.rileyLinkName = null; + } } }