NS 15 support
This commit is contained in:
parent
36153c9b49
commit
7cafeae1c6
2 changed files with 6 additions and 21 deletions
|
@ -32,10 +32,7 @@ dependencies {
|
||||||
testImplementation project(':plugins:aps')
|
testImplementation project(':plugins:aps')
|
||||||
|
|
||||||
// NSClient, Tidepool
|
// NSClient, Tidepool
|
||||||
api("io.socket:socket.io-client:1.0.2") {
|
api("io.socket:socket.io-client:2.1.0")
|
||||||
// excluding org.json which is provided by Android
|
|
||||||
exclude group: "org.json", module: "json"
|
|
||||||
}
|
|
||||||
api "com.squareup.okhttp3:okhttp:$okhttp3_version"
|
api "com.squareup.okhttp3:okhttp:$okhttp3_version"
|
||||||
api "com.squareup.okhttp3:logging-interceptor:$okhttp3_version"
|
api "com.squareup.okhttp3:logging-interceptor:$okhttp3_version"
|
||||||
//api "com.squareup.retrofit2:retrofit:$retrofit2_version"
|
//api "com.squareup.retrofit2:retrofit:$retrofit2_version"
|
||||||
|
|
|
@ -49,6 +49,7 @@ import info.nightscout.rx.events.EventConfigBuilderChange
|
||||||
import info.nightscout.rx.events.EventDismissNotification
|
import info.nightscout.rx.events.EventDismissNotification
|
||||||
import info.nightscout.rx.events.EventNSClientNewLog
|
import info.nightscout.rx.events.EventNSClientNewLog
|
||||||
import info.nightscout.rx.events.EventNSClientRestart
|
import info.nightscout.rx.events.EventNSClientRestart
|
||||||
|
import info.nightscout.rx.events.EventNewHistoryData
|
||||||
import info.nightscout.rx.events.EventPreferenceChange
|
import info.nightscout.rx.events.EventPreferenceChange
|
||||||
import info.nightscout.rx.logging.AAPSLogger
|
import info.nightscout.rx.logging.AAPSLogger
|
||||||
import info.nightscout.rx.logging.LTag
|
import info.nightscout.rx.logging.LTag
|
||||||
|
@ -165,6 +166,10 @@ class NSClientService : DaggerService() {
|
||||||
.toObservable(NSAuthAck::class.java)
|
.toObservable(NSAuthAck::class.java)
|
||||||
.observeOn(aapsSchedulers.io)
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ ack -> processAuthAck(ack) }, fabricPrivacy::logException)
|
.subscribe({ ack -> processAuthAck(ack) }, fabricPrivacy::logException)
|
||||||
|
disposable += rxBus
|
||||||
|
.toObservable(EventNewHistoryData::class.java)
|
||||||
|
.observeOn(aapsSchedulers.io)
|
||||||
|
.subscribe({ resend("NEW_DATA") }, fabricPrivacy::logException)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
|
@ -231,10 +236,6 @@ class NSClientService : DaggerService() {
|
||||||
socket = IO.socket(nsURL, opt).also { socket ->
|
socket = IO.socket(nsURL, opt).also { socket ->
|
||||||
socket.on(Socket.EVENT_CONNECT, onConnect)
|
socket.on(Socket.EVENT_CONNECT, onConnect)
|
||||||
socket.on(Socket.EVENT_DISCONNECT, onDisconnect)
|
socket.on(Socket.EVENT_DISCONNECT, onDisconnect)
|
||||||
socket.on(Socket.EVENT_ERROR, onError)
|
|
||||||
socket.on(Socket.EVENT_CONNECT_ERROR, onError)
|
|
||||||
socket.on(Socket.EVENT_CONNECT_TIMEOUT, onError)
|
|
||||||
socket.on(Socket.EVENT_PING, onPing)
|
|
||||||
rxBus.send(EventNSClientNewLog("NSCLIENT", "do connect"))
|
rxBus.send(EventNSClientNewLog("NSCLIENT", "do connect"))
|
||||||
socket.connect()
|
socket.connect()
|
||||||
socket.on("dataUpdate", onDataUpdate)
|
socket.on("dataUpdate", onDataUpdate)
|
||||||
|
@ -300,7 +301,6 @@ class NSClientService : DaggerService() {
|
||||||
@Synchronized fun destroy() {
|
@Synchronized fun destroy() {
|
||||||
socket?.off(Socket.EVENT_CONNECT)
|
socket?.off(Socket.EVENT_CONNECT)
|
||||||
socket?.off(Socket.EVENT_DISCONNECT)
|
socket?.off(Socket.EVENT_DISCONNECT)
|
||||||
socket?.off(Socket.EVENT_PING)
|
|
||||||
socket?.off("dataUpdate")
|
socket?.off("dataUpdate")
|
||||||
socket?.off("announcement")
|
socket?.off("announcement")
|
||||||
socket?.off("alarm")
|
socket?.off("alarm")
|
||||||
|
@ -336,18 +336,6 @@ class NSClientService : DaggerService() {
|
||||||
nsDevice = sp.getString("careportal_enteredby", "")
|
nsDevice = sp.getString("careportal_enteredby", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
private val onError = Emitter.Listener { args ->
|
|
||||||
var msg = "Unknown Error"
|
|
||||||
if (args.isNotEmpty() && args[0] != null) {
|
|
||||||
msg = args[0].toString()
|
|
||||||
}
|
|
||||||
rxBus.send(EventNSClientNewLog("ERROR", msg))
|
|
||||||
}
|
|
||||||
private val onPing = Emitter.Listener {
|
|
||||||
rxBus.send(EventNSClientNewLog("PING", "received"))
|
|
||||||
// send data if there is something waiting
|
|
||||||
resend("Ping received")
|
|
||||||
}
|
|
||||||
private val onAnnouncement = Emitter.Listener { args ->
|
private val onAnnouncement = Emitter.Listener { args ->
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue