We have an application that communicates with our own BLE device. When we push the new firmware, we reboot and we get centralManager: didDisconnectPeripheral: error:and centralManager: didConnectPeripheral:, but when we call [peripheral discoverServices:nil], we never get a callback for peripheral: didDiscoverServices:. We get it when we initially connect, but not when reconnecting. CoreBluetooth seems to know what services and features are, because we can interact with the device, but we want to be able to write a feature right after a reboot, but cannot find a reliable way to tell when it will be.
- = EDIT = - This is the code we use to write the characteristics. When we try to call him on the second call didConnect, it fails because the peripheral device does not have any services:
+(void)writeData:(NSData*)data toPeripheral:(CBPeripheral*)peripheral service:(NSString*)sCBUUID characteristic:(NSString*)cCBUUID
{
for(CBService *service in peripheral.services)
{
if([service.UUID.stringValue isEqualToString:sCBUUID])
{
for(CBCharacteristic *characteristic in service.characteristics)
{
if([characteristic.UUID.stringValue isEqualToString:cCBUUID])
{
[peripheral writeValue:data forCharacteristic:characteristic type:CBCharacteristicWriteWithResponse];
return;
}
}
}
}
}
source
share