adafruit / Adafruit_BluefruitLE_nRF51

Arduino library for nRF51822-based Adafruit Bluefruit LE modules
197 stars 122 forks source link

What is the motivation for starting GATT values with '!'? #31

Closed tedhenry100 closed 7 years ago

tedhenry100 commented 7 years ago

In the examples, it is not documented why the packet reading code requires all GATT values to begin with the '!' character.

Especially curious is why the replyidx is reset when a second '!' character is encountered in the value. What if a '!' character is actually intended to be part of the value the master device is trying to send to the BluefruitLE?

https://github.com/adafruit/Adafruit_BluefruitLE_nRF51/blob/b80b880a62646223ba28b93301164c2134c9f4fc/examples/cplay_neopixel_picker/packetParser.cpp#L101

ladyada commented 7 years ago

make parsing easier, so you know where to start looking - and then you checksum as well!

petermichaux commented 7 years ago

@ladyada ,

"so you know where to start looking"

If what follows the '!' is the meaningful part of the value sent to the device, is there something in the value that could reasonably come before the '!' character?

petermichaux commented 7 years ago

I see that issue #23 brings up the same point about resetting when '!' is seen somewhere in the middle of the value. That character might be part of the value rather than the start of the value.

ladyada commented 7 years ago

that codes probably before the checksum was added. there needs to be some way to know when a packet starts! :)

tedhenry100 commented 7 years ago

@ladyada, doesn't data arriving indicate a packet starting?

ladyada commented 7 years ago

no, not necessarily, bytes can be dropped by the uart interface

tedhenry100 commented 7 years ago

@ladyada, so some of the bytes at the start of the packet could be dropped meaning only the tail of the packet is being read?

That still doesn't explain resetting replyidx part way through reading a packet. Can two packets be mashed/merged together requiring the reset? If so, what if the '!' character really is part of the data in the middle of the package.

Thanks for your replies. I appreciate it. :-)

ladyada commented 7 years ago

yes, if you want to submit a pull req for the fix that would be nice - no ETA on when we'll get to it!