I am trying to make two programs that run on separate devices communicate with each other over bluetooth with CoreBluetooth. I can find and connect peripherals from the manager, and I can browse services in connected peripherals, but when I try and try and discover characteristics, I get the error The specified UUID is not allowed for this operation.
and as expected the service's characteristics come up nil.
What is this supposed to mean? I have tried to discover characteristics with specifying the UUID of the target and without, both show this error.
this is the function that prints the error.
func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?) {
print(error.localizedDescription)//prints "The specified UUID is not allowed for this operation."
if service.characteristics != nil {
for characteristic in service.characteristics! {
if characteristic.uuid == CBUUID(string: "A4389A32-90D2-402F-A3DF-47996E123DC1") {
print("characteristic found")
peripheral.readValue(for: characteristic)
}
}
}
}
this is where I look for peripherals.
func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?) {
if peripheral.services != nil {
for service in peripheral.services! {
if service.uuid == CBUUID(string: "dc495108-adce-4915-942d-bfc19cea923f") {
peripheral.discoverCharacteristics(nil, for: service)
}
}
}
}
this is how I add the service characteristic on the other device.
service = CBMutableService(type: CBUUID(string:"dc495108-adce-4915-942d-bfc19cea923f"), primary: true)
characteristic = CBMutableCharacteristic(type: CBUUID(string: "A4389A32-90D2-402F-A3DF-47996E123DC1"), properties: .write, value: nil, permissions: .writeable)
service.characteristics = [characteristic]
I tried a number of different combinations of properties and permissions (including .read/.readable) and I get the same error.