ble_mesh: stack: Add Kconfig options to make server models optional

This commit is contained in:
lly 2020-10-16 16:10:28 +08:00
parent c90def0992
commit d9ffe54991
25 changed files with 238 additions and 96 deletions

View File

@ -2581,102 +2581,126 @@ 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 client/server 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.
Enable support for Health Client model.
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.
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

View File

@ -113,22 +113,30 @@ static btc_func_t profile_tab[BTC_PID_NUM] = {
[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 BLE_MESH_GENERIC_CLIENT_ENABLE
#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 /* BLE_MESH_GENERIC_CLIENT_ENABLE */
#if BLE_MESH_LIGHTING_CLIENT_ENABLE
#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 /* BLE_MESH_LIGHTING_CLIENT_ENABLE */
#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 BLE_MESH_TIME_SCENE_CLIENT_ENABLE
#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 /* BLE_MESH_TIME_SCENE_CLIENT_ENABLE */
#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 */
};

View File

@ -222,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)
@ -246,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)
{

View File

@ -19,7 +19,7 @@
#include "btc_ble_mesh_generic_model.h"
#include "esp_ble_mesh_generic_model_api.h"
#if BLE_MESH_GENERIC_CLIENT_ENABLE
#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);
@ -90,11 +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 /* BLE_MESH_GENERIC_CLIENT_ENABLE */
#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 */

View File

@ -19,7 +19,7 @@
#include "btc_ble_mesh_lighting_model.h"
#include "esp_ble_mesh_lighting_model_api.h"
#if BLE_MESH_LIGHTING_CLIENT_ENABLE
#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);
@ -77,11 +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 /* BLE_MESH_LIGHTING_CLIENT_ENABLE */
#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 */

View File

@ -78,9 +78,11 @@ esp_err_t esp_ble_mesh_sensor_client_set_state(esp_ble_mesh_client_common_param_
}
#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 */

View File

@ -19,7 +19,7 @@
#include "btc_ble_mesh_time_scene_model.h"
#include "esp_ble_mesh_time_scene_model_api.h"
#if BLE_MESH_TIME_SCENE_CLIENT_ENABLE
#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);
@ -77,12 +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 /* BLE_MESH_TIME_SCENE_CLIENT_ENABLE */
#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 */

View File

@ -680,6 +680,7 @@ void btc_ble_mesh_config_client_cb_handler(btc_msg_t *msg)
btc_ble_mesh_config_client_free_req_data(msg);
return;
}
#endif /* CONFIG_BLE_MESH_CFG_CLI */
/* Configuration Server Model related functions */

View File

@ -19,7 +19,7 @@
#include "generic_client.h"
#include "esp_ble_mesh_generic_model_api.h"
#if BLE_MESH_GENERIC_CLIENT_ENABLE
#if CONFIG_BLE_MESH_GENERIC_CLIENT
/* Generic Client Models related functions */
@ -531,7 +531,10 @@ void btc_ble_mesh_generic_client_cb_handler(btc_msg_t *msg)
btc_ble_mesh_generic_client_free_req_data(msg);
return;
}
#endif /* BLE_MESH_GENERIC_CLIENT_ENABLE */
#endif /* CONFIG_BLE_MESH_GENERIC_CLIENT */
#if CONFIG_BLE_MESH_GENERIC_SERVER
/* Generic Server Models related functions */
@ -759,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 */

View File

@ -458,6 +458,7 @@ void btc_ble_mesh_health_client_cb_handler(btc_msg_t *msg)
btc_ble_mesh_health_client_free_req_data(msg);
return;
}
#endif /* CONFIG_BLE_MESH_HEALTH_CLI */
/* Health Server Model related functions */

View File

@ -19,7 +19,7 @@
#include "lighting_client.h"
#include "esp_ble_mesh_lighting_model_api.h"
#if BLE_MESH_LIGHTING_CLIENT_ENABLE
#if CONFIG_BLE_MESH_LIGHTING_CLIENT
/* Lighting Client Models related functions */
@ -375,7 +375,10 @@ void btc_ble_mesh_lighting_client_cb_handler(btc_msg_t *msg)
btc_ble_mesh_lighting_client_free_req_data(msg);
return;
}
#endif /* BLE_MESH_LIGHTING_CLIENT_ENABLE */
#endif /* CONFIG_BLE_MESH_LIGHTING_CLIENT */
#if CONFIG_BLE_MESH_LIGHTING_SERVER
/* Lighting Server Models related functions */
@ -573,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 */

View File

@ -489,6 +489,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 +503,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)
{
@ -1027,7 +1029,7 @@ extern const struct bt_mesh_model_cb bt_mesh_health_cli_cb;
#endif /* CONFIG_BLE_MESH_HEALTH_CLI */
/* Generic Client Models */
#if BLE_MESH_GENERIC_CLIENT_ENABLE
#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[];
@ -1037,17 +1039,17 @@ 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 /* BLE_MESH_GENERIC_CLIENT_ENABLE */
#endif /* CONFIG_BLE_MESH_GENERIC_CLIENT */
/* Lighting Client Models */
#if BLE_MESH_LIGHTING_CLIENT_ENABLE
#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 /* BLE_MESH_LIGHTING_CLIENT_ENABLE */
#endif /* CONFIG_BLE_MESH_LIGHTING_CLIENT */
/* Sensor Client Models */
#if CONFIG_BLE_MESH_SENSOR_CLI
@ -1056,14 +1058,15 @@ extern const struct bt_mesh_model_cb bt_mesh_sensor_client_cb;
#endif /* CONFIG_BLE_MESH_SENSOR_CLI */
/* Time and Scenes Client Models */
#if BLE_MESH_TIME_SCENE_CLIENT_ENABLE
#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 /* BLE_MESH_TIME_SCENE_CLIENT_ENABLE */
#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[];
@ -1092,8 +1095,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[];
@ -1105,8 +1110,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;
@ -1118,10 +1121,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[];
@ -1134,12 +1141,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)
{
@ -1199,7 +1209,7 @@ static void btc_ble_mesh_model_op_set(esp_ble_mesh_model_t *model)
break;
}
#endif /* CONFIG_BLE_MESH_HEALTH_CLI */
#if BLE_MESH_GENERIC_CLIENT_ENABLE
#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;
@ -1272,8 +1282,8 @@ static void btc_ble_mesh_model_op_set(esp_ble_mesh_model_t *model)
}
break;
}
#endif /* BLE_MESH_GENERIC_CLIENT_ENABLE */
#if BLE_MESH_LIGHTING_CLIENT_ENABLE
#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;
@ -1319,7 +1329,7 @@ static void btc_ble_mesh_model_op_set(esp_ble_mesh_model_t *model)
}
break;
}
#endif /* BLE_MESH_LIGHTING_CLIENT_ENABLE */
#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;
@ -1331,7 +1341,7 @@ static void btc_ble_mesh_model_op_set(esp_ble_mesh_model_t *model)
break;
}
#endif /* CONFIG_BLE_MESH_SENSOR_CLI */
#if BLE_MESH_TIME_SCENE_CLIENT_ENABLE
#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;
@ -1359,7 +1369,8 @@ static void btc_ble_mesh_model_op_set(esp_ble_mesh_model_t *model)
}
break;
}
#endif /* BLE_MESH_TIME_SCENE_CLIENT_ENABLE */
#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;
@ -1458,6 +1469,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;
@ -1549,6 +1562,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;
@ -1593,6 +1608,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;
@ -1607,6 +1624,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;
}
@ -2179,6 +2197,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,
@ -2186,6 +2205,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;

View File

@ -613,8 +613,11 @@ void btc_ble_mesh_sensor_client_cb_handler(btc_msg_t *msg)
btc_ble_mesh_sensor_client_free_req_data(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,
@ -891,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 */

View File

@ -19,7 +19,7 @@
#include "time_scene_client.h"
#include "esp_ble_mesh_time_scene_model_api.h"
#if BLE_MESH_TIME_SCENE_CLIENT_ENABLE
#if CONFIG_BLE_MESH_TIME_SCENE_CLIENT
/* Time and Scenes Client Models related functions */
@ -377,7 +377,10 @@ void btc_ble_mesh_time_scene_client_cb_handler(btc_msg_t *msg)
btc_ble_mesh_time_scene_client_free_req_data(msg);
return;
}
#endif /* BLE_MESH_TIME_SCENE_CLIENT_ENABLE */
#endif /* CONFIG_BLE_MESH_TIME_SCENE_CLIENT */
#if CONFIG_BLE_MESH_TIME_SCENE_SERVER
/* Time and Scenes Server Models related functions */
@ -477,3 +480,4 @@ void btc_ble_mesh_time_scene_server_cb_handler(btc_msg_t *msg)
return;
}
#endif /* CONFIG_BLE_MESH_TIME_SCENE_SERVER */

View File

@ -21,7 +21,7 @@
extern "C" {
#endif
#define BLE_MESH_GENERIC_CLIENT_ENABLE (CONFIG_BLE_MESH_GENERIC_ONOFF_CLI | \
#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 | \
@ -30,16 +30,21 @@ extern "C" {
CONFIG_BLE_MESH_GENERIC_LOCATION_CLI | \
CONFIG_BLE_MESH_GENERIC_PROPERTY_CLI)
#define BLE_MESH_TIME_SCENE_CLIENT_ENABLE (CONFIG_BLE_MESH_TIME_CLI | \
#define CONFIG_BLE_MESH_TIME_SCENE_CLIENT (CONFIG_BLE_MESH_TIME_CLI | \
CONFIG_BLE_MESH_SCENE_CLI | \
CONFIG_BLE_MESH_SCHEDULER_CLI)
#define BLE_MESH_LIGHTING_CLIENT_ENABLE (CONFIG_BLE_MESH_LIGHT_LIGHTNESS_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

View File

@ -21,7 +21,7 @@
#include "model_opcode.h"
#include "generic_client.h"
#if BLE_MESH_GENERIC_CLIENT_ENABLE
#if CONFIG_BLE_MESH_GENERIC_CLIENT
/* The followings are the macro definitions of Generic client
* model message length, and a message is composed of 3 parts:
@ -1215,4 +1215,4 @@ const struct bt_mesh_model_cb bt_mesh_generic_client_cb = {
#endif /* CONFIG_BLE_MESH_DEINIT */
};
#endif /* BLE_MESH_GENERIC_CLIENT_ENABLE */
#endif /* CONFIG_BLE_MESH_GENERIC_CLIENT */

View File

@ -21,7 +21,7 @@
#include "model_opcode.h"
#include "lighting_client.h"
#if BLE_MESH_LIGHTING_CLIENT_ENABLE
#if CONFIG_BLE_MESH_LIGHTING_CLIENT
/* The followings are the macro definitions of Lighting client
* model message length, and a message is composed of 3 parts:
@ -1405,4 +1405,4 @@ const struct bt_mesh_model_cb bt_mesh_lighting_client_cb = {
#endif /* CONFIG_BLE_MESH_DEINIT */
};
#endif /* BLE_MESH_LIGHTING_CLIENT_ENABLE */
#endif /* CONFIG_BLE_MESH_LIGHTING_CLIENT */

View File

@ -21,7 +21,7 @@
#include "model_opcode.h"
#include "time_scene_client.h"
#if BLE_MESH_TIME_SCENE_CLIENT_ENABLE
#if CONFIG_BLE_MESH_TIME_SCENE_CLIENT
/* The followings are the macro definitions of Time Scene client
* model message length, and a message is composed of 3 parts:
@ -711,4 +711,4 @@ const struct bt_mesh_model_cb bt_mesh_time_scene_client_cb = {
#endif /* CONFIG_BLE_MESH_DEINIT */
};
#endif /* BLE_MESH_TIME_SCENE_CLIENT_ENABLE */
#endif /* CONFIG_BLE_MESH_TIME_SCENE_CLIENT */

View File

@ -10,12 +10,15 @@
#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 inline void bt_mesh_generic_server_mutex_new(void)
@ -2896,3 +2899,5 @@ const struct bt_mesh_model_cb bt_mesh_gen_client_prop_srv_cb = {
.deinit = gen_client_prop_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
#endif /* CONFIG_BLE_MESH_GENERIC_SERVER */

View File

@ -10,12 +10,15 @@
#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 inline void bt_mesh_light_server_mutex_new(void)
@ -3646,3 +3649,5 @@ const struct bt_mesh_model_cb bt_mesh_light_lc_setup_srv_cb = {
.deinit = light_lc_setup_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
#endif /* CONFIG_BLE_MESH_LIGHTING_SERVER */

View File

@ -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) */
@ -1172,3 +1175,5 @@ const struct bt_mesh_model_cb bt_mesh_sensor_setup_srv_cb = {
.deinit = sensor_setup_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
#endif /* CONFIG_BLE_MESH_SENSOR_SERVER */

View File

@ -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
@ -257,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 */

View File

@ -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 */

View File

@ -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) */

View File

@ -16,11 +16,14 @@
#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 inline void bt_mesh_time_scene_server_mutex_new(void)
@ -1545,3 +1548,5 @@ const struct bt_mesh_model_cb bt_mesh_scheduler_setup_srv_cb = {
.deinit = scheduler_setup_srv_deinit,
#endif /* CONFIG_BLE_MESH_DEINIT */
};
#endif /* CONFIG_BLE_MESH_TIME_SCENE_SERVER */