Hello everyone, I’m developing simple wrapper around CoreBluetooth to send and receive data both from central/peripheral. For now I’m implementing receiving messages on peripheral side. Thus I have didReceiveWriteRequest: delegate method to process data from remote centrals. For this purposes I’ve created _BTReceiveMsgBuffer class. I store instances of that class into array in my high level abstraction class called BTServer. To determine buffer exactly _BTReceiveMsgBuffer has sender and receiving characteristic properties. Sender is simply CBCentral/Peripheral.
My current flow is : 1) Receive write requests. 2) Enumerate through all of them. 3) For each request I lookup for _BTReceiveMsgBuffer for it. If there is no buffer - it means we should create it for receiving message and first chunk that is stored in request.value property is my metadata that consist of simple UTF8 string like that : @“SOM:4022”. It signalises about start of message with 4022 bytes length. If first chunk is not a metadata chunk - I use peripheralManager:respondsToRequest:withError: passing CBATTErrorUnlikelyError. Also I’ve implementing msg sending process on CBCentralManager side. Im writing to characteristic with response. So if I didn’t get metadata chunk at the start of message - I respond to request with error. But I didn’t receive any error on CBCentralManager side it just calls peripheral:didWriteValueForCharacteristic:error: with empty error. In my logic if no error received on this routine - I send next chunk.
So it looks like now : I’m starting to send msg without metadata and server responds to it with error, however no error are recognised on the central manager state and it continue sending chunks. Why??
P.s. : I didn’t write received chunk to my characteristic.value property. Instead of that I append this received chunk to my buffer.
Please, can anyone describe why this happens? If you want sample code - I can provide it.
Waiting for your response, best regards, Yuri. |