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

ble_mesh: stack: Add a Kconfig option to make Health Server model optional

lly 5 éve
szülő
commit
4391a24c2f

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

@@ -121,7 +121,9 @@ static const btc_func_t profile_tab[BTC_PID_NUM] = {
 #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 */

+ 6 - 0
components/bt/esp_ble_mesh/Kconfig.in

@@ -873,6 +873,12 @@ if BLE_MESH
             help
                 Enable support for Health Client model.
 
+        config BLE_MESH_HEALTH_SRV
+            bool "Health Server model"
+            default y
+            help
+                Enable support for Health Server model.
+
     endmenu #Support for BLE Mesh Foundation models
 
     menu "Support for BLE Mesh Client/Server models"

+ 2 - 0
components/bt/esp_ble_mesh/api/models/esp_ble_mesh_health_model_api.c

@@ -79,6 +79,7 @@ esp_err_t esp_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_
 }
 #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);
@@ -105,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 */

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

@@ -17,10 +17,10 @@
 
 #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 */
 

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

@@ -16,10 +16,10 @@
 #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 */
 

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

@@ -17,11 +17,10 @@
 
 #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 */
 
@@ -461,6 +460,9 @@ void btc_ble_mesh_health_client_cb_handler(btc_msg_t *msg)
 
 #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,
@@ -640,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 */

+ 1 - 1
components/bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c

@@ -16,10 +16,10 @@
 #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 */
 

+ 18 - 0
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"
@@ -1021,8 +1035,10 @@ 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_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;
@@ -1186,6 +1202,7 @@ 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;
@@ -1198,6 +1215,7 @@ 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;

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

@@ -16,10 +16,10 @@
 #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 */
 

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

@@ -16,10 +16,10 @@
 #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 */
 

+ 1 - 1
components/bt/esp_ble_mesh/mesh_core/health_cli.c

@@ -17,9 +17,9 @@
 #include "mesh_config.h"
 #include "foundation.h"
 #include "mesh_common.h"
-#include "health_cli.h"
 
 #if CONFIG_BLE_MESH_HEALTH_CLI
+#include "health_cli.h"
 
 static const bt_mesh_client_op_pair_t health_op_pair[] = {
     { OP_HEALTH_FAULT_GET,   OP_HEALTH_FAULT_STATUS  },

+ 8 - 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
@@ -547,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 */

+ 1 - 1
components/bt/esp_ble_mesh/mesh_models/client/generic_client.c

@@ -19,9 +19,9 @@
 
 #include "mesh_config.h"
 #include "model_opcode.h"
-#include "generic_client.h"
 
 #if CONFIG_BLE_MESH_GENERIC_CLIENT
+#include "generic_client.h"
 
 /* The followings are the macro definitions of Generic client
  * model message length, and a message is composed of 3 parts:

+ 1 - 1
components/bt/esp_ble_mesh/mesh_models/client/lighting_client.c

@@ -19,9 +19,9 @@
 
 #include "mesh_config.h"
 #include "model_opcode.h"
-#include "lighting_client.h"
 
 #if CONFIG_BLE_MESH_LIGHTING_CLIENT
+#include "lighting_client.h"
 
 /* The followings are the macro definitions of Lighting client
  * model message length, and a message is composed of 3 parts:

+ 1 - 1
components/bt/esp_ble_mesh/mesh_models/client/sensor_client.c

@@ -19,9 +19,9 @@
 
 #include "mesh_config.h"
 #include "model_opcode.h"
-#include "sensor_client.h"
 
 #if CONFIG_BLE_MESH_SENSOR_CLI
+#include "sensor_client.h"
 
 /* The followings are the macro definitions of Sensor client
  * model message length, and a message is composed of 3 parts:

+ 1 - 1
components/bt/esp_ble_mesh/mesh_models/client/time_scene_client.c

@@ -19,9 +19,9 @@
 
 #include "mesh_config.h"
 #include "model_opcode.h"
-#include "time_scene_client.h"
 
 #if CONFIG_BLE_MESH_TIME_SCENE_CLIENT
+#include "time_scene_client.h"
 
 /* The followings are the macro definitions of Time Scene client
  * model message length, and a message is composed of 3 parts: