ble_mesh: stack: Add a Kconfig option to make deinit optional

This commit is contained in:
lly 2020-10-16 10:19:31 +08:00
parent bc4ebea32c
commit 09ac1b596d
39 changed files with 258 additions and 44 deletions

View File

@ -1798,6 +1798,13 @@ if BLE_MESH
endchoice # BLE_MESH_FREERTOS_STATIC_ALLOC_MODE
config BLE_MESH_DEINIT
bool "Support de-initialize BLE Mesh stack"
default y
help
If enabled, users can use the function esp_ble_mesh_deinit() to de-initialize
the whole BLE Mesh stack.
config BLE_MESH_FAST_PROV
bool "Enable BLE Mesh Fast Provisioning"
select BLE_MESH_NODE

View File

@ -69,6 +69,7 @@ esp_err_t esp_ble_mesh_init(esp_ble_mesh_prov_t *prov, esp_ble_mesh_comp_t *comp
return ESP_OK;
}
#if CONFIG_BLE_MESH_DEINIT
esp_err_t esp_ble_mesh_deinit(esp_ble_mesh_deinit_param_t *param)
{
btc_ble_mesh_prov_args_t arg = {0};
@ -89,4 +90,4 @@ esp_err_t esp_ble_mesh_deinit(esp_ble_mesh_deinit_param_t *param)
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_DEINIT */

View File

@ -164,6 +164,7 @@ esp_err_t esp_ble_mesh_client_model_init(esp_ble_mesh_model_t *model)
return btc_ble_mesh_client_model_init(model);
}
#if CONFIG_BLE_MESH_DEINIT
esp_err_t esp_ble_mesh_client_model_deinit(esp_ble_mesh_model_t *model)
{
if (model == NULL) {
@ -174,6 +175,7 @@ esp_err_t esp_ble_mesh_client_model_deinit(esp_ble_mesh_model_t *model)
return btc_ble_mesh_client_model_deinit(model);
}
#endif /* CONFIG_BLE_MESH_DEINIT */
esp_err_t esp_ble_mesh_server_model_send_msg(esp_ble_mesh_model_t *model,
esp_ble_mesh_msg_ctx_t *ctx,

View File

@ -468,8 +468,10 @@ typedef struct {
/** Callback used during model initialization. Initialized by the stack. */
esp_ble_mesh_cb_t init_cb;
#if CONFIG_BLE_MESH_DEINIT
/** Callback used during model deinitialization. Initialized by the stack. */
esp_ble_mesh_cb_t deinit_cb;
#endif /* CONFIG_BLE_MESH_DEINIT */
} esp_ble_mesh_model_cbs_t;
/** Abstraction that describes a Mesh Model instance.

View File

@ -962,10 +962,12 @@ int btc_ble_mesh_client_model_init(esp_ble_mesh_model_t *model)
return bt_mesh_client_init((struct bt_mesh_model *)model);
}
#if CONFIG_BLE_MESH_DEINIT
int btc_ble_mesh_client_model_deinit(esp_ble_mesh_model_t *model)
{
return bt_mesh_client_deinit((struct bt_mesh_model *)model);
}
#endif /* CONFIG_BLE_MESH_DEINIT */
int32_t btc_ble_mesh_model_pub_period_get(esp_ble_mesh_model_t *mod)
{
@ -2027,10 +2029,12 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg)
arg->model_unsub_group_addr.model_id,
arg->model_unsub_group_addr.group_addr);
break;
#if CONFIG_BLE_MESH_DEINIT
case BTC_BLE_MESH_ACT_DEINIT_MESH:
act = ESP_BLE_MESH_DEINIT_MESH_COMP_EVT;
param.deinit_mesh_comp.err_code = bt_mesh_deinit((struct bt_mesh_deinit_param *)&arg->mesh_deinit.param);
break;
#endif /* CONFIG_BLE_MESH_DEINIT */
default:
BT_WARN("%s, Unknown act %d", __func__, msg->act);
return;

View File

@ -89,11 +89,6 @@ static void bt_mesh_alarm_mutex_new(void)
}
}
static void bt_mesh_alarm_mutex_free(void)
{
bt_mesh_mutex_free(&alarm_lock);
}
void bt_mesh_alarm_lock(void)
{
bt_mesh_mutex_lock(&alarm_lock);
@ -111,11 +106,6 @@ static void bt_mesh_list_mutex_new(void)
}
}
static void bt_mesh_list_mutex_free(void)
{
bt_mesh_mutex_free(&list_lock);
}
void bt_mesh_list_lock(void)
{
bt_mesh_mutex_lock(&list_lock);
@ -133,11 +123,6 @@ static void bt_mesh_buf_mutex_new(void)
}
}
static void bt_mesh_buf_mutex_free(void)
{
bt_mesh_mutex_free(&buf_lock);
}
void bt_mesh_buf_lock(void)
{
bt_mesh_mutex_lock(&buf_lock);
@ -155,11 +140,6 @@ static void bt_mesh_atomic_mutex_new(void)
}
}
static void bt_mesh_atomic_mutex_free(void)
{
bt_mesh_mutex_free(&atomic_lock);
}
void bt_mesh_atomic_lock(void)
{
bt_mesh_mutex_lock(&atomic_lock);
@ -178,6 +158,27 @@ void bt_mesh_mutex_init(void)
bt_mesh_atomic_mutex_new();
}
#if CONFIG_BLE_MESH_DEINIT
static void bt_mesh_alarm_mutex_free(void)
{
bt_mesh_mutex_free(&alarm_lock);
}
static void bt_mesh_list_mutex_free(void)
{
bt_mesh_mutex_free(&list_lock);
}
static void bt_mesh_buf_mutex_free(void)
{
bt_mesh_mutex_free(&buf_lock);
}
static void bt_mesh_atomic_mutex_free(void)
{
bt_mesh_mutex_free(&atomic_lock);
}
void bt_mesh_mutex_deinit(void)
{
bt_mesh_alarm_mutex_free();
@ -185,3 +186,4 @@ void bt_mesh_mutex_deinit(void)
bt_mesh_buf_mutex_free();
bt_mesh_atomic_mutex_free();
}
#endif

View File

@ -51,6 +51,7 @@ void bt_mesh_timer_init(void)
__ASSERT(bm_alarm_hash_map, "Failed to create hash map");
}
#if CONFIG_BLE_MESH_DEINIT
void bt_mesh_timer_deinit(void)
{
if (bm_alarm_hash_map) {
@ -58,6 +59,7 @@ void bt_mesh_timer_deinit(void)
bm_alarm_hash_map = NULL;
}
}
#endif /* CONFIG_BLE_MESH_DEINIT */
int k_delayed_work_init(struct k_delayed_work *work, k_work_handler_t handler)
{

View File

@ -364,6 +364,23 @@ static void mod_init(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
}
}
int bt_mesh_comp_register(const struct bt_mesh_comp *comp)
{
int err = 0;
/* There must be at least one element */
if (!comp->elem_count) {
return -EINVAL;
}
dev_comp = comp;
bt_mesh_model_foreach(mod_init, &err);
return err;
}
#if CONFIG_BLE_MESH_DEINIT
static void mod_deinit(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
bool vnd, bool primary, void *user_data)
{
@ -404,22 +421,6 @@ static void mod_deinit(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
}
}
int bt_mesh_comp_register(const struct bt_mesh_comp *comp)
{
int err = 0;
/* There must be at least one element */
if (!comp->elem_count) {
return -EINVAL;
}
dev_comp = comp;
bt_mesh_model_foreach(mod_init, &err);
return err;
}
int bt_mesh_comp_deregister(void)
{
int err = 0;
@ -434,6 +435,7 @@ int bt_mesh_comp_deregister(void)
return err;
}
#endif /* CONFIG_BLE_MESH_DEINIT */
void bt_mesh_comp_provision(u16_t addr)
{

View File

@ -110,7 +110,9 @@ static struct ble_adv_tx {
#define SEND_BLE_ADV_INFINITE 0xFFFF
#if CONFIG_BLE_MESH_DEINIT
static void bt_mesh_ble_adv_deinit(void);
#endif /* CONFIG_BLE_MESH_DEINIT */
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_ADV */
struct bt_mesh_adv_task {
@ -857,6 +859,7 @@ void bt_mesh_adv_init(void)
#endif /* CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL && CONFIG_SPIRAM_CACHE_WORKAROUND && CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY */
}
#if CONFIG_BLE_MESH_DEINIT
void bt_mesh_adv_deinit(void)
{
if (adv_queue.handle == NULL) {
@ -910,6 +913,7 @@ void bt_mesh_adv_deinit(void)
bt_mesh_ble_adv_deinit();
#endif
}
#endif /* CONFIG_BLE_MESH_DEINIT */
int bt_mesh_scan_enable(void)
{
@ -1225,6 +1229,7 @@ int bt_mesh_stop_ble_advertising(u8_t index)
return 0;
}
#if CONFIG_BLE_MESH_DEINIT
static void bt_mesh_ble_adv_deinit(void)
{
for (int i = 0; i < ARRAY_SIZE(ble_adv_tx); i++) {
@ -1234,4 +1239,5 @@ static void bt_mesh_ble_adv_deinit(void)
bt_mesh_unref_buf_from_pool(&ble_adv_buf_pool);
memset(ble_adv_pool, 0, sizeof(ble_adv_pool));
}
#endif /* CONFIG_BLE_MESH_DEINIT */
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_ADV */

View File

@ -447,10 +447,12 @@ void bt_mesh_beacon_init(void)
k_delayed_work_init(&beacon_timer, beacon_send);
}
#if CONFIG_BLE_MESH_DEINIT
void bt_mesh_beacon_deinit(void)
{
k_delayed_work_free(&beacon_timer);
}
#endif /* CONFIG_BLE_MESH_DEINIT */
void bt_mesh_beacon_ivu_initiator(bool enable)
{

View File

@ -1750,6 +1750,7 @@ void bt_mesh_gatt_init(void)
#endif
}
#if CONFIG_BLE_MESH_DEINIT
void bt_mesh_gatt_deinit(void)
{
#if (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || \
@ -1779,6 +1780,7 @@ void bt_mesh_gatt_deinit(void)
}
#endif
}
#endif /* CONFIG_BLE_MESH_DEINIT */
void bt_mesh_adapt_init(void)
{

View File

@ -79,10 +79,12 @@ static void bt_mesh_cfg_client_mutex_new(void)
}
}
#if CONFIG_BLE_MESH_DEINIT
static void bt_mesh_cfg_client_mutex_free(void)
{
bt_mesh_mutex_free(&cfg_client_lock);
}
#endif /* CONFIG_BLE_MESH_DEINIT */
static void bt_mesh_cfg_client_lock(void)
{
@ -1286,6 +1288,7 @@ static int cfg_cli_init(struct bt_mesh_model *model)
return 0;
}
#if CONFIG_BLE_MESH_DEINIT
static int cfg_cli_deinit(struct bt_mesh_model *model)
{
bt_mesh_config_client_t *client = NULL;
@ -1319,8 +1322,11 @@ static int cfg_cli_deinit(struct bt_mesh_model *model)
return 0;
}
#endif /* CONFIG_BLE_MESH_DEINIT */
const struct bt_mesh_model_cb bt_mesh_cfg_cli_cb = {
.init = cfg_cli_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = cfg_cli_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};

View File

@ -3397,6 +3397,7 @@ static int cfg_srv_init(struct bt_mesh_model *model)
return 0;
}
#if CONFIG_BLE_MESH_DEINIT
static int cfg_srv_deinit(struct bt_mesh_model *model)
{
struct bt_mesh_cfg_srv *cfg = model->user_data;
@ -3423,10 +3424,13 @@ static int cfg_srv_deinit(struct bt_mesh_model *model)
return 0;
}
#endif /* CONFIG_BLE_MESH_DEINIT */
const struct bt_mesh_model_cb bt_mesh_cfg_srv_cb = {
.init = cfg_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = cfg_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
static void mod_reset(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,

View File

@ -1277,6 +1277,7 @@ int bt_mesh_friend_init(void)
return 0;
}
#if CONFIG_BLE_MESH_DEINIT
int bt_mesh_friend_deinit(void)
{
int i;
@ -1304,6 +1305,7 @@ int bt_mesh_friend_deinit(void)
return 0;
}
#endif /* CONFIG_BLE_MESH_DEINIT */
static bool is_segack(struct net_buf *buf, const u64_t *seqauth, u16_t src)
{

View File

@ -37,10 +37,12 @@ static void bt_mesh_health_client_mutex_new(void)
}
}
#if CONFIG_BLE_MESH_DEINIT
static void bt_mesh_health_client_mutex_free(void)
{
bt_mesh_mutex_free(&health_client_lock);
}
#endif /* CONFIG_BLE_MESH_DEINIT */
static void bt_mesh_health_client_lock(void)
{
@ -343,6 +345,7 @@ static int health_cli_init(struct bt_mesh_model *model)
return 0;
}
#if CONFIG_BLE_MESH_DEINIT
static int health_cli_deinit(struct bt_mesh_model *model)
{
bt_mesh_health_client_t *client = NULL;
@ -373,8 +376,11 @@ static int health_cli_deinit(struct bt_mesh_model *model)
return 0;
}
#endif /* CONFIG_BLE_MESH_DEINIT */
const struct bt_mesh_model_cb bt_mesh_health_cli_cb = {
.init = health_cli_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = health_cli_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};

View File

@ -469,6 +469,7 @@ static int health_srv_init(struct bt_mesh_model *model)
return 0;
}
#if CONFIG_BLE_MESH_DEINIT
static int health_srv_deinit(struct bt_mesh_model *model)
{
struct bt_mesh_health_srv *srv = model->user_data;
@ -499,10 +500,13 @@ static int health_srv_deinit(struct bt_mesh_model *model)
return 0;
}
#endif /* CONFIG_BLE_MESH_DEINIT */
const struct bt_mesh_model_cb bt_mesh_health_srv_cb = {
.init = health_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = health_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
void bt_mesh_attention(struct bt_mesh_model *model, u8_t time)

View File

@ -439,6 +439,7 @@ struct bt_mesh_model_cb {
*/
int (*const init)(struct bt_mesh_model *model);
#if CONFIG_BLE_MESH_DEINIT
/** @brief Model deinit callback.
*
* Called on every model instance during mesh deinitialization.
@ -451,6 +452,7 @@ struct bt_mesh_model_cb {
* @param model Model to be de-initialized.
*/
int (*const deinit)(struct bt_mesh_model *model);
#endif /* CONFIG_BLE_MESH_DEINIT */
};
/** Abstraction that describes a Mesh Model instance */

View File

@ -1090,6 +1090,7 @@ int bt_mesh_lpn_init(void)
return 0;
}
#if CONFIG_BLE_MESH_DEINIT
int bt_mesh_lpn_deinit(void)
{
struct bt_mesh_lpn *lpn = &bt_mesh.lpn;
@ -1100,5 +1101,6 @@ int bt_mesh_lpn_deinit(void)
return 0;
}
#endif /* CONFIG_BLE_MESH_DEINIT */
#endif /* CONFIG_BLE_MESH_LOW_POWER */

View File

@ -426,6 +426,7 @@ int bt_mesh_init(const struct bt_mesh_prov *prov,
return 0;
}
#if CONFIG_BLE_MESH_DEINIT
int bt_mesh_deinit(struct bt_mesh_deinit_param *param)
{
int err = 0;
@ -541,6 +542,7 @@ int bt_mesh_deinit(struct bt_mesh_deinit_param *param)
mesh_init = false;
return 0;
}
#endif /* CONFIG_BLE_MESH_DEINIT */
#if defined(CONFIG_BLE_MESH_PROVISIONER)
int bt_mesh_provisioner_enable(bt_mesh_prov_bearer_t bearers)

View File

@ -1572,6 +1572,7 @@ void bt_mesh_net_init(void)
k_work_init(&bt_mesh.local_work, bt_mesh_net_local);
}
#if CONFIG_BLE_MESH_DEINIT
void bt_mesh_net_deinit(void)
{
k_delayed_work_free(&bt_mesh.ivu_timer);
@ -1595,3 +1596,4 @@ void bt_mesh_net_deinit(void)
bt_mesh.iv_index = 0U;
bt_mesh.seq = 0U;
}
#endif /* CONFIG_BLE_MESH_DEINIT */

View File

@ -1716,6 +1716,7 @@ void bt_mesh_gatt_init(void)
#endif
}
#if CONFIG_BLE_MESH_DEINIT
void bt_mesh_gatt_deinit(void)
{
#if (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || \
@ -1739,6 +1740,7 @@ void bt_mesh_gatt_deinit(void)
}
#endif
}
#endif /* CONFIG_BLE_MESH_DEINIT */
void ble_sm_alg_ecc_init(void);

View File

@ -203,10 +203,12 @@ static void bt_mesh_pb_buf_mutex_new(void)
}
}
#if CONFIG_BLE_MESH_DEINIT
static void bt_mesh_pb_buf_mutex_free(void)
{
bt_mesh_mutex_free(&pb_buf_lock);
}
#endif /* CONFIG_BLE_MESH_DEINIT */
static void bt_mesh_pb_buf_lock(void)
{
@ -1776,6 +1778,7 @@ int bt_mesh_prov_init(const struct bt_mesh_prov *prov_info)
return 0;
}
#if CONFIG_BLE_MESH_DEINIT
int bt_mesh_prov_deinit(void)
{
if (prov == NULL) {
@ -1805,6 +1808,7 @@ int bt_mesh_prov_deinit(void)
return 0;
}
#endif /* CONFIG_BLE_MESH_DEINIT */
void bt_mesh_prov_complete(u16_t net_idx, const u8_t net_key[16],
u16_t addr, u8_t flags, u32_t iv_index)

View File

@ -43,10 +43,12 @@ static void bt_mesh_provisioner_mutex_new(void)
}
}
#if CONFIG_BLE_MESH_DEINIT
static void bt_mesh_provisioner_mutex_free(void)
{
bt_mesh_mutex_free(&provisioner_lock);
}
#endif /* CONFIG_BLE_MESH_DEINIT */
static void bt_mesh_provisioner_lock(void)
{
@ -159,6 +161,7 @@ done:
return 0;
}
#if CONFIG_BLE_MESH_DEINIT
int bt_mesh_provisioner_deinit(bool erase)
{
int i;
@ -194,6 +197,7 @@ int bt_mesh_provisioner_deinit(bool erase)
return 0;
}
#endif /* CONFIG_BLE_MESH_DEINIT */
bool bt_mesh_provisioner_check_is_addr_dup(u16_t addr, u8_t elem_num, bool comp_with_own)
{

View File

@ -363,10 +363,12 @@ static void bt_mesh_pb_adv_mutex_new(void)
}
}
#if CONFIG_BLE_MESH_DEINIT
static void bt_mesh_pb_adv_mutex_free(void)
{
bt_mesh_mutex_free(&prov_ctx.pb_adv_lock);
}
#endif /* CONFIG_BLE_MESH_DEINIT */
static void bt_mesh_pb_adv_lock(void)
{
@ -385,10 +387,12 @@ static void bt_mesh_pb_buf_mutex_new(void)
}
}
#if CONFIG_BLE_MESH_DEINIT
static void bt_mesh_pb_buf_mutex_free(void)
{
bt_mesh_mutex_free(&prov_ctx.pb_buf_lock);
}
#endif /* CONFIG_BLE_MESH_DEINIT */
static void bt_mesh_pb_buf_lock(void)
{
@ -409,10 +413,12 @@ static void bt_mesh_pb_gatt_mutex_new(void)
}
}
#if CONFIG_BLE_MESH_DEINIT
static void bt_mesh_pb_gatt_mutex_free(void)
{
bt_mesh_mutex_free(&prov_ctx.pb_gatt_lock);
}
#endif /* CONFIG_BLE_MESH_DEINIT */
static void bt_mesh_pb_gatt_lock(void)
{
@ -3348,6 +3354,7 @@ int bt_mesh_provisioner_prov_init(const struct bt_mesh_prov *prov_info)
return 0;
}
#if CONFIG_BLE_MESH_DEINIT
int bt_mesh_provisioner_prov_deinit(bool erase)
{
int i;
@ -3398,6 +3405,7 @@ int bt_mesh_provisioner_prov_deinit(bool erase)
return 0;
}
#endif /* CONFIG_BLE_MESH_DEINIT */
static bool is_unprov_dev_info_callback_to_app(bt_mesh_prov_bearer_t bearer,
const u8_t uuid[16], const bt_mesh_addr_t *addr, u16_t oob_info, s8_t rssi)

View File

@ -998,6 +998,7 @@ int bt_mesh_proxy_client_init(void)
return 0;
}
#if CONFIG_BLE_MESH_DEINIT
int bt_mesh_proxy_client_deinit(void)
{
int i;
@ -1015,5 +1016,6 @@ int bt_mesh_proxy_client_deinit(void)
return 0;
}
#endif /* CONFIG_BLE_MESH_DEINIT */
#endif /* (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || CONFIG_BLE_MESH_GATT_PROXY_CLIENT */

View File

@ -1444,6 +1444,7 @@ int bt_mesh_proxy_server_init(void)
return bt_mesh_gatts_set_local_device_name(device_name);
}
#if CONFIG_BLE_MESH_DEINIT
int bt_mesh_proxy_server_deinit(void)
{
int i;
@ -1474,5 +1475,6 @@ int bt_mesh_proxy_server_deinit(void)
return 0;
}
#endif /* CONFIG_BLE_MESH_DEINIT */
#endif /* (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || CONFIG_BLE_MESH_GATT_PROXY_SERVER */

View File

@ -178,10 +178,12 @@ static void bt_mesh_settings_mutex_new(void)
}
}
#if CONFIG_BLE_MESH_DEINIT
static void bt_mesh_settings_mutex_free(void)
{
bt_mesh_mutex_free(&settings_lock);
}
#endif /* CONFIG_BLE_MESH_DEINIT */
void bt_mesh_settings_lock(void)
{
@ -2627,6 +2629,14 @@ int settings_core_init(void)
return 0;
}
int bt_mesh_settings_init(void)
{
bt_mesh_settings_mutex_new();
bt_mesh_settings_init_foreach();
return 0;
}
#if CONFIG_BLE_MESH_DEINIT
int settings_core_deinit(void)
{
k_delayed_work_free(&pending_store);
@ -2646,18 +2656,12 @@ int settings_core_erase(void)
return 0;
}
int bt_mesh_settings_init(void)
{
bt_mesh_settings_mutex_new();
bt_mesh_settings_init_foreach();
return 0;
}
int bt_mesh_settings_deinit(bool erase)
{
bt_mesh_settings_deinit_foreach(erase);
bt_mesh_settings_mutex_free();
return 0;
}
#endif /* CONFIG_BLE_MESH_DEINIT */
#endif /* CONFIG_BLE_MESH_SETTINGS */

View File

@ -32,8 +32,10 @@ struct settings_context {
int (*settings_init)(void);
int (*settings_load)(void);
int (*settings_commit)(void);
#if CONFIG_BLE_MESH_DEINIT
int (*settings_deinit)(void);
int (*settings_erase)(void);
#endif /* CONFIG_BLE_MESH_DEINIT */
};
static struct settings_context settings_ctx[] = {
@ -42,8 +44,10 @@ static struct settings_context settings_ctx[] = {
.settings_init = settings_core_init,
.settings_load = settings_core_load,
.settings_commit = settings_core_commit,
#if CONFIG_BLE_MESH_DEINIT
.settings_deinit = settings_core_deinit,
.settings_erase = settings_core_erase,
#endif /* CONFIG_BLE_MESH_DEINIT */
},
};
@ -92,6 +96,7 @@ void bt_mesh_settings_init_foreach(void)
}
}
#if CONFIG_BLE_MESH_DEINIT
void bt_mesh_settings_deinit_foreach(bool erase)
{
int i;
@ -116,6 +121,7 @@ void bt_mesh_settings_deinit_foreach(bool erase)
nvs_flash_deinit_partition(CONFIG_BLE_MESH_PARTITION_NAME);
#endif
}
#endif /* CONFIG_BLE_MESH_DEINIT */
/* API used to get BLE Mesh related nvs handle */

View File

@ -123,10 +123,12 @@ static void bt_mesh_tx_seg_mutex_new(void)
}
}
#if CONFIG_BLE_MESH_DEINIT
static void bt_mesh_tx_seg_mutex_free(void)
{
bt_mesh_mutex_free(&tx_seg_lock);
}
#endif /* CONFIG_BLE_MESH_DEINIT */
static void bt_mesh_tx_seg_lock(void)
{
@ -145,10 +147,12 @@ static void bt_mesh_rx_seg_mutex_new(void)
}
}
#if CONFIG_BLE_MESH_DEINIT
static void bt_mesh_rx_seg_mutex_free(void)
{
bt_mesh_mutex_free(&rx_seg_lock);
}
#endif /* CONFIG_BLE_MESH_DEINIT */
static void bt_mesh_rx_seg_lock(void)
{
@ -1859,6 +1863,7 @@ void bt_mesh_trans_init(void)
bt_mesh_rx_seg_mutex_new();
}
#if CONFIG_BLE_MESH_DEINIT
void bt_mesh_trans_deinit(bool erase)
{
int i;
@ -1877,6 +1882,7 @@ void bt_mesh_trans_deinit(bool erase)
bt_mesh_tx_seg_mutex_free();
bt_mesh_rx_seg_mutex_free();
}
#endif /* CONFIG_BLE_MESH_DEINIT */
void bt_mesh_heartbeat_send(void)
{

View File

@ -363,10 +363,12 @@ static void bt_mesh_client_model_mutex_new(void)
}
}
#if CONFIG_BLE_MESH_DEINIT
static void bt_mesh_client_model_mutex_free(void)
{
bt_mesh_mutex_free(&client_model_lock);
}
#endif /* CONFIG_BLE_MESH_DEINIT */
void bt_mesh_client_model_lock(void)
{
@ -415,6 +417,7 @@ int bt_mesh_client_init(struct bt_mesh_model *model)
return 0;
}
#if CONFIG_BLE_MESH_DEINIT
int bt_mesh_client_deinit(struct bt_mesh_model *model)
{
bt_mesh_client_user_data_t *client = NULL;
@ -443,6 +446,7 @@ int bt_mesh_client_deinit(struct bt_mesh_model *model)
return 0;
}
#endif /* CONFIG_BLE_MESH_DEINIT */
int bt_mesh_client_free_node(bt_mesh_client_node_t *node)
{

View File

@ -118,10 +118,12 @@ static void bt_mesh_generic_client_mutex_new(void)
}
}
#if CONFIG_BLE_MESH_DEINIT
static void bt_mesh_generic_client_mutex_free(void)
{
bt_mesh_mutex_free(&generic_client_lock);
}
#endif /* CONFIG_BLE_MESH_DEINIT */
static void bt_mesh_generic_client_lock(void)
{
@ -1172,6 +1174,7 @@ static int generic_client_init(struct bt_mesh_model *model)
return 0;
}
#if CONFIG_BLE_MESH_DEINIT
static int generic_client_deinit(struct bt_mesh_model *model)
{
bt_mesh_generic_client_t *client = NULL;
@ -1200,8 +1203,11 @@ static int generic_client_deinit(struct bt_mesh_model *model)
return 0;
}
#endif /* CONFIG_BLE_MESH_DEINIT */
const struct bt_mesh_model_cb bt_mesh_generic_client_cb = {
.init = generic_client_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = generic_client_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};

View File

@ -127,10 +127,12 @@ static void bt_mesh_light_client_mutex_new(void)
}
}
#if CONFIG_BLE_MESH_DEINIT
static void bt_mesh_light_client_mutex_free(void)
{
bt_mesh_mutex_free(&light_client_lock);
}
#endif /* CONFIG_BLE_MESH_DEINIT */
static void bt_mesh_light_client_lock(void)
{
@ -1362,6 +1364,7 @@ static int lighting_client_init(struct bt_mesh_model *model)
return 0;
}
#if CONFIG_BLE_MESH_DEINIT
static int lighting_client_deinit(struct bt_mesh_model *model)
{
bt_mesh_light_client_t *client = NULL;
@ -1390,8 +1393,11 @@ static int lighting_client_deinit(struct bt_mesh_model *model)
return 0;
}
#endif /* CONFIG_BLE_MESH_DEINIT */
const struct bt_mesh_model_cb bt_mesh_lighting_client_cb = {
.init = lighting_client_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = lighting_client_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};

View File

@ -56,10 +56,12 @@ static void bt_mesh_sensor_client_mutex_new(void)
}
}
#if CONFIG_BLE_MESH_DEINIT
static void bt_mesh_sensor_client_mutex_free(void)
{
bt_mesh_mutex_free(&sensor_client_lock);
}
#endif /* CONFIG_BLE_MESH_DEINIT */
static void bt_mesh_sensor_client_lock(void)
{
@ -612,6 +614,7 @@ static int sensor_client_init(struct bt_mesh_model *model)
return 0;
}
#if CONFIG_BLE_MESH_DEINIT
static int sensor_client_deinit(struct bt_mesh_model *model)
{
bt_mesh_sensor_client_t *client = NULL;
@ -640,8 +643,11 @@ static int sensor_client_deinit(struct bt_mesh_model *model)
return 0;
}
#endif /* CONFIG_BLE_MESH_DEINIT */
const struct bt_mesh_model_cb bt_mesh_sensor_client_cb = {
.init = sensor_client_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = sensor_client_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};

View File

@ -72,10 +72,12 @@ static void bt_mesh_time_scene_client_mutex_new(void)
}
}
#if CONFIG_BLE_MESH_DEINIT
static void bt_mesh_time_scene_client_mutex_free(void)
{
bt_mesh_mutex_free(&time_scene_client_lock);
}
#endif /* CONFIG_BLE_MESH_DEINIT */
static void bt_mesh_time_scene_client_lock(void)
{
@ -668,6 +670,7 @@ static int time_scene_client_init(struct bt_mesh_model *model)
return 0;
}
#if CONFIG_BLE_MESH_DEINIT
static int time_scene_client_deinit(struct bt_mesh_model *model)
{
bt_mesh_time_scene_client_t *client = NULL;
@ -696,8 +699,11 @@ static int time_scene_client_deinit(struct bt_mesh_model *model)
return 0;
}
#endif /* CONFIG_BLE_MESH_DEINIT */
const struct bt_mesh_model_cb bt_mesh_time_scene_client_cb = {
.init = time_scene_client_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = time_scene_client_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};

View File

@ -25,10 +25,12 @@ static void bt_mesh_generic_server_mutex_new(void)
}
}
#if CONFIG_BLE_MESH_DEINIT
static void bt_mesh_generic_server_mutex_free(void)
{
bt_mesh_mutex_free(&generic_server_lock);
}
#endif /* CONFIG_BLE_MESH_DEINIT */
void bt_mesh_generic_server_lock(void)
{
@ -2624,6 +2626,7 @@ static int gen_client_prop_srv_init(struct bt_mesh_model *model)
return generic_server_init(model);
}
#if CONFIG_BLE_MESH_DEINIT
static int generic_server_deinit(struct bt_mesh_model *model)
{
if (model->user_data == NULL) {
@ -2794,73 +2797,102 @@ static int gen_client_prop_srv_deinit(struct bt_mesh_model *model)
return generic_server_deinit(model);
}
#endif /* CONFIG_BLE_MESH_DEINIT */
const struct bt_mesh_model_cb bt_mesh_gen_onoff_srv_cb = {
.init = gen_onoff_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = gen_onoff_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
const struct bt_mesh_model_cb bt_mesh_gen_level_srv_cb = {
.init = gen_level_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = gen_level_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
const struct bt_mesh_model_cb bt_mesh_gen_def_trans_time_srv_cb = {
.init = gen_def_trans_time_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = gen_def_trans_time_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
const struct bt_mesh_model_cb bt_mesh_gen_power_onoff_srv_cb = {
.init = gen_power_onoff_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = gen_power_onoff_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
const struct bt_mesh_model_cb bt_mesh_gen_power_onoff_setup_srv_cb = {
.init = gen_power_onoff_setup_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = gen_power_onoff_setup_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
const struct bt_mesh_model_cb bt_mesh_gen_power_level_srv_cb = {
.init = gen_power_level_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = gen_power_level_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
const struct bt_mesh_model_cb bt_mesh_gen_power_level_setup_srv_cb = {
.init = gen_power_level_setup_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = gen_power_level_setup_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
const struct bt_mesh_model_cb bt_mesh_gen_battery_srv_cb = {
.init = gen_battery_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = gen_battery_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
const struct bt_mesh_model_cb bt_mesh_gen_location_srv_cb = {
.init = gen_location_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = gen_location_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
const struct bt_mesh_model_cb bt_mesh_gen_location_setup_srv_cb = {
.init = gen_location_setup_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = gen_location_setup_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
const struct bt_mesh_model_cb bt_mesh_gen_user_prop_srv_cb = {
.init = gen_user_prop_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = gen_user_prop_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
const struct bt_mesh_model_cb bt_mesh_gen_admin_prop_srv_cb = {
.init = gen_admin_prop_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = gen_admin_prop_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
const struct bt_mesh_model_cb bt_mesh_gen_manu_prop_srv_cb = {
.init = gen_manu_prop_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = gen_manu_prop_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
const struct bt_mesh_model_cb bt_mesh_gen_client_prop_srv_cb = {
.init = gen_client_prop_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = gen_client_prop_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};

View File

@ -25,10 +25,12 @@ static void bt_mesh_light_server_mutex_new(void)
}
}
#if CONFIG_BLE_MESH_DEINIT
static void bt_mesh_light_server_mutex_free(void)
{
bt_mesh_mutex_free(&light_server_lock);
}
#endif /* CONFIG_BLE_MESH_DEINIT */
void bt_mesh_light_server_lock(void)
{
@ -3326,6 +3328,7 @@ static int light_lc_setup_srv_init(struct bt_mesh_model *model)
return light_server_init(model);
}
#if CONFIG_BLE_MESH_DEINIT
static int light_server_deinit(struct bt_mesh_model *model)
{
if (model->user_data == NULL) {
@ -3551,68 +3554,95 @@ static int light_lc_setup_srv_deinit(struct bt_mesh_model *model)
return light_server_deinit(model);
}
#endif /* CONFIG_BLE_MESH_DEINIT */
const struct bt_mesh_model_cb bt_mesh_light_lightness_srv_cb = {
.init = light_lightness_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = light_lightness_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
const struct bt_mesh_model_cb bt_mesh_light_lightness_setup_srv_cb = {
.init = light_lightness_setup_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = light_lightness_setup_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
const struct bt_mesh_model_cb bt_mesh_light_ctl_srv_cb = {
.init = light_ctl_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = light_ctl_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
const struct bt_mesh_model_cb bt_mesh_light_ctl_setup_srv_cb = {
.init = light_ctl_setup_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = light_ctl_setup_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
const struct bt_mesh_model_cb bt_mesh_light_ctl_temp_srv_cb = {
.init = light_ctl_temp_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = light_ctl_temp_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
const struct bt_mesh_model_cb bt_mesh_light_hsl_srv_cb = {
.init = light_hsl_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = light_hsl_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
const struct bt_mesh_model_cb bt_mesh_light_hsl_setup_srv_cb = {
.init = light_hsl_setup_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = light_hsl_setup_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
const struct bt_mesh_model_cb bt_mesh_light_hsl_hue_srv_cb = {
.init = light_hsl_hue_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = light_hsl_hue_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
const struct bt_mesh_model_cb bt_mesh_light_hsl_sat_srv_cb = {
.init = light_hsl_sat_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = light_hsl_sat_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
const struct bt_mesh_model_cb bt_mesh_light_xyl_srv_cb = {
.init = light_xyl_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = light_xyl_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
const struct bt_mesh_model_cb bt_mesh_light_xyl_setup_srv_cb = {
.init = light_xyl_setup_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = light_xyl_setup_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
const struct bt_mesh_model_cb bt_mesh_light_lc_srv_cb = {
.init = light_lc_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = light_lc_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
const struct bt_mesh_model_cb bt_mesh_light_lc_setup_srv_cb = {
.init = light_lc_setup_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = light_lc_setup_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};

View File

@ -1127,6 +1127,7 @@ static int sensor_setup_srv_init(struct bt_mesh_model *model)
return sensor_server_init(model);
}
#if CONFIG_BLE_MESH_DEINIT
static int sensor_server_deinit(struct bt_mesh_model *model)
{
if (model->user_data == NULL) {
@ -1156,13 +1157,18 @@ static int sensor_setup_srv_deinit(struct bt_mesh_model *model)
return sensor_server_deinit(model);
}
#endif /* CONFIG_BLE_MESH_DEINIT */
const struct bt_mesh_model_cb bt_mesh_sensor_srv_cb = {
.init = sensor_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = sensor_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
const struct bt_mesh_model_cb bt_mesh_sensor_setup_srv_cb = {
.init = sensor_setup_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = sensor_setup_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};

View File

@ -190,6 +190,7 @@ void bt_mesh_server_alloc_ctx(struct k_work *work)
}
}
#if CONFIG_BLE_MESH_DEINIT
void bt_mesh_server_free_ctx(struct k_work *work)
{
__ASSERT(work, "Invalid parameter");
@ -198,6 +199,7 @@ void bt_mesh_server_free_ctx(struct k_work *work)
work->_reserved = NULL;
}
}
#endif /* CONFIG_BLE_MESH_DEINIT */
bool bt_mesh_is_server_recv_last_msg(struct bt_mesh_last_msg_info *last,
u8_t tid, u16_t src, u16_t dst, s64_t *now)

View File

@ -30,10 +30,12 @@ static void bt_mesh_time_scene_server_mutex_new(void)
}
}
#if CONFIG_BLE_MESH_DEINIT
static void bt_mesh_time_scene_server_mutex_free(void)
{
bt_mesh_mutex_free(&time_scene_server_lock);
}
#endif /* CONFIG_BLE_MESH_DEINIT */
void bt_mesh_time_scene_server_lock(void)
{
@ -1417,6 +1419,7 @@ static int scheduler_setup_srv_init(struct bt_mesh_model *model)
return time_scene_server_init(model);
}
#if CONFIG_BLE_MESH_DEINIT
static int time_scene_server_deinit(struct bt_mesh_model *model)
{
if (model->user_data == NULL) {
@ -1499,33 +1502,46 @@ static int scheduler_setup_srv_deinit(struct bt_mesh_model *model)
{
return time_scene_server_deinit(model);
}
#endif /* CONFIG_BLE_MESH_DEINIT */
const struct bt_mesh_model_cb bt_mesh_time_srv_cb = {
.init = time_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = time_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
const struct bt_mesh_model_cb bt_mesh_time_setup_srv_cb = {
.init = time_setup_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = time_setup_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
const struct bt_mesh_model_cb bt_mesh_scene_srv_cb = {
.init = scene_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = scene_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
const struct bt_mesh_model_cb bt_mesh_scene_setup_srv_cb = {
.init = scene_setup_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = scene_setup_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
const struct bt_mesh_model_cb bt_mesh_scheduler_srv_cb = {
.init = scheduler_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = scheduler_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
const struct bt_mesh_model_cb bt_mesh_scheduler_setup_srv_cb = {
.init = scheduler_setup_srv_init,
#if CONFIG_BLE_MESH_DEINIT
.deinit = scheduler_setup_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};