openScale icon indicating copy to clipboard operation
openScale copied to clipboard

Support for Senssun Fat scales

Open freman opened this issue 7 years ago • 28 comments

Hi.

Scales are sold here in AU at Kmart, the original app worked beautifully just one time. Stores up to 12 users, has internal storage for some information.

Found some code that covers my scales perfectly

https://github.com/zhangjing02/MySenssunSdk/blob/master/sdk/src/main/java/cn/senssun/ble/sdk/fat/BleConnectService.java#L178

pretty much has everything you need! I haven't tested any of the user storage functionality (it's way past bed time and sending commands with nRF Connect is very manual, usually resulting in the scales turning off before I can send) but everything in there seems to work with regards to measurements.

Can confirm my device service is 0000fff0-0000-1000-8000-00805f9b34fb

Can confirm notifications from 0000fff1-0000-1000-8000-00805f9b34fb of 8 bytes

Standard operation FF A5 02 03 04 05 06 07

FF is discarded A5 is measurement 06 Is type

If 06 is AA or A0 then the measurement is weight in KG and lb, AA means stable measurement, A0 unstable measurement. 02 03 is weight in 100 gram increments (611 is 61.1kg) 04 05 is weight in lb

After triggering a fat test

If 06 is B0 then the measurement is Fat and Hydration, if it's BE then there was an error

02 03 is fat in 0.1% increments (218 is 21.8%) 04 05 is hydration in 0.1% increments (53.5 is 53.5%)

If 06 is C0 then the measurement is Muscle and Bone

02 03 is muscle in 0.1% increments (543 is 54.3%) 05 04 is bone in 0.1% increments (39 is 3.9%) - nb this is backwards

If 06 is D0 then the measurement is calculated calories

02 03 app lists as amr kcal

If 06 is E0, E1, E2, or F0 then its related to stored data sets

Send command to 0000fff2-0000-1000-8000-00805f9b34fb

A5 30 00 00 00 00 00 00 00 - Set date https://github.com/zhangjing02/MySenssunSdk/blob/master/sdk/src/main/java/cn/senssun/ble/sdk/fat/BleConnectService.java#L587 A5 31 00 00 00 00 00 00 00 - Set time https://github.com/zhangjing02/MySenssunSdk/blob/master/sdk/src/main/java/cn/senssun/ble/sdk/fat/BleConnectService.java#L610

A5 10 01 24 B4 00 00 D2 00 - Triggers a fat test

A5 10 are preamble 01 is 0+1 (0 for man - 128 for woman, 1 is my 'user') 24 is age B4 is height in cm

Some log: log-2018-07-27.txt

freman avatar Jul 25 '18 21:07 freman

thanks looks good, we will definitely implement it into openScale. Unfortunately, I am a bit busy at the moment, so be patient. If you are a programmer, you could of course try to implement it by yourself and send a PR.

oliexdev avatar Jul 27 '18 13:07 oliexdev

Turns out debugging this btle stuff is hard lol.

freman avatar Jul 30 '18 09:07 freman

I have something that works some of the time.

Not made any easier by the fact that I don't think their scales work the way they think their scales work.

I copy/paste their gender code in and it still doesn't work for men, only women.

If it doesn't just ignore you outright.

freman avatar Jul 30 '18 19:07 freman

Could you send a PR with your first implementation?

oliexdev avatar Aug 01 '18 13:08 oliexdev

@freman Did you get any further on this? Do you care to share your code? Looking to buy one of these dirt cheap scales locally, and having open source support for it is a major plus in my book.

dagbdagb avatar Nov 20 '18 07:11 dagbdagb

Hi i have the same Scale. Initial Pull Request here #355.

some smaller Issues to fix (written in den PR)

hope this helps every Senssun User

also added the Checksum code from the original Code SDK

gmarco avatar Nov 25 '18 15:11 gmarco

@gmarco's PR #355 has now been merged. Looks like a good base to continue working on to fix outstanding issues.

erijo avatar Nov 25 '18 18:11 erijo

Yay! Thank you @gmarco !

dagbdagb avatar Nov 25 '18 20:11 dagbdagb

Last update works very well IF the scale will connect. i must rec/disconnect the scale very often, because it will not connect so fast (if connected, all works)

https://gist.github.com/gmarco/0678468278026dd0894cda978c87c745

here a log of the connecting tries. (i en-/disabled the BT button after nicht connecting after some seconds)

the status code 133 is also described (like in the sourcecode here written). https://android.jlelse.eu/lessons-for-first-time-android-bluetooth-le-developers-i-learned-the-hard-way-fee07646624

where must be the delay added ??

  1. can we change the API to updated the last measure ? (scale will get first , weight, later (but not everytime) it will get the other data.

gmarco avatar Nov 27 '18 08:11 gmarco

Sorry, I have my source here somewhere but I had the same problem. Couldn't decide if crap scale was crap or if I sucked at Bluetooth

freman avatar Nov 27 '18 09:11 freman

thanks @gmarco as you already linked the Android Bluetooth stack is really corrupted. I consider on issue #357 to use a Bluetooth Android library to avoid those problems.

You could temporally store your measurement to get all measures.

oliexdev avatar Nov 27 '18 10:11 oliexdev

Try making doScanWhileConnecting return false for Senssun. See #353

erijo avatar Nov 27 '18 14:11 erijo

with the doScanWhileConnecting return falseit works much much better :+1: did da time wait for new data (with fat and so on), but the timing is not every time the same.

do we have a "onDisconnect" Funtion to override ?

BTW: the openScale App is now :100: time better than the original

gmarco avatar Nov 27 '18 18:11 gmarco

Glad to hear that it works better now @gmarco!

Can you attach a log from openScale when you connect to the scale and fetch a measurement?

erijo avatar Nov 27 '18 19:11 erijo

2018-11-27 19:47:40.395 Debug [1] BluetoothSenssun: WFM 04 502 2018-11-27 19:47:55.040 Debug [2755] BluetoothCommunication$GattCallback: onConnectionStateChange: status=8, newState=0 2018-11-27 19:47:55.051 Info [1] BluetoothCommunication: Disconnecting 2018-11-27 19:47:55.084 Debug [1] MainActivity: Bluetooth connection lost 2018-11-27 19:48:00.777 Debug [1] OpenScale: Disconnecting from bluetooth device

WFM 04 502 means Only Weight get, after 502 ms.

https://gist.github.com/gmarco/48062782f9a5410721ce5fde3a2121fd

to test, you should not stand on the metal plates (so it cannot get the fat data)

sometimes 2000ms, 500ms, without fat data. somtimes the fat data can take a bit longer than 2500ms.

on Disconnect is called after every measure

gmarco avatar Nov 27 '18 19:11 gmarco

Can you post a btsnoop log from the original app as well?

erijo avatar Nov 27 '18 19:11 erijo

i would, but my phone is not saving this file, even if enabled in developer options

gmarco avatar Nov 27 '18 19:11 gmarco

You can try going to developer settings and click "Take bug report". The snoop log might be in there.

On my Nexus 5X phone i have to enable btsnoop, restart bluetooth and then the phone. After that I can get the log via the "take bug report" option.

erijo avatar Nov 27 '18 20:11 erijo

i must do the reboot later, in the normal "bug report" this file is not present. but the problem is not the phone i think, the scale will send the data not anymore (shuts also off then). i will only catch the case, when the scale can only take the weight and nothing more (shoes on, or other temp errors, causing not fat measure)

gmarco avatar Nov 27 '18 20:11 gmarco

This is what I wrote, not sure if it helps

https://gist.github.com/freman/803c3e7c2bbd40303ca4cd680da62721

freman avatar Nov 28 '18 00:11 freman

Thanks for supporting Senssun scale.

I am getting an error:

Unexpected Bluetooth error: Characteristic not found in UUID 0000fff1-0000-10000-8000-00805f9b34fb.

screeshot

I am using the latest development version by the way.

DesBw avatar Jan 20 '19 13:01 DesBw

could you attach the openScale log file and screenshots from BLE Scanner

oliexdev avatar Jan 20 '19 14:01 oliexdev

It seems like the BLE Scanner actually fixed the connection issue. The connection started to work as soon as I installed BLE scanner and scanned & connected with the scale. thank you for the assistance.

DesBw avatar Jan 20 '19 21:01 DesBw

I have these scales, but I can't get the OpenScale to connect. I've attached the debug log from the Dev version of the app. openScale_2020-07-25_08-35.txt

I can connect with BLE Scanner. But OpenScale displays IF_B6A as not supported.

edent avatar Jul 25 '20 08:07 edent

Hi, there is a regression with the Senssun fat scale which wasn't remedied with the latest update. Should I open a new issue?

vger76 avatar Dec 17 '20 00:12 vger76

Is this still being worked on? When will the scales be officially supported?

My scale is also showing up as "device not supported" with the name "IF_B2".

Would be great to use openScale because the scale's official app is not good.

mtp-24 avatar Jul 02 '21 19:07 mtp-24

@oliexdev I know this issue has been open for while now and is inactive but I'd like to give it a try and fix the issue. Any pointers on how I can support my Senssun scale with name "IF_B2"? Or are there other infos that I need to get instead of the name. Thanks.

mtp-24 avatar Jul 18 '21 12:07 mtp-24

Hi friends, any chances of having this implemented? What exactly is missing? unfortunately I'm not an android developer, but if there's anything I could do to help, I'm in.

czare avatar Jan 10 '23 23:01 czare