Merge branch 'bugfix/ble_mesh_friend_init_flag' into 'master'
ble_mesh: Add init flag for friend init/deinit Closes BLEMESH-205 See merge request espressif/esp-idf!8783
This commit is contained in:
commit
9f801fd2f5
|
@ -11,6 +11,7 @@
|
||||||
#ifndef _BLE_MESH_BUF_H_
|
#ifndef _BLE_MESH_BUF_H_
|
||||||
#define _BLE_MESH_BUF_H_
|
#define _BLE_MESH_BUF_H_
|
||||||
|
|
||||||
|
#include "sdkconfig.h"
|
||||||
#include "mesh_slist.h"
|
#include "mesh_slist.h"
|
||||||
#include "mesh_compiler.h"
|
#include "mesh_compiler.h"
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,8 @@ enum {
|
||||||
|
|
||||||
static void (*friend_cb)(bool establish, u16_t lpn_addr, u8_t reason);
|
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)
|
static struct bt_mesh_subnet *friend_subnet_get(u16_t net_idx)
|
||||||
{
|
{
|
||||||
struct bt_mesh_subnet *sub = NULL;
|
struct bt_mesh_subnet *sub = NULL;
|
||||||
|
@ -1243,6 +1245,11 @@ int bt_mesh_friend_init(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (friend_init == true) {
|
||||||
|
BT_WARN("%s, Already", __func__);
|
||||||
|
return -EALREADY;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(bt_mesh.frnd); i++) {
|
for (i = 0; i < ARRAY_SIZE(bt_mesh.frnd); i++) {
|
||||||
struct bt_mesh_friend *frnd = &bt_mesh.frnd[i];
|
struct bt_mesh_friend *frnd = &bt_mesh.frnd[i];
|
||||||
int j;
|
int j;
|
||||||
|
@ -1259,6 +1266,8 @@ int bt_mesh_friend_init(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
friend_init = true;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1266,6 +1275,11 @@ int bt_mesh_friend_deinit(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (friend_init == false) {
|
||||||
|
BT_WARN("%s, Already", __func__);
|
||||||
|
return -EALREADY;
|
||||||
|
}
|
||||||
|
|
||||||
bt_mesh_friend_clear_net_idx(BLE_MESH_KEY_ANY);
|
bt_mesh_friend_clear_net_idx(BLE_MESH_KEY_ANY);
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(bt_mesh.frnd); i++) {
|
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);
|
bt_mesh_unref_buf_from_pool(&friend_buf_pool);
|
||||||
memset(adv_pool, 0, sizeof(adv_pool));
|
memset(adv_pool, 0, sizeof(adv_pool));
|
||||||
|
|
||||||
|
friend_init = false;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#define _BLE_MESH_BEARER_ADAPT_H_
|
#define _BLE_MESH_BEARER_ADAPT_H_
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include "sdkconfig.h"
|
||||||
#include "mesh_types.h"
|
#include "mesh_types.h"
|
||||||
#include "mesh_util.h"
|
#include "mesh_util.h"
|
||||||
#include "mesh_uuid.h"
|
#include "mesh_uuid.h"
|
||||||
|
|
|
@ -109,7 +109,7 @@ static enum {
|
||||||
MESH_GATT_PROXY,
|
MESH_GATT_PROXY,
|
||||||
} gatt_svc = MESH_GATT_NONE;
|
} 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)
|
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);
|
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);
|
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)
|
#if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER)
|
||||||
bt_mesh_gatts_service_deregister(&proxy_svc);
|
bt_mesh_gatts_service_deregister(&proxy_svc);
|
||||||
|
next_idx = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_BLE_MESH_PB_GATT)
|
#if defined(CONFIG_BLE_MESH_PB_GATT)
|
||||||
|
@ -1444,6 +1446,7 @@ int bt_mesh_proxy_deinit(void)
|
||||||
memset(device_name, 0, sizeof(device_name));
|
memset(device_name, 0, sizeof(device_name));
|
||||||
|
|
||||||
bt_mesh_gatts_conn_cb_deregister();
|
bt_mesh_gatts_conn_cb_deregister();
|
||||||
|
conn_count = 0;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue