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 9387799bbb..086f8aab9e 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 @@ -92,6 +92,17 @@ public class RileyLinkBLE { if (radioResponseCountNotified != null) { radioResponseCountNotified.run(); } + + if (characteristic.getUuid().toString().equals(GattAttributes.UUID_NOTIF_CHARACTER.toString())) { + final byte[] data = characteristic.getValue(); + int first = 0xff & data[0]; + aapsLogger.info(LTag.PUMPBTCOMM, + "onCharacteristicChanged " + ByteUtil.shortHexString(characteristic.getValue()) + "=====" + first); + String fv = data[3] + "." + data[4]; + String hv = data[5] + "." + data[6]; + rileyLinkServiceData.versionOrangeFV = fv; + rileyLinkServiceData.versionOrangeHV = hv; + } } @@ -242,6 +253,9 @@ public class RileyLinkBLE { if (gattDebugEnabled) { debugService(service, 0); } + if (GattAttributes.isOrange(uuidService)) { + rileyLinkServiceData.isOrange = true; + } } if (gattDebugEnabled) { @@ -369,9 +383,21 @@ public class RileyLinkBLE { aapsLogger.error(LTag.PUMPBTCOMM, "Error setting response count notification"); return false; } + if(rileyLinkServiceData.isOrange){ + enableNotificationsOrange(); + } + return true; + } + public boolean enableNotificationsOrange() { + aapsLogger.error(LTag.PUMPBTCOMM, "enableNotificationsORG"); + BLECommOperationResult result = setNotification_blocking(GattAttributes.UUID_NOTIF_SERVICE, // + GattAttributes.UUID_NOTIF_CHARACTER); + if (result.resultCode != BLECommOperationResult.RESULT_SUCCESS) { + aapsLogger.error(LTag.PUMPBTCOMM, "Error setting response count notification"); + return false; + } return true; } - String macAddress; public void findRileyLink(String RileyLinkAddress) { diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/GattAttributes.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/GattAttributes.java index 9021bbf50c..c4cde5b3a7 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/GattAttributes.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/GattAttributes.java @@ -29,6 +29,9 @@ public class GattAttributes { public static String CHARA_RADIO_CUSTOM_NAME = "d93b2af0-1e28-11e4-8c21-0800200c9a66"; public static String CHARA_RADIO_VERSION = "30d99dc9-7c91-4295-a051-0a104d238cf2"; public static String CHARA_RADIO_LED_MODE = "c6d84241-f1a7-4f9c-a25f-fce16732f14e"; + //Orange Radio Service + public static UUID UUID_NOTIF_SERVICE = UUID.fromString("6e400001-b5a3-f393-e0a9-e50e24dcca9e"); + public static UUID UUID_NOTIF_CHARACTER = UUID.fromString("6e400003-b5a3-f393-e0a9-e50e24dcca9e"); private static final Map attributes; private static final Map attributesRileyLinkSpecific; @@ -83,5 +86,8 @@ public class GattAttributes { public static boolean isRileyLink(UUID uuid) { return attributesRileyLinkSpecific.containsKey(uuid.toString()); } + public static boolean isOrange(UUID uuid) { + return UUID_NOTIF_SERVICE.equals(uuid.toString()); + } } diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusGeneralFragment.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusGeneralFragment.java index 7ab6625951..ce96a5c2fa 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusGeneralFragment.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusGeneralFragment.java @@ -107,8 +107,14 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re RileyLinkError rileyLinkError = rileyLinkServiceData.rileyLinkError; this.connectionError.setText(rileyLinkError == null ? PLACEHOLDER : resourceHelper.gs(rileyLinkError.getResourceId(targetDevice))); - this.firmwareVersion.setText(resourceHelper.gs(R.string.rileylink_firmware_version_value, - Optional.ofNullable(rileyLinkServiceData.versionBLE113).orElse(PLACEHOLDER), Optional.ofNullable(rileyLinkServiceData.versionCC110).orElse(PLACEHOLDER))); + + if(rileyLinkServiceData.isOrange){ + this.firmwareVersion.setText("FV:"+Optional.ofNullable(rileyLinkServiceData.versionOrangeFV).orElse(PLACEHOLDER)+"\nHV:"+Optional.ofNullable(rileyLinkServiceData.versionOrangeHV).orElse(PLACEHOLDER)); + }else{ + this.firmwareVersion.setText(resourceHelper.gs(R.string.rileylink_firmware_version_value, + Optional.ofNullable(rileyLinkServiceData.versionBLE113).orElse(PLACEHOLDER), Optional.ofNullable(rileyLinkServiceData.versionCC110).orElse(PLACEHOLDER))); + + } } RileyLinkPumpDevice rileyLinkPumpDevice = (RileyLinkPumpDevice) activePlugin.getActivePump(); diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkServiceData.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkServiceData.java index 249c94d74b..c78d5b22ab 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkServiceData.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkServiceData.java @@ -48,6 +48,9 @@ public class RileyLinkServiceData { public String versionBLE113; // radio version public String versionCC110; + public boolean isOrange; + public String versionOrangeFV; + public String versionOrangeHV; public RileyLinkTargetDevice targetDevice;