diff --git a/components/bt/esp_ble_mesh/mesh_common/include/mesh_buf.h b/components/bt/esp_ble_mesh/mesh_common/include/mesh_buf.h index bcc7b513a..32c12817e 100644 --- a/components/bt/esp_ble_mesh/mesh_common/include/mesh_buf.h +++ b/components/bt/esp_ble_mesh/mesh_common/include/mesh_buf.h @@ -11,6 +11,7 @@ #ifndef _BLE_MESH_BUF_H_ #define _BLE_MESH_BUF_H_ +#include "sdkconfig.h" #include "mesh_slist.h" #include "mesh_compiler.h" diff --git a/components/bt/esp_ble_mesh/mesh_core/friend.c b/components/bt/esp_ble_mesh/mesh_core/friend.c index cf8c84642..0c714bc9b 100644 --- a/components/bt/esp_ble_mesh/mesh_core/friend.c +++ b/components/bt/esp_ble_mesh/mesh_core/friend.c @@ -67,6 +67,8 @@ enum { static void (*friend_cb)(bool establish, u16_t lpn_addr, u8_t reason); +static bool friend_init = false; + static struct bt_mesh_subnet *friend_subnet_get(u16_t net_idx) { struct bt_mesh_subnet *sub = NULL; @@ -1243,6 +1245,11 @@ int bt_mesh_friend_init(void) { int i; + if (friend_init == true) { + BT_WARN("%s, Already", __func__); + return -EALREADY; + } + for (i = 0; i < ARRAY_SIZE(bt_mesh.frnd); i++) { struct bt_mesh_friend *frnd = &bt_mesh.frnd[i]; int j; @@ -1259,6 +1266,8 @@ int bt_mesh_friend_init(void) } } + friend_init = true; + return 0; } @@ -1266,6 +1275,11 @@ int bt_mesh_friend_deinit(void) { int i; + if (friend_init == false) { + BT_WARN("%s, Already", __func__); + return -EALREADY; + } + bt_mesh_friend_clear_net_idx(BLE_MESH_KEY_ANY); for (i = 0; i < ARRAY_SIZE(bt_mesh.frnd); i++) { @@ -1280,6 +1294,8 @@ int bt_mesh_friend_deinit(void) bt_mesh_unref_buf_from_pool(&friend_buf_pool); memset(adv_pool, 0, sizeof(adv_pool)); + friend_init = false; + return 0; } diff --git a/components/bt/esp_ble_mesh/mesh_core/include/mesh_bearer_adapt.h b/components/bt/esp_ble_mesh/mesh_core/include/mesh_bearer_adapt.h index a02db01ac..c538b7021 100644 --- a/components/bt/esp_ble_mesh/mesh_core/include/mesh_bearer_adapt.h +++ b/components/bt/esp_ble_mesh/mesh_core/include/mesh_bearer_adapt.h @@ -10,6 +10,7 @@ #define _BLE_MESH_BEARER_ADAPT_H_ #include +#include "sdkconfig.h" #include "mesh_types.h" #include "mesh_util.h" #include "mesh_uuid.h" diff --git a/components/bt/esp_ble_mesh/mesh_core/proxy_server.c b/components/bt/esp_ble_mesh/mesh_core/proxy_server.c index 4305a3ebb..5f1ef084f 100644 --- a/components/bt/esp_ble_mesh/mesh_core/proxy_server.c +++ b/components/bt/esp_ble_mesh/mesh_core/proxy_server.c @@ -109,7 +109,7 @@ static enum { MESH_GATT_PROXY, } gatt_svc = MESH_GATT_NONE; -static char device_name[DEVICE_NAME_SIZE + 1] = "ESP-BLE-MESH"; +static char device_name[DEVICE_NAME_SIZE + 1]; int bt_mesh_set_device_name(const char *name) { @@ -1416,6 +1416,7 @@ int bt_mesh_proxy_init(void) bt_mesh_gatts_conn_cb_register(&conn_callbacks); + strncpy(device_name, "ESP-BLE-MESH", DEVICE_NAME_SIZE); return bt_mesh_gatts_set_local_device_name(device_name); } @@ -1428,6 +1429,7 @@ int bt_mesh_proxy_deinit(void) #if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER) bt_mesh_gatts_service_deregister(&proxy_svc); + next_idx = 0; #endif #if defined(CONFIG_BLE_MESH_PB_GATT) @@ -1444,6 +1446,7 @@ int bt_mesh_proxy_deinit(void) memset(device_name, 0, sizeof(device_name)); bt_mesh_gatts_conn_cb_deregister(); + conn_count = 0; return 0; }