starryalley / CSC_BLE_Bridge

Android app that bridges ANT+ Cycling Speed/Cadence/HR sensors as Bluetooth LE sensors
MIT License
68 stars 17 forks source link

Defined as a cadence sensor #24

Open AlEEEX777 opened 2 years ago

AlEEEX777 commented 2 years ago

Hello On my watch, a pulse sensor connected via ant+ to smartphone with CSC_BLE_Bridge is defined as a cadence sensor, not a pulse. Why is that? How to make the pulse visible on the watch?

starryalley commented 2 years ago

Hi @AlEEEX777 can you let me know what sensor it is (Brand and model number please). By your description do you mean that your heart rate sensor is shown as a cadence sensor on CSC_BLE_Bridge app, or it is correctly shown as a heart rate sensor but through bluetooth connection to your watch, it is showing as a cadence sensor on your watch?

AlEEEX777 commented 2 years ago

Polar H9 pulse sensor. Huawei GT runner watch. On the smartphone, CSC_BLE_Bridge detects h9 as a pulse sensor (the pulse is displayed) and transmits data, but on the watch it is determined as a cadence sensor (or maybe a speed sensor and offers to choose the wheel diameter).

starryalley commented 2 years ago

Hi @AlEEEX777 I don't have any knowledge on the H9 but a quick google search shows it supports both heart rate and cadence via Bluetooth and ANT+. If CSC_BLE_Bridge detects it as a heart rate sensor it should advertise itself as a BLE heart rate sensor. It should never create a BLE cadence device.

However I also don't know anything about Huawei GT runner watch and its software. Is it possible that you try with another smart phone/watch to see if it's the same? Just to identify if it's the CSC_BLE_Bridge's bug or if it's something with the watch. Thank you.

If issue is identified to be unrelated to the Huawei GT runner watch, please kindly get logcat logs about this app either through some third party app on the phone, or through adb. I don't have the hardware to test obviously so that's the only way I can help. Thank you!

AlEEEX777 commented 2 years ago

Hi @starryalley ! Polar H9 it`s chest heart rate sensor only. Maybe my watch is reading something wrong. But I was still able to set up the transmission of the heart rate to the smart watch using your program! I installed the nRF Connect app and created a Random address connectable in the Advertiser tab (Service Data: UUID:0x2A37 Data: 0x2A37. Complete list of 16-bit Service UUIDs: 0x180D, 0x2A37. ) The watch detects the heart sensor as Redmi Note X (name my phone BLE) when I run this "Polar H9" connection in nRF. To transfer the heart rate to the watch, I need to run CSC_BLE_Bridge, otherwise there will be a connection without a heart rate. Probably, it is possible to immediately transmit the heart rate via BLE advertisement without ANT+. It would be great if CSC_BLE_Bridge could do it. I just want to have the chest sensor connected at the same time to Polar Flow or Beat app (for statistics, analysis..) and have an accurate heart rate on the smart watch. Sorry for my poor English)) Thank you, Starryalley! gtrun

nRf

starryalley commented 2 years ago

Hi @AlEEEX777 sorry for the late reply. I couldn't understand your post completely so excuse my delayed response.

From my understanding, correct me if I'm wrong, you want to use H9 with Polar Flow (connected through BLE on your phone), and you want to have the heart rate reading on your watch (which is BLE only, no ANT+, that's why you want to use this app) at the same time.

In this case, you don't need nRF Connect advertising at all. You use the CSC_BLE_Bridge app that receives heart rates from H9 through ANT+, and then it advertises itself as another BLE heart rate sensor. On your watch connect to that fake sensor created by CSC BLE Bridge.

But this complicates things a bit that depends on:

My suggestion is:

Please let me know if the above is working or not, without running other things at the same time? Is the watch still detecting "Redmi Note X" as a cadence sensor? If it still is, then something may be wrong in CSC BLE Bridge and I will need the android logcat logs to know. If it works in this setup, then maybe it's not related to this app then.

Thank you. Hope it helps.

AlEEEX777 commented 2 years ago

Hi @starryalley ! I am very happy that you answered

you want to use H9 with Polar Flow (connected through BLE on your phone), and you want to have the heart rate reading on your watch (which is BLE only, no ANT+, that's why you want to use this app) at the same time.

Yes, you're right! I want my workouts to still be recorded in polar Flow (flow.polar.com - good data representation) via the polar Beat app. To do this, I need to connect H9 via BLE to a smartphone. And since H9 has only one BLE, I can't connect it to the watch at the same time. I have not found any programs that would duplicate data from the heart rate sensor connected via BLE and broadcast the smartphone as fake heart rate sensor with this data. I'm happy that you created CSC BLE Bridge and I found it)

In this case, you don't need nRF Connect advertising at all. You use the CSC_BLE_Bridge app that receives heart rates from H9 through ANT+, and then it advertises itself as another BLE heart rate sensor. On your watch connect to that fake sensor created by CSC BLE Bridge.

That's exactly what I did. Therefore, I created this topic issue. On my watch, a fake sensor is identified as not a heart rate sensor. Only with nRF Connect advertising and CSC_BLE_Bridge enabled, I was able to get heart rate on the watch.

if H9's BLE can be connected but still sending out ANT+ readings at the same time.

Yes, H9 can be connected and standing out BLE and ANT+ reading at the same time. I ran polar beat (BLE) and HRV app (ANT+) on my smartphone, everything worked.

if your Redmi Note phone can do BLE advertising while connecting to H9 through BLE (assuming you are using the same phone that runs CSC BLE Bridge and Polar Flow app). I'm not too sure about this.

I think Redmi can. Because I turned on advertising in nRF Connect with BLE H9 connected to polar beat app.

if you are running CSC BLE Bridge and nRF Connect advertising at the same time. This definitely won't work correctly I reckon.

Yes, I'm running CSC BLE Bridge and nRF Connect advertising at the same time. nRFConnect advertiser allows the watch to see the heart rate sensor Redmi Note, but it apparently does not transmit data. The heart rate data is transmitted by your application, I think so. Because if I stop CSC BLE Bridge, the heart rate on the watch is no longer displayed.

My suggestion is: use your ANT+ supported phone to run CSC BLE Bridge, nothing else. In the app, connect to H9 (through ANT+ of course) and it will advertise heart rate as a BLE device use your Huawei GT runner watch and connect to the above created device

I did it and recorded the log. Starting somewhere from 09-19 14:36:05.012 logcat123.txt Yes, my watch still detecting "Redmi Note X" as a cadence/speed sensor. I am using the latest 1.3.2 version of CSC BLE Bridge.

Thank you, Mark Kuo!

gtrun2 Screenshot_2022-09-19-14-38-03-774_idv markkuo cscblebridge

starryalley commented 2 years ago

Thank you for the update and logs. I'll check them in detail later.

At the same time, do you have another device (a PC, mac, another phone or another watch) that you can use to connect to the heart rate BLE device (Redmi Note X) created by CSC BLE Bridge app? For example, zwift or any similar sports app. Just to confirm if another device/app is also detecting the created BLE device as a cadence sensor instead of the heart rate.

AlEEEX777 commented 2 years ago

I'll check them in detail later.

Thank you, @starryalley

Yes, I checked the work of CSC BLE Bridge app with another smartphone according to this scheme: polar H9 is connected by BLE and ANT+ to Redme Note smartphone, CSC BLE Bridge and polar Beat apps are running, polar Beat app is running on another samsung smartphone and it sees the "Redmi Note X" heart sensor and shows heart rate the same as the transmitting smartphone Redmi Note. I think because polar Beat app only perceives the heart rate so it works. GT runner watch can be connected to various sensors: pulse, cadense, speed, power.. and that's why something is wrong. From logcat:

09-19 14:36:38.722 30194 30211 I BleServer: Notifying HUAWEI WATCH GT Runner-F8E

09-19 14:36:38.726 30194 30211 I BleServer: Notifying HUAWEI WATCH GT Runner-F8E for 00001816-0000-1000-8000-00805f9b34fb

09-19 14:36:38.726 30194 30211 I BleServer: Not notifying anything, ant device was null

09-19 14:36:38.729 30194 30211 I BleServer: Notifying HUAWEI WATCH GT Runner-F8E for 00001814-0000-1000-8000-00805f9b34fb

09-19 14:36:38.729 30194 30211 I BleServer: Not notifying anything, ant device was null

09-19 14:36:38.731 30194 30211 I BleServer: Notifying HUAWEI WATCH GT Runner-F8E for 0000180d-0000-1000-8000-00805f9b34fb

09-19 14:36:38.735 30194 30205 V BleServer: onNotificationSent() result:0

the watch receives notifications about :

  1. BLE_UUID_CYCLING_SPEED_AND_CADENCE 0x1816
  2. BLE_UUID_RUNNING_SPEED_AND_CADENCE 0x1814
  3. BLE_UUID_HEART_RATE_SERVICE 0x180D Perhaps if they received messages only BLE_UUID_HEART_RATE_SERVICE 0x180D: BleServer: Notifying HUAWEI WATCH GT Runner-F8E for 0000180d-0000-1000-8000-00805f9b34fb , they would show heart rate.
starryalley commented 2 years ago

Sorry for late reply again. Had a long weekend holiday last week over here.

I have looked at the log but unfortunately I can't find anything useful now. The log quoted by you is a bit misleading but is completely normal. It iterates over all supported types of device and will only notify to the connected device (Huawei watch) if there is an ANT+ sensor there. So for 0x1816 there is nothing so nothing is sent. Same for 0x1814. When it goes to heart rate, there is such an ANT+ sensor so it will actually transmit the data there. You can see onNotificationSent() print after 0x180d.

I just tried to test the app with my only ANT+ HR sensor (Garmin HRM-Run) and see what the log looks like and it is similar to yours. I'm using Zwift Mac version as the app that reads heart rate through BLE.

However when creating bluetooth server for advertising, the app will add all types of services using this function. That includes CSC, RSC and HR. This has been fine for me and others.

If you are able to build apk yourself you can modify this line and only keep HrService there. The app will then only advertise itself as HR. Also I've attached an apk that has this change for you to test. However I'm not sure if that will solve the issue. But I don't have a better idea now.

app-release.apk.zip

AlEEEX777 commented 2 years ago

@starryalley
Thank you Mark Kuo!! This is the best idea, everything works fine! The gt runner watch defines the Redmi Note as a heart rate sensor now. Great, thanks a lot again!

starryalley commented 2 years ago

Awesome news! I will keep this issue open and see how I can improve the app. Looks like some device might not work if the app is advertising itself as CSC+RSC+HR. Problem is CSC+HR or RSC+HR is two pretty common combinations. I am using CSC+HR.

@AlEEEX777 might need your help again to test in the future. Thanks again for this bug report!

AlEEEX777 commented 2 years ago

Ok, I'm ready to test. The easiest thing is probably to give users the option to configure which sensor they have connected and their combination.

@starryalley many thanks for the support and development of such the unique application! I wish you further creative successes!

starryalley commented 2 years ago

Exactly as you suggested, maybe it's best to allow users to select what BLE device types user wants to advertise (3 types: CSC, RSC and HR). Some device like Huawei GT runner may not work well if the app is advertising as having all 3 services at the same time. Maybe there is more like it.

I'll find out some time to work on this. Thanks.