iOS Swift explore basic heart rate data as broadcast messages without pairing

747 Views Asked by At

i was implementing an iOS demo app to read data from HR monitor like Polar , Wahoo. I discovered and connect/pair(ed) the devices and got data successfully from multiple simultaneous bluetooth connection.

Now my requirement is to collect data from more BLE devices(20+ in number). I tried with swift BLE API , it is not providing heart rate data without/before pairing. Besides Bluetooth does not(seems) work with this number of simultaneous connection. Someone advised me to do this like :

"If you are interested only in basic heart rate data, that is to say beats per minute value then I assume that you might be able to handle 40 units as you would not have to actually connect with the units. It would be enough to listen to the broadcast messages as the broadcast messages include the beats per minute value for each device."

This means i can get basic heart rate data from broadcast messages without pairing devices. My queries :

Q1: Can i really get basic heart rate data without pairing (by discovering only) ?

Q2: Does native BLE API supports this ?

Q3: Any way/API/SDK/example to accomplish this purpose ?

Q4: It would be better if i get data in every seconds.

Q5: Can i get any help from HealthKit for this ?

----------------Update 1 ----------------

When i discovered BLE devices using

func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) { }

I have found kCBAdvDataManufacturerData array with 6 value.

I followed this link to extract HR data from kCBAdvDataManufacturerData key of Polar H10 device , Extract data from kCBAdvDataManufacturerData on Swift

But i failed, how to achieve this ?

----------------Update 2 ----------------

Finally got the solution , please follow this link if anyone require.

https://github.com/polarofficial/polar-ble-sdk/issues/103

Thanks in advance.

1

There are 1 best solutions below

12
On

The broadcast message your friend is referring to is the advertisement data, which is quite limited (31 bytes), also it depends on if you have control of the firmware in your bluetooth device.

A1: It is possible, if hardware provides that information in the advertisement data

A2: Yes, you can get advertisement data through CBCentralManager's delegate method

A3: If you have implemented BLE to connect to one device, you probably already know how to use CBCentralManager, but if you need a link, here is a CoreBluetooth tutorial

A4: I don't think you can control the frequency of when you discover a certain peripheral

A5: I've never used HealthKit, so I cannot answer this