burnedikt / diasend-nightscout-bridge

Synchronize your diasend data to nightscout.
MIT License
18 stars 18 forks source link

Investigate CamAPS companion mode #44

Open burnedikt opened 1 year ago

burnedikt commented 1 year ago

since the companion feature is now available... have you tried to reverse engineer the data stream of camaps companion mode by the decompiling the apk? I guess this could be the key to a CamAPS2Nightscout Bridge ;)

Originally posted by @funkstille in https://github.com/burnedikt/diasend-nightscout-bridge/issues/40#issuecomment-1438232136

For reference here is a video previewing the companion mode: https://youtu.be/q-dRCGMZA_E.

Basically you need a second android phone which will get the data mirrored within the very same CamAPS app. Doesn't work with iOS devices and according to the video it is already powered by glooko. Haven't yet tried it out though.

burnedikt commented 1 year ago

Technically, this does have nothing to do with the diasend-nightscout-bridge as it works independently of diasend but from my understanding most diasend-nightscout-bridge users use it specifically for CamAPS (me included) so likely still relevant to discuss here although it might end up in a new project like CamAPS-companion-Nightscout-bridge.

burnedikt commented 1 year ago

More importantly, it's currently not possible to activate the companion mode while still using SMS follower mode. The two systems are mutually exclusive, apparently, which makes testing for me right now difficult.

funkstille commented 1 year ago

We (as parents) are using iOS devices as well (and of course xdrip + nightscout to get real time data). I wonder if companion is exclusive for Dana + CamAPS users too, because (at least until the last updates) CamAPS for Dana Pumps was sending SMS directly from the phone. Not like MyLife with a SMS Gateway on.

But anyways, in the evenings it would be possible to test a little bit. I had a look into the mylife.apk with Version 161.

Found 2 promising webservices so far.

1 is pointing towards an server of glooko https://barkley-us-m2c.dev.glooko.com/partner/camaps/login/

1 is pointing towards an server of dexcom shareServiceRepositoryImpl.setAppId("xxxxxxx"); shareServiceRepositoryImpl.setHostName("https://partner-share-us.dexcomdev.com/"); shareServiceRepositoryImpl.setPublicKeyIndex(PublicKeyIndex.Development);

And there is also some AWS Stuff...

Will investigate further.

burnedikt commented 1 year ago

I did a bit of an inspection here and it seems like mostly CamAPS is communicating with AWS for user management and all kinds of app settings. However, I couldn't get Companion mode to work in a setup that would allow me to inspect the requests on a deeper level yet using mitmproxy to see some actual glucose and treatment data. It also appears like this data will be e2e encrypted so even if we knew the requests the data would not be accessible without decryption as I got:

Unable to process data received from the person you follow as the decryption key is not available.

funkstille commented 1 year ago

I contacted CamAPS support and asked them for a client snipplet to use the companion interface with other services. Let’s see what happens - Just a try 😬

burnedikt commented 1 year ago

I'be now also "successfully" migrated to glooko and indeed it seems inferior in a bunch of aspects compared to diasend. Most prominently, you can't see what the loop does (temp basal changes) anymore and the delay in data is quite high.

So even if we get access to glooko api the delay would be huge (even larger than what it was with diasend in the end I presume).

Still might try to get access to glooko api and investigate the CamAPS companion mode a bit more.

burnedikt commented 1 year ago

Fyi: There's also a Thread discussing options on the xdrip project: https://github.com/NightscoutFoundation/xDrip/discussions/2688

funkstille commented 1 year ago

We are still on Diasend. I have asked CamAPS support if we should switch… got the following not very promising answer:

“With the latest update it is possible to update but if you rely on the Glooko app, there are a couple of problems awaiting a fix. The Glooko main site is up and running for CamAPS. “

So I stick with diasend for now.

I am really disappointed after a very promising start (in comparison to old pump / sensor) I have the feeling that CamAPS is just overwhelmed with software development and the huge amount of customers that came on board with Ypsomed release. I was hoping for some enhancements in CamAPS but from my point of view the app & reporting interface is worse then in the beggining.

I am now thinking about switching to AAPS for the next billing period.

burnedikt commented 1 year ago

We are still on Diasend. I have asked CamAPS support if we should switch… got the following not very promising answer:

“With the latest update it is possible to update but if you rely on the Glooko app, there are a couple of problems awaiting a fix. The Glooko main site is up and running for CamAPS. “

So I stick with diasend for now.

Tbh, I never used diasend much except for pulling some reports for quaterly checkups. And in the same manner I intend to use glooko. The glooko app is definitely not better than diasend and arguably worse for aspects of monitoring the hybrid loop. The biggest downside is definitely that you cannot see the temp basal adjustments made by the loop. Not sure if the data is just not there or simply not visualized within the app.

For now, I'm rolling with the setup of "just" having xDrip running on the same device as CamAPS pushing the glucose values to nightscout. So treatments and temp basal data is missing but it's still "good enough" to monitor my kid. This would be solved with CamAPS's companion mode but that one is really just the same camaps app, installed on another Android device. I've tried it and it has all the data, which is great but I personally think it's a very bad design decision to use the same app for remote monitoring / companion functionality as the actual CamAPS Fx app. It was probably easier to ship that way, as it's all one app but it definitely feels unpolished since in companion mode, 90% of the features of the app are disabled and therefore also the UI doesn't make sense in a lot of places. A separate companion app / functionality would've made way more sense and - more importantly - would have opened up possibilities to also ship it to other platforms like iOS or even the web.

I am really disappointed after a very promising start (in comparison to old pump / sensor) I have the feeling that CamAPS is just overwhelmed with software development and the huge amount of customers that came on board with Ypsomed release. I was hoping for some enhancements in CamAPS but from my point of view the app & reporting interface is worse then in the beggining.

I can very much agree on that. Also CamAPS still misses a lot of features like "stretching" boli over a (configurable!) time period (right now it's always 3 hours if I'm not mistaken) or the possibility to give a combo bolus but I would still rather stay with CamAPS than "experimenting" with AAPS on my kid. Not because I believe it's bad, if I was diagnosed with T1D myself, i would totally go for AAPS, just a bit hesitant to do that with my kid where I cannot intervene at any point (thinking about daycare etc.)


But bottom line from my perspective right now is:

bewest commented 1 year ago

Does anyone have good contacts at CAMPAPS? I'm interested in seeing if their concerns with Nightscout can be solved directly.

sulkaharo commented 1 year ago

FYI @burnedikt I just started uploading CamAPS data to Glooko and seems they're extending the types of data stored as the API in Glooko's end now contains everything we want - temporary basals, boluses, CGM data, carbs and CGM calibrations. Just ignore Glooko claiming they don't support CamAPS for now. I don't have data yet on how frequent the uploads are, but given xDrip in the Companion mode does uploads instantly, some delay in the Glooko data might be acceptable. I'm very keen to get this working asap, so let's see how we could cooperate on this. Ben has been working on the new framework for integrations, so we should probably use that. Also @bewest trying to dig a contact for you.

burnedikt commented 1 year ago

I've reached out to glooko to get official API access but the answer was that API access is not granted for "personal use".

I've also reached out to the existing glooko2nightscout-bridge but it seems like it's no longer actively maintained and also appears to be dysfunctional.

Seems like the only way forward to get a glooko-to-nightscout bridge is to mitm (man-in-the-middle) the glooko API and then build a new glooko-to-nightscout-bridge.

sulkaharo commented 1 year ago

I have a PR open on Nightscout-connect that fixes the Glooko V2 API for Camaps. Sadly the V2 API seems to be not fully supported for the pump, so if we want to capture all data (including CGM readings) we need to get the V3 API to work. You can observe that API with a browser debugger without needing to MITM the usage - just turn on Glooko in the app and sign into the site. Two things of note: 1) Glooko has a different endpoint in EU vs US and the accounts don't carry over the regions, 2) I haven't fully understood what is going on with the authentication but looks like Glooko inconsistently enforces password requirements for accounts and maybe uses some encoding for sending some of special characters they require, so I'm observing inconsistent auth results depending on what password I have on the site. Good news is the V3 API has all the data we want.

funkstille commented 1 year ago

Did you guys get any further?

This URL for EU / DE

https://de-fr.api.glooko.com/api/v3/graph/data?patient=eu-central-1-goldenrod-loftsgordon-1076&startDate=2023-07-13T00:00:00.000Z&endDate=2023-07-13T23:59:59.999Z&series[]=automaticBolus&series[]=basalBarAutomated&series[]=basalBarAutomatedMax&series[]=basalBarAutomatedSuspend&series[]=basalLabels&series[]=basalModulation&series[]=bgAbove400&series[]=bgAbove400Manual&series[]=bgHigh&series[]=bgHighManual&series[]=bgLow&series[]=bgLowManual&series[]=bgNormal&series[]=bgNormalManual&series[]=bgTargets&series[]=carbNonManual&series[]=cgmCalibrationHigh&series[]=cgmCalibrationLow&series[]=cgmCalibrationNormal&series[]=cgmHigh&series[]=cgmLow&series[]=cgmNormal&series[]=deliveredBolus&series[]=deliveredBolus&series[]=extendedBolusStep&series[]=extendedBolusStep&series[]=gkCarb&series[]=gkInsulin&series[]=gkInsulin&series[]=gkInsulinBasal&series[]=gkInsulinBolus&series[]=gkInsulinOther&series[]=gkInsulinPremixed&series[]=injectionBolus&series[]=injectionBolus&series[]=interruptedBolus&series[]=interruptedBolus&series[]=lgsPlgs&series[]=overrideAboveBolus&series[]=overrideAboveBolus&series[]=overrideBelowBolus&series[]=overrideBelowBolus&series[]=pumpAdvisoryAlert&series[]=pumpAlarm&series[]=pumpBasaliqAutomaticMode&series[]=pumpBasaliqManualMode&series[]=pumpCamapsAutomaticMode&series[]=pumpCamapsBluetoothTurnedOffMode&series[]=pumpCamapsBoostMode&series[]=pumpCamapsDailyTotalInsulinExceededMode&series[]=pumpCamapsDepoweredMode&series[]=pumpCamapsEaseOffMode&series[]=pumpCamapsExtendedBolusNotAllowedMode&series[]=pumpCamapsManualMode&series[]=pumpCamapsNoCgmMode&series[]=pumpCamapsNoPumpConnectivityMode&series[]=pumpCamapsPumpDeliverySuspendedMode&series[]=pumpCamapsUnableToProceedMode&series[]=pumpControliqAutomaticMode&series[]=pumpControliqExerciseMode&series[]=pumpControliqManualMode&series[]=pumpControliqSleepMode&series[]=pumpGenericAutomaticMode&series[]=pumpGenericManualMode&series[]=pumpOp5AutomaticMode&series[]=pumpOp5HypoprotectMode&series[]=pumpOp5LimitedMode&series[]=pumpOp5ManualMode&series[]=reservoirChange&series[]=scheduledBasal&series[]=setSiteChange&series[]=suggestedBolus&series[]=suggestedBolus&series[]=suspendBasal&series[]=temporaryBasal&series[]=unusedScheduledBasal&locale=de

Showed me more or less all data ...

burnedikt commented 1 year ago

@funkstille there's a new plugin for nightscout called "connect" which supports multiple data sources, including glooko.

I've set it up successfully but it requires some fixes still. It's already included in nightacout's dev branch (not yet part of the latest stable release though).

https://github.com/nightscout/nightscout-connect

I managed to make it import temp basal and boli, glucose is not imported (but is anyhow coming from xdrip).

AlexM4H commented 10 months ago

I think the API V3 is intended for EHR purposes and not for real-time use. Therefore, if we use it (for example, via a web crawler), I'm afraid we'll quickly get an account lockout.