verjus commented on issue #552:
URL: https://github.com/apache/mynewt-nimble/issues/552#issuecomment-703181598


   I am posting here so as to not open a duplicate issue. 
   
   I am having the exact same issue, which I solved in a similar manner. I 
maintain a list of packets representing the entire payload that I need to 
transfer. The total payload is greater than the MTU but not each packet in the 
list. I send the first packet via:
   
   ```
       struct os_mbuf *om = ble_hs_mbuf_from_flat(node->packet.data, 
node->packet.dataSize);
       int rc = ble_gattc_notify_custom(conn_handle, alexa_notify_handle, om);
   
   ```
   and wait for the  BLE_GAP_EVENT_NOTIFY_TX event. When I receive this event,
   I check event->notify_tx.status and send the next packet in the packet list. 
If there are still packets left in the list, it will trigger again a notify_tx 
even until there are no packets left.
   
   This appears to work. However, when I stress test it by sending 338 bytes 
with an MTU of 33, it fails after the 12th packet. The return code is 
notify_tx.status = 6, which seems to correspond to BLE_HS_ENOMEM. This would 
indicate a heap exhaustion situation. I don't understand how this could be 
possible. Aren't the buffers returned to the heap after each call to 
ble_gattc_notify_custom? So what am I doing wrong?
   
   Here is how it looks like:
   This is the list of packets I am trying to send with a series of 
notifications (no indicate):
   
   Packet [1/13] contains: 60 00 00 01 52 18 0a cf  02 0a 24 0a 0f 41 6c 65 
                           78 61 2e 44 69 73 63 6f  76 65 72 79 12 11 
   Packet [2/13] contains: 60 14 1b 44 69 73 63 6f  76 65 72 2e 52 65 73 70 
                           6f 6e 73 65 12 a6 02 0a  a3 02 0a 0e 41 31 
   Packet [3/13] contains: 60 24 1b 4f 52 32 44 55  50 37 4a 30 35 39 5a 12 
                           0a 4e 69 78 69 65 54 69  6d 65 72 1a 0b 4e 
   Packet [4/13] contains: 60 34 1b 69 78 69 65 20  54 69 6d 65 72 22 0e 41 
                           58 53 20 49 6e 64 75 73  74 72 69 65 73 5a 
   Packet [5/13] contains: 60 44 1b 1d 0a 0e 41 6c  65 78 61 49 6e 74 65 72 
                           66 61 63 65 12 06 41 6c  65 72 74 73 1a 03 
   Packet [6/13] contains: 60 54 1b 31 2e 31 5a 55  0a 0e 41 6c 65 78 61 49 
                           6e 74 65 72 66 61 63 65  12 1a 41 6c 65 78 
   Packet [7/13] contains: 60 64 1b 61 2e 47 61 64  67 65 74 2e 53 74 61 74 
                           65 4c 69 73 74 65 6e 65  72 1a 03 31 2e 30 
   Packet [8/13] contains: 60 74 1b 22 22 0a 08 0a  06 74 69 6d 65 72 73 0a 
                           0a 0a 08 74 69 6d 65 69  6e 66 6f 0a 0a 0a 
   Packet [9/13] contains: 60 84 1b 08 77 61 6b 65  69 6e 66 6f 62 72 0a 01 
                           30 12 40 34 32 37 38 44  43 34 35 34 33 31 
   Packet [10/13] contains: 60 94 1b 41 33 32 38 41  37 46 41 32 30 44 38 35 
                            36 36 31 36 46 34 44 32  42 37 34 41 44 33 
   Packet [11/13] contains: 60 a4 1b 34 36 46 35 32  37 42 43 33 34 33 35 36 
                            43 33 37 32 31 33 32 31  38 44 37 43 43 1a 
   Packet [12/13] contains: 60 b4 1b 01 31 22 0e 41  31 4f 52 32 44 55 50 37 
                            4a 30 35 39 5a 2a 0a 4e  69 78 69 65 54 69 
   Packet [13/13] contains: 60 c8 11 6d 65 72 32 0c  34 34 30 30 34 39 30 46 
                            36 41 31 30 
   
   after the 11th packet, I get:
   
   preparing to send chunk of data size= 30
   sending packet number 12 <<<<<<<<
   60 b4 1b 01 31 22 0e 41  31 4f 52 32 44 55 50 37 
     4a 30 35 39 5a 2a 0a 4e  69 78 69 65 54 69 
   Sending notification now
   GATT procedure initiated: notify; att_handle=12
   event type= 0x000d
   notification update; status=0   <<<<<<<<<< SUCCESS
   Notify tx connection_handle = 64
   Notify tx attr handle = 12
   Notify tx indication  = 0
   PacketList_send called with:
   firstPacket = 0
   Resp code = 0
   
   But the following packet (which is the last by design) fails:
   Preparing to send chunk of data size= 20
   sending packet number 13  <<<<<<<<
   60 c8 11 6d 65 72 32 0c  34 34 30 30 34 39 30 46 
     36 41 31 30 
   Sending notification now
   GATT procedure initiated: notify; att_handle=12
   event type= 0x000d
   notification update; status=6 <<<<<<<<<< FAILURE
   Notify tx connection_handle = 64
   Notify tx attr handle = 12
   Notify tx indication  = 0
   PacketList_send called with:
   firstPacket = 0
   Resp code = 6 <<<
   Retry
   
   and never succeed after that.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to