From cc09f5b47e933f5b445c1a440e24000492a72a6b Mon Sep 17 00:00:00 2001 From: leo Date: Sat, 3 Dec 2022 13:23:35 +0100 Subject: [PATCH] 4s conn interval --- components/BTlib/BTlib_nimble.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/components/BTlib/BTlib_nimble.c b/components/BTlib/BTlib_nimble.c index 3949218..fc4db3b 100644 --- a/components/BTlib/BTlib_nimble.c +++ b/components/BTlib/BTlib_nimble.c @@ -1,3 +1,5 @@ +#include "host/ble_gap.h" +#include "nimble/hci_common.h" #include "sdkconfig.h" #ifdef CONFIG_BT_NIMBLE_ENABLED @@ -76,6 +78,14 @@ struct ble_gap_adv_params adv_params = { .itvl_max = 0x4000, }; +struct ble_gap_upd_params conn_params = { + .itvl_min = 3200, //Minimum value for connection interval in 1.25ms units min=6 (7.5ms) max=3200 (4s) + .itvl_max = 3200, + .latency = 0, + .supervision_timeout = 3200, //Supervision timeout in 10ms units min=10 max=3200 + .min_ce_len = 0, //Minimum length of connection event in 0.625ms units + .max_ce_len = 0, +}; static struct ble_gatt_svc_def gatt_svr_svcs[] = { [ES_SVC_IDX] = { @@ -218,7 +228,10 @@ static int ble_gap_event(struct ble_gap_event *event, void* arg){ ESP_LOGI(NIMBLE_LOG_TAG, "connect event"); if(event->connect.status) ble_advertise(); - conn_handle = event->connect.conn_handle; + else { + conn_handle = event->connect.conn_handle; + ESP_ERROR_CHECK(ble_gap_update_params(event->connect.conn_handle, &conn_params)); + } break; case BLE_GAP_EVENT_DISCONNECT: ESP_LOGI(NIMBLE_LOG_TAG, "disconnect event");