Merge branch 'nsclient' of https://github.com/MilosKozak/AndroidAPS into nsclient
This commit is contained in:
commit
352902438c
|
@ -341,7 +341,7 @@ public class ExecutionService extends Service {
|
||||||
danaRPump.lastConnection = now;
|
danaRPump.lastConnection = now;
|
||||||
MainApp.bus().post(new EventDanaRNewStatus());
|
MainApp.bus().post(new EventDanaRNewStatus());
|
||||||
MainApp.bus().post(new EventInitializationChanged());
|
MainApp.bus().post(new EventInitializationChanged());
|
||||||
MainApp.getConfigBuilder().uploadDeviceStatus(60);
|
MainApp.getConfigBuilder().uploadDeviceStatus(15);
|
||||||
if (danaRPump.dailyTotalUnits > danaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning ) {
|
if (danaRPump.dailyTotalUnits > danaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning ) {
|
||||||
log.debug("Approaching daily limit: " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits);
|
log.debug("Approaching daily limit: " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits);
|
||||||
Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.sResources.getString(R.string.approachingdailylimit), Notification.URGENT);
|
Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.sResources.getString(R.string.approachingdailylimit), Notification.URGENT);
|
||||||
|
|
|
@ -332,7 +332,7 @@ public class ExecutionService extends Service {
|
||||||
danaRKoreanPump.lastConnection = now;
|
danaRKoreanPump.lastConnection = now;
|
||||||
MainApp.bus().post(new EventDanaRNewStatus());
|
MainApp.bus().post(new EventDanaRNewStatus());
|
||||||
MainApp.bus().post(new EventInitializationChanged());
|
MainApp.bus().post(new EventInitializationChanged());
|
||||||
MainApp.getConfigBuilder().uploadDeviceStatus(60);
|
MainApp.getConfigBuilder().uploadDeviceStatus(15);
|
||||||
if (danaRKoreanPump.dailyTotalUnits > danaRKoreanPump.maxDailyTotalUnits * Constants.dailyLimitWarning ) {
|
if (danaRKoreanPump.dailyTotalUnits > danaRKoreanPump.maxDailyTotalUnits * Constants.dailyLimitWarning ) {
|
||||||
log.debug("Approaching daily limit: " + danaRKoreanPump.dailyTotalUnits + "/" + danaRKoreanPump.maxDailyTotalUnits);
|
log.debug("Approaching daily limit: " + danaRKoreanPump.dailyTotalUnits + "/" + danaRKoreanPump.maxDailyTotalUnits);
|
||||||
Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.sResources.getString(R.string.approachingdailylimit), Notification.URGENT);
|
Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.sResources.getString(R.string.approachingdailylimit), Notification.URGENT);
|
||||||
|
|
|
@ -228,7 +228,7 @@ public class LoopPlugin implements PluginBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
MainApp.bus().post(new EventLoopUpdateGui());
|
MainApp.bus().post(new EventLoopUpdateGui());
|
||||||
MainApp.getConfigBuilder().uploadDeviceStatus(120);
|
MainApp.getConfigBuilder().uploadDeviceStatus(60);
|
||||||
} finally {
|
} finally {
|
||||||
if (Config.logFunctionCalls)
|
if (Config.logFunctionCalls)
|
||||||
log.debug("invoke end");
|
log.debug("invoke end");
|
||||||
|
|
|
@ -10,7 +10,6 @@ import android.os.HandlerThread;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
import com.google.common.hash.Hashing;
|
import com.google.common.hash.Hashing;
|
||||||
|
@ -59,8 +58,8 @@ import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientS
|
||||||
import info.nightscout.androidaps.plugins.Overview.Notification;
|
import info.nightscout.androidaps.plugins.Overview.Notification;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
import info.nightscout.utils.SafeParse;
|
|
||||||
import io.socket.client.IO;
|
import io.socket.client.IO;
|
||||||
import io.socket.client.Socket;
|
import io.socket.client.Socket;
|
||||||
import io.socket.emitter.Emitter;
|
import io.socket.emitter.Emitter;
|
||||||
|
@ -95,6 +94,8 @@ public class NSClientService extends Service {
|
||||||
private boolean uploading = false;
|
private boolean uploading = false;
|
||||||
public Date lastReception = new Date();
|
public Date lastReception = new Date();
|
||||||
|
|
||||||
|
public long latestDateInReceivedData = 0;
|
||||||
|
|
||||||
private String nsAPIhashCode = "";
|
private String nsAPIhashCode = "";
|
||||||
|
|
||||||
public static UploadQueue uploadQueue = new UploadQueue();
|
public static UploadQueue uploadQueue = new UploadQueue();
|
||||||
|
@ -252,6 +253,7 @@ public class NSClientService extends Service {
|
||||||
authMessage.put("history", nsHours);
|
authMessage.put("history", nsHours);
|
||||||
authMessage.put("status", true); // receive status
|
authMessage.put("status", true); // receive status
|
||||||
authMessage.put("pingme", true); // send mi pings to keep alive
|
authMessage.put("pingme", true); // send mi pings to keep alive
|
||||||
|
authMessage.put("from", latestDateInReceivedData); // send data newer than
|
||||||
authMessage.put("secret", nsAPIhashCode);
|
authMessage.put("secret", nsAPIhashCode);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -411,6 +413,11 @@ public class NSClientService extends Service {
|
||||||
|
|
||||||
// remove from upload queue if Ack is failing
|
// remove from upload queue if Ack is failing
|
||||||
UploadQueue.removeID(jsonTreatment);
|
UploadQueue.removeID(jsonTreatment);
|
||||||
|
//Find latest date in treatment
|
||||||
|
if (treatment.getMills() != null && treatment.getMills() < new Date().getTime())
|
||||||
|
if (treatment.getMills() > latestDateInReceivedData)
|
||||||
|
latestDateInReceivedData = treatment.getMills();
|
||||||
|
|
||||||
if (treatment.getAction() == null) {
|
if (treatment.getAction() == null) {
|
||||||
if (!isCurrent(treatment)) continue;
|
if (!isCurrent(treatment)) continue;
|
||||||
addedTreatments.put(jsonTreatment);
|
addedTreatments.put(jsonTreatment);
|
||||||
|
@ -485,9 +492,14 @@ public class NSClientService extends Service {
|
||||||
// Handle new sgv here
|
// Handle new sgv here
|
||||||
// remove from upload queue if Ack is failing
|
// remove from upload queue if Ack is failing
|
||||||
UploadQueue.removeID(jsonSgv);
|
UploadQueue.removeID(jsonSgv);
|
||||||
|
//Find latest date in sgv
|
||||||
|
if (sgv.getMills() != null && sgv.getMills() < new Date().getTime())
|
||||||
|
if (sgv.getMills() > latestDateInReceivedData)
|
||||||
|
latestDateInReceivedData = sgv.getMills();
|
||||||
}
|
}
|
||||||
bs.handleNewSgv(sgvs, MainApp.instance().getApplicationContext(), isDelta);
|
bs.handleNewSgv(sgvs, MainApp.instance().getApplicationContext(), isDelta);
|
||||||
}
|
}
|
||||||
|
MainApp.bus().post(new EventNSClientNewLog("LAST", DateUtil.dateAndTimeString(latestDateInReceivedData)));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -509,7 +521,7 @@ public class NSClientService extends Service {
|
||||||
message.put("_id", dbr._id);
|
message.put("_id", dbr._id);
|
||||||
message.put("data", dbr.data);
|
message.put("data", dbr.data);
|
||||||
mSocket.emit("dbUpdate", message, ack);
|
mSocket.emit("dbUpdate", message, ack);
|
||||||
MainApp.bus().post(new EventNSClientNewLog("DBUPDATE", "Sent " + dbr._id));
|
MainApp.bus().post(new EventNSClientNewLog("DBUPDATE " + dbr.collection, "Sent " + dbr._id));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -523,7 +535,7 @@ public class NSClientService extends Service {
|
||||||
message.put("_id", dbr._id);
|
message.put("_id", dbr._id);
|
||||||
message.put("data", dbr.data);
|
message.put("data", dbr.data);
|
||||||
mSocket.emit("dbUpdateUnset", message, ack);
|
mSocket.emit("dbUpdateUnset", message, ack);
|
||||||
MainApp.bus().post(new EventNSClientNewLog("DBUPDATEUNSET", "Sent " + dbr._id));
|
MainApp.bus().post(new EventNSClientNewLog("DBUPDATEUNSET " + dbr.collection, "Sent " + dbr._id));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -536,7 +548,7 @@ public class NSClientService extends Service {
|
||||||
message.put("collection", dbr.collection);
|
message.put("collection", dbr.collection);
|
||||||
message.put("_id", dbr._id);
|
message.put("_id", dbr._id);
|
||||||
mSocket.emit("dbRemove", message, ack);
|
mSocket.emit("dbRemove", message, ack);
|
||||||
MainApp.bus().post(new EventNSClientNewLog("DBREMOVE", "Sent " + dbr._id));
|
MainApp.bus().post(new EventNSClientNewLog("DBREMOVE " + dbr.collection, "Sent " + dbr._id));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -559,7 +571,7 @@ public class NSClientService extends Service {
|
||||||
message.put("collection", dbr.collection);
|
message.put("collection", dbr.collection);
|
||||||
message.put("data", dbr.data);
|
message.put("data", dbr.data);
|
||||||
mSocket.emit("dbAdd", message, ack);
|
mSocket.emit("dbAdd", message, ack);
|
||||||
MainApp.bus().post(new EventNSClientNewLog("DBADD", "Sent " + dbr.nsClientID));
|
MainApp.bus().post(new EventNSClientNewLog("DBADD " + dbr.collection, "Sent " + dbr.nsClientID));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue