Reputation: 145
I'm playing around with ANCS to try and get an understanding of how it works before moving onto trying to write some firmware for a CSR1010 Dev Kit.
I've been writing a cmd line application in objective C that acts as a central and then interrogates the ANCS service. I can receive the Notification source no problem and write back to the control point with the correct details to pull back the attributes that I want.
The problem I've got at the minute is I'm not sure when the Data Source characteristic has completed it's transmission. The MTU size I have is 20bytes so my data coming back gets spliced up into the necessary packets and sent across fine. I just can;t get my head round when the transmission ends, from what I can see there is no end of message tag or anything lie that or any way to verify all the data has arrived so that I can stitch it all back together again.
The documentation from apple here on ANCS says:
If the response to a Get App Attributes command is larger than the negotiated GATT Maximum Transmission Unit (MTU), it is split into multiple fragments by the NP. The NC must recompose the response by splicing each fragment. The response is complete when the complete tuples for each requested attribute has been received.
How do you know "when the complete tuples for each requested attribute has been received."?
Thx//56k
Upvotes: 0
Views: 836
Reputation: 11
The ANCS specification (https://developer.apple.com/library/ios/documentation/CoreBluetooth/Reference/AppleNotificationCenterServiceSpecification/Specification/Specification.html#//apple_ref/doc/uid/TP40013460-CH1-SW7) states:
If the response is larger than the negotiated GATT Maximum Transmission Unit (MTU), it is split into multiple fragments by the NP. The NC must recompose the response by splicing each fragment. The response is complete when the complete tuples for each requested attribute has been received.
When you send the GetNotificationAttributes request, you need to store the list of attributes you are requesting (or at least how many you requested). Then, when parsing the response, you need to keep waiting for more split data packets until you received all the attributes you requested. This basically means trusting ANCS to always answer fully, which should be the case; however, just for the sake of safety, I would add a timeout in your code. This way, if ANCS somehow gets stuck, you don't follow it in its mess =)
Matteo
Upvotes: 0