oliexdev / openScale

Open-source weight and body metrics tracker, with support for Bluetooth scales
GNU General Public License v3.0
1.68k stars 292 forks source link

Mi Body Composition Scale 2 #995

Closed FransM closed 11 months ago

FransM commented 11 months ago

Scale name Mi Body Composition scale 2 https://www.mi.com/nl/product/mi-body-composition-scale-2/

The scale is identified in openscale as MIBFS and as a smart scale 2. However this one does have pads to also measure things like body fat etc. Step 1: Read the general reverse engineer process

I did this (and maybe I did wrong because the next step talks about 3 log files. However the instructions (as I read them) suggests to stop and start logging but does not mention the saving of the log file inbetween (so I ended up with a single log file)

Step 2: Acquiring some Bluetooth traffic Attach 3 log files with the corresponding true values, read here for further information.

I'm a bit hesitant to provide log files as I am not too keen to expose my data. However, I can do the analysis myself (with some help)

Step 3: Discover Bluetooth services and characteristic Read here how to create the openScale debug file

The scale supports the Body Composition Profile with some extensions. The odd thing is that the wireshark dissection of the value indication handle is not correct. Screenshot from 2023-09-29 19-40-59

The screenshot was taken on sep 29, 2023 at 16:33 so the dissector is two bytes off. Also the values do not make sense. I expected a weight of 103.1 kg (so 0x0407 and a fat percentage of 32.2% (0x0142) but there is nothing like this in the packet.

Is there an endianness problem here? Or something else?

Apart from that I see also a 3 notifications after this one. These are with Handle 0x0020 (Body Composition: Unknown) An example if the value of the notification is: 0224e707091d0f231efdff1608 After that there is a notification with handle 0x0020 with the value 3. Maybe the number of messages that were sent before.

Anyone an idea how I can further analyze this?

EDIT: I discovered after writing this that a similar issue is here. This one states that the weight needs to be divided by 200 (so it is in units of 5 grammes). Then indeed 20620 results in 103.1 kg. https://github.com/oliexdev/openScale/issues/564

However note that the body composition scale 2 is NOT the same as the smart scale 2. The latter is here: https://www.mi.com/global/product/mi-smart-scale-2/

The smart scale 2 does not support fat measurements whereas the composition scale does.

EDIT2: I dug some more in the log and noticed that initially only the weight is reported, but later on there is another notification stating the impedance. The weird thing is that the packet is incomplete. See below Screenshot from 2023-09-29 20-20-51

FransM commented 11 months ago

I've closed the issue as apparently I did something wrong. The scale is already supported and reports weight and impedance. The issue in the screenshot is because the scale does not provide a body fat percentage, and that is mandatory in the bluetooth body composition measurement.