bailuk / AAT

Another Activity Tracker for Android
https://bailu.ch/aat
GNU General Public License v3.0
150 stars 41 forks source link

Sensor doesn't work with my Samsung A5 and Mi Band 3 #62

Open flogith opened 4 years ago

flogith commented 4 years ago

Hello, I just found this nice app, but sensors doesn't work on my Samsung A5 2016. The internal samsung step counters and my mi band 3 heart rate sensor are detected through the app, but I have no BPM or RPM: Thanks for your support!

cewbdex commented 4 years ago

Mi Band 3 is not compatible heart rate sensor, it uses it's own proprietary protocol.

vanous commented 4 years ago

I don't use the official MiFit app, but from what i heard, they (now) have the possibility to switch to "visible mode", as mentioned here: https://github.com/Freeyourgadget/Gadgetbridge/issues/1606

cewbdex commented 4 years ago

There should be no problem, if it uses GATT. If this was true, I would not be so confident about Xiaomi backporting it to MB 3. Currently only solution there would be using gadgetbridge's API to access the data (but I am not sure if it has one), it would serve as a decent HAL.

vanous commented 4 years ago

Gadgetbridge added support to enable the sensor via BLE, same can be done via the MiFit. In AAT, the sensor is listed as supported, then as connected, but no data arrives.

I have now tested this in anther app and it works. I have Amazefit Bip.

I can see the sensor in BLE Explorer, although I am not sure it I should be able to see the data there.

characteristic UUID: 00002a39-0000-1000-8000-00805f9b34fb service UUID: 0000180d-0000-1000-8000-00805f9b34fb value: 0 = 0 =

I haven't tried master, if you made some changes...

arsab commented 4 years ago

While reporting GATT Service and Characteristics Unfortunatly Amazefit Bip do not support the standard reporting: Gadgetbridge (should) have special design to deal with it, you need to clarify. You can verify with Nordic Semiconductor "nRF connect" and "nRF Toolbox" the non standard format or other tools... https://github.com/NordicSemiconductor

desperadoduck commented 4 years ago

Just FYI: I can see my heart rate in the nRF Connect for Moblie app (current version from playstore). I use a Mi band 4 and activated the sensor via GadgetBridge. So it seems to be possible to interpret the data from the device.

desperadoduck commented 4 years ago

Oops sorry, it was the nrf toolbox I started... Still, it seems to work.

vanous commented 4 years ago

Cool. I actually think I can see it in BLE explorer, I will try to decode it. This is the characteristics: characteristic UUID: 00002a37-0000-1000-8000-00805f9b34fb service UUID: 0000180d-0000-1000-8000-00805f9b34fb value: 44 = 17408 = D

desperadoduck commented 4 years ago

@vanous: :+1: The NRF Toolbox seems to be opensourced (https://github.com/NordicSemiconductor/Android-nRF-Toolbox), so you can also take look at what they are doing to decode the data, if you like.

vanous commented 4 years ago

Cool. So this confirms:

heartrate service: static final UUID SERVICE_UUID = UUID.fromString("0000180D-0000-1000-8000-00805f9b34fb"); // Heart Rate service

the measurement characteristics: private static final UUID MEASUREMENT_CHARACTERISTIC_UUID = UUID.fromString("00002A37-0000-1000-8000-00805f9b34fb");

vanous commented 4 years ago

@desperadoduck it is just a hex value which is displayed in BLE Explorer so yes, i can see the HR data changing live in BLE Explorer and also in NRF Toolbox, in HRM screen and also on Template screen. Btw. you do not need Gadgetbridge running anymore, it just enables it and it can disconnect, the sensor remains available (and might be drawing more battery too).

arsab commented 4 years ago

That is one of challenge: in the past I tried to get HR into Runtastic or Strava. At that time could do it by activating the sensor with "Mi Heart Rate" but needed to have it running in background continuously...... Better to: ==> Decode How the activation can happen. and maintained ==> Understand the format of reporting. ==> Then you can propose the code to collect.

Also be careful that HR on "Mi.." are not very accurate while moving.

vanous commented 4 years ago

That is one of challenge: in the past I tried to get HR into Runtastic or Strava. At that time could do it by activating the sensor with "Mi Heart Rate" but needed to have it running in background continuously......

I might be wrong and I do not use MiFit but rather Gadgetbridge, but i presume that they cannot disable this if you disconnect spontaneously, unless there is some delay in the band to periodically receive this packet. But in my testing (about 30 minutes activity), i had GB disconnected and HR kept arriving.

Better to: ==> Decode How the activation can happen. and maintained

This is already done, in GB. But this should not belong to AAT imho.

==> Understand the format of reporting. ==> Then you can propose the code to collect.

This is i think not as complex as it acts as standard sensor.

Also be careful that HR on "Mi.." are not very accurate while moving.

Agree, everybody must decide what to invest into...

arsab commented 4 years ago

Got it I assume you are referring to following change in Gadgetbridge: https://github.com/Freeyourgadget/Gadgetbridge/commit/243eec042d497ff47b7a8a7e68a42eb6d6e38e80

It might be interesting to get visibility on other hw capabilities ;-)

vanous commented 4 years ago

Got it I assume you are referring to following change in Gadgetbridge: Freeyourgadget/Gadgetbridge@243eec0

yes

It might be interesting to get visibility on other hw capabilities ;-)

this is depending on the watch really... the command just enables this functionality...

anonimno1 commented 4 years ago

Hi all,

I am using AAT 1.18 on latest build of LineageOS 16 for OnePlus 3t. I turned the heart rate sensor on my Amazfit Bip using Gadgetbridge 0.43.1 and AAT is receiving data :)! But the date is only visible on the graph screen of Cockpit A, it is not shown on the main screen of Cockpit A. On the main screen only -- is shown, although the data is shown on the graph and logged in the gpx file. Any idea what is happening here?

Regards K