|
|
@@ -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;
|