How to get list of available Bluetooth devices? How to get list of available Bluetooth devices? ios ios

How to get list of available Bluetooth devices?


This guide looks promising for Bluetooth 3.0. Remember that the CoreBluetooth framework is ONLY for Bluetooth Low Energy (4.0). At bluetooth.com's dev-pages you can see some examples of globally defined services, and as Guan Yang mentionen, you can see that the heart rate service is 0x180D. UUID`s of the unit is defined by the manufacturer.

Here's a code snippet to maybe help you along the way.

// Initialize a private variable with the heart rate service UUID    CBUUID *heartRate = [CBUUID UUIDWithString:@"180D"];// Create a dictionary for passing down to the scan with service methodNSDictionary *scanOptions = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO] forKey:CBCentralManagerScanOptionAllowDuplicatesKey];// Tell the central manager (cm) to scan for the heart rate service[cm scanForPeripheralsWithServices:[NSArray arrayWithObject:heartRate] options:scanOptions]


in Bluetooth, there are "Services". A device publishes 1..N services, and each service has 1..M characteristics. Each service has an unique identifier, called UUID.

For example, a heart rate Bluetooth Sensor that offers the service "heart rate", publishes a service with UUID 0x180D.

(more services here)

So when you perform a search, you must provide a UUID as the criteria, telling which service to search.


You should take a look at one of the examples. Here’s the relevant line:

[manager scanForPeripheralsWithServices:[NSArray arrayWithObject:[CBUUID UUIDWithString:@"180D"]] options:nil];

(I know this is a Mac OS X example, but the iOS CoreBluetooth API is very similar.)

CBUUID identifies services you are interested in, not devices. Standard services have a 16-bit UUID, in this case 0x180d for the heart rate monitor or perhaps 0x180a for device information, while proprietary services have a 128-bit UUID (16 bytes).

Most devices implement the device information service, so if you are just looking for any device, you could try [CBUUID UUIDWithString:@"180A"].