Hi Aditya,

On Thu, Mar 29, 2018 at 08:52:08PM +0530, Aditya Xavier wrote:
[...]
> And it doesn’t work when am trying to trigger it from BLE. 
> 
> Assuming it was a memory issue, I used a mem_pool, mbuf, allocating
> and reserving space. However, problem remains.
> 
> It usually encodes and sends the following structure:
> 
> {“field1”:1, “field2”:2, “field3”:[{“field4”:4,
> 
> Which naturally fails because of incomplete cbor structure.

My guess is that the Bluetooth ATT MTU is too low to accommodate the
full packet.  The ATT layer is specified with the somewhat surprising
behavior of silently truncating overly-long attribute values [1].

How are you sending the CBOR data?  If you are using a simple "write
characteristic" procedure (`ble_gattc_write()`), you can use the "write
long characteristics" procedure instead (`ble_gattc_write_long()`),
which will fragment the long attribute value for you.  If you are
sending the CBOR data in a notification, on the other hand, then I'm
afraid the BLE stack doesn't offer any means of fragmentation; you'll
need to implement an application-layer fragmentation scheme.

Chris

[1] Perhaps we should add a syscfg setting which causes an over-long
write to indicate an error to the application instead of silently
truncating the data.  The stack wouldn't be standards-conforming in this
mode, but it seems more useful.

Reply via email to