- Added the error code for the time out status.
ESP_BT_STATUS_RMT_DEV_DOWN = 10, /* relate to BT_STATUS_RMT_DEV_DOWN in bt_def.h */
ESP_BT_STATUS_AUTH_REJECTED, /* relate to BT_STATUS_AUTH_REJECTED in bt_def.h */
ESP_BT_STATUS_INVALID_STATIC_RAND_ADDR, /* relate to BT_STATUS_INVALID_STATIC_RAND_ADDR in bt_def.h */
+ ESP_BT_STATUS_PENDING, /* relate to BT_STATUS_PENDING in bt_def.h */
+ ESP_BT_STATUS_UNACCEPT_CONN_INTERVAL, /* relate to BT_UNACCEPT_CONN_INTERVAL in bt_def.h */
+ ESP_BT_STATUS_PARAM_OUT_OF_RANGE, /* relate to BT_PARAM_OUT_OF_RANGE in bt_def.h */
+ ESP_BT_STATUS_TIMEOUT, /* relate to BT_STATUS_TIMEOUT in bt_def.h */
} esp_bt_status_t;
ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT, /*!< When stop adv complete, the event comes */
ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT, /*!< When stop scan complete, the event comes */
ESP_GAP_BLE_SET_STATIC_RAND_ADDR_EVT, /*!< When set the static rand address complete, the event comes */
+ ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT, /*!< When update connection parameters complete, the event comes */
} esp_gap_ble_cb_event_t;
/// Advertising data maximum length
struct ble_set_rand_cmpl_evt_param {
esp_bt_status_t status; /*!< Indicate set static rand address operation success status */
} set_rand_addr_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_STATIC_RAND_ADDR_EVT */
+ /**
+ * @brief ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT
+ */
+ struct ble_update_conn_params_evt_param {
+ esp_bt_status_t status; /*!< Indicate update connection parameters success status */
+ esp_bd_addr_t bda; /*!< Bluetooth device address */
+ uint16_t min_int; /*!< Min connection interval */
+ uint16_t max_int; /*!< Max connection interval */
+ uint16_t latency; /*!< Slave latency for the connection in number of connection events. Range: 0x0000 to 0x01F3 */
+ uint16_t conn_int; /*!< Current connection interval */
+ uint16_t timeout; /*!< Supervision timeout for the LE Link. Range: 0x000A to 0x0C80.
+ Mandatory Range: 0x000A to 0x0C80 Time = N * 10 msec */
+ }update_conn_params; /*!< Event parameter of ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT */
} esp_ble_gap_cb_param_t;
/**
*******************************************************************************/
void bta_dm_ble_update_conn_params (tBTA_DM_MSG *p_data)
{
+ tACL_CONN *p_acl_cb = btm_bda_to_acl(p_data->ble_update_conn_params.bd_addr, BT_TRANSPORT_LE);
+ if (p_acl_cb == NULL) {
+ APPL_TRACE_ERROR("%s error: Invalid connection bd_addr.", __func__);
+ return;
+ } else {
+ p_acl_cb->update_conn_param_cb = p_data->ble_update_conn_params.update_conn_param_cb;
+ }
if (!L2CA_UpdateBleConnParams(p_data->ble_update_conn_params.bd_addr,
p_data->ble_update_conn_params.min_int,
p_data->ble_update_conn_params.max_int,
**
*******************************************************************************/
void BTA_DmBleUpdateConnectionParams(BD_ADDR bd_addr, UINT16 min_int, UINT16 max_int,
- UINT16 latency, UINT16 timeout)
+ UINT16 latency, UINT16 timeout, tBTA_UPDATE_CONN_PARAM_CBACK *update_conn_param_cb)
{
tBTA_DM_API_UPDATE_CONN_PARAM *p_msg;
p_msg->max_int = max_int;
p_msg->latency = latency;
p_msg->timeout = timeout;
-
+ p_msg->update_conn_param_cb = update_conn_param_cb;
bta_sys_sendmsg(p_msg);
}
}
UINT16 max_int;
UINT16 latency;
UINT16 timeout;
+ tBTA_UPDATE_CONN_PARAM_CBACK *update_conn_param_cb;
} tBTA_DM_API_UPDATE_CONN_PARAM;
#if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE
void bta_gatts_set_attr_value(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg)
{
tBTA_GATTS_RCB *p_rcb = &bta_gatts_cb.rcb[p_srvc_cb->rcb_idx];
- UINT16 attr_id = 0;
+ UINT16 service_id = p_srvc_cb->service_id;
tBTA_GATTS cb_data;
tBTA_GATT_STATUS gatts_status;
gatts_status = GATTS_SetAttributeValue(p_msg->api_add_char_descr.hdr.layer_specific,
p_msg->api_set_val.value);
cb_data.attr_val.server_if = p_rcb->gatt_if;
- cb_data.attr_val.service_id = p_msg->api_set_val.hdr.layer_specific;
- cb_data.attr_val.attr_id = attr_id;
+ cb_data.attr_val.service_id = service_id;
+ cb_data.attr_val.attr_id = p_msg->api_set_val.hdr.layer_specific;
cb_data.attr_val.status = gatts_status;
if (p_rcb->p_cback) {
typedef BOOLEAN (tBTA_DM_BLE_SEL_CBACK)(BD_ADDR random_bda, UINT8 *p_remote_name);
+typedef tBTM_LE_UPDATE_CONN_PRAMS tBTA_LE_UPDATE_CONN_PRAMS;
+typedef tBTM_UPDATE_CONN_PARAM_CBACK tBTA_UPDATE_CONN_PARAM_CBACK;
+
+
/* Structure associated with BTA_DM_BLE_SEC_REQ_EVT */
typedef struct {
BD_ADDR bd_addr; /* peer address */
**
*******************************************************************************/
extern void BTA_DmBleUpdateConnectionParams(BD_ADDR bd_addr, UINT16 min_int,
- UINT16 max_int, UINT16 latency, UINT16 timeout);
+ UINT16 max_int, UINT16 latency, UINT16 timeout, tBTA_UPDATE_CONN_PARAM_CBACK *update_conn_param_cb);
/*******************************************************************************
**
}
+static esp_bt_status_t btc_hci_to_esp_status(uint8_t hci_status)
+{
+ esp_bt_status_t esp_status = ESP_BT_STATUS_FAIL;
+ switch(hci_status) {
+ case HCI_SUCCESS:
+ esp_status = ESP_BT_STATUS_SUCCESS;
+ break;
+ case HCI_ERR_HOST_TIMEOUT:
+ esp_status = ESP_BT_STATUS_TIMEOUT;
+ break;
+ case HCI_ERR_ILLEGAL_COMMAND:
+ esp_status = ESP_BT_STATUS_PENDING;
+ break;
+ case HCI_ERR_UNACCEPT_CONN_INTERVAL:
+ esp_status = ESP_BT_STATUS_UNACCEPT_CONN_INTERVAL;
+ break;
+ case HCI_ERR_PARAM_OUT_OF_RANGE:
+ esp_status = ESP_BT_STATUS_PARAM_OUT_OF_RANGE;
+ break;
+ default:
+ esp_status = ESP_BT_STATUS_FAIL;
+ break;
+ }
+
+ return esp_status;
+}
+
static void btc_to_bta_adv_data(esp_ble_adv_data_t *p_adv_data, tBTA_BLE_ADV_DATA *bta_adv_data, uint32_t *data_mask)
{
uint32_t mask;
}
}
+void btc_update_conn_param_callback (UINT8 status, BD_ADDR bd_addr,
+ tBTM_LE_UPDATE_CONN_PRAMS *update_conn_params)
+{
+ esp_ble_gap_cb_param_t param;
+ bt_status_t ret;
+ btc_msg_t msg;
+ msg.sig = BTC_SIG_API_CB;
+ msg.pid = BTC_PID_GAP_BLE;
+ msg.act = ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT;
+ param.update_conn_params.status = btc_hci_to_esp_status(status);
+ param.update_conn_params.min_int = update_conn_params->min_conn_int;
+ param.update_conn_params.max_int = update_conn_params->max_conn_int;
+ param.update_conn_params.conn_int = update_conn_params->conn_int;
+ param.update_conn_params.latency = update_conn_params->slave_latency;
+ param.update_conn_params.timeout = update_conn_params->supervision_tout;
+ memcpy(param.update_conn_params.bda, bd_addr, sizeof(esp_bd_addr_t));
+ ret = btc_transfer_context(&msg, ¶m,
+ sizeof(esp_ble_gap_cb_param_t), NULL);
+
+ if (ret != BT_STATUS_SUCCESS) {
+ LOG_ERROR("%s btc_transfer_context failed\n", __func__);
+ }
+}
+
+
#if (SMP_INCLUDED == TRUE)
static void btc_set_encryption_callback(BD_ADDR bd_addr, tBTA_TRANSPORT transport, tBTA_STATUS enc_status)
{
}
static void btc_ble_update_conn_params(BD_ADDR bd_addr, uint16_t min_int,
- uint16_t max_int, uint16_t latency, uint16_t timeout)
+ uint16_t max_int, uint16_t latency, uint16_t timeout,
+ tBTA_UPDATE_CONN_PARAM_CBACK *update_conn_param_cb)
{
if (min_int > max_int) {
min_int = max_int;
}
BTA_DmBleUpdateConnectionParams(bd_addr, min_int, max_int,
- latency, timeout);
+ latency, timeout, update_conn_param_cb);
}
static void btc_ble_set_pkt_data_len(BD_ADDR remote_device, uint16_t tx_data_length)
break;
case ESP_GAP_BLE_SET_STATIC_RAND_ADDR_EVT:
btc_gap_ble_cb_to_app(ESP_GAP_BLE_SET_STATIC_RAND_ADDR_EVT, param);
+ break;
+ case ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT:
+ btc_gap_ble_cb_to_app(ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT, param);
+ break;
default:
break;
arg->conn_update_params.conn_params.min_int,
arg->conn_update_params.conn_params.max_int,
arg->conn_update_params.conn_params.latency,
- arg->conn_update_params.conn_params.timeout);
+ arg->conn_update_params.conn_params.timeout,
+ btc_update_conn_param_callback);
break;
case BTC_GAP_BLE_ACT_SET_PKT_DATA_LEN:
btc_ble_set_pkt_data_len(arg->set_pkt_data_len.remote_device, arg->set_pkt_data_len.tx_data_length);
BT_STATUS_RMT_DEV_DOWN,
BT_STATUS_AUTH_REJECTED,
BT_STATUS_INVALID_STATIC_RAND_ADDR,
+ BT_STATUS_PENDING,
+ BT_STATUS_UNACCEPT_CONN_INTERVAL,
+ BT_STATUS_PARAM_OUT_OF_RANGE,
+ BT_STATUS_TIMEOUT,
} bt_status_t;
#ifndef CPU_LITTLE_ENDIAN
/* We can enable the update request if the result is a success. */
/* extract the HCI handle first */
UINT8 status;
- UINT16 handle;
-
+ UINT16 handle, conn_interval, conn_latency, conn_timeout;
STREAM_TO_UINT8 (status, p);
STREAM_TO_UINT16 (handle, p);
- l2cble_process_conn_update_evt(handle, status);
+ STREAM_TO_UINT16 (conn_interval, p);
+ STREAM_TO_UINT16 (conn_latency, p);
+ STREAM_TO_UINT16 (conn_timeout, p);
+
+ l2cble_process_conn_update_evt(handle, status, conn_interval,
+ conn_latency, conn_timeout);
}
static void btu_ble_read_remote_feat_evt (UINT8 *p)
case BTU_TTYPE_L2CAP_HOLD:
case BTU_TTYPE_L2CAP_INFO:
case BTU_TTYPE_L2CAP_FCR_ACK:
+ case BTU_TTYPE_L2CAP_UPDA_CONN_PARAMS:
l2c_process_timeout (p_tle);
break;
#if (defined(SDP_INCLUDED) && SDP_INCLUDED == TRUE)
typedef UINT8 tBTM_DEV_STATUS;
+typedef struct {
+ UINT16 min_conn_int;
+ UINT16 max_conn_int;
+ UINT16 conn_int;
+ UINT16 slave_latency;
+ UINT16 supervision_tout;
+}tBTM_LE_UPDATE_CONN_PRAMS;
+
typedef void (tBTM_DEV_STATUS_CB) (tBTM_DEV_STATUS status);
*/
typedef UINT8 (tBTM_FILTER_CB) (BD_ADDR bd_addr, DEV_CLASS dc);
+typedef void (tBTM_UPDATE_CONN_PARAM_CBACK) (UINT8 status, BD_ADDR bd_addr, tBTM_LE_UPDATE_CONN_PRAMS *update_conn_params);
+
+
/*****************************************************************************
** DEVICE DISCOVERY - Inquiry, Remote Name, Discovery, Class of Device
*****************************************************************************/
BD_ADDR active_remote_addr; /* remote address used on this connection */
UINT8 active_remote_addr_type; /* local device address type for this connection */
BD_FEATURES peer_le_features; /* Peer LE Used features mask for the device */
-
+tBTM_UPDATE_CONN_PARAM_CBACK *update_conn_param_cb;
#endif
} tACL_CONN;
/* eL2CAP Info Request and other proto cmds timer */
#define BTU_TTYPE_L2CAP_FCR_ACK 78
#define BTU_TTYPE_L2CAP_INFO 79
+/* L2CAP update connection parameters timer */
+#define BTU_TTYPE_L2CAP_UPDA_CONN_PARAMS 80
#define BTU_TTYPE_MCA_CCB_RSP 98
#define L2CAP_DELAY_CHECK_SM4 2 /* 2 seconds */
#define L2CAP_WAIT_INFO_RSP_TOUT 3 /* 3 seconds */
#define L2CAP_WAIT_UNPARK_TOUT 2 /* 2 seconds */
-#define L2CAP_LINK_INFO_RESP_TOUT 2 /* 2 seconds */
+#define L2CAP_LINK_INFO_RESP_TOUT 2 /* 2 seconds */
+#define L2CAP_UPDATE_CONN_PARAM_TOUT 6 /* 6 seconds */
#define L2CAP_BLE_LINK_CONNECT_TOUT 30 /* 30 seconds */
-#define L2CAP_BLE_CONN_PARAM_UPD_TOUT 30 /* 30 seconds */
+#define L2CAP_BLE_CONN_PARAM_UPD_TOUT 30 /* 30 seconds */
/* quick timer uses millisecond unit */
#define L2CAP_DEFAULT_RETRANS_TOUT 2000 /* 2000 milliseconds */
tL2C_CCB *p_pending_ccb; /* ccb of waiting channel during link disconnect */
TIMER_LIST_ENT info_timer_entry; /* Timer entry for info resp timeout evt */
+ TIMER_LIST_ENT upda_con_timer; /* Timer entry for update connection parametr */
BD_ADDR remote_bd_addr; /* The BD address of the remote */
UINT8 link_role; /* Master or slave */
UINT16 min_interval; /* parameters as requested by peripheral */
UINT16 max_interval;
+ UINT16 conn_int;
UINT16 latency;
UINT16 timeout;
extern BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb);
extern void l2cble_notify_le_connection (BD_ADDR bda);
extern void l2c_ble_link_adjust_allocation (void);
-extern void l2cble_process_conn_update_evt (UINT16 handle, UINT8 status);
+extern void l2cble_process_conn_update_evt (UINT16 handle, UINT8 status, UINT16 conn_interval,
+ UINT16 conn_latency, UINT16 conn_timeout);
#if (defined BLE_LLT_INCLUDED) && (BLE_LLT_INCLUDED == TRUE)
extern void l2cble_process_rc_param_request_evt(UINT16 handle, UINT16 int_min, UINT16 int_max,
extern void l2cble_update_data_length(tL2C_LCB *p_lcb);
extern void l2cble_set_fixed_channel_tx_data_length(BD_ADDR remote_bda, UINT16 fix_cid,
UINT16 tx_mtu);
+extern void l2c_send_update_conn_params_cb(tL2C_LCB *p_lcb, UINT8 status);
extern void l2cble_process_data_length_change_event(UINT16 handle, UINT16 tx_data_len,
UINT16 rx_data_len);
{
UINT16 min_conn_int, max_conn_int, slave_latency, supervision_tout;
tACL_CONN *p_acl_cb = btm_bda_to_acl(p_lcb->remote_bd_addr, BT_TRANSPORT_LE);
+ UINT8 status;
+ btu_start_timer(&p_lcb->upda_con_timer, BTU_TTYPE_L2CAP_UPDA_CONN_PARAMS, L2CAP_UPDATE_CONN_PARAM_TOUT);
if (p_lcb->conn_update_mask & L2C_BLE_UPDATE_PENDING) {
+ if (p_acl_cb != NULL && p_acl_cb->update_conn_param_cb != NULL) {
+ status = HCI_ERR_ILLEGAL_COMMAND;
+ L2CAP_TRACE_ERROR("%s, staus = %x", __func__, status);
+ btu_stop_timer(&p_lcb->upda_con_timer);
+ l2c_send_update_conn_params_cb(p_lcb, status);
+ }
return;
}
}
p_lcb->conn_update_mask &= ~L2C_BLE_NOT_DEFAULT_PARAM;
p_lcb->conn_update_mask |= L2C_BLE_NEW_CONN_PARAM;
+ } else {
+ status = HCI_ERR_ILLEGAL_COMMAND;
+ L2CAP_TRACE_DEBUG("%s, staus = %x", __func__, status);
+ btu_stop_timer(&p_lcb->upda_con_timer);
+ l2c_send_update_conn_params_cb(p_lcb, status);
+ return;
}
} else {
/* application allows to do update, if we were delaying one do it now */
}
p_lcb->conn_update_mask &= ~L2C_BLE_NEW_CONN_PARAM;
p_lcb->conn_update_mask |= L2C_BLE_NOT_DEFAULT_PARAM;
+ } else {
+ status = HCI_ERR_ILLEGAL_COMMAND;
+ L2CAP_TRACE_DEBUG("%s, staus = %x", __func__, status);
+ btu_stop_timer(&p_lcb->upda_con_timer);
+ l2c_send_update_conn_params_cb(p_lcb, status);
+ return;
}
}
}
** Returns void
**
*******************************************************************************/
-void l2cble_process_conn_update_evt (UINT16 handle, UINT8 status)
+void l2cble_process_conn_update_evt (UINT16 handle, UINT8 status, UINT16 conn_interval,
+ UINT16 conn_latency, UINT16 conn_timeout)
{
tL2C_LCB *p_lcb;
return;
}
+ tACL_CONN *p_acl_cb = btm_bda_to_acl(p_lcb->remote_bd_addr, BT_TRANSPORT_LE);
p_lcb->conn_update_mask &= ~L2C_BLE_UPDATE_PENDING;
if (status != HCI_SUCCESS) {
l2cble_start_conn_update(p_lcb);
+ btu_stop_timer (&p_lcb->timer_entry);
+ btu_stop_timer (&p_lcb->upda_con_timer);
+
+ if (p_acl_cb->update_conn_param_cb != NULL) {
+ l2c_send_update_conn_params_cb(p_lcb, status);
+ }
+
L2CAP_TRACE_DEBUG("l2cble_process_conn_update_evt: conn_update_mask=%d", p_lcb->conn_update_mask);
}
/*******************************************************************************
latency > BTM_BLE_CONN_LATENCY_MAX ||
/*(timeout >= max_interval && latency > (timeout * 10/(max_interval * 1.25) - 1)) ||*/
timeout < BTM_BLE_CONN_SUP_TOUT_MIN || timeout > BTM_BLE_CONN_SUP_TOUT_MAX ||
+ timeout <= ((1 + latency)*BTM_BLE_CONN_INT_MAX*2) ||
max_interval < min_interval) {
l2cu_send_peer_ble_par_rsp (p_lcb, L2CAP_CFG_UNACCEPTABLE_PARAMS, id);
+ UINT8 status = HCI_ERR_PARAM_OUT_OF_RANGE;
+ l2c_send_update_conn_params_cb(p_lcb, status);
} else {
l2cu_send_peer_ble_par_rsp (p_lcb, L2CAP_CFG_OK, id);
}
break;
- case L2CAP_CMD_BLE_UPDATE_RSP:
- p += 2;
+ case L2CAP_CMD_BLE_UPDATE_RSP: {
+ UINT16 result = 0;
+ STREAM_TO_UINT16(result, p); //result = 0 connection param accepted, result = 1 connection param rejected.
+ UINT8 status = (result == 0) ? HCI_SUCCESS : HCI_ERR_PARAM_OUT_OF_RANGE;
+ if (status != HCI_SUCCESS) {
+ btu_stop_timer(&p_lcb->upda_con_timer);
+ l2c_send_update_conn_params_cb(p_lcb, status);
+ }
break;
-
+ }
default:
L2CAP_TRACE_WARNING ("L2CAP - LE - unknown cmd code: %d", cmd_code);
l2cu_send_peer_cmd_reject (p_lcb, L2CAP_CMD_REJ_NOT_UNDERSTOOD, id, 0, 0);
l2cble_update_data_length(p_lcb);
}
+
+/*******************************************************************************
+**
+** Function l2c_send_update_conn_params_cb
+**
+** Description This function send the update connection parameter callback to the uplayer.
+**
+** Returns void
+**
+*******************************************************************************/
+void l2c_send_update_conn_params_cb(tL2C_LCB *p_lcb, UINT8 status)
+{
+ tACL_CONN *p_acl_cb = btm_bda_to_acl(p_lcb->remote_bd_addr, BT_TRANSPORT_LE);
+ if (p_acl_cb != NULL && p_acl_cb->update_conn_param_cb != NULL) {
+ tBTM_LE_UPDATE_CONN_PRAMS update_param;
+ update_param.max_conn_int = p_lcb->max_interval;
+ update_param.min_conn_int = p_lcb->min_interval;
+ update_param.conn_int = p_lcb->conn_int;
+ update_param.slave_latency = p_lcb->latency;
+ update_param.supervision_tout = p_lcb->timeout;
+ (p_acl_cb->update_conn_param_cb)(status, p_acl_cb->active_remote_addr, &update_param);
+ }
+}
+
#endif /* (BLE_INCLUDED == TRUE) */
case BTU_TTYPE_L2CAP_INFO:
l2c_info_timeout((tL2C_LCB *)p_tle->param);
break;
+ case BTU_TTYPE_L2CAP_UPDA_CONN_PARAMS: {
+ UINT8 status = HCI_ERR_HOST_TIMEOUT;
+ l2c_send_update_conn_params_cb((tL2C_LCB *)p_tle->param, status);
+ break;
+ }
}
}
p_lcb->link_flush_tout = 0xFFFF;
p_lcb->timer_entry.param = (TIMER_PARAM_TYPE)p_lcb;
p_lcb->info_timer_entry.param = (TIMER_PARAM_TYPE)p_lcb;
+ p_lcb->upda_con_timer.param = (TIMER_PARAM_TYPE)p_lcb;
p_lcb->idle_timeout = l2cb.idle_timeout;
p_lcb->id = 1; /* spec does not allow '0' */
p_lcb->is_bonding = is_bonding;
SMP_TRACE_EVENT ("%s", __func__);
if (transport != BT_TRANSPORT_BR_EDR) {
- SMP_TRACE_WARNING("%s is called on unexpected transport %d\n",
+ SMP_TRACE_EVENT ("%s is called on unexpected transport %d\n",
__func__, transport);
return;
}
ESP_LOGI(GATTS_TAG, "Stop adv successfully\n");
}
break;
+ case ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT:
+ ESP_LOGI(GATTS_TAG, "update connetion params status = %d, min_int = %x, max_int = %x,\
+ conn_int = %d,latency = %d, timeout = %d", param->update_conn_params.status,
+ param->update_conn_params.min_int,
+ param->update_conn_params.max_int,
+ param->update_conn_params.conn_int,
+ param->update_conn_params.latency,
+ param->update_conn_params.timeout);
+ break;
default:
break;
}
break;
case ESP_GATTS_STOP_EVT:
break;
- case ESP_GATTS_CONNECT_EVT:
+ case ESP_GATTS_CONNECT_EVT: {
+ esp_ble_conn_update_params_t conn_params = {0};
+ memcpy(conn_params.bda, param->connect.remote_bda, sizeof(esp_bd_addr_t));
+ conn_params.latency = 0;
+ conn_params.max_int = 0x50; // max_int = 0x50*1.25ms = 100ms
+ conn_params.min_int = 0x30; // min_int = 0x30*1.25ms = 60ms
+ conn_params.timeout = 400; // timeout = 400*10ms = 4000ms
ESP_LOGI(GATTS_TAG, "ESP_GATTS_CONNECT_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_tab[PROFILE_A_APP_ID].conn_id = param->connect.conn_id;
+ //start sent the update connection parameters to the peer device.
+ esp_ble_gap_update_conn_params(&conn_params);
break;
+ }
case ESP_GATTS_DISCONNECT_EVT:
esp_ble_gap_start_advertising(&test_adv_params);
break;