Search code examples
iosbluetoothcore-bluetooth

iOS Core bluetooth get all features description from device


How to can I get all available features from my device using Core Bluetooth.

I figured that before get any information we need to observe all devices via low energy bluetooth.

So the first step is scan for all peripheral devices scanForPeripheralsWithServices via CBCentralManager. In the delegate callback:

- (void)centralManager:(CBCentralManager *)central
 didDiscoverPeripheral:(CBPeripheral *)peripheral
     advertisementData:(NSDictionary *)advertisementData
                  RSSI:(NSNumber *)RSSI 

we can save peripheral identifier and save peripheral to handle it in future like change some characteristics, switch off/on and etc.

But my question how to get description of this function, for example I got some characteristic, but I don't know how to use. Where to find info about this future.

Let me describe situation. For example I have sound player with some options where I can handle volume of sound via bluetooth.

So I need to get peripheral first, then detect service and then discover characteristic to find volume "property", but how can I find it, how should I understand which is min/max amount of volume where to find this information. For example we can pass 0 as min volume amount and 1 as a max. But it also could be in range from 0 to 1000 or any other. How to detect this information?


Solution

  • You can't be sure to find the "documentation" for each characteristics, like what are the possible values, etc.
    If the Services & the Characteristics follow the documentation of Bluetooth, and are per se "documented", it just follow the doc, it's here. In theory, theses "well known" services and characters should have an UUID like "0x0000".
    Example: Battery service is 0x180F, Battery Level is 0x2A19 and the possible values have a defined protocol.

    For other custom services/characteristics, it's more difficult. Each one has their own documentation, and the UUID is longer (if it's developed respecting the rules). If set, you can read the CBDescriptor to get more info.

    In all case, you have to either refer to the Bluetooth Low Energy Documentation, or if it's custom to the manufacturer. Either wise, it's all about reverse-engeenering.