-->

Connect to Paired Bluetooth Device iOS8.1

2019-06-05 15:49发布

问题:

Newbie to all things CoreBlooth here. I have successfully written a small app to connect to a Wahoo Blue HR heart rate monitor and retrieve the bpm for my heart rate etc. I used the tutorial below but rewrote the code into swift.

Link to tutorial

I am now trying to write a simple app to retrieve the Blood Pressure readings from a Bluetooth LE BP reader I have. The model in question is an iHealth BP5.

When I scan for this device using the following code I get nothing.

func centralManagerDidUpdateState(central: CBCentralManager!) {

    if central.state == CBCentralManagerState.PoweredOff {
        println("CoreBluetooth BLE hardware is powered off")
    }
    else if central.state == CBCentralManagerState.PoweredOn {
        println("CoreBluetooth BLE hardware is powered on and ready")
        let IHEALTHBP5_BP_DEVICE_INFO_SERVICE_UUID = CBUUID(string:"1810")
        let services = [IHEALTHBP5_BP_DEVICE_INFO_SERVICE_UUID]
        centralManager!.scanForPeripheralsWithServices(services, options: nil)
    }

}

I have obviously changed the service UUID to a BP monitor and checked using an iPad running LightBlue and starting a blood pressure service. It works fine with the iPad simulating a BP service but not the BP5 device itself?

I have been reading something about manufacturers being able to hide devices? Could this be what is happening.

I have noticed that the BP5 device has to actually be 'Paired' through the iOS Bluetooth settings to work with the official app whereas the heart rate monitor did not. Does this suggest the heart rate monitor broadcasts to anyone but the BP5 has a more secure connection type?

Apologies if the terminology is off but I am new to the bluetooth world.

Any help or guidance appreciated.

regards

Olly

PS After checking the device was 'connected' in the bluetooth settings app and by the bluetooth light on the device moving from flashing to solid, I used the following method but this returned a result of zero.

let connectedPeripherals =   centralManager!.retrieveConnectedPeripheralsWithServices(services)
        println("Number of Connected Devices : \(connectedPeripherals.count)")

回答1:

The product's web page states that it uses "Wireless communication: Bluetooth V3.0+EDR Class 2 SPP", which is a "legacy" Bluetooth serial port protocol, not Bluetooth Low Energy/Bluetooth 4.0. This matches with your description of needing to pair the device and the device not being visible to Core Bluetooth.

This type of device is managed by the External Accessory Framework. You would need to identify the vendor ID that they have registered under the MFi program and then either find documentation on their protocol or reverse engineer their protocol as it won't be the same as a BLE BP monitor, which uses the GATT protocol.