Changing Supervision timeout on BLE
-
- Posts: 20
- Joined: Wed Jun 28, 2017 1:22 pm
Changing Supervision timeout on BLE
I am trying to change the timeout for the esp32 to drop the connection to the device, but I'm unsure how to do that. I have seen a timeout entry in one of the structs ( esp_ble_conn_update_params_t ) but I'm unsure where I would apply it in the initialization.
To be clear, I think the android device I am connecting to the ESP32 is being timed out and dropped by the esp32 ( android phone is the client )
To be clear, I think the android device I am connecting to the ESP32 is being timed out and dropped by the esp32 ( android phone is the client )
-
- Posts: 79
- Joined: Tue Apr 26, 2016 5:10 am
Re: Changing Supervision timeout on BLE
hi @frostyowned
A function like the following should help you configure the timeout. This is configurable on the GATT Sever side only.
A function like the following should help you configure the timeout. This is configurable on the GATT Sever side only.
Code: Select all
void gatt_perihperal_update_connection_params(uint8_t* client_addr)
{
esp_ble_conn_update_params_t conn_params;
memcpy(conn_params.bda, client_addr, BLE_MAC_ADDR_LEN);
conn_params.min_int = 0x06; // x 1.25ms
conn_params.max_int = 0x40; // x 1.25ms
conn_params.latency = 0x00; //number of skippable connection events
conn_params.timeout = 0xA0; // x 6.25ms, time before peripherial will assume connection is dropped.
esp_ble_gap_update_conn_params(&conn_params);
}
-
- Posts: 20
- Joined: Wed Jun 28, 2017 1:22 pm
Re: Changing Supervision timeout on BLE
Thank you for that! I have tried putting it in my code and have gotten an error ( second line ). The first line is to show the mac address was successfully obtained using the parameters from the connection
It was placed in the event handler under this case:
and finally here is the edited version of the function you gave me:
Code: Select all
I (63594) wOS: SERVICE_START_EVT, conn_id 0, remote e4:12:1d:a3:f2:2f:, is_conn 1
E (63594) BT: bta_dm_ble_update_conn_params error: Invalid connection bd_addr.
Code: Select all
case ESP_GATTS_CONNECT_EVT:
ESP_LOGI(GATTS_TAG, "SERVICE_START_EVT, conn_id %d, remote %02x:%02x:%02x:%02x:%02x:%02x:, is_conn %d\n",
param->connect.conn_id,
param->connect.remote_bda[0], param->connect.remote_bda[1], param->connect.remote_bda[2],
param->connect.remote_bda[3], param->connect.remote_bda[4], param->connect.remote_bda[5],
param->connect.is_connected);
gl_profile.conn_id = param->connect.conn_id;
uint8_t client_addr[6] = { param->connect.remote_bda[0], param->connect.remote_bda[1], param->connect.remote_bda[2], param->connect.remote_bda[3], param->connect.remote_bda[4], param->connect.remote_bda[5] };
gatt_perihperal_update_connection_params( client_addr );
break;
Code: Select all
void gatt_perihperal_update_connection_params(uint8_t* client_addr)
{
esp_ble_conn_update_params_t conn_params;
memcpy(conn_params.bda, client_addr, sizeof( 6 ) );
conn_params.min_int = 0x06;
conn_params.max_int = 0x40;
conn_params.latency = 0x00;
conn_params.timeout = 0x0C80; // Maximum value to test if timeout is the issue with Android
esp_ble_gap_update_conn_params(&conn_params);
}
-
- Posts: 79
- Joined: Tue Apr 26, 2016 5:10 am
Re: Changing Supervision timeout on BLE
Hi Frostyowned
Hmm that is quite strange. I have placed the function in essentially the same location and it works well for me.
Not sure why this would be erroring, unless for some reason the connection event was not successful?
FYI you can just pass to the function without doing this bit of code
Hmm that is quite strange. I have placed the function in essentially the same location and it works well for me.
Not sure why this would be erroring, unless for some reason the connection event was not successful?
FYI you can just pass
Code: Select all
param->connect.remote_bda
Code: Select all
uint8_t client_addr[6] = { param->connect.remote_bda[0], param->connect.remote_bda[1], param->connect.remote_bda[2], param->connect.remote_bda[3], param->connect.remote_bda[4], param->connect.remote_bda[5] };
Re: Changing Supervision timeout on BLE
hi frostyowned,
you may try with the latest IDF. There was a bug that slave can't update conn param.
@Lucas.Hutchinson update conn param should be a function available both for master and slave.
you may try with the latest IDF. There was a bug that slave can't update conn param.
@Lucas.Hutchinson update conn param should be a function available both for master and slave.
-
- Posts: 20
- Joined: Wed Jun 28, 2017 1:22 pm
Re: Changing Supervision timeout on BLE
I tried to update to latest IDF but am now seeing this error when I try to compileheyinling wrote:hi frostyowned,
you may try with the latest IDF. There was a bug that slave can't update conn param.
@Lucas.Hutchinson update conn param should be a function available both for master and slave.
Code: Select all
C:\msys32\opt\xtensa-esp32-elf\bin\xtensa-esp32-elf-gcc-ar.exe: Cannot find plugin 'liblto_plugin-0.dll'
-
- Posts: 79
- Joined: Tue Apr 26, 2016 5:10 am
Re: Changing Supervision timeout on BLE
This is part of espressif changing the bootloader to use LTO during compilation to save compiled code size.
More details and a solution can be found here:
https://github.com/espressif/esp-idf/issues/828
Alternately switch to using the release/v2.1 branch.
More details and a solution can be found here:
https://github.com/espressif/esp-idf/issues/828
Alternately switch to using the release/v2.1 branch.
Who is online
Users browsing this forum: No registered users and 88 guests