Forráskód Böngészése

Merge branch 'optimize/ble_mesh_reduce_code_size_v3.3' into 'release/v3.3'

ble_mesh: stack: Optimization introduced to reduce code size (v3.3)

See merge request espressif/esp-idf!11250
Island 5 éve
szülő
commit
f62e92c35f
94 módosított fájl, 1287 hozzáadás és 213 törlés
  1. 81 40
      components/bt/Kconfig
  2. 22 0
      components/bt/common/btc/core/btc_task.c
  3. 2 1
      components/bt/esp_ble_mesh/api/core/esp_ble_mesh_common_api.c
  4. 4 0
      components/bt/esp_ble_mesh/api/core/esp_ble_mesh_networking_api.c
  5. 3 0
      components/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h
  6. 9 7
      components/bt/esp_ble_mesh/api/models/esp_ble_mesh_config_model_api.c
  7. 4 0
      components/bt/esp_ble_mesh/api/models/esp_ble_mesh_generic_model_api.c
  8. 11 7
      components/bt/esp_ble_mesh/api/models/esp_ble_mesh_health_model_api.c
  9. 4 0
      components/bt/esp_ble_mesh/api/models/esp_ble_mesh_lighting_model_api.c
  10. 4 2
      components/bt/esp_ble_mesh/api/models/esp_ble_mesh_sensor_model_api.c
  11. 4 1
      components/bt/esp_ble_mesh/api/models/esp_ble_mesh_time_scene_model_api.c
  12. 5 1
      components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c
  13. 9 1
      components/bt/esp_ble_mesh/btc/btc_ble_mesh_generic_model.c
  14. 9 2
      components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c
  15. 10 2
      components/bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c
  16. 79 4
      components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c
  17. 9 1
      components/bt/esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c
  18. 8 1
      components/bt/esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c
  19. 1 0
      components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_prov.h
  20. 8 8
      components/bt/esp_ble_mesh/mesh_common/include/mesh_buf.h
  21. 52 0
      components/bt/esp_ble_mesh/mesh_common/include/mesh_config.h
  22. 6 4
      components/bt/esp_ble_mesh/mesh_common/include/mesh_dlist.h
  23. 1 1
      components/bt/esp_ble_mesh/mesh_common/include/mesh_kernel.h
  24. 3 3
      components/bt/esp_ble_mesh/mesh_common/include/mesh_slist.h
  25. 5 5
      components/bt/esp_ble_mesh/mesh_common/mesh_buf.c
  26. 26 24
      components/bt/esp_ble_mesh/mesh_common/mesh_mutex.c
  27. 2 0
      components/bt/esp_ble_mesh/mesh_common/mesh_timer.c
  28. 18 16
      components/bt/esp_ble_mesh/mesh_core/access.c
  29. 6 0
      components/bt/esp_ble_mesh/mesh_core/adv.c
  30. 2 0
      components/bt/esp_ble_mesh/mesh_core/beacon.c
  31. 2 0
      components/bt/esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c
  32. 15 4
      components/bt/esp_ble_mesh/mesh_core/cfg_cli.c
  33. 4 0
      components/bt/esp_ble_mesh/mesh_core/cfg_srv.c
  34. 2 0
      components/bt/esp_ble_mesh/mesh_core/friend.c
  35. 15 4
      components/bt/esp_ble_mesh/mesh_core/health_cli.c
  36. 12 0
      components/bt/esp_ble_mesh/mesh_core/health_srv.c
  37. 3 1
      components/bt/esp_ble_mesh/mesh_core/include/mesh_access.h
  38. 2 2
      components/bt/esp_ble_mesh/mesh_core/include/mesh_bearer_adapt.h
  39. 2 0
      components/bt/esp_ble_mesh/mesh_core/lpn.c
  40. 2 0
      components/bt/esp_ble_mesh/mesh_core/main.c
  41. 2 0
      components/bt/esp_ble_mesh/mesh_core/net.c
  42. 2 0
      components/bt/esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c
  43. 8 4
      components/bt/esp_ble_mesh/mesh_core/prov.c
  44. 8 4
      components/bt/esp_ble_mesh/mesh_core/provisioner_main.c
  45. 20 12
      components/bt/esp_ble_mesh/mesh_core/provisioner_prov.c
  46. 2 0
      components/bt/esp_ble_mesh/mesh_core/proxy_client.c
  47. 2 0
      components/bt/esp_ble_mesh/mesh_core/proxy_server.c
  48. 13 9
      components/bt/esp_ble_mesh/mesh_core/settings.c
  49. 6 0
      components/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.c
  50. 14 8
      components/bt/esp_ble_mesh/mesh_core/transport.c
  51. 6 2
      components/bt/esp_ble_mesh/mesh_models/client/client_common.c
  52. 15 4
      components/bt/esp_ble_mesh/mesh_models/client/generic_client.c
  53. 11 0
      components/bt/esp_ble_mesh/mesh_models/client/lighting_client.c
  54. 15 4
      components/bt/esp_ble_mesh/mesh_models/client/sensor_client.c
  55. 15 4
      components/bt/esp_ble_mesh/mesh_models/client/time_scene_client.c
  56. 39 2
      components/bt/esp_ble_mesh/mesh_models/server/generic_server.c
  57. 37 2
      components/bt/esp_ble_mesh/mesh_models/server/lighting_server.c
  58. 11 0
      components/bt/esp_ble_mesh/mesh_models/server/sensor_server.c
  59. 8 1
      components/bt/esp_ble_mesh/mesh_models/server/server_common.c
  60. 8 0
      components/bt/esp_ble_mesh/mesh_models/server/state_binding.c
  61. 35 13
      components/bt/esp_ble_mesh/mesh_models/server/state_transition.c
  62. 23 2
      components/bt/esp_ble_mesh/mesh_models/server/time_scene_server.c
  63. 16 0
      examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_client/sdkconfig.ci.bluedroid_deinit
  64. 20 0
      examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_client/sdkconfig.ci.model
  65. 16 0
      examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_client/sdkconfig.ci.nimble_deinit
  66. 16 0
      examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/sdkconfig.ci.bluedroid_deinit
  67. 19 0
      examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/sdkconfig.ci.model
  68. 15 0
      examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/sdkconfig.ci.nimble_deinit
  69. 18 0
      examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/sdkconfig.ci.bluedroid_deinit
  70. 22 0
      examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/sdkconfig.ci.model
  71. 15 0
      examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/sdkconfig.ci.nimble_deinit
  72. 16 0
      examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/sdkconfig.ci.bluedroid_deinit
  73. 19 0
      examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/sdkconfig.ci.model
  74. 15 0
      examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/sdkconfig.ci.nimble_deinit
  75. 18 0
      examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/sdkconfig.ci.bluedroid_deinit
  76. 22 0
      examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/sdkconfig.ci.model
  77. 16 0
      examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/sdkconfig.ci.nimble_deinit
  78. 16 0
      examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_client/sdkconfig.ci.bluedroid_deinit
  79. 20 0
      examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_client/sdkconfig.ci.model
  80. 16 0
      examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_client/sdkconfig.ci.nimble_deinit
  81. 15 0
      examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_server/sdkconfig.ci.bluedroid_deinit
  82. 18 0
      examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_server/sdkconfig.ci.model
  83. 14 0
      examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_server/sdkconfig.ci.nimble_deinit
  84. 15 0
      examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/sdkconfig.ci.bluedroid_deinit
  85. 19 0
      examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/sdkconfig.ci.model
  86. 15 0
      examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/sdkconfig.ci.nimble_deinit
  87. 15 0
      examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_server/sdkconfig.ci.bluedroid_deinit
  88. 19 0
      examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_server/sdkconfig.ci.model
  89. 14 0
      examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_server/sdkconfig.ci.nimble_deinit
  90. 18 0
      examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/sdkconfig.ci.bluedroid_deinit
  91. 21 0
      examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/sdkconfig.ci.model
  92. 17 0
      examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/sdkconfig.ci.nimble_deinit
  93. 4 0
      examples/bluetooth/esp_ble_mesh/components/fast_provisioning/ble_mesh_fast_prov_client_model.c
  94. 2 0
      examples/bluetooth/esp_ble_mesh/components/fast_provisioning/ble_mesh_fast_prov_operation.c

+ 81 - 40
components/bt/Kconfig

@@ -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
@@ -2574,104 +2581,138 @@ if BLE_MESH
             uses 0 as the timeout value when sending acknowledged messages, then
             the default value will be used which is four seconds.
 
-    menu "Support for BLE Mesh Client Models"
+    menu "Support for BLE Mesh Foundation models"
 
         config BLE_MESH_CFG_CLI
-            bool "Configuration Client Model"
+            bool "Configuration Client model"
             help
-                Enable support for Configuration client model.
+                Enable support for Configuration Client model.
 
         config BLE_MESH_HEALTH_CLI
-            bool "Health Client Model"
+            bool "Health Client model"
+            help
+                Enable support for Health Client model.
+
+        config BLE_MESH_HEALTH_SRV
+            bool "Health Server model"
+            default y
             help
-                Enable support for Health client model.
+                Enable support for Health Server model.
+
+    endmenu #Support for BLE Mesh Foundation models
+
+    menu "Support for BLE Mesh Client/Server models"
 
         config BLE_MESH_GENERIC_ONOFF_CLI
-            bool "Generic OnOff Client Model"
+            bool "Generic OnOff Client model"
             help
-                Enable support for Generic OnOff client model.
+                Enable support for Generic OnOff Client model.
 
         config BLE_MESH_GENERIC_LEVEL_CLI
-            bool "Generic Level Client Model"
+            bool "Generic Level Client model"
             help
-                Enable support for Generic Level client model.
+                Enable support for Generic Level Client model.
 
         config BLE_MESH_GENERIC_DEF_TRANS_TIME_CLI
-            bool "Generic Default Transition Time Client Model"
+            bool "Generic Default Transition Time Client model"
             help
-                Enable support for Generic Default Transition Time client model.
+                Enable support for Generic Default Transition Time Client model.
 
         config BLE_MESH_GENERIC_POWER_ONOFF_CLI
-            bool "Generic Power OnOff Client Model"
+            bool "Generic Power OnOff Client model"
             help
-                Enable support for Generic Power OnOff client model.
+                Enable support for Generic Power OnOff Client model.
 
         config BLE_MESH_GENERIC_POWER_LEVEL_CLI
-            bool "Generic Power Level Client Model"
+            bool "Generic Power Level Client model"
             help
-                Enable support for Generic Power Level client model.
+                Enable support for Generic Power Level Client model.
 
         config BLE_MESH_GENERIC_BATTERY_CLI
-            bool "Generic Battery Client Model"
+            bool "Generic Battery Client model"
             help
-                Enable support for Generic Battery client model.
+                Enable support for Generic Battery Client model.
 
         config BLE_MESH_GENERIC_LOCATION_CLI
-            bool "Generic Location Client Model"
+            bool "Generic Location Client model"
             help
-                Enable support for Generic Location client model.
+                Enable support for Generic Location Client model.
 
         config BLE_MESH_GENERIC_PROPERTY_CLI
-            bool "Generic Property Client Model"
+            bool "Generic Property Client model"
             help
-                Enable support for Generic Property client model.
+                Enable support for Generic Property Client model.
 
         config BLE_MESH_SENSOR_CLI
-            bool "Sensor Client Model"
+            bool "Sensor Client model"
             help
-                Enable support for Sensor client model.
+                Enable support for Sensor Client model.
 
         config BLE_MESH_TIME_CLI
-            bool "Time Client Model"
+            bool "Time Client model"
             help
-                Enable support for Time client model.
+                Enable support for Time Client model.
 
         config BLE_MESH_SCENE_CLI
-            bool "Scene Client Model"
+            bool "Scene Client model"
             help
-                Enable support for Scene client model.
+                Enable support for Scene Client model.
 
         config BLE_MESH_SCHEDULER_CLI
-            bool "Scheduler Client Model"
+            bool "Scheduler Client model"
             help
-                Enable support for Scheduler client model.
+                Enable support for Scheduler Client model.
 
         config BLE_MESH_LIGHT_LIGHTNESS_CLI
-            bool "Light Lightness Client Model"
+            bool "Light Lightness Client model"
             help
-                Enable support for Light Lightness client model.
+                Enable support for Light Lightness Client model.
 
         config BLE_MESH_LIGHT_CTL_CLI
-            bool "Light CTL Client Model"
+            bool "Light CTL Client model"
             help
-                Enable support for Light CTL client model.
+                Enable support for Light CTL Client model.
 
         config BLE_MESH_LIGHT_HSL_CLI
-            bool "Light HSL Client Model"
+            bool "Light HSL Client model"
             help
-                Enable support for Light HSL client model.
+                Enable support for Light HSL Client model.
 
         config BLE_MESH_LIGHT_XYL_CLI
-            bool "Light XYL Client Model"
+            bool "Light XYL Client model"
             help
-                Enable support for Light XYL client model.
+                Enable support for Light XYL Client model.
 
         config BLE_MESH_LIGHT_LC_CLI
-            bool "Light LC Client Model"
+            bool "Light LC Client model"
             help
-                Enable support for Light LC client model.
+                Enable support for Light LC Client model.
 
-    endmenu
+        config BLE_MESH_GENERIC_SERVER
+            bool "Generic server models"
+            default y
+            help
+                Enable support for Generic server models.
+
+        config BLE_MESH_SENSOR_SERVER
+            bool "Sensor server models"
+            default y
+            help
+                Enable support for Sensor server models.
+
+        config BLE_MESH_TIME_SCENE_SERVER
+            bool "Time and Scenes server models"
+            default y
+            help
+                Enable support for Time and Scenes server models.
+
+        config BLE_MESH_LIGHTING_SERVER
+            bool "Lighting server models"
+            default y
+            help
+                Enable support for Lighting server models.
+
+    endmenu #Support for BLE Mesh Client/Server models
 
     config BLE_MESH_IV_UPDATE_TEST
         bool "Test the IV Update Procedure"

+ 22 - 0
components/bt/common/btc/core/btc_task.c

@@ -105,18 +105,40 @@ static btc_func_t profile_tab[BTC_PID_NUM] = {
 #if CONFIG_BLE_MESH
     [BTC_PID_PROV]              = {btc_ble_mesh_prov_call_handler,              btc_ble_mesh_prov_cb_handler             },
     [BTC_PID_MODEL]             = {btc_ble_mesh_model_call_handler,             btc_ble_mesh_model_cb_handler            },
+#if CONFIG_BLE_MESH_HEALTH_CLI
     [BTC_PID_HEALTH_CLIENT]     = {btc_ble_mesh_health_client_call_handler,     btc_ble_mesh_health_client_cb_handler    },
+#endif /* CONFIG_BLE_MESH_HEALTH_CLI */
+#if CONFIG_BLE_MESH_HEALTH_SRV
     [BTC_PID_HEALTH_SERVER]     = {btc_ble_mesh_health_server_call_handler,     btc_ble_mesh_health_server_cb_handler    },
+#endif /* CONFIG_BLE_MESH_HEALTH_SRV */
+#if CONFIG_BLE_MESH_CFG_CLI
     [BTC_PID_CONFIG_CLIENT]     = {btc_ble_mesh_config_client_call_handler,     btc_ble_mesh_config_client_cb_handler    },
+#endif /* CONFIG_BLE_MESH_CFG_CLI */
     [BTC_PID_CONFIG_SERVER]     = {NULL,                                        btc_ble_mesh_config_server_cb_handler    },
+#if CONFIG_BLE_MESH_GENERIC_CLIENT
     [BTC_PID_GENERIC_CLIENT]    = {btc_ble_mesh_generic_client_call_handler,    btc_ble_mesh_generic_client_cb_handler   },
+#endif /* CONFIG_BLE_MESH_GENERIC_CLIENT */
+#if CONFIG_BLE_MESH_LIGHTING_CLIENT
     [BTC_PID_LIGHTING_CLIENT]   = {btc_ble_mesh_lighting_client_call_handler,   btc_ble_mesh_lighting_client_cb_handler  },
+#endif /* CONFIG_BLE_MESH_LIGHTING_CLIENT */
+#if CONFIG_BLE_MESH_SENSOR_CLI
     [BTC_PID_SENSOR_CLIENT]     = {btc_ble_mesh_sensor_client_call_handler,     btc_ble_mesh_sensor_client_cb_handler    },
+#endif /* CONFIG_BLE_MESH_SENSOR_CLI */
+#if CONFIG_BLE_MESH_TIME_SCENE_CLIENT
     [BTC_PID_TIME_SCENE_CLIENT] = {btc_ble_mesh_time_scene_client_call_handler, btc_ble_mesh_time_scene_client_cb_handler},
+#endif /* CONFIG_BLE_MESH_TIME_SCENE_CLIENT */
+#if CONFIG_BLE_MESH_GENERIC_SERVER
     [BTC_PID_GENERIC_SERVER]    = {NULL,                                        btc_ble_mesh_generic_server_cb_handler   },
+#endif /* CONFIG_BLE_MESH_GENERIC_SERVER */
+#if CONFIG_BLE_MESH_LIGHTING_SERVER
     [BTC_PID_LIGHTING_SERVER]   = {NULL,                                        btc_ble_mesh_lighting_server_cb_handler  },
+#endif /* CONFIG_BLE_MESH_LIGHTING_SERVER */
+#if CONFIG_BLE_MESH_SENSOR_SERVER
     [BTC_PID_SENSOR_SERVER]     = {NULL,                                        btc_ble_mesh_sensor_server_cb_handler    },
+#endif /* CONFIG_BLE_MESH_SENSOR_SERVER */
+#if CONFIG_BLE_MESH_TIME_SCENE_SERVER
     [BTC_PID_TIME_SCENE_SERVER] = {NULL,                                        btc_ble_mesh_time_scene_server_cb_handler},
+#endif /* CONFIG_BLE_MESH_TIME_SCENE_SERVER */
 #endif /* #if CONFIG_BLE_MESH */
 };
 

+ 2 - 1
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 */

+ 4 - 0
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,
@@ -220,6 +222,7 @@ esp_err_t esp_ble_mesh_model_publish(esp_ble_mesh_model_t *model, uint32_t opcod
                                    length, data, 0, false, device_role);
 }
 
+#if CONFIG_BLE_MESH_SERVER_MODEL
 esp_err_t esp_ble_mesh_server_model_update_state(esp_ble_mesh_model_t *model,
                                                  esp_ble_mesh_server_state_type_t type,
                                                  esp_ble_mesh_server_state_value_t *value)
@@ -244,6 +247,7 @@ esp_err_t esp_ble_mesh_server_model_update_state(esp_ble_mesh_model_t *model,
     return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_model_args_t), btc_ble_mesh_model_arg_deep_copy)
             == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
+#endif /* CONFIG_BLE_MESH_SERVER_MODEL */
 
 esp_err_t esp_ble_mesh_node_local_reset(void)
 {

+ 3 - 0
components/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h

@@ -17,6 +17,7 @@
 
 #include <stdint.h>
 
+#include "mesh_config.h"
 #include "mesh_common.h"
 #include "proxy_server.h"
 #include "provisioner_main.h"
@@ -468,8 +469,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.

+ 9 - 7
components/bt/esp_ble_mesh/api/models/esp_ble_mesh_config_model_api.c

@@ -19,6 +19,7 @@
 #include "btc_ble_mesh_config_model.h"
 #include "esp_ble_mesh_config_model_api.h"
 
+#if CONFIG_BLE_MESH_CFG_CLI
 esp_err_t esp_ble_mesh_register_config_client_callback(esp_ble_mesh_cfg_client_cb_t callback)
 {
     ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
@@ -26,13 +27,6 @@ esp_err_t esp_ble_mesh_register_config_client_callback(esp_ble_mesh_cfg_client_c
     return (btc_profile_cb_set(BTC_PID_CONFIG_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
 }
 
-esp_err_t esp_ble_mesh_register_config_server_callback(esp_ble_mesh_cfg_server_cb_t callback)
-{
-    ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
-
-    return (btc_profile_cb_set(BTC_PID_CONFIG_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
-}
-
 static bool config_client_get_need_param(esp_ble_mesh_opcode_t opcode)
 {
     switch (opcode) {
@@ -101,3 +95,11 @@ esp_err_t esp_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_
     return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_config_client_args_t), btc_ble_mesh_config_client_arg_deep_copy)
             == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
+#endif /* CONFIG_BLE_MESH_CFG_CLI */
+
+esp_err_t esp_ble_mesh_register_config_server_callback(esp_ble_mesh_cfg_server_cb_t callback)
+{
+    ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
+
+    return (btc_profile_cb_set(BTC_PID_CONFIG_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
+}

+ 4 - 0
components/bt/esp_ble_mesh/api/models/esp_ble_mesh_generic_model_api.c

@@ -19,6 +19,7 @@
 #include "btc_ble_mesh_generic_model.h"
 #include "esp_ble_mesh_generic_model_api.h"
 
+#if CONFIG_BLE_MESH_GENERIC_CLIENT
 esp_err_t esp_ble_mesh_register_generic_client_callback(esp_ble_mesh_generic_client_cb_t callback)
 {
     ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
@@ -89,10 +90,13 @@ esp_err_t esp_ble_mesh_generic_client_set_state(esp_ble_mesh_client_common_param
     return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_generic_client_args_t), btc_ble_mesh_generic_client_arg_deep_copy)
             == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
+#endif /* CONFIG_BLE_MESH_GENERIC_CLIENT */
 
+#if CONFIG_BLE_MESH_GENERIC_SERVER
 esp_err_t esp_ble_mesh_register_generic_server_callback(esp_ble_mesh_generic_server_cb_t callback)
 {
     ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
 
     return (btc_profile_cb_set(BTC_PID_GENERIC_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
 }
+#endif /* CONFIG_BLE_MESH_GENERIC_SERVER */

+ 11 - 7
components/bt/esp_ble_mesh/api/models/esp_ble_mesh_health_model_api.c

@@ -19,6 +19,7 @@
 #include "btc_ble_mesh_health_model.h"
 #include "esp_ble_mesh_health_model_api.h"
 
+#if CONFIG_BLE_MESH_HEALTH_CLI
 esp_err_t esp_ble_mesh_register_health_client_callback(esp_ble_mesh_health_client_cb_t callback)
 {
     ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
@@ -26,13 +27,6 @@ esp_err_t esp_ble_mesh_register_health_client_callback(esp_ble_mesh_health_clien
     return (btc_profile_cb_set(BTC_PID_HEALTH_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
 }
 
-esp_err_t esp_ble_mesh_register_health_server_callback(esp_ble_mesh_health_server_cb_t callback)
-{
-    ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
-
-    return (btc_profile_cb_set(BTC_PID_HEALTH_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
-}
-
 esp_err_t esp_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_t *params,
                                                esp_ble_mesh_health_client_get_state_t *get_state)
 {
@@ -83,6 +77,15 @@ esp_err_t esp_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_
     return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_health_client_args_t), btc_ble_mesh_health_client_arg_deep_copy)
             == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
+#endif /* CONFIG_BLE_MESH_HEALTH_CLI */
+
+#if CONFIG_BLE_MESH_HEALTH_SRV
+esp_err_t esp_ble_mesh_register_health_server_callback(esp_ble_mesh_health_server_cb_t callback)
+{
+    ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
+
+    return (btc_profile_cb_set(BTC_PID_HEALTH_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
+}
 
 esp_err_t esp_ble_mesh_health_server_fault_update(esp_ble_mesh_elem_t *element)
 {
@@ -103,3 +106,4 @@ esp_err_t esp_ble_mesh_health_server_fault_update(esp_ble_mesh_elem_t *element)
     return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_health_server_args_t), NULL)
             == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
+#endif /* CONFIG_BLE_MESH_HEALTH_SRV */

+ 4 - 0
components/bt/esp_ble_mesh/api/models/esp_ble_mesh_lighting_model_api.c

@@ -19,6 +19,7 @@
 #include "btc_ble_mesh_lighting_model.h"
 #include "esp_ble_mesh_lighting_model_api.h"
 
+#if CONFIG_BLE_MESH_LIGHTING_CLIENT
 esp_err_t esp_ble_mesh_register_light_client_callback(esp_ble_mesh_light_client_cb_t callback)
 {
     ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
@@ -76,10 +77,13 @@ esp_err_t esp_ble_mesh_light_client_set_state(esp_ble_mesh_client_common_param_t
     return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_lighting_client_args_t), btc_ble_mesh_lighting_client_arg_deep_copy)
             == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
+#endif /* CONFIG_BLE_MESH_LIGHTING_CLIENT */
 
+#if CONFIG_BLE_MESH_LIGHTING_SERVER
 esp_err_t esp_ble_mesh_register_lighting_server_callback(esp_ble_mesh_lighting_server_cb_t callback)
 {
     ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
 
     return (btc_profile_cb_set(BTC_PID_LIGHTING_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
 }
+#endif /* CONFIG_BLE_MESH_LIGHTING_SERVER */

+ 4 - 2
components/bt/esp_ble_mesh/api/models/esp_ble_mesh_sensor_model_api.c

@@ -19,6 +19,7 @@
 #include "btc_ble_mesh_sensor_model.h"
 #include "esp_ble_mesh_sensor_model_api.h"
 
+#if CONFIG_BLE_MESH_SENSOR_CLI
 esp_err_t esp_ble_mesh_register_sensor_client_callback(esp_ble_mesh_sensor_client_cb_t callback)
 {
     ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
@@ -75,12 +76,13 @@ esp_err_t esp_ble_mesh_sensor_client_set_state(esp_ble_mesh_client_common_param_
     return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_sensor_client_args_t), btc_ble_mesh_sensor_client_arg_deep_copy)
             == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
+#endif /* CONFIG_BLE_MESH_SENSOR_CLI */
 
+#if CONFIG_BLE_MESH_SENSOR_SERVER
 esp_err_t esp_ble_mesh_register_sensor_server_callback(esp_ble_mesh_sensor_server_cb_t callback)
 {
     ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
 
     return (btc_profile_cb_set(BTC_PID_SENSOR_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
 }
-
-
+#endif /* CONFIG_BLE_MESH_SENSOR_SERVER */

+ 4 - 1
components/bt/esp_ble_mesh/api/models/esp_ble_mesh_time_scene_model_api.c

@@ -19,6 +19,7 @@
 #include "btc_ble_mesh_time_scene_model.h"
 #include "esp_ble_mesh_time_scene_model_api.h"
 
+#if CONFIG_BLE_MESH_TIME_SCENE_CLIENT
 esp_err_t esp_ble_mesh_register_time_scene_client_callback(esp_ble_mesh_time_scene_client_cb_t callback)
 {
     ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
@@ -76,11 +77,13 @@ esp_err_t esp_ble_mesh_time_scene_client_set_state(esp_ble_mesh_client_common_pa
     return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_time_scene_client_args_t), btc_ble_mesh_time_scene_client_arg_deep_copy)
             == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
+#endif /* CONFIG_BLE_MESH_TIME_SCENE_CLIENT */
 
+#if CONFIG_BLE_MESH_TIME_SCENE_SERVER
 esp_err_t esp_ble_mesh_register_time_scene_server_callback(esp_ble_mesh_time_scene_server_cb_t callback)
 {
     ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
 
     return (btc_profile_cb_set(BTC_PID_TIME_SCENE_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
 }
-
+#endif /* CONFIG_BLE_MESH_TIME_SCENE_SERVER */

+ 5 - 1
components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c

@@ -17,9 +17,11 @@
 
 #include "btc_ble_mesh_config_model.h"
 #include "foundation.h"
-#include "cfg_cli.h"
 #include "esp_ble_mesh_config_model_api.h"
 
+#if CONFIG_BLE_MESH_CFG_CLI
+#include "cfg_cli.h"
+
 /* Configuration Client Model related functions */
 
 static inline void btc_ble_mesh_config_client_cb_to_app(esp_ble_mesh_cfg_client_cb_event_t event,
@@ -679,6 +681,8 @@ void btc_ble_mesh_config_client_cb_handler(btc_msg_t *msg)
     return;
 }
 
+#endif /* CONFIG_BLE_MESH_CFG_CLI */
+
 /* Configuration Server Model related functions */
 
 static inline void btc_ble_mesh_config_server_cb_to_app(esp_ble_mesh_cfg_server_cb_event_t event,

+ 9 - 1
components/bt/esp_ble_mesh/btc/btc_ble_mesh_generic_model.c

@@ -16,9 +16,11 @@
 #include <errno.h>
 
 #include "btc_ble_mesh_generic_model.h"
-#include "generic_client.h"
 #include "esp_ble_mesh_generic_model_api.h"
 
+#if CONFIG_BLE_MESH_GENERIC_CLIENT
+#include "generic_client.h"
+
 /* Generic Client Models related functions */
 
 static inline void btc_ble_mesh_generic_client_cb_to_app(esp_ble_mesh_generic_client_cb_event_t event,
@@ -530,6 +532,10 @@ void btc_ble_mesh_generic_client_cb_handler(btc_msg_t *msg)
     return;
 }
 
+#endif /* CONFIG_BLE_MESH_GENERIC_CLIENT */
+
+#if CONFIG_BLE_MESH_GENERIC_SERVER
+
 /* Generic Server Models related functions */
 
 static inline void btc_ble_mesh_generic_server_cb_to_app(esp_ble_mesh_generic_server_cb_event_t event,
@@ -756,3 +762,5 @@ void btc_ble_mesh_generic_server_cb_handler(btc_msg_t *msg)
     btc_ble_mesh_generic_server_free_req_data(msg);
     return;
 }
+
+#endif /* CONFIG_BLE_MESH_GENERIC_SERVER */

+ 9 - 2
components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c

@@ -17,10 +17,11 @@
 
 #include "btc_ble_mesh_health_model.h"
 #include "foundation.h"
-#include "health_srv.h"
-#include "health_cli.h"
 #include "esp_ble_mesh_health_model_api.h"
 
+#if CONFIG_BLE_MESH_HEALTH_CLI
+#include "health_cli.h"
+
 /* Health Client Model related functions */
 
 static inline void btc_ble_mesh_health_client_cb_to_app(esp_ble_mesh_health_client_cb_event_t event,
@@ -457,6 +458,11 @@ void btc_ble_mesh_health_client_cb_handler(btc_msg_t *msg)
     return;
 }
 
+#endif /* CONFIG_BLE_MESH_HEALTH_CLI */
+
+#if CONFIG_BLE_MESH_HEALTH_SRV
+#include "health_srv.h"
+
 /* Health Server Model related functions */
 
 static inline void btc_ble_mesh_health_server_cb_to_app(esp_ble_mesh_health_server_cb_event_t event,
@@ -636,3 +642,4 @@ void btc_ble_mesh_health_server_attention_off(struct bt_mesh_model *model)
 
     btc_ble_mesh_health_server_callback(&param, ESP_BLE_MESH_HEALTH_SERVER_ATTENTION_OFF_EVT);
 }
+#endif /* CONFIG_BLE_MESH_HEALTH_SRV */

+ 10 - 2
components/bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c

@@ -16,9 +16,11 @@
 #include <errno.h>
 
 #include "btc_ble_mesh_lighting_model.h"
-#include "lighting_client.h"
 #include "esp_ble_mesh_lighting_model_api.h"
 
+#if CONFIG_BLE_MESH_LIGHTING_CLIENT
+#include "lighting_client.h"
+
 /* Lighting Client Models related functions */
 
 static inline void btc_ble_mesh_lighting_client_cb_to_app(esp_ble_mesh_light_client_cb_event_t event,
@@ -374,6 +376,10 @@ void btc_ble_mesh_lighting_client_cb_handler(btc_msg_t *msg)
     return;
 }
 
+#endif /* CONFIG_BLE_MESH_LIGHTING_CLIENT */
+
+#if CONFIG_BLE_MESH_LIGHTING_SERVER
+
 /* Lighting Server Models related functions */
 
 static inline void btc_ble_mesh_lighting_server_cb_to_app(esp_ble_mesh_lighting_server_cb_event_t event,
@@ -570,4 +576,6 @@ void btc_ble_mesh_lighting_server_cb_handler(btc_msg_t *msg)
 
     btc_ble_mesh_lighting_server_free_req_data(msg);
     return;
-}
+}
+
+#endif /* CONFIG_BLE_MESH_LIGHTING_SERVER */

+ 79 - 4
components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c

@@ -34,14 +34,28 @@
 #include "provisioner_prov.h"
 #include "provisioner_main.h"
 
+#if CONFIG_BLE_MESH_CFG_CLI
 #include "cfg_cli.h"
+#endif /* CONFIG_BLE_MESH_CFG_CLI */
+#if CONFIG_BLE_MESH_HEALTH_CLI
 #include "health_cli.h"
+#endif /* CONFIG_BLE_MESH_HEALTH_CLI */
 #include "cfg_srv.h"
+#if CONFIG_BLE_MESH_HEALTH_SRV
 #include "health_srv.h"
+#endif /* CONFIG_BLE_MESH_HEALTH_SRV */
+#if CONFIG_BLE_MESH_GENERIC_CLIENT
 #include "generic_client.h"
+#endif /* CONFIG_BLE_MESH_GENERIC_CLIENT */
+#if CONFIG_BLE_MESH_LIGHTING_CLIENT
 #include "lighting_client.h"
+#endif /* CONFIG_BLE_MESH_LIGHTING_CLIENT */
+#if CONFIG_BLE_MESH_SENSOR_CLI
 #include "sensor_client.h"
+#endif /* CONFIG_BLE_MESH_SENSOR_CLI */
+#if CONFIG_BLE_MESH_TIME_SCENE_CLIENT
 #include "time_scene_client.h"
+#endif /* CONFIG_BLE_MESH_TIME_SCENE_CLIENT */
 #include "client_common.h"
 #include "state_binding.h"
 #include "local_operation.h"
@@ -489,6 +503,7 @@ static int btc_ble_mesh_model_publish_update(struct bt_mesh_model *mod)
     return (ret == BT_STATUS_SUCCESS) ? 0 : -1;
 }
 
+#if CONFIG_BLE_MESH_SERVER_MODEL
 static void btc_ble_mesh_server_model_update_state_comp_cb(esp_ble_mesh_model_t *model,
                                                            esp_ble_mesh_server_state_type_t type,
                                                            int err)
@@ -502,6 +517,7 @@ static void btc_ble_mesh_server_model_update_state_comp_cb(esp_ble_mesh_model_t
     btc_ble_mesh_model_callback(&mesh_param, ESP_BLE_MESH_SERVER_MODEL_UPDATE_STATE_COMP_EVT);
     return;
 }
+#endif /* CONFIG_BLE_MESH_SERVER_MODEL */
 
 static bt_status_t btc_ble_mesh_prov_callback(esp_ble_mesh_prov_cb_param_t *param, uint8_t act)
 {
@@ -962,10 +978,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)
 {
@@ -1010,15 +1028,24 @@ const esp_ble_mesh_comp_t *btc_ble_mesh_comp_get(void)
 
 /* Configuration Models */
 extern const struct bt_mesh_model_op bt_mesh_cfg_srv_op[];
-extern const struct bt_mesh_model_op bt_mesh_cfg_cli_op[];
 extern const struct bt_mesh_model_cb bt_mesh_cfg_srv_cb;
+#if CONFIG_BLE_MESH_CFG_CLI
+extern const struct bt_mesh_model_op bt_mesh_cfg_cli_op[];
 extern const struct bt_mesh_model_cb bt_mesh_cfg_cli_cb;
+#endif /* CONFIG_BLE_MESH_CFG_CLI */
+
 /* Health Models */
+#if CONFIG_BLE_MESH_HEALTH_SRV
 extern const struct bt_mesh_model_op bt_mesh_health_srv_op[];
-extern const struct bt_mesh_model_op bt_mesh_health_cli_op[];
 extern const struct bt_mesh_model_cb bt_mesh_health_srv_cb;
+#endif /* CONFIG_BLE_MESH_HEALTH_SRV */
+#if CONFIG_BLE_MESH_HEALTH_CLI
+extern const struct bt_mesh_model_op bt_mesh_health_cli_op[];
 extern const struct bt_mesh_model_cb bt_mesh_health_cli_cb;
+#endif /* CONFIG_BLE_MESH_HEALTH_CLI */
+
 /* Generic Client Models */
+#if CONFIG_BLE_MESH_GENERIC_CLIENT
 extern const struct bt_mesh_model_op bt_mesh_gen_onoff_cli_op[];
 extern const struct bt_mesh_model_op bt_mesh_gen_level_cli_op[];
 extern const struct bt_mesh_model_op bt_mesh_gen_def_trans_time_cli_op[];
@@ -1028,22 +1055,34 @@ extern const struct bt_mesh_model_op bt_mesh_gen_battery_cli_op[];
 extern const struct bt_mesh_model_op bt_mesh_gen_location_cli_op[];
 extern const struct bt_mesh_model_op bt_mesh_gen_property_cli_op[];
 extern const struct bt_mesh_model_cb bt_mesh_generic_client_cb;
+#endif /* CONFIG_BLE_MESH_GENERIC_CLIENT */
+
 /* Lighting Client Models */
+#if CONFIG_BLE_MESH_LIGHTING_CLIENT
 extern const struct bt_mesh_model_op bt_mesh_light_lightness_cli_op[];
 extern const struct bt_mesh_model_op bt_mesh_light_ctl_cli_op[];
 extern const struct bt_mesh_model_op bt_mesh_light_hsl_cli_op[];
 extern const struct bt_mesh_model_op bt_mesh_light_xyl_cli_op[];
 extern const struct bt_mesh_model_op bt_mesh_light_lc_cli_op[];
 extern const struct bt_mesh_model_cb bt_mesh_lighting_client_cb;
+#endif /* CONFIG_BLE_MESH_LIGHTING_CLIENT */
+
 /* Sensor Client Models */
+#if CONFIG_BLE_MESH_SENSOR_CLI
 extern const struct bt_mesh_model_op bt_mesh_sensor_cli_op[];
 extern const struct bt_mesh_model_cb bt_mesh_sensor_client_cb;
+#endif /* CONFIG_BLE_MESH_SENSOR_CLI */
+
 /* Time and Scenes Client Models */
+#if CONFIG_BLE_MESH_TIME_SCENE_CLIENT
 extern const struct bt_mesh_model_op bt_mesh_time_cli_op[];
 extern const struct bt_mesh_model_op bt_mesh_scene_cli_op[];
 extern const struct bt_mesh_model_op bt_mesh_scheduler_cli_op[];
 extern const struct bt_mesh_model_cb bt_mesh_time_scene_client_cb;
+#endif /* CONFIG_BLE_MESH_TIME_SCENE_CLIENT */
+
 /* Generic Server Models */
+#if CONFIG_BLE_MESH_GENERIC_SERVER
 extern const struct bt_mesh_model_op bt_mesh_gen_onoff_srv_op[];
 extern const struct bt_mesh_model_op bt_mesh_gen_level_srv_op[];
 extern const struct bt_mesh_model_op bt_mesh_gen_def_trans_time_srv_op[];
@@ -1072,7 +1111,10 @@ extern const struct bt_mesh_model_cb bt_mesh_gen_user_prop_srv_cb;
 extern const struct bt_mesh_model_cb bt_mesh_gen_admin_prop_srv_cb;
 extern const struct bt_mesh_model_cb bt_mesh_gen_manu_prop_srv_cb;
 extern const struct bt_mesh_model_cb bt_mesh_gen_client_prop_srv_cb;
+#endif /* CONFIG_BLE_MESH_GENERIC_SERVER */
+
 /* Lighting Server Models */
+#if CONFIG_BLE_MESH_LIGHTING_SERVER
 extern const struct bt_mesh_model_op bt_mesh_light_lightness_srv_op[];
 extern const struct bt_mesh_model_op bt_mesh_light_lightness_setup_srv_op[];
 extern const struct bt_mesh_model_op bt_mesh_light_ctl_srv_op[];
@@ -1084,8 +1126,6 @@ extern const struct bt_mesh_model_op bt_mesh_light_hsl_sat_srv_op[];
 extern const struct bt_mesh_model_op bt_mesh_light_hsl_setup_srv_op[];
 extern const struct bt_mesh_model_op bt_mesh_light_xyl_srv_op[];
 extern const struct bt_mesh_model_op bt_mesh_light_xyl_setup_srv_op[];
-extern const struct bt_mesh_model_op bt_mesh_light_lc_srv_op[];
-extern const struct bt_mesh_model_op bt_mesh_light_lc_setup_srv_op[];
 extern const struct bt_mesh_model_cb bt_mesh_light_lightness_srv_cb;
 extern const struct bt_mesh_model_cb bt_mesh_light_lightness_setup_srv_cb;
 extern const struct bt_mesh_model_cb bt_mesh_light_ctl_srv_cb;
@@ -1097,9 +1137,14 @@ extern const struct bt_mesh_model_cb bt_mesh_light_hsl_sat_srv_cb;
 extern const struct bt_mesh_model_cb bt_mesh_light_hsl_setup_srv_cb;
 extern const struct bt_mesh_model_cb bt_mesh_light_xyl_srv_cb;
 extern const struct bt_mesh_model_cb bt_mesh_light_xyl_setup_srv_cb;
+extern const struct bt_mesh_model_op bt_mesh_light_lc_srv_op[];
+extern const struct bt_mesh_model_op bt_mesh_light_lc_setup_srv_op[];
 extern const struct bt_mesh_model_cb bt_mesh_light_lc_srv_cb;
 extern const struct bt_mesh_model_cb bt_mesh_light_lc_setup_srv_cb;
+#endif /* CONFIG_BLE_MESH_LIGHTING_SERVER */
+
 /* Time and Scenes Server Models */
+#if CONFIG_BLE_MESH_TIME_SCENE_SERVER
 extern const struct bt_mesh_model_op bt_mesh_time_srv_op[];
 extern const struct bt_mesh_model_op bt_mesh_time_setup_srv_op[];
 extern const struct bt_mesh_model_op bt_mesh_scene_srv_op[];
@@ -1112,11 +1157,15 @@ extern const struct bt_mesh_model_cb bt_mesh_scene_srv_cb;
 extern const struct bt_mesh_model_cb bt_mesh_scene_setup_srv_cb;
 extern const struct bt_mesh_model_cb bt_mesh_scheduler_srv_cb;
 extern const struct bt_mesh_model_cb bt_mesh_scheduler_setup_srv_cb;
+#endif /* CONFIG_BLE_MESH_TIME_SCENE_SERVER */
+
 /* Sensor Server Models */
+#if CONFIG_BLE_MESH_SENSOR_SERVER
 extern const struct bt_mesh_model_op bt_mesh_sensor_srv_op[];
 extern const struct bt_mesh_model_op bt_mesh_sensor_setup_srv_op[];
 extern const struct bt_mesh_model_cb bt_mesh_sensor_srv_cb;
 extern const struct bt_mesh_model_cb bt_mesh_sensor_setup_srv_cb;
+#endif /* CONFIG_BLE_MESH_SENSOR_SERVER */
 
 static void btc_ble_mesh_model_op_set(esp_ble_mesh_model_t *model)
 {
@@ -1142,6 +1191,7 @@ static void btc_ble_mesh_model_op_set(esp_ble_mesh_model_t *model)
         }
         break;
     }
+#if CONFIG_BLE_MESH_CFG_CLI
     case BLE_MESH_MODEL_ID_CFG_CLI: {
         model->op = (esp_ble_mesh_model_op_t *)bt_mesh_cfg_cli_op;
         model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_cfg_cli_cb;
@@ -1151,6 +1201,8 @@ static void btc_ble_mesh_model_op_set(esp_ble_mesh_model_t *model)
         }
         break;
     }
+#endif /* CONFIG_BLE_MESH_CFG_CLI */
+#if CONFIG_BLE_MESH_HEALTH_SRV
     case BLE_MESH_MODEL_ID_HEALTH_SRV: {
         model->op = (esp_ble_mesh_model_op_t *)bt_mesh_health_srv_op;
         model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_health_srv_cb;
@@ -1163,6 +1215,8 @@ static void btc_ble_mesh_model_op_set(esp_ble_mesh_model_t *model)
         }
         break;
     }
+#endif /* CONFIG_BLE_MESH_HEALTH_SRV */
+#if CONFIG_BLE_MESH_HEALTH_CLI
     case BLE_MESH_MODEL_ID_HEALTH_CLI: {
         model->op = (esp_ble_mesh_model_op_t *)bt_mesh_health_cli_op;
         model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_health_cli_cb;
@@ -1172,6 +1226,8 @@ static void btc_ble_mesh_model_op_set(esp_ble_mesh_model_t *model)
         }
         break;
     }
+#endif /* CONFIG_BLE_MESH_HEALTH_CLI */
+#if CONFIG_BLE_MESH_GENERIC_CLIENT
     case BLE_MESH_MODEL_ID_GEN_ONOFF_CLI: {
         model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_onoff_cli_op;
         model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_generic_client_cb;
@@ -1244,6 +1300,8 @@ static void btc_ble_mesh_model_op_set(esp_ble_mesh_model_t *model)
         }
         break;
     }
+#endif /* CONFIG_BLE_MESH_GENERIC_CLIENT */
+#if CONFIG_BLE_MESH_LIGHTING_CLIENT
     case BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI: {
         model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_lightness_cli_op;
         model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_lighting_client_cb;
@@ -1289,6 +1347,8 @@ static void btc_ble_mesh_model_op_set(esp_ble_mesh_model_t *model)
         }
         break;
     }
+#endif /* CONFIG_BLE_MESH_LIGHTING_CLIENT */
+#if CONFIG_BLE_MESH_SENSOR_CLI
     case BLE_MESH_MODEL_ID_SENSOR_CLI: {
         model->op = (esp_ble_mesh_model_op_t *)bt_mesh_sensor_cli_op;
         model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_sensor_client_cb;
@@ -1298,6 +1358,8 @@ static void btc_ble_mesh_model_op_set(esp_ble_mesh_model_t *model)
         }
         break;
     }
+#endif /* CONFIG_BLE_MESH_SENSOR_CLI */
+#if CONFIG_BLE_MESH_TIME_SCENE_CLIENT
     case BLE_MESH_MODEL_ID_TIME_CLI: {
         model->op = (esp_ble_mesh_model_op_t *)bt_mesh_time_cli_op;
         model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_time_scene_client_cb;
@@ -1325,6 +1387,8 @@ static void btc_ble_mesh_model_op_set(esp_ble_mesh_model_t *model)
         }
         break;
     }
+#endif /* CONFIG_BLE_MESH_TIME_SCENE_CLIENT */
+#if CONFIG_BLE_MESH_GENERIC_SERVER
     case BLE_MESH_MODEL_ID_GEN_ONOFF_SRV:
         model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_onoff_srv_op;
         model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_gen_onoff_srv_cb;
@@ -1423,6 +1487,8 @@ static void btc_ble_mesh_model_op_set(esp_ble_mesh_model_t *model)
             model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
         }
         break;
+#endif /* CONFIG_BLE_MESH_GENERIC_SERVER */
+#if CONFIG_BLE_MESH_LIGHTING_SERVER
     case BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV:
         model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_lightness_srv_op;
         model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_light_lightness_srv_cb;
@@ -1514,6 +1580,8 @@ static void btc_ble_mesh_model_op_set(esp_ble_mesh_model_t *model)
             model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
         }
         break;
+#endif /* CONFIG_BLE_MESH_LIGHTING_SERVER */
+#if CONFIG_BLE_MESH_TIME_SCENE_SERVER
     case BLE_MESH_MODEL_ID_TIME_SRV:
         model->op = (esp_ble_mesh_model_op_t *)bt_mesh_time_srv_op;
         model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_time_srv_cb;
@@ -1558,6 +1626,8 @@ static void btc_ble_mesh_model_op_set(esp_ble_mesh_model_t *model)
             model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
         }
         break;
+#endif /* CONFIG_BLE_MESH_TIME_SCENE_SERVER */
+#if CONFIG_BLE_MESH_SENSOR_SERVER
     case BLE_MESH_MODEL_ID_SENSOR_SRV:
         model->op = (esp_ble_mesh_model_op_t *)bt_mesh_sensor_srv_op;
         model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_sensor_srv_cb;
@@ -1572,6 +1642,7 @@ static void btc_ble_mesh_model_op_set(esp_ble_mesh_model_t *model)
             model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
         }
         break;
+#endif /* CONFIG_BLE_MESH_SENSOR_SERVER */
     default:
         goto set_vnd_op;
     }
@@ -2027,10 +2098,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;
@@ -2142,6 +2215,7 @@ void btc_ble_mesh_model_call_handler(btc_msg_t *msg)
                                         arg->model_send.opcode, err);
         break;
     }
+#if CONFIG_BLE_MESH_SERVER_MODEL
     case BTC_BLE_MESH_ACT_SERVER_MODEL_UPDATE_STATE:
         err = bt_mesh_update_binding_state(
                   (struct bt_mesh_model *)arg->model_update_state.model, arg->model_update_state.type,
@@ -2149,6 +2223,7 @@ void btc_ble_mesh_model_call_handler(btc_msg_t *msg)
         btc_ble_mesh_server_model_update_state_comp_cb(arg->model_update_state.model,
                 arg->model_update_state.type, err);
         break;
+#endif /* CONFIG_BLE_MESH_SERVER_MODEL */
     default:
         BT_WARN("%s, Unknown act %d", __func__, msg->act);
         break;

+ 9 - 1
components/bt/esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c

@@ -16,9 +16,11 @@
 #include <errno.h>
 
 #include "btc_ble_mesh_sensor_model.h"
-#include "sensor_client.h"
 #include "esp_ble_mesh_sensor_model_api.h"
 
+#if CONFIG_BLE_MESH_SENSOR_CLI
+#include "sensor_client.h"
+
 /* Sensor Client Models related functions */
 
 static inline void btc_ble_mesh_sensor_client_cb_to_app(esp_ble_mesh_sensor_client_cb_event_t event,
@@ -612,6 +614,10 @@ void btc_ble_mesh_sensor_client_cb_handler(btc_msg_t *msg)
     return;
 }
 
+#endif /* CONFIG_BLE_MESH_SENSOR_CLI */
+
+#if CONFIG_BLE_MESH_SENSOR_SERVER
+
 /* Sensor Server Models related functions */
 
 static inline void btc_ble_mesh_sensor_server_cb_to_app(esp_ble_mesh_sensor_server_cb_event_t event,
@@ -888,3 +894,5 @@ void btc_ble_mesh_sensor_server_cb_handler(btc_msg_t *msg)
     btc_ble_mesh_sensor_server_free_req_data(msg);
     return;
 }
+
+#endif /* CONFIG_BLE_MESH_SENSOR_SERVER */

+ 8 - 1
components/bt/esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c

@@ -16,9 +16,11 @@
 #include <errno.h>
 
 #include "btc_ble_mesh_time_scene_model.h"
-#include "time_scene_client.h"
 #include "esp_ble_mesh_time_scene_model_api.h"
 
+#if CONFIG_BLE_MESH_TIME_SCENE_CLIENT
+#include "time_scene_client.h"
+
 /* Time and Scenes Client Models related functions */
 
 static inline void btc_ble_mesh_time_scene_client_cb_to_app(esp_ble_mesh_time_scene_client_cb_event_t event,
@@ -376,6 +378,10 @@ void btc_ble_mesh_time_scene_client_cb_handler(btc_msg_t *msg)
     return;
 }
 
+#endif /* CONFIG_BLE_MESH_TIME_SCENE_CLIENT */
+
+#if CONFIG_BLE_MESH_TIME_SCENE_SERVER
+
 /* Time and Scenes Server Models related functions */
 
 static inline void btc_ble_mesh_time_scene_server_cb_to_app(esp_ble_mesh_time_scene_server_cb_event_t event,
@@ -474,3 +480,4 @@ void btc_ble_mesh_time_scene_server_cb_handler(btc_msg_t *msg)
     return;
 }
 
+#endif /* CONFIG_BLE_MESH_TIME_SCENE_SERVER */

+ 1 - 0
components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_prov.h

@@ -17,6 +17,7 @@
 
 #include "btc/btc_manage.h"
 #include "mesh_byteorder.h"
+#include "mesh_config.h"
 #include "mesh_main.h"
 #include "fast_prov.h"
 #include "provisioner_prov.h"

+ 8 - 8
components/bt/esp_ble_mesh/mesh_common/include/mesh_buf.h

@@ -11,7 +11,7 @@
 #ifndef _BLE_MESH_BUF_H_
 #define _BLE_MESH_BUF_H_
 
-#include "sdkconfig.h"
+#include "mesh_config.h"
 #include "mesh_slist.h"
 #include "mesh_compiler.h"
 
@@ -717,7 +717,7 @@ static inline void net_buf_simple_save(struct net_buf_simple *buf,
  * @param state Stored state.
  */
 static inline void net_buf_simple_restore(struct net_buf_simple *buf,
-        struct net_buf_simple_state *state)
+                                          struct net_buf_simple_state *state)
 {
     buf->data = buf->__buf + state->offset;
     buf->len = state->len;
@@ -963,7 +963,7 @@ int net_buf_id(struct net_buf *buf);
  */
 #if defined(CONFIG_BLE_MESH_NET_BUF_LOG)
 struct net_buf *net_buf_alloc_fixed_debug(struct net_buf_pool *pool, s32_t timeout,
-        const char *func, int line);
+                                          const char *func, int line);
 #define net_buf_alloc_fixed(_pool, _timeout) \
     net_buf_alloc_fixed_debug(_pool, _timeout, __func__, __LINE__)
 #else
@@ -1631,8 +1631,8 @@ struct net_buf *net_buf_frag_add(struct net_buf *head, struct net_buf *frag);
  */
 #if defined(CONFIG_BLE_MESH_NET_BUF_LOG)
 struct net_buf *net_buf_frag_del_debug(struct net_buf *parent,
-                       struct net_buf *frag,
-                       const char *func, int line);
+                                       struct net_buf *frag,
+                                       const char *func, int line);
 #define net_buf_frag_del(_parent, _frag) \
     net_buf_frag_del_debug(_parent, _frag, __func__, __LINE__)
 #else
@@ -1655,7 +1655,7 @@ struct net_buf *net_buf_frag_del(struct net_buf *parent, struct net_buf *frag);
  * @return number of bytes actually copied
  */
 size_t net_buf_linearize(void *dst, size_t dst_len,
-             struct net_buf *src, size_t offset, size_t len);
+                         struct net_buf *src, size_t offset, size_t len);
 
 /**
  * @typedef net_buf_allocator_cb
@@ -1694,8 +1694,8 @@ typedef struct net_buf *(*net_buf_allocator_cb)(s32_t timeout, void *user_data);
  *         were no free fragments in a pool to accommodate all data.
  */
 size_t net_buf_append_bytes(struct net_buf *buf, size_t len,
-                const void *value, s32_t timeout,
-                net_buf_allocator_cb allocate_cb, void *user_data);
+                            const void *value, s32_t timeout,
+                            net_buf_allocator_cb allocate_cb, void *user_data);
 
 /**
  * @brief Skip N number of bytes in a net_buf

+ 52 - 0
components/bt/esp_ble_mesh/mesh_common/include/mesh_config.h

@@ -0,0 +1,52 @@
+// Copyright 2020-2021 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef _BLE_MESH_CONFIG_H_
+#define _BLE_MESH_CONFIG_H_
+
+#include "sdkconfig.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define CONFIG_BLE_MESH_GENERIC_CLIENT (CONFIG_BLE_MESH_GENERIC_ONOFF_CLI | \
+                                        CONFIG_BLE_MESH_GENERIC_LEVEL_CLI | \
+                                        CONFIG_BLE_MESH_GENERIC_DEF_TRANS_TIME_CLI | \
+                                        CONFIG_BLE_MESH_GENERIC_POWER_ONOFF_CLI | \
+                                        CONFIG_BLE_MESH_GENERIC_POWER_LEVEL_CLI | \
+                                        CONFIG_BLE_MESH_GENERIC_BATTERY_CLI | \
+                                        CONFIG_BLE_MESH_GENERIC_LOCATION_CLI | \
+                                        CONFIG_BLE_MESH_GENERIC_PROPERTY_CLI)
+
+#define CONFIG_BLE_MESH_TIME_SCENE_CLIENT (CONFIG_BLE_MESH_TIME_CLI | \
+                                           CONFIG_BLE_MESH_SCENE_CLI | \
+                                           CONFIG_BLE_MESH_SCHEDULER_CLI)
+
+#define CONFIG_BLE_MESH_LIGHTING_CLIENT (CONFIG_BLE_MESH_LIGHT_LIGHTNESS_CLI | \
+                                         CONFIG_BLE_MESH_LIGHT_CTL_CLI | \
+                                         CONFIG_BLE_MESH_LIGHT_HSL_CLI | \
+                                         CONFIG_BLE_MESH_LIGHT_XYL_CLI | \
+                                         CONFIG_BLE_MESH_LIGHT_LC_CLI)
+
+#define CONFIG_BLE_MESH_SERVER_MODEL (CONFIG_BLE_MESH_GENERIC_SERVER | \
+                                      CONFIG_BLE_MESH_SENSOR_SERVER | \
+                                      CONFIG_BLE_MESH_TIME_SCENE_SERVER | \
+                                      CONFIG_BLE_MESH_LIGHTING_SERVER)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _BLE_MESH_CONFIG_H_ */

+ 6 - 4
components/bt/esp_ble_mesh/mesh_common/include/mesh_dlist.h

@@ -291,7 +291,7 @@ static inline sys_dnode_t *sys_dlist_peek_head_not_empty(sys_dlist_t *list)
  */
 
 static inline sys_dnode_t *sys_dlist_peek_next_no_check(sys_dlist_t *list,
-        sys_dnode_t *node)
+                                                        sys_dnode_t *node)
 {
     return (node == list->tail) ? NULL : node->next;
 }
@@ -307,7 +307,7 @@ static inline sys_dnode_t *sys_dlist_peek_next_no_check(sys_dlist_t *list,
  */
 
 static inline sys_dnode_t *sys_dlist_peek_next(sys_dlist_t *list,
-        sys_dnode_t *node)
+                                               sys_dnode_t *node)
 {
     return node ? sys_dlist_peek_next_no_check(list, node) : NULL;
 }
@@ -379,7 +379,8 @@ static inline void sys_dlist_prepend(sys_dlist_t *list, sys_dnode_t *node)
  */
 
 static inline void sys_dlist_insert_after(sys_dlist_t *list,
-        sys_dnode_t *insert_point, sys_dnode_t *node)
+                                          sys_dnode_t *insert_point,
+                                          sys_dnode_t *node)
 {
     if (!insert_point) {
         sys_dlist_prepend(list, node);
@@ -405,7 +406,8 @@ static inline void sys_dlist_insert_after(sys_dlist_t *list,
  */
 
 static inline void sys_dlist_insert_before(sys_dlist_t *list,
-        sys_dnode_t *insert_point, sys_dnode_t *node)
+                                           sys_dnode_t *insert_point,
+                                           sys_dnode_t *node)
 {
     if (!insert_point) {
         sys_dlist_append(list, node);

+ 1 - 1
components/bt/esp_ble_mesh/mesh_common/include/mesh_kernel.h

@@ -13,7 +13,7 @@
 #include "freertos/queue.h"
 #include "freertos/semphr.h"
 
-#include "sdkconfig.h"
+#include "mesh_config.h"
 #include "mesh_types.h"
 
 #ifdef __cplusplus

+ 3 - 3
components/bt/esp_ble_mesh/mesh_common/include/mesh_slist.h

@@ -312,7 +312,7 @@ static inline void sys_slist_append(sys_slist_t *list,
  * @param tail A pointer to the last element of the list to append
  */
 static inline void sys_slist_append_list(sys_slist_t *list,
-        void *head, void *tail)
+                                         void *head, void *tail)
 {
     if (!list->tail) {
         list->head = (sys_snode_t *)head;
@@ -333,7 +333,7 @@ static inline void sys_slist_append_list(sys_slist_t *list,
  * @param list_to_append A pointer to the list to append.
  */
 static inline void sys_slist_merge_slist(sys_slist_t *list,
-        sys_slist_t *list_to_append)
+                                         sys_slist_t *list_to_append)
 {
     sys_slist_append_list(list, list_to_append->head,
                           list_to_append->tail);
@@ -443,7 +443,7 @@ static inline void sys_slist_remove(sys_slist_t *list,
  * @return true if node was removed
  */
 static inline bool sys_slist_find_and_remove(sys_slist_t *list,
-        sys_snode_t *node)
+                                             sys_snode_t *node)
 {
     sys_snode_t *prev = NULL;
     sys_snode_t *test;

+ 5 - 5
components/bt/esp_ble_mesh/mesh_common/mesh_buf.c

@@ -16,7 +16,7 @@ int net_buf_id(struct net_buf *buf)
 }
 
 static inline struct net_buf *pool_get_uninit(struct net_buf_pool *pool,
-        u16_t uninit_count)
+                                              u16_t uninit_count)
 {
     struct net_buf *buf = NULL;
 
@@ -604,8 +604,8 @@ success:
 
 #if defined(CONFIG_BLE_MESH_NET_BUF_LOG)
 struct net_buf *net_buf_alloc_fixed_debug(struct net_buf_pool *pool,
-        s32_t timeout, const char *func,
-        int line)
+                                          s32_t timeout, const char *func,
+                                          int line)
 {
     const struct net_buf_pool_fixed *fixed = pool->alloc->alloc_data;
 
@@ -728,8 +728,8 @@ size_t net_buf_linearize(void *dst, size_t dst_len, struct net_buf *src,
  * the buffer. It assumes that the buffer has at least one fragment.
  */
 size_t net_buf_append_bytes(struct net_buf *buf, size_t len,
-                const void *value, s32_t timeout,
-                net_buf_allocator_cb allocate_cb, void *user_data)
+                            const void *value, s32_t timeout,
+                            net_buf_allocator_cb allocate_cb, void *user_data)
 {
     struct net_buf *frag = net_buf_frag_last(buf);
     size_t added_len = 0U;

+ 26 - 24
components/bt/esp_ble_mesh/mesh_common/mesh_mutex.c

@@ -82,18 +82,13 @@ void bt_mesh_mutex_unlock(bt_mesh_mutex_t *mutex)
     }
 }
 
-static void bt_mesh_alarm_mutex_new(void)
+static inline void bt_mesh_alarm_mutex_new(void)
 {
     if (!alarm_lock.mutex) {
         bt_mesh_mutex_create(&alarm_lock);
     }
 }
 
-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);
@@ -104,18 +99,13 @@ void bt_mesh_alarm_unlock(void)
     bt_mesh_mutex_unlock(&alarm_lock);
 }
 
-static void bt_mesh_list_mutex_new(void)
+static inline void bt_mesh_list_mutex_new(void)
 {
     if (!list_lock.mutex) {
         bt_mesh_mutex_create(&list_lock);
     }
 }
 
-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);
@@ -126,18 +116,13 @@ void bt_mesh_list_unlock(void)
     bt_mesh_mutex_unlock(&list_lock);
 }
 
-static void bt_mesh_buf_mutex_new(void)
+static inline void bt_mesh_buf_mutex_new(void)
 {
     if (!buf_lock.mutex) {
         bt_mesh_mutex_create(&buf_lock);
     }
 }
 
-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);
@@ -148,18 +133,13 @@ void bt_mesh_buf_unlock(void)
     bt_mesh_mutex_unlock(&buf_lock);
 }
 
-static void bt_mesh_atomic_mutex_new(void)
+static inline void bt_mesh_atomic_mutex_new(void)
 {
     if (!atomic_lock.mutex) {
         bt_mesh_mutex_create(&atomic_lock);
     }
 }
 
-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 inline void bt_mesh_alarm_mutex_free(void)
+{
+    bt_mesh_mutex_free(&alarm_lock);
+}
+
+static inline void bt_mesh_list_mutex_free(void)
+{
+    bt_mesh_mutex_free(&list_lock);
+}
+
+static inline void bt_mesh_buf_mutex_free(void)
+{
+    bt_mesh_mutex_free(&buf_lock);
+}
+
+static inline 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 /* CONFIG_BLE_MESH_DEINIT */

+ 2 - 0
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)
 {

+ 18 - 16
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)
 {

+ 6 - 0
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 */

+ 2 - 0
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)
 {

+ 2 - 0
components/bt/esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c

@@ -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)
 {

+ 15 - 4
components/bt/esp_ble_mesh/mesh_core/cfg_cli.c

@@ -16,10 +16,13 @@
 #include "btc_ble_mesh_config_model.h"
 
 #include "mesh.h"
+#include "mesh_config.h"
 #include "foundation.h"
 #include "mesh_common.h"
 #include "cfg_cli.h"
 
+#if CONFIG_BLE_MESH_CFG_CLI
+
 static const bt_mesh_client_op_pair_t cfg_op_pair[] = {
     { OP_BEACON_GET,           OP_BEACON_STATUS        },
     { OP_BEACON_SET,           OP_BEACON_STATUS        },
@@ -72,24 +75,26 @@ static const bt_mesh_client_op_pair_t cfg_op_pair[] = {
 
 static bt_mesh_mutex_t cfg_client_lock;
 
-static void bt_mesh_cfg_client_mutex_new(void)
+static inline void bt_mesh_cfg_client_mutex_new(void)
 {
     if (!cfg_client_lock.mutex) {
         bt_mesh_mutex_create(&cfg_client_lock);
     }
 }
 
-static void bt_mesh_cfg_client_mutex_free(void)
+#if CONFIG_BLE_MESH_DEINIT
+static inline 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)
+static inline void bt_mesh_cfg_client_lock(void)
 {
     bt_mesh_mutex_lock(&cfg_client_lock);
 }
 
-static void bt_mesh_cfg_client_unlock(void)
+static inline void bt_mesh_cfg_client_unlock(void)
 {
     bt_mesh_mutex_unlock(&cfg_client_lock);
 }
@@ -1286,6 +1291,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 +1325,13 @@ 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 */
 };
+
+#endif /* CONFIG_BLE_MESH_CFG_CLI */

+ 4 - 0
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,

+ 2 - 0
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)
 {

+ 15 - 4
components/bt/esp_ble_mesh/mesh_core/health_cli.c

@@ -14,8 +14,11 @@
 
 #include "btc_ble_mesh_health_model.h"
 
+#include "mesh_config.h"
 #include "foundation.h"
 #include "mesh_common.h"
+
+#if CONFIG_BLE_MESH_HEALTH_CLI
 #include "health_cli.h"
 
 static const bt_mesh_client_op_pair_t health_op_pair[] = {
@@ -30,24 +33,26 @@ static const bt_mesh_client_op_pair_t health_op_pair[] = {
 
 static bt_mesh_mutex_t health_client_lock;
 
-static void bt_mesh_health_client_mutex_new(void)
+static inline void bt_mesh_health_client_mutex_new(void)
 {
     if (!health_client_lock.mutex) {
         bt_mesh_mutex_create(&health_client_lock);
     }
 }
 
-static void bt_mesh_health_client_mutex_free(void)
+#if CONFIG_BLE_MESH_DEINIT
+static inline 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)
+static inline void bt_mesh_health_client_lock(void)
 {
     bt_mesh_mutex_lock(&health_client_lock);
 }
 
-static void bt_mesh_health_client_unlock(void)
+static inline void bt_mesh_health_client_unlock(void)
 {
     bt_mesh_mutex_unlock(&health_client_lock);
 }
@@ -343,6 +348,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 +379,13 @@ 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 */
 };
+
+#endif /* CONFIG_BLE_MESH_HEALTH_CLI */

+ 12 - 0
components/bt/esp_ble_mesh/mesh_core/health_srv.c

@@ -17,6 +17,8 @@
 #include "access.h"
 #include "foundation.h"
 #include "mesh_common.h"
+
+#if CONFIG_BLE_MESH_HEALTH_SRV
 #include "health_srv.h"
 
 #define HEALTH_TEST_STANDARD    0x00
@@ -469,6 +471,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 +502,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)
@@ -543,3 +549,9 @@ void bt_mesh_attention(struct bt_mesh_model *model, u8_t time)
         }
     }
 }
+#else /* CONFIG_BLE_MESH_HEALTH_SRV */
+void bt_mesh_attention(struct bt_mesh_model *model, u8_t time)
+{
+    return;
+}
+#endif /* CONFIG_BLE_MESH_HEALTH_SRV */

+ 3 - 1
components/bt/esp_ble_mesh/mesh_core/include/mesh_access.h

@@ -11,7 +11,7 @@
 #ifndef _BLE_MESH_ACCESS_H_
 #define _BLE_MESH_ACCESS_H_
 
-#include "sdkconfig.h"
+#include "mesh_config.h"
 #include "mesh_buf.h"
 #include "mesh_timer.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 */

+ 2 - 2
components/bt/esp_ble_mesh/mesh_core/include/mesh_bearer_adapt.h

@@ -10,7 +10,7 @@
 #define _BLE_MESH_BEARER_ADAPT_H_
 
 #include <sys/types.h>
-#include "sdkconfig.h"
+#include "mesh_config.h"
 #include "mesh_types.h"
 #include "mesh_util.h"
 #include "mesh_uuid.h"
@@ -474,7 +474,7 @@ typedef void (*bt_mesh_dh_key_cb_t)(const u8_t key[32], const u8_t idx);
  *  or BLE_MESH_GATT_ITER_STOP to stop.
  */
 typedef u8_t (*bt_mesh_gatt_attr_func_t)(const struct bt_mesh_gatt_attr *attr,
-        void *user_data);
+                                         void *user_data);
 
 /** @brief Connection callback structure.
  *

+ 2 - 0
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 */

+ 2 - 0
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)

+ 2 - 0
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 */

+ 2 - 0
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);
 

+ 8 - 4
components/bt/esp_ble_mesh/mesh_core/prov.c

@@ -196,24 +196,26 @@ static const struct bt_mesh_prov *prov;
 #if defined(CONFIG_BLE_MESH_PB_ADV)
 static bt_mesh_mutex_t pb_buf_lock;
 
-static void bt_mesh_pb_buf_mutex_new(void)
+static inline void bt_mesh_pb_buf_mutex_new(void)
 {
     if (!pb_buf_lock.mutex) {
         bt_mesh_mutex_create(&pb_buf_lock);
     }
 }
 
-static void bt_mesh_pb_buf_mutex_free(void)
+#if CONFIG_BLE_MESH_DEINIT
+static inline 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)
+static inline void bt_mesh_pb_buf_lock(void)
 {
     bt_mesh_mutex_lock(&pb_buf_lock);
 }
 
-static void bt_mesh_pb_buf_unlock(void)
+static inline void bt_mesh_pb_buf_unlock(void)
 {
     bt_mesh_mutex_unlock(&pb_buf_lock);
 }
@@ -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)

+ 8 - 4
components/bt/esp_ble_mesh/mesh_core/provisioner_main.c

@@ -36,24 +36,26 @@ static u16_t node_count;
 
 static int provisioner_remove_node(u16_t index, bool erase);
 
-static void bt_mesh_provisioner_mutex_new(void)
+static inline void bt_mesh_provisioner_mutex_new(void)
 {
     if (!provisioner_lock.mutex) {
         bt_mesh_mutex_create(&provisioner_lock);
     }
 }
 
-static void bt_mesh_provisioner_mutex_free(void)
+#if CONFIG_BLE_MESH_DEINIT
+static inline 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)
+static inline void bt_mesh_provisioner_lock(void)
 {
     bt_mesh_mutex_lock(&provisioner_lock);
 }
 
-static void bt_mesh_provisioner_unlock(void)
+static inline void bt_mesh_provisioner_unlock(void)
 {
     bt_mesh_mutex_unlock(&provisioner_lock);
 }
@@ -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)
 {

+ 20 - 12
components/bt/esp_ble_mesh/mesh_core/provisioner_prov.c

@@ -356,70 +356,76 @@ static u8_t adv_buf_data[ADV_BUF_SIZE * CONFIG_BLE_MESH_PBA_SAME_TIME];
 }
 
 #if defined(CONFIG_BLE_MESH_PB_ADV)
-static void bt_mesh_pb_adv_mutex_new(void)
+static inline void bt_mesh_pb_adv_mutex_new(void)
 {
     if (!prov_ctx.pb_adv_lock.mutex) {
         bt_mesh_mutex_create(&prov_ctx.pb_adv_lock);
     }
 }
 
-static void bt_mesh_pb_adv_mutex_free(void)
+#if CONFIG_BLE_MESH_DEINIT
+static inline 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)
+static inline void bt_mesh_pb_adv_lock(void)
 {
     bt_mesh_mutex_lock(&prov_ctx.pb_adv_lock);
 }
 
-static void bt_mesh_pb_adv_unlock(void)
+static inline void bt_mesh_pb_adv_unlock(void)
 {
     bt_mesh_mutex_unlock(&prov_ctx.pb_adv_lock);
 }
 
-static void bt_mesh_pb_buf_mutex_new(void)
+static inline void bt_mesh_pb_buf_mutex_new(void)
 {
     if (!prov_ctx.pb_buf_lock.mutex) {
         bt_mesh_mutex_create(&prov_ctx.pb_buf_lock);
     }
 }
 
-static void bt_mesh_pb_buf_mutex_free(void)
+#if CONFIG_BLE_MESH_DEINIT
+static inline 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)
+static inline void bt_mesh_pb_buf_lock(void)
 {
     bt_mesh_mutex_lock(&prov_ctx.pb_buf_lock);
 }
 
-static void bt_mesh_pb_buf_unlock(void)
+static inline void bt_mesh_pb_buf_unlock(void)
 {
     bt_mesh_mutex_unlock(&prov_ctx.pb_buf_lock);
 }
 #endif /* CONFIG_BLE_MESH_PB_ADV */
 
 #if defined(CONFIG_BLE_MESH_PB_GATT)
-static void bt_mesh_pb_gatt_mutex_new(void)
+static inline void bt_mesh_pb_gatt_mutex_new(void)
 {
     if (!prov_ctx.pb_gatt_lock.mutex) {
         bt_mesh_mutex_create(&prov_ctx.pb_gatt_lock);
     }
 }
 
-static void bt_mesh_pb_gatt_mutex_free(void)
+#if CONFIG_BLE_MESH_DEINIT
+static inline 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)
+static inline void bt_mesh_pb_gatt_lock(void)
 {
     bt_mesh_mutex_lock(&prov_ctx.pb_gatt_lock);
 }
 
-static void bt_mesh_pb_gatt_unlock(void)
+static inline void bt_mesh_pb_gatt_unlock(void)
 {
     bt_mesh_mutex_unlock(&prov_ctx.pb_gatt_lock);
 }
@@ -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)

+ 2 - 0
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 */

+ 2 - 0
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 */

+ 13 - 9
components/bt/esp_ble_mesh/mesh_core/settings.c

@@ -171,17 +171,19 @@ struct node_info {
 
 static bt_mesh_mutex_t settings_lock;
 
-static void bt_mesh_settings_mutex_new(void)
+static inline void bt_mesh_settings_mutex_new(void)
 {
     if (settings_lock.mutex == NULL) {
         bt_mesh_mutex_create(&settings_lock);
     }
 }
 
-static void bt_mesh_settings_mutex_free(void)
+#if CONFIG_BLE_MESH_DEINIT
+static inline 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 */

+ 6 - 0
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 */
 

+ 14 - 8
components/bt/esp_ble_mesh/mesh_core/transport.c

@@ -116,46 +116,50 @@ static u16_t hb_sub_dst = BLE_MESH_ADDR_UNASSIGNED;
 static bt_mesh_mutex_t tx_seg_lock;
 static bt_mesh_mutex_t rx_seg_lock;
 
-static void bt_mesh_tx_seg_mutex_new(void)
+static inline void bt_mesh_tx_seg_mutex_new(void)
 {
     if (!tx_seg_lock.mutex) {
         bt_mesh_mutex_create(&tx_seg_lock);
     }
 }
 
-static void bt_mesh_tx_seg_mutex_free(void)
+#if CONFIG_BLE_MESH_DEINIT
+static inline 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)
+static inline void bt_mesh_tx_seg_lock(void)
 {
     bt_mesh_mutex_lock(&tx_seg_lock);
 }
 
-static void bt_mesh_tx_seg_unlock(void)
+static inline void bt_mesh_tx_seg_unlock(void)
 {
     bt_mesh_mutex_unlock(&tx_seg_lock);
 }
 
-static void bt_mesh_rx_seg_mutex_new(void)
+static inline void bt_mesh_rx_seg_mutex_new(void)
 {
     if (!rx_seg_lock.mutex) {
         bt_mesh_mutex_create(&rx_seg_lock);
     }
 }
 
-static void bt_mesh_rx_seg_mutex_free(void)
+#if CONFIG_BLE_MESH_DEINIT
+static inline 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)
+static inline void bt_mesh_rx_seg_lock(void)
 {
     bt_mesh_mutex_lock(&rx_seg_lock);
 }
 
-static void bt_mesh_rx_seg_unlock(void)
+static inline void bt_mesh_rx_seg_unlock(void)
 {
     bt_mesh_mutex_unlock(&rx_seg_lock);
 }
@@ -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)
 {

+ 6 - 2
components/bt/esp_ble_mesh/mesh_models/client/client_common.c

@@ -356,17 +356,19 @@ int bt_mesh_client_send_msg(bt_mesh_client_common_param_t *param,
 
 static bt_mesh_mutex_t client_model_lock;
 
-static void bt_mesh_client_model_mutex_new(void)
+static inline void bt_mesh_client_model_mutex_new(void)
 {
     if (!client_model_lock.mutex) {
         bt_mesh_mutex_create(&client_model_lock);
     }
 }
 
-static void bt_mesh_client_model_mutex_free(void)
+#if CONFIG_BLE_MESH_DEINIT
+static inline 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)
 {

+ 15 - 4
components/bt/esp_ble_mesh/mesh_models/client/generic_client.c

@@ -17,7 +17,10 @@
 
 #include "btc_ble_mesh_generic_model.h"
 
+#include "mesh_config.h"
 #include "model_opcode.h"
+
+#if CONFIG_BLE_MESH_GENERIC_CLIENT
 #include "generic_client.h"
 
 /* The followings are the macro definitions of Generic client
@@ -111,24 +114,26 @@ static const bt_mesh_client_op_pair_t gen_op_pair[] = {
 
 static bt_mesh_mutex_t generic_client_lock;
 
-static void bt_mesh_generic_client_mutex_new(void)
+static inline void bt_mesh_generic_client_mutex_new(void)
 {
     if (!generic_client_lock.mutex) {
         bt_mesh_mutex_create(&generic_client_lock);
     }
 }
 
-static void bt_mesh_generic_client_mutex_free(void)
+#if CONFIG_BLE_MESH_DEINIT
+static inline 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)
+static inline void bt_mesh_generic_client_lock(void)
 {
     bt_mesh_mutex_lock(&generic_client_lock);
 }
 
-static void bt_mesh_generic_client_unlock(void)
+static inline void bt_mesh_generic_client_unlock(void)
 {
     bt_mesh_mutex_unlock(&generic_client_lock);
 }
@@ -1172,6 +1177,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 +1206,13 @@ 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 */
 };
+
+#endif /* CONFIG_BLE_MESH_GENERIC_CLIENT */

+ 11 - 0
components/bt/esp_ble_mesh/mesh_models/client/lighting_client.c

@@ -17,7 +17,10 @@
 
 #include "btc_ble_mesh_lighting_model.h"
 
+#include "mesh_config.h"
 #include "model_opcode.h"
+
+#if CONFIG_BLE_MESH_LIGHTING_CLIENT
 #include "lighting_client.h"
 
 /* The followings are the macro definitions of Lighting client
@@ -127,10 +130,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 +1367,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 +1396,13 @@ 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 */
 };
+
+#endif /* CONFIG_BLE_MESH_LIGHTING_CLIENT */

+ 15 - 4
components/bt/esp_ble_mesh/mesh_models/client/sensor_client.c

@@ -17,7 +17,10 @@
 
 #include "btc_ble_mesh_sensor_model.h"
 
+#include "mesh_config.h"
 #include "model_opcode.h"
+
+#if CONFIG_BLE_MESH_SENSOR_CLI
 #include "sensor_client.h"
 
 /* The followings are the macro definitions of Sensor client
@@ -49,24 +52,26 @@ static const bt_mesh_client_op_pair_t sensor_op_pair[] = {
 
 static bt_mesh_mutex_t sensor_client_lock;
 
-static void bt_mesh_sensor_client_mutex_new(void)
+static inline void bt_mesh_sensor_client_mutex_new(void)
 {
     if (!sensor_client_lock.mutex) {
         bt_mesh_mutex_create(&sensor_client_lock);
     }
 }
 
-static void bt_mesh_sensor_client_mutex_free(void)
+#if CONFIG_BLE_MESH_DEINIT
+static inline 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)
+static inline void bt_mesh_sensor_client_lock(void)
 {
     bt_mesh_mutex_lock(&sensor_client_lock);
 }
 
-static void bt_mesh_sensor_client_unlock(void)
+static inline void bt_mesh_sensor_client_unlock(void)
 {
     bt_mesh_mutex_unlock(&sensor_client_lock);
 }
@@ -612,6 +617,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 +646,13 @@ 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 */
 };
+
+#endif /* CONFIG_BLE_MESH_SENSOR_CLI */

+ 15 - 4
components/bt/esp_ble_mesh/mesh_models/client/time_scene_client.c

@@ -17,7 +17,10 @@
 
 #include "btc_ble_mesh_time_scene_model.h"
 
+#include "mesh_config.h"
 #include "model_opcode.h"
+
+#if CONFIG_BLE_MESH_TIME_SCENE_CLIENT
 #include "time_scene_client.h"
 
 /* The followings are the macro definitions of Time Scene client
@@ -65,24 +68,26 @@ static const bt_mesh_client_op_pair_t time_scene_op_pair[] = {
 
 static bt_mesh_mutex_t time_scene_client_lock;
 
-static void bt_mesh_time_scene_client_mutex_new(void)
+static inline void bt_mesh_time_scene_client_mutex_new(void)
 {
     if (!time_scene_client_lock.mutex) {
         bt_mesh_mutex_create(&time_scene_client_lock);
     }
 }
 
-static void bt_mesh_time_scene_client_mutex_free(void)
+#if CONFIG_BLE_MESH_DEINIT
+static inline 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)
+static inline void bt_mesh_time_scene_client_lock(void)
 {
     bt_mesh_mutex_lock(&time_scene_client_lock);
 }
 
-static void bt_mesh_time_scene_client_unlock(void)
+static inline void bt_mesh_time_scene_client_unlock(void)
 {
     bt_mesh_mutex_unlock(&time_scene_client_lock);
 }
@@ -668,6 +673,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 +702,13 @@ 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 */
 };
+
+#endif /* CONFIG_BLE_MESH_TIME_SCENE_CLIENT */

+ 39 - 2
components/bt/esp_ble_mesh/mesh_models/server/generic_server.c

@@ -10,25 +10,30 @@
 
 #include "btc_ble_mesh_generic_model.h"
 
+#include "mesh_config.h"
 #include "access.h"
 #include "transport.h"
 #include "model_opcode.h"
 #include "state_transition.h"
 #include "device_property.h"
 
+#if CONFIG_BLE_MESH_GENERIC_SERVER
+
 static bt_mesh_mutex_t generic_server_lock;
 
-static void bt_mesh_generic_server_mutex_new(void)
+static inline void bt_mesh_generic_server_mutex_new(void)
 {
     if (!generic_server_lock.mutex) {
         bt_mesh_mutex_create(&generic_server_lock);
     }
 }
 
-static void bt_mesh_generic_server_mutex_free(void)
+#if CONFIG_BLE_MESH_DEINIT
+static inline 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 +2629,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 +2800,104 @@ 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 */
 };
+
+#endif /* CONFIG_BLE_MESH_GENERIC_SERVER */

+ 37 - 2
components/bt/esp_ble_mesh/mesh_models/server/lighting_server.c

@@ -10,25 +10,30 @@
 
 #include "btc_ble_mesh_lighting_model.h"
 
+#include "mesh_config.h"
 #include "access.h"
 #include "transport.h"
 #include "model_opcode.h"
 #include "state_transition.h"
 #include "device_property.h"
 
+#if CONFIG_BLE_MESH_LIGHTING_SERVER
+
 static bt_mesh_mutex_t light_server_lock;
 
-static void bt_mesh_light_server_mutex_new(void)
+static inline void bt_mesh_light_server_mutex_new(void)
 {
     if (!light_server_lock.mutex) {
         bt_mesh_mutex_create(&light_server_lock);
     }
 }
 
-static void bt_mesh_light_server_mutex_free(void)
+#if CONFIG_BLE_MESH_DEINIT
+static inline 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 +3331,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 +3557,97 @@ 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 */
 };
+
+#endif /* CONFIG_BLE_MESH_LIGHTING_SERVER */

+ 11 - 0
components/bt/esp_ble_mesh/mesh_models/server/sensor_server.c

@@ -16,12 +16,15 @@
 
 #include "btc_ble_mesh_sensor_model.h"
 
+#include "mesh_config.h"
 #include "access.h"
 #include "transport.h"
 #include "model_opcode.h"
 #include "state_transition.h"
 #include "device_property.h"
 
+#if CONFIG_BLE_MESH_SENSOR_SERVER
+
 static void update_sensor_periodic_pub(struct bt_mesh_model *model, u16_t prop_id);
 
 /* message handlers (Start) */
@@ -1127,6 +1130,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 +1160,20 @@ 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 */
 };
+
+#endif /* CONFIG_BLE_MESH_SENSOR_SERVER */

+ 8 - 1
components/bt/esp_ble_mesh/mesh_models/server/server_common.c

@@ -15,11 +15,14 @@
 #include <errno.h>
 
 #include "mesh.h"
+#include "mesh_config.h"
 #include "access.h"
 #include "mesh_common.h"
 #include "generic_server.h"
 #include "lighting_server.h"
 
+#if CONFIG_BLE_MESH_SERVER_MODEL
+
 /**
  * According to Mesh Model Spec:
  * If the Transition Time field is not present and the Generic Default Transition
@@ -190,6 +193,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 +202,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)
@@ -255,4 +260,6 @@ struct net_buf_simple *bt_mesh_server_get_pub_msg(struct bt_mesh_model *model, u
     }
 
     return buf;
-}
+}
+
+#endif /* CONFIG_BLE_MESH_SERVER_MODEL */

+ 8 - 0
components/bt/esp_ble_mesh/mesh_models/server/state_binding.c

@@ -8,11 +8,14 @@
 
 #include <errno.h>
 
+#include "mesh_config.h"
 #include "mesh_common.h"
 #include "model_opcode.h"
 #include "state_binding.h"
 #include "state_transition.h"
 
+#if CONFIG_BLE_MESH_SERVER_MODEL
+
 #define MINDIFF (2.25e-308)
 
 static float bt_mesh_sqrt(float square)
@@ -102,6 +105,7 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model,
     }
 
     switch (type) {
+#if CONFIG_BLE_MESH_GENERIC_SERVER
     case GENERIC_ONOFF_STATE: {
         if (model->id != BLE_MESH_MODEL_ID_GEN_ONOFF_SRV) {
             BT_ERR("Invalid Generic OnOff Server, model id 0x%04x", model->id);
@@ -168,6 +172,8 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model,
         gen_power_level_publish(model, BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_STATUS);
         break;
     }
+#endif /* CONFIG_BLE_MESH_GENERIC_SERVER */
+#if CONFIG_BLE_MESH_LIGHTING_SERVER
     case LIGHT_LIGHTNESS_ACTUAL_STATE: {
         if (model->id != BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV) {
             BT_ERR("Invalid Light Lightness Server, model id 0x%04x", model->id);
@@ -331,6 +337,7 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model,
         light_lc_publish(model, BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_STATUS);
         break;
     }
+#endif /* CONFIG_BLE_MESH_LIGHTING_SERVER */
     default:
         BT_WARN("Unknown binding state type 0x%02x", type);
         return -EINVAL;
@@ -339,3 +346,4 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model,
     return 0;
 }
 
+#endif /* CONFIG_BLE_MESH_SERVER_MODEL */

+ 35 - 13
components/bt/esp_ble_mesh/mesh_models/server/state_transition.c

@@ -11,9 +11,14 @@
 #include "btc_ble_mesh_time_scene_model.h"
 #include "btc_ble_mesh_sensor_model.h"
 
+#include "mesh_config.h"
 #include "model_opcode.h"
 #include "state_transition.h"
 
+#if (CONFIG_BLE_MESH_GENERIC_SERVER | \
+     CONFIG_BLE_MESH_TIME_SCENE_SERVER | \
+     CONFIG_BLE_MESH_LIGHTING_SERVER)
+
 /* Function to calculate Remaining Time (Start) */
 
 void bt_mesh_server_calc_remain_time(struct bt_mesh_state_transition *transition)
@@ -98,6 +103,20 @@ static void transition_time_values(struct bt_mesh_state_transition *transition,
     transition->quo_tt = transition->total_duration / transition->counter;
 }
 
+static void transition_timer_start(struct bt_mesh_state_transition *transition)
+{
+    transition->start_timestamp = k_uptime_get();
+    k_delayed_work_submit_periodic(&transition->timer, K_MSEC(transition->quo_tt));
+    bt_mesh_atomic_set_bit(transition->flag, BLE_MESH_TRANS_TIMER_START);
+}
+
+static void transition_timer_stop(struct bt_mesh_state_transition *transition)
+{
+    k_delayed_work_cancel(&transition->timer);
+    bt_mesh_atomic_clear_bit(transition->flag, BLE_MESH_TRANS_TIMER_START);
+}
+
+#if CONFIG_BLE_MESH_GENERIC_SERVER
 void generic_onoff_tt_values(struct bt_mesh_gen_onoff_srv *srv,
                              u8_t trans_time, u8_t delay)
 {
@@ -119,7 +138,9 @@ void generic_power_level_tt_values(struct bt_mesh_gen_power_level_srv *srv,
     srv->tt_delta_level =
         ((float) (srv->state->power_actual - srv->state->target_power_actual) / srv->transition.counter);
 }
+#endif /* CONFIG_BLE_MESH_GENERIC_SERVER */
 
+#if CONFIG_BLE_MESH_LIGHTING_SERVER
 void light_lightness_actual_tt_values(struct bt_mesh_light_lightness_srv *srv,
                                       u8_t trans_time, u8_t delay)
 {
@@ -203,26 +224,18 @@ void light_lc_tt_values(struct bt_mesh_light_lc_srv *srv,
 {
     transition_time_values(&srv->transition, trans_time, delay);
 }
+#endif /* CONFIG_BLE_MESH_LIGHTING_SERVER */
 
+#if CONFIG_BLE_MESH_TIME_SCENE_SERVER
 void scene_tt_values(struct bt_mesh_scene_srv *srv, u8_t trans_time, u8_t delay)
 {
     transition_time_values(&srv->transition, trans_time, delay);
 }
-
-static void transition_timer_start(struct bt_mesh_state_transition *transition)
-{
-    transition->start_timestamp = k_uptime_get();
-    k_delayed_work_submit_periodic(&transition->timer, K_MSEC(transition->quo_tt));
-    bt_mesh_atomic_set_bit(transition->flag, BLE_MESH_TRANS_TIMER_START);
-}
-
-static void transition_timer_stop(struct bt_mesh_state_transition *transition)
-{
-    k_delayed_work_cancel(&transition->timer);
-    bt_mesh_atomic_clear_bit(transition->flag, BLE_MESH_TRANS_TIMER_START);
-}
+#endif /* CONFIG_BLE_MESH_TIME_SCENE_SERVER */
 
 /* Timers related handlers & threads (Start) */
+
+#if CONFIG_BLE_MESH_GENERIC_SERVER
 void generic_onoff_work_handler(struct k_work *work)
 {
     struct bt_mesh_gen_onoff_srv *srv =
@@ -424,7 +437,9 @@ void generic_power_level_work_handler(struct k_work *work)
     bt_mesh_generic_server_unlock();
     return;
 }
+#endif /* CONFIG_BLE_MESH_GENERIC_SERVER */
 
+#if CONFIG_BLE_MESH_LIGHTING_SERVER
 void light_lightness_actual_work_handler(struct k_work *work)
 {
     struct bt_mesh_light_lightness_srv *srv =
@@ -943,7 +958,9 @@ void light_lc_work_handler(struct k_work *work)
     bt_mesh_light_server_unlock();
     return;
 }
+#endif /* CONFIG_BLE_MESH_LIGHTING_SERVER */
 
+#if CONFIG_BLE_MESH_TIME_SCENE_SERVER
 void scene_recall_work_handler(struct k_work *work)
 {
     struct bt_mesh_scene_srv *srv =
@@ -996,6 +1013,7 @@ void scene_recall_work_handler(struct k_work *work)
     bt_mesh_time_scene_server_unlock();
     return;
 }
+#endif /* CONFIG_BLE_MESH_TIME_SCENE_SERVER */
 
 /* Timers related handlers & threads (End) */
 
@@ -1018,3 +1036,7 @@ void bt_mesh_server_start_transition(struct bt_mesh_state_transition *transition
 }
 
 /* Messages handlers (End) */
+
+#endif /* (CONFIG_BLE_MESH_GENERIC_SERVER | \
+           CONFIG_BLE_MESH_TIME_SCENE_SERVER | \
+           CONFIG_BLE_MESH_LIGHTING_SERVER) */

+ 23 - 2
components/bt/esp_ble_mesh/mesh_models/server/time_scene_server.c

@@ -16,24 +16,29 @@
 
 #include "btc_ble_mesh_time_scene_model.h"
 
+#include "mesh_config.h"
 #include "access.h"
 #include "transport.h"
 #include "model_opcode.h"
 #include "state_transition.h"
 
+#if CONFIG_BLE_MESH_TIME_SCENE_SERVER
+
 static bt_mesh_mutex_t time_scene_server_lock;
 
-static void bt_mesh_time_scene_server_mutex_new(void)
+static inline void bt_mesh_time_scene_server_mutex_new(void)
 {
     if (!time_scene_server_lock.mutex) {
         bt_mesh_mutex_create(&time_scene_server_lock);
     }
 }
 
-static void bt_mesh_time_scene_server_mutex_free(void)
+#if CONFIG_BLE_MESH_DEINIT
+static inline 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 +1422,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 +1505,48 @@ 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 */
 };
+
+#endif /* CONFIG_BLE_MESH_TIME_SCENE_SERVER */

+ 16 - 0
examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_client/sdkconfig.ci.bluedroid_deinit

@@ -0,0 +1,16 @@
+CONFIG_BT_ENABLED=y
+CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y
+CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n
+CONFIG_BTDM_CONTROLLER_MODE_BTDM=n
+CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n
+CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y
+CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
+CONFIG_BTU_TASK_STACK_SIZE=4512
+
+CONFIG_BLE_MESH=y
+CONFIG_BLE_MESH_DEINIT=n
+CONFIG_BLE_MESH_PROVISIONER=y
+CONFIG_BLE_MESH_PB_GATT=y
+CONFIG_BLE_MESH_SETTINGS=y
+CONFIG_BLE_MESH_CFG_CLI=y
+CONFIG_BLE_MESH_GENERIC_ONOFF_CLI=y

+ 20 - 0
examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_client/sdkconfig.ci.model

@@ -0,0 +1,20 @@
+CONFIG_BT_ENABLED=y
+CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y
+CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n
+CONFIG_BTDM_CONTROLLER_MODE_BTDM=n
+CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n
+CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y
+CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
+CONFIG_BTU_TASK_STACK_SIZE=4512
+
+CONFIG_BLE_MESH=y
+CONFIG_BLE_MESH_PROVISIONER=y
+CONFIG_BLE_MESH_PB_GATT=y
+CONFIG_BLE_MESH_SETTINGS=y
+CONFIG_BLE_MESH_CFG_CLI=y
+CONFIG_BLE_MESH_HEALTH_SRV=n
+CONFIG_BLE_MESH_GENERIC_ONOFF_CLI=y
+CONFIG_BLE_MESH_GENERIC_SERVER=n
+CONFIG_BLE_MESH_SENSOR_SERVER=n
+CONFIG_BLE_MESH_TIME_SCENE_SERVER=n
+CONFIG_BLE_MESH_LIGHTING_SERVER=n

+ 16 - 0
examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_client/sdkconfig.ci.nimble_deinit

@@ -0,0 +1,16 @@
+CONFIG_BT_ENABLED=y
+CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y
+CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n
+CONFIG_BTDM_CONTROLLER_MODE_BTDM=n
+CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n
+CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y
+CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
+CONFIG_NIMBLE_ENABLED=y
+
+CONFIG_BLE_MESH=y
+CONFIG_BLE_MESH_DEINIT=n
+CONFIG_BLE_MESH_PROVISIONER=y
+CONFIG_BLE_MESH_PB_GATT=y
+CONFIG_BLE_MESH_SETTINGS=y
+CONFIG_BLE_MESH_CFG_CLI=y
+CONFIG_BLE_MESH_GENERIC_ONOFF_CLI=y

+ 16 - 0
examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/sdkconfig.ci.bluedroid_deinit

@@ -0,0 +1,16 @@
+CONFIG_BT_ENABLED=y
+CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y
+CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n
+CONFIG_BTDM_CONTROLLER_MODE_BTDM=n
+CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n
+CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y
+CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
+CONFIG_GATTS_SEND_SERVICE_CHANGE_MANUAL=y
+CONFIG_BTU_TASK_STACK_SIZE=4512
+
+CONFIG_BLE_MESH=y
+CONFIG_BLE_MESH_DEINIT=n
+CONFIG_BLE_MESH_FAST_PROV=y
+CONFIG_BLE_MESH_PB_GATT=y
+CONFIG_BLE_MESH_SETTINGS=y
+CONFIG_BLE_MESH_CFG_CLI=y

+ 19 - 0
examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/sdkconfig.ci.model

@@ -0,0 +1,19 @@
+CONFIG_BT_ENABLED=y
+CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y
+CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n
+CONFIG_BTDM_CONTROLLER_MODE_BTDM=n
+CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n
+CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y
+CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
+CONFIG_GATTS_SEND_SERVICE_CHANGE_MANUAL=y
+CONFIG_BTU_TASK_STACK_SIZE=4512
+
+CONFIG_BLE_MESH=y
+CONFIG_BLE_MESH_FAST_PROV=y
+CONFIG_BLE_MESH_PB_GATT=y
+CONFIG_BLE_MESH_SETTINGS=y
+CONFIG_BLE_MESH_CFG_CLI=y
+CONFIG_BLE_MESH_HEALTH_SRV=n
+CONFIG_BLE_MESH_SENSOR_SERVER=n
+CONFIG_BLE_MESH_TIME_SCENE_SERVER=n
+CONFIG_BLE_MESH_LIGHTING_SERVER=n

+ 15 - 0
examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/sdkconfig.ci.nimble_deinit

@@ -0,0 +1,15 @@
+CONFIG_BT_ENABLED=y
+CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y
+CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n
+CONFIG_BTDM_CONTROLLER_MODE_BTDM=n
+CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n
+CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y
+CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
+CONFIG_NIMBLE_ENABLED=y
+
+CONFIG_BLE_MESH=y
+CONFIG_BLE_MESH_DEINIT=n
+CONFIG_BLE_MESH_FAST_PROV=y
+CONFIG_BLE_MESH_PB_GATT=y
+CONFIG_BLE_MESH_SETTINGS=y
+CONFIG_BLE_MESH_CFG_CLI=y

+ 18 - 0
examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/sdkconfig.ci.bluedroid_deinit

@@ -0,0 +1,18 @@
+CONFIG_BT_ENABLED=y
+CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y
+CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n
+CONFIG_BTDM_CONTROLLER_MODE_BTDM=n
+CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n
+CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y
+CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
+CONFIG_GATTS_SEND_SERVICE_CHANGE_MANUAL=y
+CONFIG_BTU_TASK_STACK_SIZE=4512
+
+#| Proxy  | PB-GATT | Proxy Server | Proxy Client |
+#| Enable | Enable  | Enable       | Disable      |
+CONFIG_BLE_MESH=y
+CONFIG_BLE_MESH_DEINIT=n
+CONFIG_BLE_MESH_NODE=y
+CONFIG_BLE_MESH_PB_GATT=y
+CONFIG_BLE_MESH_SETTINGS=y
+CONFIG_BLE_MESH_GENERIC_ONOFF_CLI=y

+ 22 - 0
examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/sdkconfig.ci.model

@@ -0,0 +1,22 @@
+CONFIG_BT_ENABLED=y
+CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y
+CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n
+CONFIG_BTDM_CONTROLLER_MODE_BTDM=n
+CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n
+CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y
+CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
+CONFIG_GATTS_SEND_SERVICE_CHANGE_MANUAL=y
+CONFIG_BTU_TASK_STACK_SIZE=4512
+
+#| Proxy  | PB-GATT | Proxy Server | Proxy Client |
+#| Enable | Enable  | Enable       | Disable      |
+CONFIG_BLE_MESH=y
+CONFIG_BLE_MESH_NODE=y
+CONFIG_BLE_MESH_PB_GATT=y
+CONFIG_BLE_MESH_SETTINGS=y
+CONFIG_BLE_MESH_HEALTH_SRV=n
+CONFIG_BLE_MESH_GENERIC_ONOFF_CLI=y
+CONFIG_BLE_MESH_GENERIC_SERVER=n
+CONFIG_BLE_MESH_SENSOR_SERVER=n
+CONFIG_BLE_MESH_TIME_SCENE_SERVER=n
+CONFIG_BLE_MESH_LIGHTING_SERVER=n

+ 15 - 0
examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/sdkconfig.ci.nimble_deinit

@@ -0,0 +1,15 @@
+CONFIG_BT_ENABLED=y
+CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y
+CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n
+CONFIG_BTDM_CONTROLLER_MODE_BTDM=n
+CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n
+CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y
+CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
+CONFIG_NIMBLE_ENABLED=y
+
+CONFIG_BLE_MESH=y
+CONFIG_BLE_MESH_DEINIT=n
+CONFIG_BLE_MESH_NODE=y
+CONFIG_BLE_MESH_PB_GATT=y
+CONFIG_BLE_MESH_SETTINGS=y
+CONFIG_BLE_MESH_GENERIC_ONOFF_CLI=y

+ 16 - 0
examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/sdkconfig.ci.bluedroid_deinit

@@ -0,0 +1,16 @@
+CONFIG_BT_ENABLED=y
+CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y
+CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n
+CONFIG_BTDM_CONTROLLER_MODE_BTDM=n
+CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n
+CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y
+CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
+CONFIG_GATTS_SEND_SERVICE_CHANGE_MANUAL=y
+CONFIG_BTU_TASK_STACK_SIZE=4512
+
+CONFIG_BLE_MESH=y
+CONFIG_BLE_MESH_DEINIT=n
+CONFIG_BLE_MESH_NODE=y
+CONFIG_BLE_MESH_PB_GATT=y
+CONFIG_BLE_MESH_FRIEND=y
+CONFIG_BLE_MESH_SETTINGS=y

+ 19 - 0
examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/sdkconfig.ci.model

@@ -0,0 +1,19 @@
+CONFIG_BT_ENABLED=y
+CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y
+CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n
+CONFIG_BTDM_CONTROLLER_MODE_BTDM=n
+CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n
+CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y
+CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
+CONFIG_GATTS_SEND_SERVICE_CHANGE_MANUAL=y
+CONFIG_BTU_TASK_STACK_SIZE=4512
+
+CONFIG_BLE_MESH=y
+CONFIG_BLE_MESH_NODE=y
+CONFIG_BLE_MESH_PB_GATT=y
+CONFIG_BLE_MESH_FRIEND=y
+CONFIG_BLE_MESH_SETTINGS=y
+CONFIG_BLE_MESH_HEALTH_SRV=n
+CONFIG_BLE_MESH_SENSOR_SERVER=n
+CONFIG_BLE_MESH_TIME_SCENE_SERVER=n
+CONFIG_BLE_MESH_LIGHTING_SERVER=n

+ 15 - 0
examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/sdkconfig.ci.nimble_deinit

@@ -0,0 +1,15 @@
+CONFIG_BT_ENABLED=y
+CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y
+CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n
+CONFIG_BTDM_CONTROLLER_MODE_BTDM=n
+CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n
+CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y
+CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
+CONFIG_NIMBLE_ENABLED=y
+
+CONFIG_BLE_MESH=y
+CONFIG_BLE_MESH_DEINIT=n
+CONFIG_BLE_MESH_NODE=y
+CONFIG_BLE_MESH_PB_GATT=y
+CONFIG_BLE_MESH_LOW_POWER=y
+CONFIG_BLE_MESH_SETTINGS=y

+ 18 - 0
examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/sdkconfig.ci.bluedroid_deinit

@@ -0,0 +1,18 @@
+CONFIG_BT_ENABLED=y
+CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y
+CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n
+CONFIG_BTDM_CONTROLLER_MODE_BTDM=n
+CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n
+CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y
+CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
+CONFIG_BTU_TASK_STACK_SIZE=4512
+
+#| Proxy  | PB-GATT | Proxy Client |
+#| Enable | Enable  | Disable      |
+CONFIG_BLE_MESH=y
+CONFIG_BLE_MESH_DEINIT=n
+CONFIG_BLE_MESH_PROVISIONER=y
+CONFIG_BLE_MESH_PB_GATT=y
+CONFIG_BLE_MESH_SETTINGS=y
+CONFIG_BLE_MESH_CFG_CLI=y
+CONFIG_BLE_MESH_GENERIC_ONOFF_CLI=y

+ 22 - 0
examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/sdkconfig.ci.model

@@ -0,0 +1,22 @@
+CONFIG_BT_ENABLED=y
+CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y
+CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n
+CONFIG_BTDM_CONTROLLER_MODE_BTDM=n
+CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n
+CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y
+CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
+CONFIG_BTU_TASK_STACK_SIZE=4512
+
+#| Proxy  | PB-GATT | Proxy Client |
+#| Enable | Enable  | Disable      |
+CONFIG_BLE_MESH=y
+CONFIG_BLE_MESH_PROVISIONER=y
+CONFIG_BLE_MESH_PB_GATT=y
+CONFIG_BLE_MESH_SETTINGS=y
+CONFIG_BLE_MESH_CFG_CLI=y
+CONFIG_BLE_MESH_HEALTH_SRV=n
+CONFIG_BLE_MESH_GENERIC_ONOFF_CLI=y
+CONFIG_BLE_MESH_GENERIC_SERVER=n
+CONFIG_BLE_MESH_SENSOR_SERVER=n
+CONFIG_BLE_MESH_TIME_SCENE_SERVER=n
+CONFIG_BLE_MESH_LIGHTING_SERVER=n

+ 16 - 0
examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/sdkconfig.ci.nimble_deinit

@@ -0,0 +1,16 @@
+CONFIG_BT_ENABLED=y
+CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y
+CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n
+CONFIG_BTDM_CONTROLLER_MODE_BTDM=n
+CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n
+CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y
+CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
+CONFIG_NIMBLE_ENABLED=y
+
+CONFIG_BLE_MESH=y
+CONFIG_BLE_MESH_DEINIT=n
+CONFIG_BLE_MESH_PROVISIONER=y
+CONFIG_BLE_MESH_PB_GATT=y
+CONFIG_BLE_MESH_SETTINGS=y
+CONFIG_BLE_MESH_CFG_CLI=y
+CONFIG_BLE_MESH_GENERIC_ONOFF_CLI=y

+ 16 - 0
examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_client/sdkconfig.ci.bluedroid_deinit

@@ -0,0 +1,16 @@
+CONFIG_BT_ENABLED=y
+CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y
+CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n
+CONFIG_BTDM_CONTROLLER_MODE_BTDM=n
+CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n
+CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y
+CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
+CONFIG_BTU_TASK_STACK_SIZE=4512
+
+CONFIG_BLE_MESH=y
+CONFIG_BLE_MESH_DEINIT=n
+CONFIG_BLE_MESH_PROVISIONER=y
+CONFIG_BLE_MESH_PB_GATT=y
+CONFIG_BLE_MESH_SETTINGS=y
+CONFIG_BLE_MESH_CFG_CLI=y
+CONFIG_BLE_MESH_SENSOR_CLI=y

+ 20 - 0
examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_client/sdkconfig.ci.model

@@ -0,0 +1,20 @@
+CONFIG_BT_ENABLED=y
+CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y
+CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n
+CONFIG_BTDM_CONTROLLER_MODE_BTDM=n
+CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n
+CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y
+CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
+CONFIG_BTU_TASK_STACK_SIZE=4512
+
+CONFIG_BLE_MESH=y
+CONFIG_BLE_MESH_PROVISIONER=y
+CONFIG_BLE_MESH_PB_GATT=y
+CONFIG_BLE_MESH_SETTINGS=y
+CONFIG_BLE_MESH_CFG_CLI=y
+CONFIG_BLE_MESH_HEALTH_SRV=n
+CONFIG_BLE_MESH_SENSOR_CLI=y
+CONFIG_BLE_MESH_GENERIC_SERVER=n
+CONFIG_BLE_MESH_SENSOR_SERVER=n
+CONFIG_BLE_MESH_TIME_SCENE_SERVER=n
+CONFIG_BLE_MESH_LIGHTING_SERVER=n

+ 16 - 0
examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_client/sdkconfig.ci.nimble_deinit

@@ -0,0 +1,16 @@
+CONFIG_BT_ENABLED=y
+CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y
+CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n
+CONFIG_BTDM_CONTROLLER_MODE_BTDM=n
+CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n
+CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y
+CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
+CONFIG_NIMBLE_ENABLED=y
+
+CONFIG_BLE_MESH=y
+CONFIG_BLE_MESH_DEINIT=n
+CONFIG_BLE_MESH_PROVISIONER=y
+CONFIG_BLE_MESH_PB_GATT=y
+CONFIG_BLE_MESH_SETTINGS=y
+CONFIG_BLE_MESH_CFG_CLI=y
+CONFIG_BLE_MESH_SENSOR_CLI=y

+ 15 - 0
examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_server/sdkconfig.ci.bluedroid_deinit

@@ -0,0 +1,15 @@
+CONFIG_BT_ENABLED=y
+CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y
+CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n
+CONFIG_BTDM_CONTROLLER_MODE_BTDM=n
+CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n
+CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y
+CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
+CONFIG_GATTS_SEND_SERVICE_CHANGE_MANUAL=y
+CONFIG_BTU_TASK_STACK_SIZE=4512
+
+CONFIG_BLE_MESH=y
+CONFIG_BLE_MESH_DEINIT=n
+CONFIG_BLE_MESH_NODE=y
+CONFIG_BLE_MESH_PB_GATT=y
+CONFIG_BLE_MESH_SETTINGS=y

+ 18 - 0
examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_server/sdkconfig.ci.model

@@ -0,0 +1,18 @@
+CONFIG_BT_ENABLED=y
+CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y
+CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n
+CONFIG_BTDM_CONTROLLER_MODE_BTDM=n
+CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n
+CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y
+CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
+CONFIG_GATTS_SEND_SERVICE_CHANGE_MANUAL=y
+CONFIG_BTU_TASK_STACK_SIZE=4512
+
+CONFIG_BLE_MESH=y
+CONFIG_BLE_MESH_NODE=y
+CONFIG_BLE_MESH_PB_GATT=y
+CONFIG_BLE_MESH_SETTINGS=y
+CONFIG_BLE_MESH_HEALTH_SRV=n
+CONFIG_BLE_MESH_GENERIC_SERVER=n
+CONFIG_BLE_MESH_TIME_SCENE_SERVER=n
+CONFIG_BLE_MESH_LIGHTING_SERVER=n

+ 14 - 0
examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_server/sdkconfig.ci.nimble_deinit

@@ -0,0 +1,14 @@
+CONFIG_BT_ENABLED=y
+CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y
+CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n
+CONFIG_BTDM_CONTROLLER_MODE_BTDM=n
+CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n
+CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y
+CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
+CONFIG_NIMBLE_ENABLED=y
+
+CONFIG_BLE_MESH=y
+CONFIG_BLE_MESH_DEINIT=n
+CONFIG_BLE_MESH_NODE=y
+CONFIG_BLE_MESH_PB_GATT=y
+CONFIG_BLE_MESH_SETTINGS=y

+ 15 - 0
examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/sdkconfig.ci.bluedroid_deinit

@@ -0,0 +1,15 @@
+CONFIG_BT_ENABLED=y
+CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y
+CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n
+CONFIG_BTDM_CONTROLLER_MODE_BTDM=n
+CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n
+CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y
+CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
+CONFIG_BTU_TASK_STACK_SIZE=4512
+
+CONFIG_BLE_MESH=y
+CONFIG_BLE_MESH_DEINIT=n
+CONFIG_BLE_MESH_PROVISIONER=y
+CONFIG_BLE_MESH_PB_GATT=y
+CONFIG_BLE_MESH_SETTINGS=y
+CONFIG_BLE_MESH_CFG_CLI=y

+ 19 - 0
examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/sdkconfig.ci.model

@@ -0,0 +1,19 @@
+CONFIG_BT_ENABLED=y
+CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y
+CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n
+CONFIG_BTDM_CONTROLLER_MODE_BTDM=n
+CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n
+CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y
+CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
+CONFIG_BTU_TASK_STACK_SIZE=4512
+
+CONFIG_BLE_MESH=y
+CONFIG_BLE_MESH_PROVISIONER=y
+CONFIG_BLE_MESH_PB_GATT=y
+CONFIG_BLE_MESH_SETTINGS=y
+CONFIG_BLE_MESH_CFG_CLI=y
+CONFIG_BLE_MESH_HEALTH_SRV=n
+CONFIG_BLE_MESH_GENERIC_SERVER=n
+CONFIG_BLE_MESH_SENSOR_SERVER=n
+CONFIG_BLE_MESH_TIME_SCENE_SERVER=n
+CONFIG_BLE_MESH_LIGHTING_SERVER=n

+ 15 - 0
examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/sdkconfig.ci.nimble_deinit

@@ -0,0 +1,15 @@
+CONFIG_BT_ENABLED=y
+CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y
+CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n
+CONFIG_BTDM_CONTROLLER_MODE_BTDM=n
+CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n
+CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y
+CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
+CONFIG_NIMBLE_ENABLED=y
+
+CONFIG_BLE_MESH=y
+CONFIG_BLE_MESH_DEINIT=n
+CONFIG_BLE_MESH_PROVISIONER=y
+CONFIG_BLE_MESH_PB_GATT=y
+CONFIG_BLE_MESH_SETTINGS=y
+CONFIG_BLE_MESH_CFG_CLI=y

+ 15 - 0
examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_server/sdkconfig.ci.bluedroid_deinit

@@ -0,0 +1,15 @@
+CONFIG_BT_ENABLED=y
+CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y
+CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n
+CONFIG_BTDM_CONTROLLER_MODE_BTDM=n
+CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n
+CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y
+CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
+CONFIG_GATTS_SEND_SERVICE_CHANGE_MANUAL=y
+CONFIG_BTU_TASK_STACK_SIZE=4512
+
+CONFIG_BLE_MESH=y
+CONFIG_BLE_MESH_DEINIT=n
+CONFIG_BLE_MESH_NODE=y
+CONFIG_BLE_MESH_PB_GATT=y
+CONFIG_BLE_MESH_SETTINGS=y

+ 19 - 0
examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_server/sdkconfig.ci.model

@@ -0,0 +1,19 @@
+CONFIG_BT_ENABLED=y
+CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y
+CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n
+CONFIG_BTDM_CONTROLLER_MODE_BTDM=n
+CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n
+CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y
+CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
+CONFIG_GATTS_SEND_SERVICE_CHANGE_MANUAL=y
+CONFIG_BTU_TASK_STACK_SIZE=4512
+
+CONFIG_BLE_MESH=y
+CONFIG_BLE_MESH_NODE=y
+CONFIG_BLE_MESH_PB_GATT=y
+CONFIG_BLE_MESH_SETTINGS=y
+CONFIG_BLE_MESH_HEALTH_SRV=n
+CONFIG_BLE_MESH_GENERIC_SERVER=n
+CONFIG_BLE_MESH_SENSOR_SERVER=n
+CONFIG_BLE_MESH_TIME_SCENE_SERVER=n
+CONFIG_BLE_MESH_LIGHTING_SERVER=n

+ 14 - 0
examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_server/sdkconfig.ci.nimble_deinit

@@ -0,0 +1,14 @@
+CONFIG_BT_ENABLED=y
+CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y
+CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n
+CONFIG_BTDM_CONTROLLER_MODE_BTDM=n
+CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n
+CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y
+CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
+CONFIG_NIMBLE_ENABLED=y
+
+CONFIG_BLE_MESH=y
+CONFIG_BLE_MESH_DEINIT=n
+CONFIG_BLE_MESH_NODE=y
+CONFIG_BLE_MESH_PB_GATT=y
+CONFIG_BLE_MESH_SETTINGS=y

+ 18 - 0
examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/sdkconfig.ci.bluedroid_deinit

@@ -0,0 +1,18 @@
+CONFIG_BT_ENABLED=y
+CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y
+CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n
+CONFIG_BTDM_CONTROLLER_MODE_BTDM=n
+CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n
+CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y
+CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
+CONFIG_GATTS_SEND_SERVICE_CHANGE_MANUAL=y
+CONFIG_BTU_TASK_STACK_SIZE=4512
+
+CONFIG_BLE_MESH=y
+CONFIG_BLE_MESH_DEINIT=n
+CONFIG_BLE_MESH_FAST_PROV=y
+CONFIG_BLE_MESH_PB_GATT=y
+CONFIG_BLE_MESH_CFG_CLI=y
+
+CONFIG_PARTITION_TABLE_CUSTOM=y
+CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y

+ 21 - 0
examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/sdkconfig.ci.model

@@ -0,0 +1,21 @@
+CONFIG_BT_ENABLED=y
+CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y
+CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n
+CONFIG_BTDM_CONTROLLER_MODE_BTDM=n
+CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n
+CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y
+CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
+CONFIG_GATTS_SEND_SERVICE_CHANGE_MANUAL=y
+CONFIG_BTU_TASK_STACK_SIZE=4512
+
+CONFIG_BLE_MESH=y
+CONFIG_BLE_MESH_FAST_PROV=y
+CONFIG_BLE_MESH_PB_GATT=y
+CONFIG_BLE_MESH_CFG_CLI=y
+CONFIG_BLE_MESH_HEALTH_SRV=n
+CONFIG_BLE_MESH_SENSOR_SERVER=n
+CONFIG_BLE_MESH_TIME_SCENE_SERVER=n
+CONFIG_BLE_MESH_LIGHTING_SERVER=n
+
+CONFIG_PARTITION_TABLE_CUSTOM=y
+CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y

+ 17 - 0
examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/sdkconfig.ci.nimble_deinit

@@ -0,0 +1,17 @@
+CONFIG_BT_ENABLED=y
+CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y
+CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n
+CONFIG_BTDM_CONTROLLER_MODE_BTDM=n
+CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n
+CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y
+CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y
+CONFIG_NIMBLE_ENABLED=y
+
+CONFIG_BLE_MESH=y
+CONFIG_BLE_MESH_DEINIT=n
+CONFIG_BLE_MESH_FAST_PROV=y
+CONFIG_BLE_MESH_PB_GATT=y
+CONFIG_BLE_MESH_CFG_CLI=y
+
+CONFIG_PARTITION_TABLE_CUSTOM=y
+CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y

+ 4 - 0
examples/bluetooth/esp_ble_mesh/components/fast_provisioning/ble_mesh_fast_prov_client_model.c

@@ -33,8 +33,10 @@
 static struct k_delayed_work    get_all_node_addr_timer;
 #endif
 
+#if !defined(CONFIG_BLE_MESH_FAST_PROV)
 /* Unicast address of the Primary Provisioner */
 static uint16_t prim_prov_addr;
+#endif
 
 /* Note: these variables are used by ble_mesh_fast_prov_server demo */
 
@@ -370,6 +372,7 @@ esp_err_t example_fast_prov_client_recv_status(esp_ble_mesh_model_t *model,
     }
     case ESP_BLE_MESH_VND_MODEL_OP_FAST_PROV_NODE_ADDR_STATUS: {
         ESP_LOG_BUFFER_HEX("Node address", data, len);
+#if CONFIG_BLE_MESH_GENERIC_ONOFF_CLI
         esp_ble_mesh_model_t *cli_model = NULL;
         example_node_info_t *node = NULL;
         esp_err_t err;
@@ -396,6 +399,7 @@ esp_err_t example_fast_prov_client_recv_status(esp_ble_mesh_model_t *model,
             ESP_LOGE(TAG, "%s: Failed to send Generic OnOff Set Unack message", __func__);
             return ESP_FAIL;
         }
+#endif /* CONFIG_BLE_MESH_GENERIC_ONOFF_CLI */
         break;
     }
     default:

+ 2 - 0
examples/bluetooth/esp_ble_mesh/components/fast_provisioning/ble_mesh_fast_prov_operation.c

@@ -387,6 +387,7 @@ esp_err_t example_send_generic_onoff_get(esp_ble_mesh_model_t *model,
     return esp_ble_mesh_generic_client_get_state(&common, &get);
 }
 
+#if CONFIG_BLE_MESH_GENERIC_ONOFF_CLI
 esp_err_t example_send_generic_onoff_set(esp_ble_mesh_model_t *model,
         example_msg_common_info_t *info,
         uint8_t onoff, uint8_t tid, bool need_ack)
@@ -418,6 +419,7 @@ esp_err_t example_send_generic_onoff_set(esp_ble_mesh_model_t *model,
 
     return esp_ble_mesh_generic_client_set_state(&common, &set);
 }
+#endif /* CONFIG_BLE_MESH_GENERIC_ONOFF_CLI */
 
 esp_err_t example_send_fast_prov_info_set(esp_ble_mesh_model_t *model,
         example_msg_common_info_t *info,