0

I am trying to get the write request sent from Central and no delegate is getting called for the same in Peripheral. If I unsubscribe characteristic from Central then didUnsubscribeFromCharacteristic gets called. I am not sure how will I get the request in Peripheral application.

Central code:

[peripheral writeValue:data forCharacteristic:characteristic type:CBCharacteristicWriteWithResponse];

Tried calling same method with type:CBCharacteristicWriteWithoutResponse, its not working as expected.

Any help will be appriciated.

Thanks in advance!

Community
  • 1
  • 1
Mobile_Dev
  • 91
  • 6

2 Answers2

0

I think in Peripheral you should call didReceiveWriteRequests delegate.

aNa12
  • 145
  • 1
  • 10
0

How do you init your characteristics in the peripheral? Check their properties, you need:

properties: CBCharacteristicPropertyWrite
permissions: CBAttributePermissionWriteable

Which of the PeripheralManager Delegate methods get called? Must be more than just peripheralManager:central:didUnsubscribeFromCharacteristic

peripheralManagerDidUpdateState
peripheralManager:didAddService:error
peripheralManagerDidStartAdvertising:error
...

See the CBPeripheralManagerDelegate.... Check if all of them get called and the errors. Maybe something is wrong with your services/characteristics...

And check, if methods in your central get called, too. E.g.

- (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service
             error:(NSError *)error

And, of course, you have to init your peripheralManager in your peripheral with the correct delegate (and implement all other needed delegate methods):

self.peripheralManager  = [[CBPeripheralManager alloc] initWithDelegate:self queue:nil options:nil];
Threepwood
  • 41
  • 4