This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Multiple packets per connection interval - s132/IOS

Target - NRF52832 populated on a custom PCB using SDK 14.0.0 and s132 5.0

Background - end device will be used to send logged IMU data to the cloud via a smart device, 2-3mB expected to be sent at a time

Looking for a bit of help to increase the throughput using an IOS master (or really any device, but I'm currently using an iphoneSE). I'm running a lightly modified version of the peripheral ble_app_uart example - no UART functionality is now used, I am simply sending dummy data to evaluate throughput. Data length is successfully negotiated to 182 bytes. Connection interval is confirmed at 30ms. I am sending 182 byte packets (using ble_nus_string_send) upon every receipt of BLE_GATTS_EVT_HVN_TX_COMPLETE. Reviewing a log of packets received on the iphone (using lightBlue), I am predominately seeing a packet sent every ~30ms, with occasional packets separated by a few milliseconds. This results in a functional throughput of about 7kB/s.

I expected (hoped) that I would see multiple packets received within that 30ms window.

My questions:

  1. I've read that the connection interval can be dropped to 15ms with iOS devices - can you provide guidance with regards to the best way to complete this. I attempted to negotiate after a connection was made (using ble_conn_params_change_conn_params), but the 30ms interval was maintained. I understand that it may be better to stick with a longer connection interval given the bigger packet size (and assuming I can get to 6 or 7 packets per interval), but if I am limited to fewer packets per interval, a shorter connection interval would be better.

  2. What might be limiting me to 1, occasionally 2, packets per interval? Should I be attempting to send more frequently than waiting for BLE_GATTS_EVT_HVN_TX_COMPLETE?

Any help appreciated, I have searched, and turned up a number of good threads that have helped me get this far, but I think I've hit a bit of a wall.

-Chris

  • Hung- I am doing the following with regards to queuing up packets (quoted from my above post) -

    "I've also increased hvn_tx_queue_size to 7 and event_length to 320 (per other posts) in an attempt to increase the packets per interval (and adjusted ram start as needed). I am calling ble_nus_string_send (effectively sd_ble_gatts_hvx) until the response is no longer NRF_SUCCESS - at this point, I wait until I receive BLE_GATTS_EVT_HVN_TX_COMPLETE before calling ble_nus_string_send again."

    Based on this implementation, I can't exceed more than one call to ble_nus_string_send before I receive a NRF_ERROR_RESOURCES response. Is there some other way I should be queueing up packets? Or is there something else I should be doing to increase the buffer size?

  • Hi Chris,

    You are telling that even with hvn_tx_queue_size = 7 you can only queue 1 packet ?

    Could you try testing with very small packet says 1 byte payload and see if you seeing the same issue ?

    Also when you configure the softdevice, you should declare max MTU :

    ble_cfg.conn_cfg.params.gatt_conn_cfg.att_mtu = NRF_SDH_BLE_GATT_MAX_MTU_SIZE;
    
  • Yes, with hvn_tx_queue_size = 7, and with the necessary updates to ram_start implemented, I can only call ble_nus_string_send once before receipt of a NRF_ERROR_RESOURCE return (in other words, upon the second call of ble_nus_string_send, with a 182 byte packet, I receive the NRF_ERROR_RESOURCE error).

    I am making this call in gatt_init:

    err_code = nrf_ble_gatt_att_mtu_periph_set(&m_gatt, NRF_SDH_BLE_GATT_MAX_MTU_SIZE);
    

    Is that not sufficient to configure mtu size? Certainly this is what enabled 182 byte data transfers.

    Thanks for your help!

    -Chris

  • Yes, but you also need to tell the softdevice to prepare big enough buffer for large packet (and x7 of them) when you enable the softdevice.

    You can find the code I pointed above in nrf_sdh_ble_default_cfg_set() in nrf_sdh_ble.c . I assume the function is used in your code and NRF_SDH_BLE_GATT_MAX_MTU_SIZE in sdk_config.h isn't modified to smth else but 247 ?

  • Hung - Yes, this is already done in nrf_sdh_ble.c:

    #if (NRF_SDH_BLE_GATT_MAX_MTU_SIZE != 23)
    memset(&ble_cfg, 0x00, sizeof(ble_cfg));
    ble_cfg.conn_cfg.conn_cfg_tag                 = conn_cfg_tag;
    ble_cfg.conn_cfg.params.gatt_conn_cfg.att_mtu = NRF_SDH_BLE_GATT_MAX_MTU_SIZE;
    

    In the sdk:

    #ifndef NRF_SDH_BLE_GATT_MAX_MTU_SIZE
    #define NRF_SDH_BLE_GATT_MAX_MTU_SIZE 247
    #endif
    

    So it seems like the buffer and softdevice are configured correctly, right? Anything else that must be configured to enable multiple packets per interval? I know I still need to test a smaller packet size, I should get to this in the afternoon.

    -Chris

Related