iosbluetoothbluetooth-lowenergycore-bluetoothios-bluetooth

short cbuuid vs long cbuuid ble connection ios


I am guessing this but connection is not successful?

0000180A-0000-1000-8000-00805f9b34fb

- (void)scan
{

  
  NSMutableArray *serviceUUIDs = [NSMutableArray new];
  NSDictionary* options = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:CBCentralManagerScanOptionAllowDuplicatesKey];
  [serviceUUIDs addObject:[CBUUID UUIDWithString:@"0000180A

  [_sharedManager scanForPeripheralsWithServices:serviceUUIDs options:options];
  
  // callback(@[]);
}

Solution

  • Bluetooth 4.0 can use both 16 bit and 128 bit UUID values. 16 bit UUIDs obviously take less space in the advertisement packets, but there are fewer of them.

    The Bluetooth SIG assigns 16 bit UUIDs for well known services and to member organisations on request. The current assigned values are here

    For example 0x1801 is the GATT profile and 0x180A is the device information service.

    There is no 128-bit equivalent of a 16 bit UUID.

    The list of services that a device offers and the services that it advertises are not the same.

    As there is limited space in the advertisement packet, devices typically only advertise a subset of their services; the services that are most "useful".

    For example, a heart rate monitor will advertise the heart rate service (0x180D) but not the battery or device info services, even though it will most likely offer these.

    This is why you cannot discover peripherals when scanning for service 0x180A - The device information service is typically not advertised.

    Once you connect to a device you can discover all of the services that it offers.