Disable the garmin client for now.

This commit is contained in:
Robert Buessow 2023-11-14 16:42:38 +01:00
parent 07cc0e19c7
commit f3d1acffcd
5 changed files with 19 additions and 10 deletions

View file

@ -89,8 +89,13 @@ class GarminDeviceClient(
bindLock.notifyAll() bindLock.notifyAll()
} }
if (notifyReceiver) receiver.onConnect(this@GarminDeviceClient) if (notifyReceiver) receiver.onConnect(this@GarminDeviceClient)
ciq.connectedDevices?.forEach { d -> try {
receiver.onConnectDevice(this@GarminDeviceClient, d.deviceIdentifier, d.friendlyName) } ciq.connectedDevices?.forEach { d ->
receiver.onConnectDevice(this@GarminDeviceClient, d.deviceIdentifier, d.friendlyName)
}
} catch (e: Exception) {
aapsLogger.error(LTag.GARMIN, "getting devices failed", e)
}
} }
override fun onServiceDisconnected(name: ComponentName?) { override fun onServiceDisconnected(name: ComponentName?) {
synchronized(bindLock) { synchronized(bindLock) {

View file

@ -26,7 +26,7 @@ class GarminMessenger(
appIdNames.putAll(applicationIdNames) appIdNames.putAll(applicationIdNames)
if (enableConnectIq) startDeviceClient() if (enableConnectIq) startDeviceClient()
if (enableSimulator) { if (enableSimulator) {
appIdNames["SimAp"] = "SimulatorApp" appIdNames["SimApp"] = "SimulatorApp"
GarminSimulatorClient(aapsLogger, this) GarminSimulatorClient(aapsLogger, this)
} }
} }

View file

@ -86,12 +86,13 @@ class GarminPlugin @Inject constructor(
private val garminAapsKey get() = sp.getString("garmin_aaps_key", "") private val garminAapsKey get() = sp.getString("garmin_aaps_key", "")
private fun onPreferenceChange(event: EventPreferenceChange) { private fun onPreferenceChange(event: EventPreferenceChange) {
aapsLogger.info(LTag.GARMIN, "preferences change ${event.changedKey}")
when (event.changedKey) { when (event.changedKey) {
"communication_debug_mode" -> setupGarminMessenger() "communication_debug_mode" -> setupGarminMessenger()
"communication_http", "communication_http_port" -> setupHttpServer() "communication_http", "communication_http_port" -> setupHttpServer()
"garmin_aaps_key" -> sendPhoneAppMessage() "garmin_aaps_key" -> sendPhoneAppMessage()
else -> return
} }
aapsLogger.info(LTag.GARMIN, "preferences change ${event.changedKey}")
} }
private fun setupGarminMessenger() { private fun setupGarminMessenger() {
@ -120,7 +121,7 @@ class GarminPlugin @Inject constructor(
.subscribe(::onNewBloodGlucose) .subscribe(::onNewBloodGlucose)
) )
setupHttpServer() setupHttpServer()
setupGarminMessenger() // setupGarminMessenger()
} }
fun setupHttpServer() { fun setupHttpServer() {
@ -167,8 +168,10 @@ class GarminPlugin @Inject constructor(
@VisibleForTesting @VisibleForTesting
fun onConnectDevice(device: GarminDevice) { fun onConnectDevice(device: GarminDevice) {
aapsLogger.info(LTag.GARMIN, "onConnectDevice $device sending glucose") if (garminAapsKey.isNotEmpty()) {
if (garminAapsKey.isNotEmpty()) sendPhoneAppMessage(device) aapsLogger.info(LTag.GARMIN, "onConnectDevice $device sending glucose")
sendPhoneAppMessage(device)
}
} }
private fun sendPhoneAppMessage(device: GarminDevice) { private fun sendPhoneAppMessage(device: GarminDevice) {

View file

@ -83,7 +83,8 @@ class GarminSimulatorClient(
} }
} }
} catch (e: SocketException) { } catch (e: SocketException) {
aapsLogger.warn(LTag.GARMIN, "socket read failed ${e.message}") aapsLogger.warn(LTag.GARMIN, "socket read failed ${e.message}")
break
} }
} }
aapsLogger.info(LTag.GARMIN, "disconnect ${device.name}" ) aapsLogger.info(LTag.GARMIN, "disconnect ${device.name}" )
@ -162,7 +163,7 @@ class GarminSimulatorClient(
override fun isDisposed() = serverSocket.isClosed override fun isDisposed() = serverSocket.isClosed
override fun retrieveApplicationInfo(device: GarminDevice, appId: String, appName: String) { override fun retrieveApplicationInfo(device: GarminDevice, appId: String, appName: String) {
receiver.onApplicationInfo(device, appId, true) receiver.onApplicationInfo(device, appId, appId == iqApp.applicationID)
} }
private fun getConnection(device: GarminDevice): Connection? { private fun getConnection(device: GarminDevice): Connection? {

View file

@ -62,7 +62,7 @@ class GarminSimulatorClientTest: TestBase() {
verify(receiver).onConnect(client) verify(receiver).onConnect(client)
verify(receiver, timeout(1_000)).onConnectDevice(eq(client), any(), any()) verify(receiver, timeout(1_000)).onConnectDevice(eq(client), any(), any())
} }
verify(receiver).onReceiveMessage( verify(receiver, timeout(1_000)).onReceiveMessage(
eq(client), eq(device!!.id), eq("SimApp"), eq(client), eq(device!!.id), eq("SimApp"),
argThat { p -> payload.contentEquals(p) }) argThat { p -> payload.contentEquals(p) })
} }