diff --git a/app/src/main/java/info/nightscout/android/medtronic/MainActivity.java b/app/src/main/java/info/nightscout/android/medtronic/MainActivity.java index c7456d6cd7afeca93af66712f81d7b28675572ad..87893ba9aa8a58aeebcdeabe5357f708b0680ea1 100644 --- a/app/src/main/java/info/nightscout/android/medtronic/MainActivity.java +++ b/app/src/main/java/info/nightscout/android/medtronic/MainActivity.java @@ -875,11 +875,11 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc public void draw(Canvas canvas, Paint paint, float x, float y, DataPointInterface dataPoint) { double sgv = dataPoint.getY(); boolean mmolxl = configurationStore.isMmolxl(); - if (sgv < (mmolxl ? 4.5 : 80)) + if (sgv < 80) paint.setColor(Color.RED); - else if (sgv <= (mmolxl ? 10 : 180)) + else if (sgv <= 180) paint.setColor(Color.GREEN); - else if (sgv <= (mmolxl ? 14 : 260)) + else if (sgv <= 260) paint.setColor(Color.YELLOW); else paint.setColor(Color.RED); diff --git a/app/src/main/java/info/nightscout/android/medtronic/MedtronicCnlReader.java b/app/src/main/java/info/nightscout/android/medtronic/MedtronicCnlReader.java index e6d92eb7a97a1d15120ece272c79740127a5f3a9..9c2080c5b70aab426520174927c1b0a67b6b9cfe 100644 --- a/app/src/main/java/info/nightscout/android/medtronic/MedtronicCnlReader.java +++ b/app/src/main/java/info/nightscout/android/medtronic/MedtronicCnlReader.java @@ -141,6 +141,7 @@ public class MedtronicCnlReader { if (lastChannel != null) { radioChannels.add(0, lastChannel); + radioChannels.add(5, lastChannel); // retry last used channel again, this allows for transient noise if missed on first attempt when pump is in range } } diff --git a/app/src/main/java/info/nightscout/android/medtronic/service/MedtronicCnlIntentService.java b/app/src/main/java/info/nightscout/android/medtronic/service/MedtronicCnlIntentService.java index 286c75df52b5027030e1dfb70af280908a329aa9..36e332d980a5912c0e921bb13a8ca8cedd9e9ea4 100644 --- a/app/src/main/java/info/nightscout/android/medtronic/service/MedtronicCnlIntentService.java +++ b/app/src/main/java/info/nightscout/android/medtronic/service/MedtronicCnlIntentService.java @@ -205,6 +205,11 @@ public class MedtronicCnlIntentService extends IntentService { sendStatus("Could not communicate with the pump. Is it nearby?"); Log.i(TAG, "Could not communicate with the pump. Is it nearby?"); pollInterval = configurationStore.getPollInterval() / (configurationStore.isReducePollOnPumpAway() ? 2L : 1L); // reduce polling interval to half until pump is available + } else if (cnlReader.getPumpSession().getRadioRSSIpercentage() < 5) { + sendStatus(String.format(Locale.getDefault(), "Connected on channel %d RSSI: %d%%", (int) radioChannel, cnlReader.getPumpSession().getRadioRSSIpercentage())); + sendStatus("Warning: pump signal too weak. Is it nearby?"); + Log.i(TAG, "Warning: pump signal too weak. Is it nearby?"); + pollInterval = configurationStore.getPollInterval() / (configurationStore.isReducePollOnPumpAway() ? 2L : 1L); // reduce polling interval to half until pump is available } else { dataStore.setActivePumpMac(pumpMAC); @@ -242,7 +247,7 @@ public class MedtronicCnlIntentService extends IntentService { dataStore.getLastPumpStatus().getPumpDate() != null && pumpRecord.getPumpDate().getTime() - dataStore.getLastPumpStatus().getPumpDate().getTime() < 5000L && timePollExpected - timePollStarted < 5000L) { - sendStatus("Pump sent old SGV event, re-polling..."); + sendStatus("Pump sent old SGV event"); } dataStore.clearUnavailableSGVCount(); // reset unavailable sgv count @@ -273,11 +278,11 @@ public class MedtronicCnlIntentService extends IntentService { } catch (UnexpectedMessageException e) { Log.e(TAG, "Unexpected Message", e); sendStatus("Communication Error: " + e.getMessage()); - pollInterval = configurationStore.getPollInterval() / (configurationStore.isReducePollOnPumpAway() ? 2L : 1L); + pollInterval = 60000L; // retry once during this poll period, this allows for transient radio noise } catch (TimeoutException e) { Log.e(TAG, "Timeout communicating with the Contour Next Link.", e); sendStatus("Timeout communicating with the Contour Next Link."); - pollInterval = configurationStore.getPollInterval() / (configurationStore.isReducePollOnPumpAway() ? 2L : 1L); + pollInterval = 60000L; // retry once during this poll period, this allows for transient radio noise } catch (NoSuchAlgorithmException e) { Log.e(TAG, "Could not determine CNL HMAC", e); sendStatus("Error connecting to Contour Next Link: Hashing error.");