I try to read data from a BLE device, but keep getting a permission error. The demo project can be found here: https://github.com/sergiomtzlosa/CoreBluetooth-Demo (keep in mind - my codes are slightly different from this).
There are no problems with the connection and the meaning of reading in general, but there are some characteristics (which are significant) that give a permission error.
Console log: update error !!! Feature: "Unknown (<fff4>)" with an error: "Reading is not allowed."
So, when I subscribe or read data from this sign, it sends me NULL every time (likely reason: lack of read permission).
Console Log: Feature: "Unknown (<fff4>)" β with value: (Zero)
Here is the code snippet:
//Action on discovering services - (void)peripheral:(CBPeripheral *)peripheral didDiscoverServices:(NSError *)error { if (error) { NSLog(@"Discovered services for %@ with error: %@", peripheral.name, [error localizedDescription]); return; } for (CBService *service in peripheral.services) { NSLog(@"Discovereddddddddddd service %@", service.UUID); [testPeripheral discoverCharacteristics:nil forService:service]; } NSLog(@"didDiscoverServicesEnd"); } //Action on discovered characteristics - (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error { NSLog(@"didDiscoverCharacteristicsForService!"); for (CBCharacteristic *characteristic in service.characteristics) { NSLog(@"Discovered characteristic %@", characteristic.UUID); NSLog(@"---------------------------------------------------"); NSLog(@"Reading value for characteristic %@", characteristic.UUID); [peripheral readValueForCharacteristic:characteristic]; NSLog(@"+++++++++++++++++++++++++++++++++++++++++++++++++++"); [peripheral setNotifyValue:YES forCharacteristic:characteristic]; } } //Action on reading value - (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error{ if (error){ NSLog(@"Update error!!! Characteristic: %@ with error: %@", characteristic.UUID, [error localizedDescription]); return; }else{ NSData *data = characteristic.value; NSString *str = [NSString stringWithUTF8String:[data bytes]]; NSLog(@"Characteristic: %@ -> with value: %@", characteristic.UUID, str); } }
What happened? Is there any way to overcome this problem?
source share