Merge branch 'bugfix/ble_mesh_friend_init_flag_v3.3' into 'release/v3.3'

Bugfix/ble mesh friend init flag (v3.3)

See merge request espressif/esp-idf!8849
This commit is contained in:
Island 2020-05-22 10:50:55 +08:00
commit 796dc4bb35
4 changed files with 22 additions and 1 deletions

View file

@ -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"

View file

@ -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;
}

View file

@ -10,6 +10,7 @@
#define _BLE_MESH_BEARER_ADAPT_H_
#include <sys/types.h>
#include "sdkconfig.h"
#include "mesh_types.h"
#include "mesh_util.h"
#include "mesh_uuid.h"

View file

@ -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;
}