From 2c66a824343b229cbeb6eec60a01aaa821307449 Mon Sep 17 00:00:00 2001 From: lly Date: Mon, 19 Oct 2020 21:12:17 +0800 Subject: [PATCH] ble_mesh: stack: Add a Kconfig option to make Health Server model optional --- components/bt/Kconfig | 6 ++++++ components/bt/common/btc/core/btc_task.c | 2 ++ .../api/models/esp_ble_mesh_health_model_api.c | 2 ++ .../btc/btc_ble_mesh_config_model.c | 2 +- .../btc/btc_ble_mesh_generic_model.c | 2 +- .../btc/btc_ble_mesh_health_model.c | 7 +++++-- .../btc/btc_ble_mesh_lighting_model.c | 2 +- .../bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c | 18 ++++++++++++++++++ .../btc/btc_ble_mesh_sensor_model.c | 2 +- .../btc/btc_ble_mesh_time_scene_model.c | 2 +- .../bt/esp_ble_mesh/mesh_core/health_cli.c | 2 +- .../bt/esp_ble_mesh/mesh_core/health_srv.c | 8 ++++++++ .../mesh_models/client/generic_client.c | 2 +- .../mesh_models/client/lighting_client.c | 2 +- .../mesh_models/client/sensor_client.c | 2 +- .../mesh_models/client/time_scene_client.c | 2 +- 16 files changed, 51 insertions(+), 12 deletions(-) diff --git a/components/bt/Kconfig b/components/bt/Kconfig index d5f5fabd83..7b6b7e49ae 100644 --- a/components/bt/Kconfig +++ b/components/bt/Kconfig @@ -2593,6 +2593,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" diff --git a/components/bt/common/btc/core/btc_task.c b/components/bt/common/btc/core/btc_task.c index 809a9c7e5d..af60227f9a 100644 --- a/components/bt/common/btc/core/btc_task.c +++ b/components/bt/common/btc/core/btc_task.c @@ -108,7 +108,9 @@ static 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 */ diff --git a/components/bt/esp_ble_mesh/api/models/esp_ble_mesh_health_model_api.c b/components/bt/esp_ble_mesh/api/models/esp_ble_mesh_health_model_api.c index 217bbc15af..95c7536b4d 100644 --- a/components/bt/esp_ble_mesh/api/models/esp_ble_mesh_health_model_api.c +++ b/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 */ diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c index 775d378b1c..637252f6f3 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c +++ b/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 */ diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_generic_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_generic_model.c index 8de11ca4b8..6f588ab078 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_generic_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_generic_model.c @@ -16,10 +16,10 @@ #include #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 */ diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c index 36c0150352..39a5b295a0 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c +++ b/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(¶m, ESP_BLE_MESH_HEALTH_SERVER_ATTENTION_OFF_EVT); } +#endif /* CONFIG_BLE_MESH_HEALTH_SRV */ diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c index f173031b56..b6dce6cec5 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c @@ -16,10 +16,10 @@ #include #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 */ diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c index 41eb421ae3..1365aeced0 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c @@ -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; diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c index 3a9de041b2..65ddec0d02 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c @@ -16,10 +16,10 @@ #include #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 */ diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c index 58ae40558c..937f8fd0bb 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c @@ -16,10 +16,10 @@ #include #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 */ diff --git a/components/bt/esp_ble_mesh/mesh_core/health_cli.c b/components/bt/esp_ble_mesh/mesh_core/health_cli.c index c94dc95fc3..e0d644da7b 100644 --- a/components/bt/esp_ble_mesh/mesh_core/health_cli.c +++ b/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 }, diff --git a/components/bt/esp_ble_mesh/mesh_core/health_srv.c b/components/bt/esp_ble_mesh/mesh_core/health_srv.c index 4d6088fb44..4d13b6a0b1 100644 --- a/components/bt/esp_ble_mesh/mesh_core/health_srv.c +++ b/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 */ diff --git a/components/bt/esp_ble_mesh/mesh_models/client/generic_client.c b/components/bt/esp_ble_mesh/mesh_models/client/generic_client.c index d284ee0eee..64abe802f6 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/generic_client.c +++ b/components/bt/esp_ble_mesh/mesh_models/client/generic_client.c @@ -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: diff --git a/components/bt/esp_ble_mesh/mesh_models/client/lighting_client.c b/components/bt/esp_ble_mesh/mesh_models/client/lighting_client.c index c291da5cb1..147ba73f58 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/lighting_client.c +++ b/components/bt/esp_ble_mesh/mesh_models/client/lighting_client.c @@ -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: diff --git a/components/bt/esp_ble_mesh/mesh_models/client/sensor_client.c b/components/bt/esp_ble_mesh/mesh_models/client/sensor_client.c index 857f7d30eb..f97c5f606d 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/sensor_client.c +++ b/components/bt/esp_ble_mesh/mesh_models/client/sensor_client.c @@ -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: diff --git a/components/bt/esp_ble_mesh/mesh_models/client/time_scene_client.c b/components/bt/esp_ble_mesh/mesh_models/client/time_scene_client.c index d328e4ac77..c1a13665c2 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/time_scene_client.c +++ b/components/bt/esp_ble_mesh/mesh_models/client/time_scene_client.c @@ -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: