Core Bluetooth - Advertising with Multiple Service Keys

I have installed two apps on two separate devices.

The first acts as a basic central Bluetooth dispatcher and scans for new devices:

- (id)init:(NSString *)channel {
    _channel = [CBUUID UUIDWithString:channel];
    return self;
}

- (void) centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI{
    NSString *allKeys = advertisementData[CBAdvertisementDataServiceUUIDsKey];
    NSString *allOverflowKeys = advertisementData[CBAdvertisementDataOverflowServiceUUIDsKey];
}

      

The second acts as a basic Bluetooth peripheral and broadcasts itself:

- (id)init:(NSString *)channel :(NSString *)username {
    _channel  = [CBUUID UUIDWithString:channel];
    _username = [CBUUID UUIDWithString:username];

    _advertisingData = @{CBAdvertisementDataServiceUUIDsKey:@[_username, _channel]};
    return self;
}

- (void)peripheralManagerDidUpdateState:(CBPeripheralManager *)peripheral{
    if(peripheral.state == CBPeripheralManagerStatePoweredOn){
        [peripheralManager startAdvertising:_advertisingData];
        _isBroadcasting = YES;
    }
}

      

When I write keys or overflow keys from the central manager, I always only see one UUID, although I have specified several for the periphery. Why is this? I have also tried grabbing firstObject

and lastObject

, but it always results in the first UUID passed to CBAdvertisementDataServiceUUIDsKey

in the peripheral being returned .

+3


source to share





All Articles