From 5465e8f5aa848a7ae67aece73bd831ecae23dfcd Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Fri, 19 Oct 2018 00:01:01 +0200 Subject: [PATCH] try to catch bad devicenames --- .../plugins/Overview/notifications/Notification.java | 1 + .../androidaps/plugins/PumpDanaRS/services/BLEComm.java | 8 +++++++- app/src/main/res/values/strings.xml | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/Notification.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/Notification.java index 23e9ec9643..3d2cb435fd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/Notification.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/Notification.java @@ -68,6 +68,7 @@ public class Notification { public static final int NSMALFUNCTION = 40; public static final int NEWVERSIONDETECTED = 41; public static final int SENDLOGFILES = 42; + public static final int DEVICENOTPAIRED = 43; public int id; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java index be241dbbfd..fcd65bbb1e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java @@ -662,7 +662,13 @@ public class BLEComm { private void SendPumpCheck() { // 1st message sent to pump after connect - byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK, null, getConnectDeviceName()); + String devicename = getConnectDeviceName(); + if(devicename == null || devicename == ""){ + Notification n = new Notification(Notification.DEVICENOTPAIRED, MainApp.gs(R.string.pairfirst), Notification.URGENT); + MainApp.bus().post(new EventNewNotification(n)); + return; + } + byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK, null, devicename); if (L.isEnabled(L.PUMPBTCOMM)) log.debug(">>>>> " + "ENCRYPTION__PUMP_CHECK (0x00)" + " " + DanaRS_Packet.toHexString(bytes)); writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7846abd514..0bde7cfbb7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1209,6 +1209,7 @@ Minimal request change [%] Loop will popup new change request only if change is bigger than this value. Default value is 20% short_tabtitles + Please pair your pump with your phone! %1$d day