diff --git a/components/bt/esp_ble_mesh/Kconfig.in b/components/bt/esp_ble_mesh/Kconfig.in index 300e97eaaf..b061d60444 100644 --- a/components/bt/esp_ble_mesh/Kconfig.in +++ b/components/bt/esp_ble_mesh/Kconfig.in @@ -78,6 +78,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 diff --git a/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_common_api.c b/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_common_api.c index 09e453a2a3..b8f1c3c8b9 100644 --- a/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_common_api.c +++ b/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_common_api.c @@ -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 */ diff --git a/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_networking_api.c b/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_networking_api.c index f614798ca4..5e850a7436 100644 --- a/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_networking_api.c +++ b/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_networking_api.c @@ -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, diff --git a/components/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h b/components/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h index 246e304d26..271002be5b 100644 --- a/components/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h +++ b/components/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h @@ -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. diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c index 6bd6016651..636ff92222 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c @@ -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; diff --git a/components/bt/esp_ble_mesh/mesh_common/mesh_mutex.c b/components/bt/esp_ble_mesh/mesh_common/mesh_mutex.c index 5cee41e4f7..d8b3496622 100644 --- a/components/bt/esp_ble_mesh/mesh_common/mesh_mutex.c +++ b/components/bt/esp_ble_mesh/mesh_common/mesh_mutex.c @@ -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 diff --git a/components/bt/esp_ble_mesh/mesh_common/mesh_timer.c b/components/bt/esp_ble_mesh/mesh_common/mesh_timer.c index 0f7bcfe193..e1a88d0612 100644 --- a/components/bt/esp_ble_mesh/mesh_common/mesh_timer.c +++ b/components/bt/esp_ble_mesh/mesh_common/mesh_timer.c @@ -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) { diff --git a/components/bt/esp_ble_mesh/mesh_core/access.c b/components/bt/esp_ble_mesh/mesh_core/access.c index 2f6fe91402..7c67a81979 100644 --- a/components/bt/esp_ble_mesh/mesh_core/access.c +++ b/components/bt/esp_ble_mesh/mesh_core/access.c @@ -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) { diff --git a/components/bt/esp_ble_mesh/mesh_core/adv.c b/components/bt/esp_ble_mesh/mesh_core/adv.c index 60e1ea664c..388f256be6 100644 --- a/components/bt/esp_ble_mesh/mesh_core/adv.c +++ b/components/bt/esp_ble_mesh/mesh_core/adv.c @@ -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 */ diff --git a/components/bt/esp_ble_mesh/mesh_core/beacon.c b/components/bt/esp_ble_mesh/mesh_core/beacon.c index 1ae51acdf2..03776de7d0 100644 --- a/components/bt/esp_ble_mesh/mesh_core/beacon.c +++ b/components/bt/esp_ble_mesh/mesh_core/beacon.c @@ -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) { diff --git a/components/bt/esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c b/components/bt/esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c index 7e9241a3fb..af3e7f4630 100644 --- a/components/bt/esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c +++ b/components/bt/esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c @@ -1749,6 +1749,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) || \ @@ -1778,6 +1779,7 @@ void bt_mesh_gatt_deinit(void) } #endif } +#endif /* CONFIG_BLE_MESH_DEINIT */ void bt_mesh_adapt_init(void) { diff --git a/components/bt/esp_ble_mesh/mesh_core/cfg_cli.c b/components/bt/esp_ble_mesh/mesh_core/cfg_cli.c index 16c2f6d909..83e74d0c45 100644 --- a/components/bt/esp_ble_mesh/mesh_core/cfg_cli.c +++ b/components/bt/esp_ble_mesh/mesh_core/cfg_cli.c @@ -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 */ }; diff --git a/components/bt/esp_ble_mesh/mesh_core/cfg_srv.c b/components/bt/esp_ble_mesh/mesh_core/cfg_srv.c index 0f6429cd69..cb07f8c10e 100644 --- a/components/bt/esp_ble_mesh/mesh_core/cfg_srv.c +++ b/components/bt/esp_ble_mesh/mesh_core/cfg_srv.c @@ -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, diff --git a/components/bt/esp_ble_mesh/mesh_core/friend.c b/components/bt/esp_ble_mesh/mesh_core/friend.c index b9955709a8..ba46c6bd5b 100644 --- a/components/bt/esp_ble_mesh/mesh_core/friend.c +++ b/components/bt/esp_ble_mesh/mesh_core/friend.c @@ -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) { diff --git a/components/bt/esp_ble_mesh/mesh_core/health_cli.c b/components/bt/esp_ble_mesh/mesh_core/health_cli.c index 07c0c0cc34..be4bf8b122 100644 --- a/components/bt/esp_ble_mesh/mesh_core/health_cli.c +++ b/components/bt/esp_ble_mesh/mesh_core/health_cli.c @@ -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 */ }; diff --git a/components/bt/esp_ble_mesh/mesh_core/health_srv.c b/components/bt/esp_ble_mesh/mesh_core/health_srv.c index e37ff6943f..4d6088fb44 100644 --- a/components/bt/esp_ble_mesh/mesh_core/health_srv.c +++ b/components/bt/esp_ble_mesh/mesh_core/health_srv.c @@ -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) diff --git a/components/bt/esp_ble_mesh/mesh_core/include/mesh_access.h b/components/bt/esp_ble_mesh/mesh_core/include/mesh_access.h index 0ee1859e30..d02f965787 100644 --- a/components/bt/esp_ble_mesh/mesh_core/include/mesh_access.h +++ b/components/bt/esp_ble_mesh/mesh_core/include/mesh_access.h @@ -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 */ diff --git a/components/bt/esp_ble_mesh/mesh_core/lpn.c b/components/bt/esp_ble_mesh/mesh_core/lpn.c index 7ba704573a..0562c059bb 100644 --- a/components/bt/esp_ble_mesh/mesh_core/lpn.c +++ b/components/bt/esp_ble_mesh/mesh_core/lpn.c @@ -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 */ diff --git a/components/bt/esp_ble_mesh/mesh_core/main.c b/components/bt/esp_ble_mesh/mesh_core/main.c index 341fc8dd6f..f2bbd63714 100644 --- a/components/bt/esp_ble_mesh/mesh_core/main.c +++ b/components/bt/esp_ble_mesh/mesh_core/main.c @@ -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) diff --git a/components/bt/esp_ble_mesh/mesh_core/net.c b/components/bt/esp_ble_mesh/mesh_core/net.c index ab6867833e..eb83b9e802 100644 --- a/components/bt/esp_ble_mesh/mesh_core/net.c +++ b/components/bt/esp_ble_mesh/mesh_core/net.c @@ -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 */ diff --git a/components/bt/esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c b/components/bt/esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c index 6d1e06c6aa..b337fdc935 100644 --- a/components/bt/esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c +++ b/components/bt/esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c @@ -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); diff --git a/components/bt/esp_ble_mesh/mesh_core/prov.c b/components/bt/esp_ble_mesh/mesh_core/prov.c index 268f83d606..f560a911b5 100644 --- a/components/bt/esp_ble_mesh/mesh_core/prov.c +++ b/components/bt/esp_ble_mesh/mesh_core/prov.c @@ -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) diff --git a/components/bt/esp_ble_mesh/mesh_core/provisioner_main.c b/components/bt/esp_ble_mesh/mesh_core/provisioner_main.c index fd6008a8ea..6f52902cea 100644 --- a/components/bt/esp_ble_mesh/mesh_core/provisioner_main.c +++ b/components/bt/esp_ble_mesh/mesh_core/provisioner_main.c @@ -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) { diff --git a/components/bt/esp_ble_mesh/mesh_core/provisioner_prov.c b/components/bt/esp_ble_mesh/mesh_core/provisioner_prov.c index e9fcd12782..454833569b 100644 --- a/components/bt/esp_ble_mesh/mesh_core/provisioner_prov.c +++ b/components/bt/esp_ble_mesh/mesh_core/provisioner_prov.c @@ -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) diff --git a/components/bt/esp_ble_mesh/mesh_core/proxy_client.c b/components/bt/esp_ble_mesh/mesh_core/proxy_client.c index c9072ba872..334e078aaf 100644 --- a/components/bt/esp_ble_mesh/mesh_core/proxy_client.c +++ b/components/bt/esp_ble_mesh/mesh_core/proxy_client.c @@ -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 */ 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 0ae040e73e..1480e44a04 100644 --- a/components/bt/esp_ble_mesh/mesh_core/proxy_server.c +++ b/components/bt/esp_ble_mesh/mesh_core/proxy_server.c @@ -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 */ diff --git a/components/bt/esp_ble_mesh/mesh_core/settings.c b/components/bt/esp_ble_mesh/mesh_core/settings.c index ccd1bdaa1f..59aebd94aa 100644 --- a/components/bt/esp_ble_mesh/mesh_core/settings.c +++ b/components/bt/esp_ble_mesh/mesh_core/settings.c @@ -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 */ diff --git a/components/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.c b/components/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.c index af84ab4d7e..8786598722 100644 --- a/components/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.c +++ b/components/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.c @@ -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 */ diff --git a/components/bt/esp_ble_mesh/mesh_core/transport.c b/components/bt/esp_ble_mesh/mesh_core/transport.c index 40ca3eb9d0..176250ea04 100644 --- a/components/bt/esp_ble_mesh/mesh_core/transport.c +++ b/components/bt/esp_ble_mesh/mesh_core/transport.c @@ -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) { diff --git a/components/bt/esp_ble_mesh/mesh_models/client/client_common.c b/components/bt/esp_ble_mesh/mesh_models/client/client_common.c index b61c5579c0..6064e92e5e 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/client_common.c +++ b/components/bt/esp_ble_mesh/mesh_models/client/client_common.c @@ -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) { diff --git a/components/bt/esp_ble_mesh/mesh_models/client/generic_client.c b/components/bt/esp_ble_mesh/mesh_models/client/generic_client.c index 91542536ca..432d81137f 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/generic_client.c +++ b/components/bt/esp_ble_mesh/mesh_models/client/generic_client.c @@ -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 */ }; diff --git a/components/bt/esp_ble_mesh/mesh_models/client/lighting_client.c b/components/bt/esp_ble_mesh/mesh_models/client/lighting_client.c index eaf96b01aa..3371f1ab06 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/lighting_client.c +++ b/components/bt/esp_ble_mesh/mesh_models/client/lighting_client.c @@ -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 */ }; diff --git a/components/bt/esp_ble_mesh/mesh_models/client/sensor_client.c b/components/bt/esp_ble_mesh/mesh_models/client/sensor_client.c index 47ee42e2c0..52731ff585 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/sensor_client.c +++ b/components/bt/esp_ble_mesh/mesh_models/client/sensor_client.c @@ -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 */ }; diff --git a/components/bt/esp_ble_mesh/mesh_models/client/time_scene_client.c b/components/bt/esp_ble_mesh/mesh_models/client/time_scene_client.c index d99a685fc4..9308ecf2e9 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/time_scene_client.c +++ b/components/bt/esp_ble_mesh/mesh_models/client/time_scene_client.c @@ -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 */ }; diff --git a/components/bt/esp_ble_mesh/mesh_models/server/generic_server.c b/components/bt/esp_ble_mesh/mesh_models/server/generic_server.c index 3de3a15454..cf78cd3541 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/generic_server.c +++ b/components/bt/esp_ble_mesh/mesh_models/server/generic_server.c @@ -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 */ }; diff --git a/components/bt/esp_ble_mesh/mesh_models/server/lighting_server.c b/components/bt/esp_ble_mesh/mesh_models/server/lighting_server.c index a974c244d8..f11178c0a5 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/lighting_server.c +++ b/components/bt/esp_ble_mesh/mesh_models/server/lighting_server.c @@ -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 */ }; diff --git a/components/bt/esp_ble_mesh/mesh_models/server/sensor_server.c b/components/bt/esp_ble_mesh/mesh_models/server/sensor_server.c index 2cdccb8cab..d01aa2e2aa 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/sensor_server.c +++ b/components/bt/esp_ble_mesh/mesh_models/server/sensor_server.c @@ -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 */ }; diff --git a/components/bt/esp_ble_mesh/mesh_models/server/server_common.c b/components/bt/esp_ble_mesh/mesh_models/server/server_common.c index b1efe926f1..236e9e53b3 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/server_common.c +++ b/components/bt/esp_ble_mesh/mesh_models/server/server_common.c @@ -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) diff --git a/components/bt/esp_ble_mesh/mesh_models/server/time_scene_server.c b/components/bt/esp_ble_mesh/mesh_models/server/time_scene_server.c index ad382b7cb3..d0bd7a1244 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/time_scene_server.c +++ b/components/bt/esp_ble_mesh/mesh_models/server/time_scene_server.c @@ -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 */ };