Characteristic Notification Not Working
Characteristic Notification Not Working
- Subject: Characteristic Notification Not Working
- From: Joe Rossano <email@hidden>
- Date: Wed, 11 Jun 2014 18:45:30 +0000
- Thread-topic: Characteristic Notification Not Working
Hi Folks,
I am trying to write a BTLE monitoring app that receives notifications. I
have built both the central app and a mock peripheral app using Core
Bluetooth (on iOS 7.1). My central can connect fine to the peripheral,
which advertises a service that has 2 CBCharacteristicPropertyNotify
characteristics. But here is what happens once the central discovers the
characteristics (removing non-essential code for clarity).
PD = CBPeripheralDelegate in central
PMD = CBPeripheralManagerDelegate in peripheral
PD callback invoked
- (void)peripheral:(CBPeripheral *)peripheral
didDiscoverCharacteristicsForService:(CBService *)service error:(NSError
*)error
{
for (CBCharacteristic *characteristic in service.characteristics)
{
[peripheral setNotifyValue:YES forCharacteristic:characteristic];
}
}
PMD callback invoked twice for the 2 characteristics
- (void)peripheralManager:(CBPeripheralManager *)peripheral
central:(CBCentral *)central
didSubscribeToCharacteristic:(CBCharacteristic *)characteristic
{
if ([characteristic.UUID isEqual:[CBUUID
UUIDWithString:FILTER_GENUINE_CHARACTERISTIC_UUID]])
{
BOOL genuineSent = [self.peripheralManager updateValue:genuineValue
forCharacteristic:self.filterGenuineCharacteristic
onSubscribedCentrals:nil];
}
else if ([characteristic.UUID isEqual:[CBUUID
UUIDWithString:FILTER_LOADING_CHARACTERISTIC_UUID]])
{
BOOL loadingSent = [self.peripheralManager updateValue:loadingValue
forCharacteristic:self.filterLoadingCharacteristic
onSubscribedCentrals:nil];
}
}
* The first time this method is invoked the return from
updateValue:forCharacteristic:onSubscribedCentrals: in YES.The second time
the return is always NO.
PD callback invoked twice for the 2 characteristics
- (void)peripheral:(CBPeripheral *)peripheral
didUpdateNotificationStateForCharacteristic:(CBCharacteristic
*)characteristic error:(NSError *)error
* characteristic.isNotifying is always YES.
But that¹s it, no other callback methods are invoked!
PMD callback peripheralManagerIsReadyToUpdateSubscribers: is never called
for the updateValue:forCharacteristic:onSubscribedCentrals: call that
returned NO
- (void)peripheralManagerIsReadyToUpdateSubscribers:(CBPeripheralManager
*)peripheral
PD callback peripheral:didUpdateValueForCharacteristic:error: is never
called for the updateValue:forCharacteristic:onSubscribedCentrals: call
that returned YES
- (void)peripheral:(CBPeripheral *)peripheral
didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic
error:(NSError *)error
I have been testing these apps on an iPad Air and iPhone 5s, both running
iOS 7.1.
Any idea why the notification is never invoked?
Thanks,
Joe
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Bluetooth-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden