Oximeter - Sleep as Android

com.chakaponden.sleepasandroid.o2ring
com.chakaponden.sleepasandroid.go2sleep

1 Like

Big thanks!

Big thanks, I’m will be releasing this later today…

1 Like

I believe I have the latest beta. Selecting automatic connects to my huawei watch but does not connect to either go2sleep, nor o2ring. Their services don’t start and they don’t vibrate or light up as they would normally on connection. Do I need to do anything else to allow the add ons to send data to SAA?

@petr-urbandroid ? ^

Many thanks @Michael… @Den I guess the add-ons require the com.urbandroid.sleep.watch.CHECK_CONNECTED to start sending the HR data? In this case I will try to find a better workaround…

1 Like

Hi @petr-urbandroid & @Den I have the O2Ring and Viatom’s PC software installed to download the stored data from the ring. I’ve also downloaded the stored data using the Android app they provide.

I’m considering two approaches to using that composite data which comprises oxygen, heart rate and motion.

I’ve exported the downloaded ring data to CSV. Would a solution (at least on the interim) be to use Automate to read the CSV content and perform a “playback” of the CSV content into Sleep as Android via its API?

The other alternative that would seem to need substantially more external processing would be to translate the series from the csv exported ring data into format for import into SaA.

@Den If I recall correctly you received information from Wellue that helped you implement your add-on. If yes, did that also include information on the format of their binary save file?

I don’t mind not having the data appear in SaA in real time. A batch data load when I wake up is fine with me.

Any other approaches to to consider in possibly consuming O2Ring data (all channels i.e. O2, HR, movement)?

Could you describe how API should be changed to be compatible with the latest beta?

Nope. I have only BLE packets format from Wellue. You can contact them and request additional information.

Thanks @Den
I was fortunate to find another source from somebody who reverse engineered it:

Example from the post above I plan to try with my data:
Code:

    00000000  03 00 e3 07 0b 19 17 20  29 9d 71 00 00 c4 5a 00  |....... ).q...Z.|

    00000010  00 60 5c 02 00 00 00 00  00 63 00 00 00 00 00 00  |.`\......c......|

    00000020  00 00 00 00 00 00 00 00  ff ff ff 00 00 ff ff ff  |................|

    00000030  00 00 61 3a 00 00 00 61  3a 00 00 00 61 3a 00 08  |..a:...a:...a:..|

    00000040  00 61 3a 00 08 00 61 3a  00 01 00 61 3a 00 01 00  |.a:...a:...a:...|

    00000050  61 3c 00 00 00 61 3c 00  00 00 61 3b 00 01 00 61  |a<...a<...a;...a| 

There’s a “signature” 0x0003, followed by binary year (uint16), month, day, hour, minute and second (all uint8), then some stuff I don’t understand, and finally 5-byte records of O2, Heart, ???, Motion, ??? (all uint8) at 2 seconds each.

I read the whole thread, and as a few others, I’d love to know whether the O2 sensor in my Amazfit Band 5 will be supported too. Notify & Fitness for Amazfit, which I use, reads and displays my O2 together with my heartbeat, and since it transmits the later to Sleep as Android, I imagine it could also transmit the former.

Is this something the SaA needs to implement on its end, as in, does it need to ask this data from N&FfA, which already has it passively available for consumption? Or is it the other way around, with N&FfA having to actively transmit this data to SaA, which passively receives it?

If it’s the later, I might try asking at N&FfA’s support to begin providing it.

PS: I don’t purchase a better O2 sensor, as the ones suggested here in the thread or in the official documentation, because they’re very expensive in the Brazilian market. Our government taxes gadgets (plus their shipping cost) at close to 100%, so an imported $70 O2 reader would cost close to $200 here.

The AB5, in contrast, is cheap. I paid $40 for mine, and while it fails to read O2 data very frequently, that’s still better than nothing, as my goal is COVID prevention more than anything else (if my O2 goes down and stay there I’ll run to the hospital).

Having the data on N&FfA’s app alone covers that angle, but as a long time SaA user I was pleasantly surprised when I discovered they talk with each other. It’d be doubly amazing then if they could go all the way and share O2 data too.

Thanks! :slightly_smiling_face:

2 Likes

So I tried to fabricate a backup file from the 02Ring .csv export from today’s sleep record.

SaA did not complain but the resulting imported data appears to no fit properly in the time frame.

Simple calculation error. I forgot to add in the 4 hour offset from UTC to US Eastern Daylight Time.

4 Likes

Hello, I did implement a more robust way to allow multiple devices in the latest BETA version of the app… @Michael would you be willing to give it a try? It is version 20210323… I cannot test it with the usual setup but i have tried this 2 nights with a Wear OS + Amazfit Band 5 and it seems to be working well…

To make this working:

  1. Settings > Wearables > Automatic needs to be the choice
  2. Sleep tracking needs to be started from the phone

If something is not working please use menu - report a bug please…

Many thanks…

@Den

Hi @petr-urbandroid, yes definitely happy to test. That version hasn’t come through yet but I will test it as soon as I get it. Will the add ins require any changes? I gather it won’t allow the light phaser to be used for motion tracking?

I assume this update (or other recent ones) won’t be offered in Play Store for older OS? My tablet manufacturer stopped at Android 5 :derelict_house:

Also I’m continuing work on translating each night’s O2Ring exported data into a SaA sleep backup record. It seems to be accepting and plotting O2 and HR data as expected, but motion data appears less so. I’ve tried scaling the values for import to fall between 0 and 10. Is that the range SaA expects? Should I expect that motion data to generate a sleep level (range from deep sleep to awake) when imported into SaA? It seems to need the “cycles” value. Is that right? For the sleep record Mar 21 (image above) I used w cycles value of 3, from that night’s record originally generated with Mi Band and re-imported with O2Ring data.

Seems to have worked well last night! I posted a bug report in case that provides some additional insight. My huawei watch has an HR sensor, so I’m not sure which sensor was used for hr (watch or o2ring)? Will test again tonight.

1 Like

@petr-urbandroid I spoke too soon. Something isn’t working - couldn’t get o2ring data for any sessions last night and the o2ring add on continues to be in a running state after tracking is stopped. Manually stopping the add on ensures it automatically connects to my o2ring for the next session, however no data is being transmitted and it doesn’t stop running when tracking ends.

@petr-urbandroid, @Den I decided to install the go2sleep add on tonight (and uninstall o2ring add on) and it too worked for the first session - hr and spo2 from the add on and movement from the gear os watch. But after stopping tracking, the add on was still running in the foreground. So I stopped the service and now it doesn’t provide hr/spo2 data. It is definitely starting when the session starts (but not stopping at the end). The notification comes up and my go2sleep device vibrates. But no data is being sent. It’s like the messages channel is blocked after the first proper run. I tried uninstalling and reinstalling the add on to no avail.

1 Like

@petr-urbandroid toggling the bluetooth smart for hr setting seems to re enable hr and spo2 from the add on. It seems to need the Bluetooth smart setting toggled from on to off or vice versa after every sleep session to enable saa to receive data from the add ons…

1 Like