mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
fix(nimble): Added security related fixes
This commit is contained in:
committed by
Rahul Tank
parent
9212238bf1
commit
b5f5f08022
Submodule components/bt/host/nimble/nimble updated: 655895824d...843673ada2
@@ -159,17 +159,17 @@ static void gatts_profile_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_
|
|||||||
adv_config_done |= scan_rsp_config_flag;
|
adv_config_done |= scan_rsp_config_flag;
|
||||||
break;
|
break;
|
||||||
case ESP_GATTS_READ_EVT:
|
case ESP_GATTS_READ_EVT:
|
||||||
if (g_ble_cfg_p) {
|
if (g_ble_cfg_p && g_ble_cfg_p->read_fn) {
|
||||||
g_ble_cfg_p->read_fn(event, gatts_if, param);
|
g_ble_cfg_p->read_fn(event, gatts_if, param);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ESP_GATTS_WRITE_EVT:
|
case ESP_GATTS_WRITE_EVT:
|
||||||
if (g_ble_cfg_p) {
|
if (g_ble_cfg_p && g_ble_cfg_p->write_fn) {
|
||||||
g_ble_cfg_p->write_fn(event, gatts_if, param);
|
g_ble_cfg_p->write_fn(event, gatts_if, param);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ESP_GATTS_EXEC_WRITE_EVT:
|
case ESP_GATTS_EXEC_WRITE_EVT:
|
||||||
if (g_ble_cfg_p) {
|
if (g_ble_cfg_p && g_ble_cfg_p->exec_write_fn) {
|
||||||
g_ble_cfg_p->exec_write_fn(event, gatts_if, param);
|
g_ble_cfg_p->exec_write_fn(event, gatts_if, param);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -187,7 +187,7 @@ static void gatts_profile_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_
|
|||||||
break;
|
break;
|
||||||
case ESP_GATTS_CONNECT_EVT:
|
case ESP_GATTS_CONNECT_EVT:
|
||||||
ESP_LOGD(TAG, "ESP_GATTS_CONNECT_EVT, conn_id = %d", param->connect.conn_id);
|
ESP_LOGD(TAG, "ESP_GATTS_CONNECT_EVT, conn_id = %d", param->connect.conn_id);
|
||||||
if (g_ble_cfg_p) {
|
if (g_ble_cfg_p && g_ble_cfg_p->connect_fn) {
|
||||||
g_ble_cfg_p->connect_fn(event, gatts_if, param);
|
g_ble_cfg_p->connect_fn(event, gatts_if, param);
|
||||||
}
|
}
|
||||||
esp_ble_conn_update_params_t conn_params = {0};
|
esp_ble_conn_update_params_t conn_params = {0};
|
||||||
@@ -202,7 +202,7 @@ static void gatts_profile_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_
|
|||||||
break;
|
break;
|
||||||
case ESP_GATTS_DISCONNECT_EVT:
|
case ESP_GATTS_DISCONNECT_EVT:
|
||||||
ESP_LOGD(TAG, "ESP_GATTS_DISCONNECT_EVT, reason = %d", param->disconnect.reason);
|
ESP_LOGD(TAG, "ESP_GATTS_DISCONNECT_EVT, reason = %d", param->disconnect.reason);
|
||||||
if (g_ble_cfg_p) {
|
if (g_ble_cfg_p && g_ble_cfg_p->disconnect_fn) {
|
||||||
g_ble_cfg_p->disconnect_fn(event, gatts_if, param);
|
g_ble_cfg_p->disconnect_fn(event, gatts_if, param);
|
||||||
}
|
}
|
||||||
memset(s_cached_remote_bda, 0, sizeof(esp_bd_addr_t));
|
memset(s_cached_remote_bda, 0, sizeof(esp_bd_addr_t));
|
||||||
@@ -263,7 +263,6 @@ esp_err_t simple_ble_deinit(void)
|
|||||||
simple_ble_cfg_t *ble_cfg = g_ble_cfg_p;
|
simple_ble_cfg_t *ble_cfg = g_ble_cfg_p;
|
||||||
g_ble_cfg_p = NULL;
|
g_ble_cfg_p = NULL;
|
||||||
if (ble_cfg) {
|
if (ble_cfg) {
|
||||||
free(ble_cfg->gatt_db);
|
|
||||||
ble_cfg->gatt_db = NULL;
|
ble_cfg->gatt_db = NULL;
|
||||||
free(ble_cfg);
|
free(ble_cfg);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ typedef struct _protocomm_ble {
|
|||||||
} _protocomm_ble_internal_t;
|
} _protocomm_ble_internal_t;
|
||||||
|
|
||||||
static _protocomm_ble_internal_t *protoble_internal;
|
static _protocomm_ble_internal_t *protoble_internal;
|
||||||
|
static esp_gatts_attr_db_t *s_gatt_db;
|
||||||
|
|
||||||
static bool protocomm_ble_transport_active(void)
|
static bool protocomm_ble_transport_active(void)
|
||||||
{
|
{
|
||||||
@@ -715,6 +716,8 @@ static ssize_t populate_gatt_db(esp_gatts_attr_db_t **gatt_db_generated)
|
|||||||
static void protocomm_ble_cleanup(void)
|
static void protocomm_ble_cleanup(void)
|
||||||
{
|
{
|
||||||
protocomm_ble_reset_prepare_write();
|
protocomm_ble_reset_prepare_write();
|
||||||
|
free(s_gatt_db);
|
||||||
|
s_gatt_db = NULL;
|
||||||
if (protoble_internal) {
|
if (protoble_internal) {
|
||||||
if (protoble_internal->service_uuid) {
|
if (protoble_internal->service_uuid) {
|
||||||
free(protoble_internal->service_uuid);
|
free(protoble_internal->service_uuid);
|
||||||
@@ -891,6 +894,7 @@ esp_err_t protocomm_ble_start(protocomm_t *pc, const protocomm_ble_config_t *con
|
|||||||
|
|
||||||
ble_config->device_name = protocomm_ble_device_name;
|
ble_config->device_name = protocomm_ble_device_name;
|
||||||
ble_config->gatt_db_count = populate_gatt_db(&ble_config->gatt_db);
|
ble_config->gatt_db_count = populate_gatt_db(&ble_config->gatt_db);
|
||||||
|
s_gatt_db = ble_config->gatt_db;
|
||||||
|
|
||||||
ble_config->ble_bonding = config->ble_bonding;
|
ble_config->ble_bonding = config->ble_bonding;
|
||||||
ble_config->ble_sm_sc = config->ble_sm_sc;
|
ble_config->ble_sm_sc = config->ble_sm_sc;
|
||||||
@@ -904,7 +908,9 @@ esp_err_t protocomm_ble_start(protocomm_t *pc, const protocomm_ble_config_t *con
|
|||||||
|
|
||||||
if (ble_config->gatt_db_count == -1) {
|
if (ble_config->gatt_db_count == -1) {
|
||||||
ESP_LOGE(TAG, "Invalid GATT database count");
|
ESP_LOGE(TAG, "Invalid GATT database count");
|
||||||
free(ble_config->gatt_db);
|
free(s_gatt_db);
|
||||||
|
s_gatt_db = NULL;
|
||||||
|
ble_config->gatt_db = NULL;
|
||||||
free(ble_config);
|
free(ble_config);
|
||||||
protocomm_ble_cleanup();
|
protocomm_ble_cleanup();
|
||||||
return ESP_ERR_INVALID_STATE;
|
return ESP_ERR_INVALID_STATE;
|
||||||
|
|||||||
Reference in New Issue
Block a user