iosbluetooth-lowenergycore-bluetoothpsoccypress-psoc

Cypress PSoC Creator / iOS App: Add BLE device address to advertisement data


I try to add the BLE device address to the advertisement data in Cypress PSoC Creator 4.2.

enter image description here

I checked the associated box in the GAP Settings and build the project for my PSoC 4 device (CYBLE-212006-01).


In my iOS App I use the following routine (CBCentralManager) to discover peripherals and print the advertisement data:

func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber){
    if peripheral.name != nil {
        if peripheral.name!.contains("TEST") {
        print(advertisementData)
        self.internalPeripheralArray.append(BluetoothPeripheral(name: peripheral.name!, UUID: peripheral.identifier, RSSI: RSSI, peripheral: peripheral, selected: false))
            self.internalPeripheralArray.sort(by: {($0.RSSI.intValue) > ($1.RSSI.intValue)})
        }
    }
}

The console prints:

["kCBAdvDataLocalName": TEST, "kCBAdvDataIsConnectable": 1]

I can't understand, why my BLE device address is not printed!

BTW:

If I add any other advertisement data package, for example the TX power level, it is immediately shown in my print output.


Solution

  • Core Bluetooth does not expose the raw advertisement data to your app; You can only access the advertisement data that is associated with the Advertisement keys - The device address is not one of those keys, while TX power level is.

    There is no way to find the device address in Core Bluetooth unless the device exposes it in some other way, such as via a GATT characteristic or in the Manufacturer specific data, for example.