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

Change GAP parameters dynamically over a short period

Hi,

I need to be able to change the GAP parameters of my connection for only a short period of time to save battery life but have high throughput when I need it. My firmware will only need to send data for a few seconds every 5 minutes, and the nRF52 will be in deep sleep for the rest of those 5 minutes. If I try to update the connection parameters before and after sending data, the firmware crashes. I suspect it could be because the new connection interval isn't fully set before we start sending data. I have also read that requesting connection parameter updates more frequently than every 30 seconds isn't recommended, so how can I go about doing this so that it is stable and I won't have to leave deep sleep 30 seconds after sending data?

This is the basic flow I need:

wake up
set fast connection interval
send ble data // only takes a few seconds
set slow connection interval
go back to sleep

Here is the code I have tried that crashes:

uint32_t err_code;
ble_gap_conn_params_t fast_gap_conn_params = { // set fast interval };
err_code = ble_conn_params_change_conn_params(&fast_gap_conn_params);
APP_ERROR_CHECK(err_code);

ble_send_data(data, data_size); // my own send function

ble_gap_conn_params_t slow_gap_conn_params = { // set slow interval };
err_code = ble_conn_params_change_conn_params(&slow_gap_conn_params);
APP_ERROR_CHECK(err_code);

Any help would be appreciated. Thanks!

  • If you try to change the connection parameters more often than every 30 second I assume you get an error from the softdevice wich will probably end up in the app fault handler and reset your device (unless you handle it in your app). I would suggest that you ask for a faster interval before you start sending, and in addition use slave latency, so you don't have to listen to all the master packets after you finish transmitting. Then you can send a new conn param update request after 30 seconds has passed to get slower parameters again.

  • Thanks for your response. I already knew most of this, but I gave up on switching the GAP parameters dynamically and just chose a good interval with a higher slave latency to get the best of both worlds. Thanks!

Related