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
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{
dataStore.setActivePumpMac(pumpMAC);
activePump.setLastRadioChannel(radioChannel);
sendStatus(String.format(Locale.getDefault(),"Connected on channel %d RSSI: %d%%",(int)radioChannel,cnlReader.getPumpSession().getRadioRSSIpercentage()));
Log.d(TAG,String.format("Connected to Contour Next Link on channel %d.",(int)radioChannel));
activePump.setLastRadioChannel(radioChannel);
sendStatus(String.format(Locale.getDefault(),"Connected on channel %d RSSI: %d%%",(int)radioChannel,cnlReader.getPumpSession().getRadioRSSIpercentage()));
Log.d(TAG,String.format("Connected to Contour Next Link on channel %d.",(int)radioChannel));
// extended unavailable SGV may be due to clash with the current polling time
// while we wait for a good SGV event, polling is auto adjusted by offsetting the next poll based on miss count
if(dataStore.getUnavailableSGVCount()>0){
if(timeLastGoodSGV==0){
nextRequestedPollTime+=POLL_PERIOD_MS/5L;// if there is a uploader/sensor poll clash on startup then this will push the next attempt out by 60 seconds
}elseif(dataStore.getUnavailableSGVCount()>2){
sendStatus("Warning: No SGV available from pump for "+dataStore.getUnavailableSGVCount()+" attempts");
nextRequestedPollTime+=((long)((dataStore.getUnavailableSGVCount()-2)%5))*(POLL_PERIOD_MS/10L);// adjust poll time in 1/10 steps to avoid potential poll clash (max adjustment at 5/10)
// extended unavailable SGV may be due to clash with the current polling time
// while we wait for a good SGV event, polling is auto adjusted by offsetting the next poll based on miss count
if(dataStore.getUnavailableSGVCount()>0){
if(timeLastGoodSGV==0){
nextRequestedPollTime+=POLL_PERIOD_MS/5L;// if there is a uploader/sensor poll clash on startup then this will push the next attempt out by 60 seconds
}elseif(dataStore.getUnavailableSGVCount()>2){
sendStatus("Warning: No SGV available from pump for "+dataStore.getUnavailableSGVCount()+" attempts");
nextRequestedPollTime+=((long)((dataStore.getUnavailableSGVCount()-2)%5))*(POLL_PERIOD_MS/10L);// adjust poll time in 1/10 steps to avoid potential poll clash (max adjustment at 5/10)