does central get a callback after central sends write request?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

After a central sends a write request to a peripheral, will there be a callback to indicate that write request was successful?

0 Likes
1 Solution
asridharan
Employee
Employee
10 comments on KBA 5 comments on KBA First comment on KBA

See leatt_regWriteRspCb() and how hello_client sample app uses this. The callback registered with this function will be invoked when the write is executed successfully by the server.

View solution in original post

2 Replies
Anonymous
Not applicable

If your central is an iOS app and you are connected to a BTLE device (peripheral) you can use this:

- (void)writeValue:(NSData *)data forCharacteristic:(CBCharacteristic *)characteristic type:(CBCharacteristicWriteType)type

As type you use:

CBCharacteristicWriteWithResponse (to get the response)

or:

CBCharacteristicWriteWithoutResponse (no response)

If you choose the response you will get a callback:

- (void)peripheral:(CBPeripheral *)peripheral didWriteValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error


then you can check  error value:

if (error == NULL)

{

     //write successful

}


0 Likes
asridharan
Employee
Employee
10 comments on KBA 5 comments on KBA First comment on KBA

See leatt_regWriteRspCb() and how hello_client sample app uses this. The callback registered with this function will be invoked when the write is executed successfully by the server.