ble_mesh: stack: Use model callback for operations [Zephyr]

- Previously when a model is initialized or deinitialized, in the
  access layer, we need to check the model id with the ids in the
  table in order to find the proper model operation function.
- Currently all the operation functions of each model will be set
  during the mesh initialization. When the model is found, we can
  directly use the corresponding callback for different operations.
- Currently only init/deinit operations are registered, later we
  will add more operations.
This commit is contained in:
lly 2020-07-07 18:25:29 +08:00
parent a3ef2bbe33
commit 9b70ddbb77
32 changed files with 864 additions and 1233 deletions

View file

@ -271,7 +271,7 @@ typedef enum {
#define ESP_BLE_MESH_MODEL_OP_2(b0, b1) (((b0) << 8) | (b1))
#define ESP_BLE_MESH_MODEL_OP_3(b0, cid) ((((b0) << 16) | 0xC00000) | (cid))
/*!< This macro is associated with BLE_MESH_MODEL in mesh_access.h */
/*!< This macro is associated with BLE_MESH_MODEL_CB in mesh_access.h */
#define ESP_BLE_MESH_SIG_MODEL(_id, _op, _pub, _user_data) \
{ \
.model_id = (_id), \
@ -284,7 +284,7 @@ typedef enum {
.user_data = _user_data, \
}
/*!< This macro is associated with BLE_MESH_MODEL_VND in mesh_access.h */
/*!< This macro is associated with BLE_MESH_MODEL_VND_CB in mesh_access.h */
#define ESP_BLE_MESH_VENDOR_MODEL(_company, _id, _op, _pub, _user_data) \
{ \
.vnd.company_id = (_company), \
@ -461,6 +461,17 @@ typedef struct {
*/
#define ESP_BLE_MESH_MODEL_OP_END {0, 0, 0}
/** Abstraction that describes a model callback structure.
* This structure is associated with struct bt_mesh_model_cb in mesh_access.h.
*/
typedef struct {
/** Callback used during model initialization. Initialized by the stack. */
esp_ble_mesh_cb_t init_cb;
/** Callback used during model deinitialization. Initialized by the stack. */
esp_ble_mesh_cb_t deinit_cb;
} esp_ble_mesh_model_cbs_t;
/** Abstraction that describes a Mesh Model instance.
* This structure is associated with struct bt_mesh_model in mesh_access.h
*/
@ -494,6 +505,9 @@ struct esp_ble_mesh_model {
/** Model operation context */
esp_ble_mesh_model_op_t *op;
/** Model callback structure */
esp_ble_mesh_model_cbs_t *cb;
/** Model-specific user data */
void *user_data;
};

View file

@ -1006,74 +1006,115 @@ 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;
extern const struct bt_mesh_model_cb bt_mesh_cfg_cli_cb;
/* Health Models */
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;
extern const struct bt_mesh_model_cb bt_mesh_health_cli_cb;
/* Generic Client Models */
extern const struct bt_mesh_model_op gen_onoff_cli_op[];
extern const struct bt_mesh_model_op gen_level_cli_op[];
extern const struct bt_mesh_model_op gen_def_trans_time_cli_op[];
extern const struct bt_mesh_model_op gen_power_onoff_cli_op[];
extern const struct bt_mesh_model_op gen_power_level_cli_op[];
extern const struct bt_mesh_model_op gen_battery_cli_op[];
extern const struct bt_mesh_model_op gen_location_cli_op[];
extern const struct bt_mesh_model_op gen_property_cli_op[];
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[];
extern const struct bt_mesh_model_op bt_mesh_gen_power_onoff_cli_op[];
extern const struct bt_mesh_model_op bt_mesh_gen_power_level_cli_op[];
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;
/* Lighting Client Models */
extern const struct bt_mesh_model_op light_lightness_cli_op[];
extern const struct bt_mesh_model_op light_ctl_cli_op[];
extern const struct bt_mesh_model_op light_hsl_cli_op[];
extern const struct bt_mesh_model_op light_xyl_cli_op[];
extern const struct bt_mesh_model_op light_lc_cli_op[];
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;
/* Sensor Client Models */
extern const struct bt_mesh_model_op sensor_cli_op[];
extern const struct bt_mesh_model_op bt_mesh_sensor_cli_op[];
extern const struct bt_mesh_model_cb bt_mesh_sensor_client_cb;
/* Time and Scenes Client Models */
extern const struct bt_mesh_model_op time_cli_op[];
extern const struct bt_mesh_model_op scene_cli_op[];
extern const struct bt_mesh_model_op scheduler_cli_op[];
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;
/* Generic Server Models */
extern const struct bt_mesh_model_op gen_onoff_srv_op[];
extern const struct bt_mesh_model_op gen_level_srv_op[];
extern const struct bt_mesh_model_op gen_def_trans_time_srv_op[];
extern const struct bt_mesh_model_op gen_power_onoff_srv_op[];
extern const struct bt_mesh_model_op gen_power_onoff_setup_srv_op[];
extern const struct bt_mesh_model_op gen_power_level_srv_op[];
extern const struct bt_mesh_model_op gen_power_level_setup_srv_op[];
extern const struct bt_mesh_model_op gen_battery_srv_op[];
extern const struct bt_mesh_model_op gen_location_srv_op[];
extern const struct bt_mesh_model_op gen_location_setup_srv_op[];
extern const struct bt_mesh_model_op gen_user_prop_srv_op[];
extern const struct bt_mesh_model_op gen_admin_prop_srv_op[];
extern const struct bt_mesh_model_op gen_manu_prop_srv_op[];
extern const struct bt_mesh_model_op gen_client_prop_srv_op[];
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[];
extern const struct bt_mesh_model_op bt_mesh_gen_power_onoff_srv_op[];
extern const struct bt_mesh_model_op bt_mesh_gen_power_onoff_setup_srv_op[];
extern const struct bt_mesh_model_op bt_mesh_gen_power_level_srv_op[];
extern const struct bt_mesh_model_op bt_mesh_gen_power_level_setup_srv_op[];
extern const struct bt_mesh_model_op bt_mesh_gen_battery_srv_op[];
extern const struct bt_mesh_model_op bt_mesh_gen_location_srv_op[];
extern const struct bt_mesh_model_op bt_mesh_gen_location_setup_srv_op[];
extern const struct bt_mesh_model_op bt_mesh_gen_user_prop_srv_op[];
extern const struct bt_mesh_model_op bt_mesh_gen_admin_prop_srv_op[];
extern const struct bt_mesh_model_op bt_mesh_gen_manu_prop_srv_op[];
extern const struct bt_mesh_model_op bt_mesh_gen_client_prop_srv_op[];
extern const struct bt_mesh_model_cb bt_mesh_gen_onoff_srv_cb;
extern const struct bt_mesh_model_cb bt_mesh_gen_level_srv_cb;
extern const struct bt_mesh_model_cb bt_mesh_gen_def_trans_time_srv_cb;
extern const struct bt_mesh_model_cb bt_mesh_gen_power_onoff_srv_cb;
extern const struct bt_mesh_model_cb bt_mesh_gen_power_onoff_setup_srv_cb;
extern const struct bt_mesh_model_cb bt_mesh_gen_power_level_srv_cb;
extern const struct bt_mesh_model_cb bt_mesh_gen_power_level_setup_srv_cb;
extern const struct bt_mesh_model_cb bt_mesh_gen_battery_srv_cb;
extern const struct bt_mesh_model_cb bt_mesh_gen_location_srv_cb;
extern const struct bt_mesh_model_cb bt_mesh_gen_location_setup_srv_cb;
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;
/* Lighting Server Models */
extern const struct bt_mesh_model_op light_lightness_srv_op[];
extern const struct bt_mesh_model_op light_lightness_setup_srv_op[];
extern const struct bt_mesh_model_op light_ctl_srv_op[];
extern const struct bt_mesh_model_op light_ctl_setup_srv_op[];
extern const struct bt_mesh_model_op light_ctl_temp_srv_op[];
extern const struct bt_mesh_model_op light_hsl_srv_op[];
extern const struct bt_mesh_model_op light_hsl_hue_srv_op[];
extern const struct bt_mesh_model_op light_hsl_sat_srv_op[];
extern const struct bt_mesh_model_op light_hsl_setup_srv_op[];
extern const struct bt_mesh_model_op light_xyl_srv_op[];
extern const struct bt_mesh_model_op light_xyl_setup_srv_op[];
extern const struct bt_mesh_model_op light_lc_srv_op[];
extern const struct bt_mesh_model_op light_lc_setup_srv_op[];
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[];
extern const struct bt_mesh_model_op bt_mesh_light_ctl_setup_srv_op[];
extern const struct bt_mesh_model_op bt_mesh_light_ctl_temp_srv_op[];
extern const struct bt_mesh_model_op bt_mesh_light_hsl_srv_op[];
extern const struct bt_mesh_model_op bt_mesh_light_hsl_hue_srv_op[];
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;
extern const struct bt_mesh_model_cb bt_mesh_light_ctl_setup_srv_cb;
extern const struct bt_mesh_model_cb bt_mesh_light_ctl_temp_srv_cb;
extern const struct bt_mesh_model_cb bt_mesh_light_hsl_srv_cb;
extern const struct bt_mesh_model_cb bt_mesh_light_hsl_hue_srv_cb;
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_cb bt_mesh_light_lc_srv_cb;
extern const struct bt_mesh_model_cb bt_mesh_light_lc_setup_srv_cb;
/* Time and Scenes Server Models */
extern const struct bt_mesh_model_op time_srv_op[];
extern const struct bt_mesh_model_op time_setup_srv_op[];
extern const struct bt_mesh_model_op scene_srv_op[];
extern const struct bt_mesh_model_op scene_setup_srv_op[];
extern const struct bt_mesh_model_op scheduler_srv_op[];
extern const struct bt_mesh_model_op scheduler_setup_srv_op[];
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[];
extern const struct bt_mesh_model_op bt_mesh_scene_setup_srv_op[];
extern const struct bt_mesh_model_op bt_mesh_scheduler_srv_op[];
extern const struct bt_mesh_model_op bt_mesh_scheduler_setup_srv_op[];
extern const struct bt_mesh_model_cb bt_mesh_time_srv_cb;
extern const struct bt_mesh_model_cb bt_mesh_time_setup_srv_cb;
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;
/* Sensor Server Models */
extern const struct bt_mesh_model_op sensor_srv_op[];
extern const struct bt_mesh_model_op sensor_setup_srv_op[];
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;
static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model)
static void btc_ble_mesh_model_op_set(esp_ble_mesh_model_t *model)
{
esp_ble_mesh_model_op_t *op = NULL;
if (!model) {
BT_ERR("%s, Invalid parameter", __func__);
return;
@ -1082,13 +1123,14 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model)
/* For SIG client and server models, model->op will be NULL and initialized here.
* For vendor models whose opcode is 3 bytes, model->op will be initialized here.
*/
if ((model->op != NULL) && (model->op->opcode >= 0x10000)) {
goto add_model_op;
if (model->op && BLE_MESH_MODEL_OP_LEN(model->op->opcode) == 3) {
goto set_vnd_op;
}
switch (model->model_id) {
case BLE_MESH_MODEL_ID_CFG_SRV: {
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_cfg_srv_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_cfg_srv_cb;
struct bt_mesh_cfg_srv *srv = (struct bt_mesh_cfg_srv *)model->user_data;
if (srv) {
srv->hb_sub.func = btc_ble_mesh_heartbeat_msg_recv_cb;
@ -1097,6 +1139,7 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model)
}
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;
bt_mesh_config_client_t *cli = (bt_mesh_config_client_t *)model->user_data;
if (cli != NULL) {
cli->publish_status = btc_ble_mesh_config_client_publish_callback;
@ -1105,6 +1148,7 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model)
}
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;
struct bt_mesh_health_srv *srv = (struct bt_mesh_health_srv *)model->user_data;
if (srv) {
srv->cb.fault_clear = btc_ble_mesh_health_server_fault_clear;
@ -1116,6 +1160,7 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model)
}
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;
bt_mesh_health_client_t *cli = (bt_mesh_health_client_t *)model->user_data;
if (cli != NULL) {
cli->publish_status = btc_ble_mesh_health_publish_callback;
@ -1123,7 +1168,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model)
break;
}
case BLE_MESH_MODEL_ID_GEN_ONOFF_CLI: {
model->op = ((esp_ble_mesh_model_op_t *)gen_onoff_cli_op);
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;
bt_mesh_gen_onoff_client_t *cli = (bt_mesh_gen_onoff_client_t *)model->user_data;
if (cli != NULL) {
cli->publish_status = btc_ble_mesh_generic_client_publish_callback;
@ -1131,7 +1177,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model)
break;
}
case BLE_MESH_MODEL_ID_GEN_LEVEL_CLI: {
model->op = ((esp_ble_mesh_model_op_t *)gen_level_cli_op);
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_level_cli_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_generic_client_cb;
bt_mesh_gen_level_client_t *cli = (bt_mesh_gen_level_client_t *)model->user_data;
if (cli != NULL) {
cli->publish_status = btc_ble_mesh_generic_client_publish_callback;
@ -1139,7 +1186,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model)
break;
}
case BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI: {
model->op = ((esp_ble_mesh_model_op_t *)gen_def_trans_time_cli_op);
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_def_trans_time_cli_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_generic_client_cb;
bt_mesh_gen_def_trans_time_client_t *cli = (bt_mesh_gen_def_trans_time_client_t *)model->user_data;
if (cli != NULL) {
cli->publish_status = btc_ble_mesh_generic_client_publish_callback;
@ -1147,7 +1195,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model)
break;
}
case BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI: {
model->op = ((esp_ble_mesh_model_op_t *)gen_power_onoff_cli_op);
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_power_onoff_cli_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_generic_client_cb;
bt_mesh_gen_power_onoff_client_t *cli = (bt_mesh_gen_power_onoff_client_t *)model->user_data;
if (cli != NULL) {
cli->publish_status = btc_ble_mesh_generic_client_publish_callback;
@ -1155,7 +1204,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model)
break;
}
case BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI: {
model->op = ((esp_ble_mesh_model_op_t *)gen_power_level_cli_op);
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_power_level_cli_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_generic_client_cb;
bt_mesh_gen_power_level_client_t *cli = (bt_mesh_gen_power_level_client_t *)model->user_data;
if (cli != NULL) {
cli->publish_status = btc_ble_mesh_generic_client_publish_callback;
@ -1163,7 +1213,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model)
break;
}
case BLE_MESH_MODEL_ID_GEN_BATTERY_CLI: {
model->op = ((esp_ble_mesh_model_op_t *)gen_battery_cli_op);
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_battery_cli_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_generic_client_cb;
bt_mesh_gen_battery_client_t *cli = (bt_mesh_gen_battery_client_t *)model->user_data;
if (cli != NULL) {
cli->publish_status = btc_ble_mesh_generic_client_publish_callback;
@ -1171,7 +1222,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model)
break;
}
case BLE_MESH_MODEL_ID_GEN_LOCATION_CLI: {
model->op = ((esp_ble_mesh_model_op_t *)gen_location_cli_op);
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_location_cli_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_generic_client_cb;
bt_mesh_gen_location_client_t *cli = (bt_mesh_gen_location_client_t *)model->user_data;
if (cli != NULL) {
cli->publish_status = btc_ble_mesh_generic_client_publish_callback;
@ -1179,7 +1231,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model)
break;
}
case BLE_MESH_MODEL_ID_GEN_PROP_CLI: {
model->op = ((esp_ble_mesh_model_op_t *)gen_property_cli_op);
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_property_cli_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_generic_client_cb;
bt_mesh_gen_property_client_t *cli = (bt_mesh_gen_property_client_t *)model->user_data;
if (cli != NULL) {
cli->publish_status = btc_ble_mesh_generic_client_publish_callback;
@ -1187,7 +1240,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model)
break;
}
case BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI: {
model->op = ((esp_ble_mesh_model_op_t *)light_lightness_cli_op);
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;
bt_mesh_light_lightness_client_t *cli = (bt_mesh_light_lightness_client_t *)model->user_data;
if (cli != NULL) {
cli->publish_status = btc_ble_mesh_lighting_client_publish_callback;
@ -1195,7 +1249,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model)
break;
}
case BLE_MESH_MODEL_ID_LIGHT_CTL_CLI: {
model->op = ((esp_ble_mesh_model_op_t *)light_ctl_cli_op);
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_ctl_cli_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_lighting_client_cb;
bt_mesh_light_ctl_client_t *cli = (bt_mesh_light_ctl_client_t *)model->user_data;
if (cli != NULL) {
cli->publish_status = btc_ble_mesh_lighting_client_publish_callback;
@ -1203,7 +1258,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model)
break;
}
case BLE_MESH_MODEL_ID_LIGHT_HSL_CLI: {
model->op = ((esp_ble_mesh_model_op_t *)light_hsl_cli_op);
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_hsl_cli_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_lighting_client_cb;
bt_mesh_light_hsl_client_t *cli = (bt_mesh_light_hsl_client_t *)model->user_data;
if (cli != NULL) {
cli->publish_status = btc_ble_mesh_lighting_client_publish_callback;
@ -1211,7 +1267,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model)
break;
}
case BLE_MESH_MODEL_ID_LIGHT_XYL_CLI: {
model->op = ((esp_ble_mesh_model_op_t *)light_xyl_cli_op);
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_xyl_cli_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_lighting_client_cb;
bt_mesh_light_xyl_client_t *cli = (bt_mesh_light_xyl_client_t *)model->user_data;
if (cli != NULL) {
cli->publish_status = btc_ble_mesh_lighting_client_publish_callback;
@ -1219,7 +1276,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model)
break;
}
case BLE_MESH_MODEL_ID_LIGHT_LC_CLI: {
model->op = ((esp_ble_mesh_model_op_t *)light_lc_cli_op);
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_lc_cli_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_lighting_client_cb;
bt_mesh_light_lc_client_t *cli = (bt_mesh_light_lc_client_t *)model->user_data;
if (cli != NULL) {
cli->publish_status = btc_ble_mesh_lighting_client_publish_callback;
@ -1227,7 +1285,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model)
break;
}
case BLE_MESH_MODEL_ID_SENSOR_CLI: {
model->op = ((esp_ble_mesh_model_op_t *)sensor_cli_op);
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;
bt_mesh_sensor_client_t *cli = (bt_mesh_sensor_client_t *)model->user_data;
if (cli != NULL) {
cli->publish_status = btc_ble_mesh_sensor_client_publish_callback;
@ -1235,7 +1294,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model)
break;
}
case BLE_MESH_MODEL_ID_TIME_CLI: {
model->op = ((esp_ble_mesh_model_op_t *)time_cli_op);
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;
bt_mesh_time_client_t *cli = (bt_mesh_time_client_t *)model->user_data;
if (cli != NULL) {
cli->publish_status = btc_ble_mesh_time_scene_client_publish_callback;
@ -1243,7 +1303,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model)
break;
}
case BLE_MESH_MODEL_ID_SCENE_CLI: {
model->op = ((esp_ble_mesh_model_op_t *)scene_cli_op);
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_scene_cli_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_time_scene_client_cb;
bt_mesh_scene_client_t *cli = (bt_mesh_scene_client_t *)model->user_data;
if (cli != NULL) {
cli->publish_status = btc_ble_mesh_time_scene_client_publish_callback;
@ -1251,7 +1312,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model)
break;
}
case BLE_MESH_MODEL_ID_SCHEDULER_CLI: {
model->op = ((esp_ble_mesh_model_op_t *)scheduler_cli_op);
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_scheduler_cli_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_time_scene_client_cb;
bt_mesh_scheduler_client_t *cli = (bt_mesh_scheduler_client_t *)model->user_data;
if (cli != NULL) {
cli->publish_status = btc_ble_mesh_time_scene_client_publish_callback;
@ -1259,175 +1321,204 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model)
break;
}
case BLE_MESH_MODEL_ID_GEN_ONOFF_SRV:
model->op = (esp_ble_mesh_model_op_t *)gen_onoff_srv_op;
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;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
case BLE_MESH_MODEL_ID_GEN_LEVEL_SRV:
model->op = (esp_ble_mesh_model_op_t *)gen_level_srv_op;
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_level_srv_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_gen_level_srv_cb;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
case BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_SRV:
model->op = (esp_ble_mesh_model_op_t *)gen_def_trans_time_srv_op;
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_def_trans_time_srv_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_gen_def_trans_time_srv_cb;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
case BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SRV:
model->op = (esp_ble_mesh_model_op_t *)gen_power_onoff_srv_op;
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_power_onoff_srv_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_gen_power_onoff_srv_cb;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
case BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SETUP_SRV:
model->op = (esp_ble_mesh_model_op_t *)gen_power_onoff_setup_srv_op;
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_power_onoff_setup_srv_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_gen_power_onoff_setup_srv_cb;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
case BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV:
model->op = (esp_ble_mesh_model_op_t *)gen_power_level_srv_op;
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_power_level_srv_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_gen_power_level_srv_cb;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
case BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV:
model->op = (esp_ble_mesh_model_op_t *)gen_power_level_setup_srv_op;
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_power_level_setup_srv_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_gen_power_level_setup_srv_cb;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
case BLE_MESH_MODEL_ID_GEN_BATTERY_SRV:
model->op = (esp_ble_mesh_model_op_t *)gen_battery_srv_op;
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_battery_srv_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_gen_battery_srv_cb;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
case BLE_MESH_MODEL_ID_GEN_LOCATION_SRV:
model->op = (esp_ble_mesh_model_op_t *)gen_location_srv_op;
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_location_srv_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_gen_location_srv_cb;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
case BLE_MESH_MODEL_ID_GEN_USER_PROP_SRV:
model->op = (esp_ble_mesh_model_op_t *)gen_user_prop_srv_op;
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_user_prop_srv_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_gen_user_prop_srv_cb;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
case BLE_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV:
model->op = (esp_ble_mesh_model_op_t *)gen_admin_prop_srv_op;
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_admin_prop_srv_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_gen_admin_prop_srv_cb;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
case BLE_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV:
model->op = (esp_ble_mesh_model_op_t *)gen_manu_prop_srv_op;
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_manu_prop_srv_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_gen_manu_prop_srv_cb;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
case BLE_MESH_MODEL_ID_GEN_CLIENT_PROP_SRV:
model->op = (esp_ble_mesh_model_op_t *)gen_client_prop_srv_op;
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_client_prop_srv_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_gen_client_prop_srv_cb;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
case BLE_MESH_MODEL_ID_GEN_LOCATION_SETUP_SRV:
model->op = (esp_ble_mesh_model_op_t *)gen_location_setup_srv_op;
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_location_setup_srv_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_gen_location_setup_srv_cb;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
case BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV:
model->op = (esp_ble_mesh_model_op_t *)light_lightness_srv_op;
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;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
case BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SETUP_SRV:
model->op = (esp_ble_mesh_model_op_t *)light_lightness_setup_srv_op;
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_lightness_setup_srv_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_light_lightness_setup_srv_cb;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
case BLE_MESH_MODEL_ID_LIGHT_CTL_SRV:
model->op = (esp_ble_mesh_model_op_t *)light_ctl_srv_op;
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_ctl_srv_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_light_ctl_srv_cb;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
case BLE_MESH_MODEL_ID_LIGHT_CTL_SETUP_SRV:
model->op = (esp_ble_mesh_model_op_t *)light_ctl_setup_srv_op;
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_ctl_setup_srv_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_light_ctl_setup_srv_cb;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
case BLE_MESH_MODEL_ID_LIGHT_CTL_TEMP_SRV:
model->op = (esp_ble_mesh_model_op_t *)light_ctl_temp_srv_op;
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_ctl_temp_srv_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_light_ctl_temp_srv_cb;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
case BLE_MESH_MODEL_ID_LIGHT_HSL_SRV:
model->op = (esp_ble_mesh_model_op_t *)light_hsl_srv_op;
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_hsl_srv_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_light_hsl_srv_cb;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
case BLE_MESH_MODEL_ID_LIGHT_HSL_HUE_SRV:
model->op = (esp_ble_mesh_model_op_t *)light_hsl_hue_srv_op;
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_hsl_hue_srv_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_light_hsl_hue_srv_cb;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
case BLE_MESH_MODEL_ID_LIGHT_HSL_SAT_SRV:
model->op = (esp_ble_mesh_model_op_t *)light_hsl_sat_srv_op;
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_hsl_sat_srv_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_light_hsl_sat_srv_cb;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
case BLE_MESH_MODEL_ID_LIGHT_HSL_SETUP_SRV:
model->op = (esp_ble_mesh_model_op_t *)light_hsl_setup_srv_op;
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_hsl_setup_srv_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_light_hsl_setup_srv_cb;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
case BLE_MESH_MODEL_ID_LIGHT_XYL_SRV:
model->op = (esp_ble_mesh_model_op_t *)light_xyl_srv_op;
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_xyl_srv_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_light_xyl_srv_cb;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
case BLE_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV:
model->op = (esp_ble_mesh_model_op_t *)light_xyl_setup_srv_op;
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_xyl_setup_srv_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_light_xyl_setup_srv_cb;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
case BLE_MESH_MODEL_ID_LIGHT_LC_SRV:
model->op = (esp_ble_mesh_model_op_t *)light_lc_srv_op;
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_lc_srv_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_light_lc_srv_cb;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
case BLE_MESH_MODEL_ID_LIGHT_LC_SETUP_SRV:
model->op = (esp_ble_mesh_model_op_t *)light_lc_setup_srv_op;
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_lc_setup_srv_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_light_lc_setup_srv_cb;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
case BLE_MESH_MODEL_ID_TIME_SRV:
model->op = (esp_ble_mesh_model_op_t *)time_srv_op;
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;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
case BLE_MESH_MODEL_ID_TIME_SETUP_SRV:
model->op = (esp_ble_mesh_model_op_t *)time_setup_srv_op;
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_time_setup_srv_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_time_setup_srv_cb;
if (model->pub) {
/* Time Setup Server model does not support subscribing nor publishing. */
BT_ERR("Time Setup Server shall not support publication");
@ -1435,51 +1526,57 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model)
}
break;
case BLE_MESH_MODEL_ID_SCENE_SRV:
model->op = (esp_ble_mesh_model_op_t *)scene_srv_op;
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_scene_srv_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_scene_srv_cb;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
case BLE_MESH_MODEL_ID_SCENE_SETUP_SRV:
model->op = (esp_ble_mesh_model_op_t *)scene_setup_srv_op;
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_scene_setup_srv_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_scene_setup_srv_cb;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
case BLE_MESH_MODEL_ID_SCHEDULER_SRV:
model->op = (esp_ble_mesh_model_op_t *)scheduler_srv_op;
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_scheduler_srv_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_scheduler_srv_cb;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
case BLE_MESH_MODEL_ID_SCHEDULER_SETUP_SRV:
model->op = (esp_ble_mesh_model_op_t *)scheduler_setup_srv_op;
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_scheduler_setup_srv_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_scheduler_setup_srv_cb;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
case BLE_MESH_MODEL_ID_SENSOR_SRV:
model->op = (esp_ble_mesh_model_op_t *)sensor_srv_op;
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;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
case BLE_MESH_MODEL_ID_SENSOR_SETUP_SRV:
model->op = (esp_ble_mesh_model_op_t *)sensor_setup_srv_op;
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_sensor_setup_srv_op;
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_sensor_setup_srv_cb;
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
break;
default:
goto add_model_op;
goto set_vnd_op;
}
return;
add_model_op:
set_vnd_op:
if (model->pub) {
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
}
op = model->op;
esp_ble_mesh_model_op_t *op = model->op;
while (op != NULL && op->opcode != 0) {
op->param_cb = (esp_ble_mesh_cb_t)btc_ble_mesh_server_model_op_cb;
op++;
@ -1502,30 +1599,27 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg)
switch (msg->act) {
case BTC_BLE_MESH_ACT_MESH_INIT: {
int err_code = 0;
for (int i = 0; i < arg->mesh_init.comp->element_count; i++) {
esp_ble_mesh_elem_t *elem = &arg->mesh_init.comp->elements[i];
/* For SIG models */
for (int j = 0; j < elem->sig_model_count; j++) {
esp_ble_mesh_model_t *sig_model = &elem->sig_models[j];
/* The opcode of sig model should be 1 or 2 bytes. */
if (sig_model && sig_model->op && (sig_model->op->opcode >= 0x10000)) {
err_code = -EINVAL;
btc_ble_mesh_prov_register_complete_cb(err_code);
if (sig_model->op && BLE_MESH_MODEL_OP_LEN(sig_model->op->opcode) == 3) {
/* Opcode of SIG model must be 1 or 2 bytes. */
btc_ble_mesh_prov_register_complete_cb(-EINVAL);
return;
}
btc_ble_mesh_model_op_add(sig_model);
btc_ble_mesh_model_op_set(sig_model);
}
/* For vendor models */
for (int k = 0; k < elem->vnd_model_count; k++) {
esp_ble_mesh_model_t *vnd_model = &elem->vnd_models[k];
/* The opcode of vendor model should be 3 bytes. */
if (vnd_model && vnd_model->op && vnd_model->op->opcode < 0x10000) {
err_code = -EINVAL;
btc_ble_mesh_prov_register_complete_cb(err_code);
if (vnd_model->op && BLE_MESH_MODEL_OP_LEN(vnd_model->op->opcode) < 3) {
/* Opcode of vendor model must be 3 bytes. */
btc_ble_mesh_prov_register_complete_cb(-EINVAL);
return;
}
btc_ble_mesh_model_op_add(vnd_model);
btc_ble_mesh_model_op_set(vnd_model);
}
}
#if CONFIG_BLE_MESH_NODE
@ -1559,8 +1653,8 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg)
bt_mesh_proxy_client_set_disconn_cb(btc_ble_mesh_proxy_client_disconnect_cb);
bt_mesh_proxy_client_set_filter_status_cb(btc_ble_mesh_proxy_client_filter_status_recv_cb);
#endif /* CONFIG_BLE_MESH_GATT_PROXY_CLIENT */
err_code = bt_mesh_init((struct bt_mesh_prov *)arg->mesh_init.prov,
(struct bt_mesh_comp *)arg->mesh_init.comp);
int err_code = bt_mesh_init((struct bt_mesh_prov *)arg->mesh_init.prov,
(struct bt_mesh_comp *)arg->mesh_init.comp);
/* Give the semaphore when BLE Mesh initialization is finished. */
xSemaphoreGive(arg->mesh_init.semaphore);
btc_ble_mesh_prov_register_complete_cb(err_code);

View file

@ -22,221 +22,11 @@
#include "fast_prov.h"
#include "provisioner_main.h"
#include "generic_client.h"
#include "sensor_client.h"
#include "time_scene_client.h"
#include "lighting_client.h"
#include "generic_server.h"
#include "sensor_server.h"
#include "time_scene_server.h"
#include "lighting_server.h"
#define BLE_MESH_SDU_MAX_LEN 384
static const struct bt_mesh_comp *dev_comp;
static u16_t dev_primary_addr;
static const struct {
const u16_t id;
int (*const init)(struct bt_mesh_model *model, bool primary);
} model_init[] = {
{ BLE_MESH_MODEL_ID_CFG_SRV, bt_mesh_cfg_srv_init },
{ BLE_MESH_MODEL_ID_HEALTH_SRV, bt_mesh_health_srv_init },
#if defined(CONFIG_BLE_MESH_CFG_CLI)
{ BLE_MESH_MODEL_ID_CFG_CLI, bt_mesh_cfg_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_HEALTH_CLI)
{ BLE_MESH_MODEL_ID_HEALTH_CLI, bt_mesh_health_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_ONOFF_CLI)
{ BLE_MESH_MODEL_ID_GEN_ONOFF_CLI, bt_mesh_gen_onoff_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_LEVEL_CLI)
{ BLE_MESH_MODEL_ID_GEN_LEVEL_CLI, bt_mesh_gen_level_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_DEF_TRANS_TIME_CLI)
{ BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI, bt_mesh_gen_def_trans_time_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_POWER_ONOFF_CLI)
{ BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI, bt_mesh_gen_pwr_onoff_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_POWER_LEVEL_CLI)
{ BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI, bt_mesh_gen_pwr_level_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_BATTERY_CLI)
{ BLE_MESH_MODEL_ID_GEN_BATTERY_CLI, bt_mesh_gen_battery_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_LOCATION_CLI)
{ BLE_MESH_MODEL_ID_GEN_LOCATION_CLI, bt_mesh_gen_location_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_PROPERTY_CLI)
{ BLE_MESH_MODEL_ID_GEN_PROP_CLI, bt_mesh_gen_property_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_SENSOR_CLI)
{ BLE_MESH_MODEL_ID_SENSOR_CLI, bt_mesh_sensor_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_TIME_CLI)
{ BLE_MESH_MODEL_ID_TIME_CLI, bt_mesh_time_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_SCENE_CLI)
{ BLE_MESH_MODEL_ID_SCENE_CLI, bt_mesh_scene_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_SCHEDULER_CLI)
{ BLE_MESH_MODEL_ID_SCHEDULER_CLI, bt_mesh_scheduler_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_LIGHT_LIGHTNESS_CLI)
{ BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI, bt_mesh_light_lightness_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_LIGHT_CTL_CLI)
{ BLE_MESH_MODEL_ID_LIGHT_CTL_CLI, bt_mesh_light_ctl_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_LIGHT_HSL_CLI)
{ BLE_MESH_MODEL_ID_LIGHT_HSL_CLI, bt_mesh_light_hsl_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_LIGHT_XYL_CLI)
{ BLE_MESH_MODEL_ID_LIGHT_XYL_CLI, bt_mesh_light_xyl_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_LIGHT_LC_CLI)
{ BLE_MESH_MODEL_ID_LIGHT_LC_CLI, bt_mesh_light_lc_cli_init },
#endif
{ BLE_MESH_MODEL_ID_GEN_ONOFF_SRV, bt_mesh_gen_onoff_srv_init },
{ BLE_MESH_MODEL_ID_GEN_LEVEL_SRV, bt_mesh_gen_level_srv_init },
{ BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_SRV, bt_mesh_gen_def_trans_time_srv_init },
{ BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SRV, bt_mesh_gen_power_onoff_srv_init },
{ BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SETUP_SRV, bt_mesh_gen_power_onoff_setup_srv_init },
{ BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV, bt_mesh_gen_power_level_srv_init },
{ BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV, bt_mesh_gen_power_level_setup_srv_init },
{ BLE_MESH_MODEL_ID_GEN_BATTERY_SRV, bt_mesh_gen_battery_srv_init },
{ BLE_MESH_MODEL_ID_GEN_LOCATION_SRV, bt_mesh_gen_location_srv_init },
{ BLE_MESH_MODEL_ID_GEN_LOCATION_SETUP_SRV, bt_mesh_gen_location_setup_srv_init },
{ BLE_MESH_MODEL_ID_GEN_USER_PROP_SRV, bt_mesh_gen_user_prop_srv_init },
{ BLE_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV, bt_mesh_gen_admin_prop_srv_init },
{ BLE_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV, bt_mesh_gen_manu_prop_srv_init },
{ BLE_MESH_MODEL_ID_GEN_CLIENT_PROP_SRV, bt_mesh_gen_client_prop_srv_init },
{ BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV, bt_mesh_light_lightness_srv_init },
{ BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SETUP_SRV, bt_mesh_light_lightness_setup_srv_init },
{ BLE_MESH_MODEL_ID_LIGHT_CTL_SRV, bt_mesh_light_ctl_srv_init },
{ BLE_MESH_MODEL_ID_LIGHT_CTL_SETUP_SRV, bt_mesh_light_ctl_setup_srv_init },
{ BLE_MESH_MODEL_ID_LIGHT_CTL_TEMP_SRV, bt_mesh_light_ctl_temp_srv_init },
{ BLE_MESH_MODEL_ID_LIGHT_HSL_SRV, bt_mesh_light_hsl_srv_init },
{ BLE_MESH_MODEL_ID_LIGHT_HSL_HUE_SRV, bt_mesh_light_hsl_hue_srv_init },
{ BLE_MESH_MODEL_ID_LIGHT_HSL_SAT_SRV, bt_mesh_light_hsl_sat_srv_init },
{ BLE_MESH_MODEL_ID_LIGHT_HSL_SETUP_SRV, bt_mesh_light_hsl_setup_srv_init },
{ BLE_MESH_MODEL_ID_LIGHT_XYL_SRV, bt_mesh_light_xyl_srv_init },
{ BLE_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV, bt_mesh_light_xyl_setup_srv_init },
{ BLE_MESH_MODEL_ID_LIGHT_LC_SRV, bt_mesh_light_lc_srv_init },
{ BLE_MESH_MODEL_ID_LIGHT_LC_SETUP_SRV, bt_mesh_light_lc_setup_srv_init },
{ BLE_MESH_MODEL_ID_TIME_SRV, bt_mesh_time_srv_init },
{ BLE_MESH_MODEL_ID_TIME_SETUP_SRV, bt_mesh_time_setup_srv_init },
{ BLE_MESH_MODEL_ID_SCENE_SRV, bt_mesh_scene_srv_init },
{ BLE_MESH_MODEL_ID_SCENE_SETUP_SRV, bt_mesh_scene_setup_srv_init },
{ BLE_MESH_MODEL_ID_SCHEDULER_SRV, bt_mesh_scheduler_srv_init },
{ BLE_MESH_MODEL_ID_SCHEDULER_SETUP_SRV, bt_mesh_scheduler_setup_srv_init },
{ BLE_MESH_MODEL_ID_SENSOR_SRV, bt_mesh_sensor_srv_init },
{ BLE_MESH_MODEL_ID_SENSOR_SETUP_SRV, bt_mesh_sensor_setup_srv_init },
};
static const struct {
const u16_t id;
int (*const deinit)(struct bt_mesh_model *model, bool primary);
} model_deinit[] = {
{ BLE_MESH_MODEL_ID_CFG_SRV, bt_mesh_cfg_srv_deinit },
{ BLE_MESH_MODEL_ID_HEALTH_SRV, bt_mesh_health_srv_deinit },
#if defined(CONFIG_BLE_MESH_CFG_CLI)
{ BLE_MESH_MODEL_ID_CFG_CLI, bt_mesh_cfg_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_HEALTH_CLI)
{ BLE_MESH_MODEL_ID_HEALTH_CLI, bt_mesh_health_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_ONOFF_CLI)
{ BLE_MESH_MODEL_ID_GEN_ONOFF_CLI, bt_mesh_gen_onoff_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_LEVEL_CLI)
{ BLE_MESH_MODEL_ID_GEN_LEVEL_CLI, bt_mesh_gen_level_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_DEF_TRANS_TIME_CLI)
{ BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI, bt_mesh_gen_def_trans_time_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_POWER_ONOFF_CLI)
{ BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI, bt_mesh_gen_pwr_onoff_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_POWER_LEVEL_CLI)
{ BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI, bt_mesh_gen_pwr_level_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_BATTERY_CLI)
{ BLE_MESH_MODEL_ID_GEN_BATTERY_CLI, bt_mesh_gen_battery_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_LOCATION_CLI)
{ BLE_MESH_MODEL_ID_GEN_LOCATION_CLI, bt_mesh_gen_location_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_PROPERTY_CLI)
{ BLE_MESH_MODEL_ID_GEN_PROP_CLI, bt_mesh_gen_property_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_SENSOR_CLI)
{ BLE_MESH_MODEL_ID_SENSOR_CLI, bt_mesh_sensor_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_TIME_CLI)
{ BLE_MESH_MODEL_ID_TIME_CLI, bt_mesh_time_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_SCENE_CLI)
{ BLE_MESH_MODEL_ID_SCENE_CLI, bt_mesh_scene_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_SCHEDULER_CLI)
{ BLE_MESH_MODEL_ID_SCHEDULER_CLI, bt_mesh_scheduler_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_LIGHT_LIGHTNESS_CLI)
{ BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI, bt_mesh_light_lightness_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_LIGHT_CTL_CLI)
{ BLE_MESH_MODEL_ID_LIGHT_CTL_CLI, bt_mesh_light_ctl_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_LIGHT_HSL_CLI)
{ BLE_MESH_MODEL_ID_LIGHT_HSL_CLI, bt_mesh_light_hsl_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_LIGHT_XYL_CLI)
{ BLE_MESH_MODEL_ID_LIGHT_XYL_CLI, bt_mesh_light_xyl_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_LIGHT_LC_CLI)
{ BLE_MESH_MODEL_ID_LIGHT_LC_CLI, bt_mesh_light_lc_cli_deinit },
#endif
{ BLE_MESH_MODEL_ID_GEN_ONOFF_SRV, bt_mesh_gen_onoff_srv_deinit },
{ BLE_MESH_MODEL_ID_GEN_LEVEL_SRV, bt_mesh_gen_level_srv_deinit },
{ BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_SRV, bt_mesh_gen_def_trans_time_srv_deinit },
{ BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SRV, bt_mesh_gen_power_onoff_srv_deinit },
{ BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SETUP_SRV, bt_mesh_gen_power_onoff_setup_srv_deinit },
{ BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV, bt_mesh_gen_power_level_srv_deinit },
{ BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV, bt_mesh_gen_power_level_setup_srv_deinit },
{ BLE_MESH_MODEL_ID_GEN_BATTERY_SRV, bt_mesh_gen_battery_srv_deinit },
{ BLE_MESH_MODEL_ID_GEN_LOCATION_SRV, bt_mesh_gen_location_srv_deinit },
{ BLE_MESH_MODEL_ID_GEN_LOCATION_SETUP_SRV, bt_mesh_gen_location_setup_srv_deinit },
{ BLE_MESH_MODEL_ID_GEN_USER_PROP_SRV, bt_mesh_gen_user_prop_srv_deinit },
{ BLE_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV, bt_mesh_gen_admin_prop_srv_deinit },
{ BLE_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV, bt_mesh_gen_manu_prop_srv_deinit },
{ BLE_MESH_MODEL_ID_GEN_CLIENT_PROP_SRV, bt_mesh_gen_client_prop_srv_deinit },
{ BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV, bt_mesh_light_lightness_srv_deinit },
{ BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SETUP_SRV, bt_mesh_light_lightness_setup_srv_deinit },
{ BLE_MESH_MODEL_ID_LIGHT_CTL_SRV, bt_mesh_light_ctl_srv_deinit },
{ BLE_MESH_MODEL_ID_LIGHT_CTL_SETUP_SRV, bt_mesh_light_ctl_setup_srv_deinit },
{ BLE_MESH_MODEL_ID_LIGHT_CTL_TEMP_SRV, bt_mesh_light_ctl_temp_srv_deinit },
{ BLE_MESH_MODEL_ID_LIGHT_HSL_SRV, bt_mesh_light_hsl_srv_deinit },
{ BLE_MESH_MODEL_ID_LIGHT_HSL_HUE_SRV, bt_mesh_light_hsl_hue_srv_deinit },
{ BLE_MESH_MODEL_ID_LIGHT_HSL_SAT_SRV, bt_mesh_light_hsl_sat_srv_deinit },
{ BLE_MESH_MODEL_ID_LIGHT_HSL_SETUP_SRV, bt_mesh_light_hsl_setup_srv_deinit },
{ BLE_MESH_MODEL_ID_LIGHT_XYL_SRV, bt_mesh_light_xyl_srv_deinit },
{ BLE_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV, bt_mesh_light_xyl_setup_srv_deinit },
{ BLE_MESH_MODEL_ID_LIGHT_LC_SRV, bt_mesh_light_lc_srv_deinit },
{ BLE_MESH_MODEL_ID_LIGHT_LC_SETUP_SRV, bt_mesh_light_lc_setup_srv_deinit },
{ BLE_MESH_MODEL_ID_TIME_SRV, bt_mesh_time_srv_deinit },
{ BLE_MESH_MODEL_ID_TIME_SETUP_SRV, bt_mesh_time_setup_srv_deinit },
{ BLE_MESH_MODEL_ID_SCENE_SRV, bt_mesh_scene_srv_deinit },
{ BLE_MESH_MODEL_ID_SCENE_SETUP_SRV, bt_mesh_scene_setup_srv_deinit },
{ BLE_MESH_MODEL_ID_SCHEDULER_SRV, bt_mesh_scheduler_srv_deinit },
{ BLE_MESH_MODEL_ID_SCHEDULER_SETUP_SRV, bt_mesh_scheduler_setup_srv_deinit },
{ BLE_MESH_MODEL_ID_SENSOR_SRV, bt_mesh_sensor_srv_deinit },
{ BLE_MESH_MODEL_ID_SENSOR_SETUP_SRV, bt_mesh_sensor_setup_srv_deinit },
};
void bt_mesh_model_foreach(void (*func)(struct bt_mesh_model *mod,
struct bt_mesh_elem *elem,
bool vnd, bool primary,
@ -531,8 +321,19 @@ struct bt_mesh_model *bt_mesh_model_get(bool vnd, u8_t elem_idx, u8_t mod_idx)
static void mod_init(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
bool vnd, bool primary, void *user_data)
{
int *err = user_data;
int i;
if (!user_data) {
BT_ERR("Invalid model init user data");
return;
}
if (*err) {
BT_ERR("Model init failed (err %d)", *err);
return;
}
mod->elem = elem;
if (mod->pub) {
@ -556,18 +357,27 @@ static void mod_init(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
return;
}
for (i = 0; i < ARRAY_SIZE(model_init); i++) {
if (model_init[i].id == mod->id) {
model_init[i].init(mod, primary);
}
if (mod->cb && mod->cb->init) {
*err = mod->cb->init(mod);
}
}
static void mod_deinit(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
bool vnd, bool primary, void *user_data)
{
int *err = user_data;
int i;
if (!user_data) {
BT_ERR("Invalid model deinit user data");
return;
}
if (*err) {
BT_ERR("Model deinit failed (err %d)", *err);
return;
}
mod->elem = NULL;
if (mod->pub) {
@ -587,15 +397,15 @@ static void mod_deinit(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
return;
}
for (i = 0; i < ARRAY_SIZE(model_deinit); i++) {
if (model_deinit[i].id == mod->id) {
model_deinit[i].deinit(mod, primary);
}
if (mod->cb && mod->cb->deinit) {
*err = mod->cb->deinit(mod);
}
}
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;
@ -603,23 +413,24 @@ int bt_mesh_comp_register(const struct bt_mesh_comp *comp)
dev_comp = comp;
bt_mesh_model_foreach(mod_init, NULL);
bt_mesh_model_foreach(mod_init, &err);
return 0;
return err;
}
int bt_mesh_comp_deregister(void)
{
int err = 0;
if (dev_comp == NULL) {
return -EINVAL;
}
bt_mesh_model_foreach(mod_deinit, NULL);
bt_mesh_model_foreach(mod_deinit, &err);
dev_primary_addr = BLE_MESH_ADDR_UNASSIGNED;
dev_comp = NULL;
return 0;
return err;
}
void bt_mesh_comp_provision(u16_t addr)
@ -645,8 +456,6 @@ void bt_mesh_comp_unprovision(void)
BT_DBG("%s", __func__);
dev_primary_addr = BLE_MESH_ADDR_UNASSIGNED;
bt_mesh_model_foreach(mod_init, NULL);
}
u16_t bt_mesh_primary_addr(void)
@ -668,7 +477,7 @@ u16_t *bt_mesh_model_find_group(struct bt_mesh_model *mod, u16_t addr)
}
static struct bt_mesh_model *bt_mesh_elem_find_group(struct bt_mesh_elem *elem,
u16_t group_addr)
u16_t group_addr)
{
struct bt_mesh_model *model = NULL;
u16_t *match = NULL;

View file

@ -29,10 +29,6 @@ u8_t bt_mesh_elem_count(void);
/* Find local element based on unicast or group address */
struct bt_mesh_elem *bt_mesh_elem_find(u16_t addr);
struct bt_mesh_model *bt_mesh_model_find_vnd(struct bt_mesh_elem *elem,
u16_t company, u16_t id);
struct bt_mesh_model *bt_mesh_model_find(struct bt_mesh_elem *elem, u16_t id);
u16_t *bt_mesh_model_find_group(struct bt_mesh_model *mod, u16_t addr);
bool bt_mesh_fixed_group_match(u16_t addr);

View file

@ -1240,20 +1240,18 @@ int bt_mesh_cfg_net_transmit_set(bt_mesh_client_common_param_t *param, u8_t tran
return send_msg_with_u8(param, OP_NET_TRANSMIT_SET, transmit);
}
int bt_mesh_cfg_cli_init(struct bt_mesh_model *model, bool primary)
static int cfg_cli_init(struct bt_mesh_model *model)
{
config_internal_data_t *internal = NULL;
bt_mesh_config_client_t *client = NULL;
BT_DBG("primary %u", primary);
if (!primary) {
BT_ERR("Configuration Client only allowed in primary element");
if (!model) {
BT_ERR("Invalid Configuration Client model");
return -EINVAL;
}
if (!model) {
BT_ERR("Configuration Client model is NULL");
if (!bt_mesh_model_in_primary(model)) {
BT_ERR("Configuration Client only allowed in primary element");
return -EINVAL;
}
@ -1288,17 +1286,17 @@ int bt_mesh_cfg_cli_init(struct bt_mesh_model *model, bool primary)
return 0;
}
int bt_mesh_cfg_cli_deinit(struct bt_mesh_model *model, bool primary)
static int cfg_cli_deinit(struct bt_mesh_model *model)
{
bt_mesh_config_client_t *client = NULL;
if (!primary) {
BT_ERR("Configuration Client only allowed in primary element");
if (!model) {
BT_ERR("Invalid Configuration Client model");
return -EINVAL;
}
if (!model) {
BT_ERR("Configuration Client model is NULL");
if (!bt_mesh_model_in_primary(model)) {
BT_ERR("Configuration Client only allowed in primary element");
return -EINVAL;
}
@ -1321,3 +1319,8 @@ int bt_mesh_cfg_cli_deinit(struct bt_mesh_model *model, bool primary)
return 0;
}
const struct bt_mesh_model_cb bt_mesh_cfg_cli_cb = {
.init = cfg_cli_init,
.deinit = cfg_cli_deinit,
};

View file

@ -3344,10 +3344,15 @@ static bool conf_is_valid(struct bt_mesh_cfg_srv *cfg)
return true;
}
int bt_mesh_cfg_srv_init(struct bt_mesh_model *model, bool primary)
static int cfg_srv_init(struct bt_mesh_model *model)
{
struct bt_mesh_cfg_srv *cfg = model->user_data;
if (!bt_mesh_model_in_primary(model)) {
BT_ERR("Configuration Server only allowed in primary element");
return -EINVAL;
}
if (!cfg) {
BT_ERR("No Configuration Server context provided");
return -EINVAL;
@ -3384,10 +3389,15 @@ int bt_mesh_cfg_srv_init(struct bt_mesh_model *model, bool primary)
return 0;
}
int bt_mesh_cfg_srv_deinit(struct bt_mesh_model *model, bool primary)
static int cfg_srv_deinit(struct bt_mesh_model *model)
{
struct bt_mesh_cfg_srv *cfg = model->user_data;
if (!bt_mesh_model_in_primary(model)) {
BT_ERR("Configuration Server only allowed in primary element");
return -EINVAL;
}
if (!cfg) {
BT_ERR("No Configuration Server context provided");
return -EINVAL;
@ -3403,6 +3413,11 @@ int bt_mesh_cfg_srv_deinit(struct bt_mesh_model *model, bool primary)
return 0;
}
const struct bt_mesh_model_cb bt_mesh_cfg_srv_cb = {
.init = cfg_srv_init,
.deinit = cfg_srv_deinit,
};
static void mod_reset(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
bool vnd, bool primary, void *user_data)
{

View file

@ -132,18 +132,6 @@ struct label {
bt_mesh_atomic_t flags[1];
};
int bt_mesh_cfg_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_health_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_cfg_srv_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_health_srv_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_cfg_cli_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_health_cli_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_cfg_cli_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_health_cli_deinit(struct bt_mesh_model *model, bool primary);
void bt_mesh_cfg_reset(void);
void bt_mesh_heartbeat(u16_t src, u16_t dst, u8_t hops, u16_t feat);

View file

@ -303,18 +303,18 @@ int bt_mesh_health_fault_get(bt_mesh_client_common_param_t *param, u16_t cid)
return bt_mesh_client_send_msg(param, &msg, true, timeout_handler);
}
int bt_mesh_health_cli_init(struct bt_mesh_model *model, bool primary)
static int health_cli_init(struct bt_mesh_model *model)
{
health_internal_data_t *internal = NULL;
bt_mesh_health_client_t *client = NULL;
BT_DBG("primary %u", primary);
if (!model) {
BT_ERR("%s, Invalid parameter", __func__);
BT_ERR("Invalid Health Client model");
return -EINVAL;
}
BT_DBG("primary %u", bt_mesh_model_in_primary(model));
client = (bt_mesh_health_client_t *)model->user_data;
if (!client) {
BT_ERR("No Health Client context provided");
@ -343,15 +343,17 @@ int bt_mesh_health_cli_init(struct bt_mesh_model *model, bool primary)
return 0;
}
int bt_mesh_health_cli_deinit(struct bt_mesh_model *model, bool primary)
static int health_cli_deinit(struct bt_mesh_model *model)
{
bt_mesh_health_client_t *client = NULL;
if (!model) {
BT_ERR("%s, Invalid parameter", __func__);
BT_ERR("Invalid Health Client model");
return -EINVAL;
}
BT_DBG("primary %u", bt_mesh_model_in_primary(model));
client = (bt_mesh_health_client_t *)model->user_data;
if (!client) {
BT_ERR("No Health Client context provided");
@ -371,3 +373,8 @@ int bt_mesh_health_cli_deinit(struct bt_mesh_model *model, bool primary)
return 0;
}
const struct bt_mesh_model_cb bt_mesh_health_cli_cb = {
.init = health_cli_init,
.deinit = health_cli_deinit,
};

View file

@ -429,7 +429,7 @@ static void attention_off(struct k_work *work)
srv->attn_timer_start = false;
}
int bt_mesh_health_srv_init(struct bt_mesh_model *model, bool primary)
static int health_srv_init(struct bt_mesh_model *model)
{
struct bt_mesh_health_srv *srv = model->user_data;
@ -438,11 +438,6 @@ int bt_mesh_health_srv_init(struct bt_mesh_model *model, bool primary)
*/
if (!srv) {
if (!primary) {
/* If Health Server is in the secondary element with NULL user_data. */
return 0;
}
BT_ERR("No Health Server context provided");
return -EINVAL;
}
@ -467,23 +462,18 @@ int bt_mesh_health_srv_init(struct bt_mesh_model *model, bool primary)
memset(srv->test.curr_faults, HEALTH_NO_FAULT, ARRAY_SIZE(srv->test.curr_faults));
memset(srv->test.reg_faults, HEALTH_NO_FAULT, ARRAY_SIZE(srv->test.reg_faults));
if (primary) {
if (bt_mesh_model_in_primary(model)) {
health_srv = srv;
}
return 0;
}
int bt_mesh_health_srv_deinit(struct bt_mesh_model *model, bool primary)
static int health_srv_deinit(struct bt_mesh_model *model)
{
struct bt_mesh_health_srv *srv = model->user_data;
if (!srv) {
if (!primary) {
/* If Health Server is in the secondary element with NULL user_data. */
return 0;
}
BT_ERR("No Health Server context provided");
return -EINVAL;
}
@ -503,13 +493,18 @@ int bt_mesh_health_srv_deinit(struct bt_mesh_model *model, bool primary)
k_delayed_work_free(&srv->attn_timer);
if (primary) {
if (bt_mesh_model_in_primary(model)) {
health_srv = NULL;
}
return 0;
}
const struct bt_mesh_model_cb bt_mesh_health_srv_cb = {
.init = health_srv_init,
.deinit = health_srv_deinit,
};
void bt_mesh_attention(struct bt_mesh_model *model, u8_t time)
{
struct bt_mesh_health_srv *srv = NULL;

View file

@ -29,10 +29,11 @@ typedef bt_mesh_client_user_data_t bt_mesh_config_client_t;
typedef bt_mesh_client_internal_data_t config_internal_data_t;
extern const struct bt_mesh_model_op bt_mesh_cfg_cli_op[];
extern const struct bt_mesh_model_cb bt_mesh_cfg_cli_cb;
#define BLE_MESH_MODEL_CFG_CLI(cli_data) \
BLE_MESH_MODEL(BLE_MESH_MODEL_ID_CFG_CLI, \
bt_mesh_cfg_cli_op, NULL, cli_data)
BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_CFG_CLI, \
bt_mesh_cfg_cli_op, NULL, cli_data, &bt_mesh_cfg_cli_cb)
int bt_mesh_cfg_comp_data_get(bt_mesh_client_common_param_t *param, u8_t page);

View file

@ -63,10 +63,11 @@ struct bt_mesh_cfg_srv {
};
extern const struct bt_mesh_model_op bt_mesh_cfg_srv_op[];
extern const struct bt_mesh_model_cb bt_mesh_cfg_srv_cb;
#define BLE_MESH_MODEL_CFG_SRV(srv_data) \
BLE_MESH_MODEL(BLE_MESH_MODEL_ID_CFG_SRV, \
bt_mesh_cfg_srv_op, NULL, srv_data)
BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_CFG_SRV, \
bt_mesh_cfg_srv_op, NULL, srv_data, &bt_mesh_cfg_srv_cb)
typedef union {
struct {

View file

@ -29,10 +29,11 @@ typedef bt_mesh_client_user_data_t bt_mesh_health_client_t;
typedef bt_mesh_client_internal_data_t health_internal_data_t;
extern const struct bt_mesh_model_op bt_mesh_health_cli_op[];
extern const struct bt_mesh_model_cb bt_mesh_health_cli_cb;
#define BLE_MESH_MODEL_HEALTH_CLI(cli_data) \
BLE_MESH_MODEL(BLE_MESH_MODEL_ID_HEALTH_CLI, \
bt_mesh_health_cli_op, NULL, cli_data)
BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_HEALTH_CLI, \
bt_mesh_health_cli_op, NULL, cli_data, &bt_mesh_health_cli_cb)
int bt_mesh_health_fault_get(bt_mesh_client_common_param_t *param, u16_t cid);

View file

@ -75,6 +75,7 @@ struct bt_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;
/** @def BLE_MESH_MODEL_HEALTH_SRV
*
@ -89,8 +90,8 @@ extern const struct bt_mesh_model_op bt_mesh_health_srv_op[];
* @return New mesh model instance.
*/
#define BLE_MESH_MODEL_HEALTH_SRV(srv, pub) \
BLE_MESH_MODEL(BLE_MESH_MODEL_ID_HEALTH_SRV, \
bt_mesh_health_srv_op, pub, srv)
BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_HEALTH_SRV, \
bt_mesh_health_srv_op, pub, srv, &bt_mesh_health_srv_cb)
int bt_mesh_fault_update(struct bt_mesh_elem *elem);

View file

@ -190,12 +190,12 @@ struct bt_mesh_model_op {
{ BLE_MESH_MODEL_OP_END })
/** Helper to define an empty model array */
#define BLE_MESH_MODEL_NONE ((struct bt_mesh_model []){})
#define BLE_MESH_MODEL_NONE ((struct bt_mesh_model []){})
/** Length of a short Mesh MIC. */
#define BLE_MESH_MIC_SHORT 4
#define BLE_MESH_MIC_SHORT 4
/** Length of a long Mesh MIC. */
#define BLE_MESH_MIC_LONG 8
#define BLE_MESH_MIC_LONG 8
/** @def BLE_MESH_MODEL_OP_LEN
*
@ -240,31 +240,54 @@ struct bt_mesh_model_op {
* @param _payload_len Length of the model message payload.
*/
#define BLE_MESH_MODEL_BUF_DEFINE(_buf, _op, _payload_len) \
NET_BUF_SIMPLE_DEFINE(_buf, BLE_MESH_MODEL_BUF_LEN(_op, (_payload_len)))
NET_BUF_SIMPLE_DEFINE(_buf, BLE_MESH_MODEL_BUF_LEN((_op), (_payload_len)))
#define BLE_MESH_MODEL(_id, _op, _pub, _user_data) \
/** @def BLE_MESH_MODEL_CB
*
* @brief Composition data SIG model entry with callback functions.
*
* @param _id Model ID.
* @param _op Array of model opcode handlers.
* @param _pub Model publish parameters.
* @param _user_data User data for the model.
* @param _cb Callback structure, or NULL to keep no callbacks.
*/
#define BLE_MESH_MODEL_CB(_id, _op, _pub, _user_data, _cb) \
{ \
.id = (_id), \
.op = _op, \
.op = (_op), \
.keys = { [0 ... (CONFIG_BLE_MESH_MODEL_KEY_COUNT - 1)] = \
BLE_MESH_KEY_UNUSED }, \
.pub = _pub, \
.pub = (_pub), \
.groups = { [0 ... (CONFIG_BLE_MESH_MODEL_GROUP_COUNT - 1)] = \
BLE_MESH_ADDR_UNASSIGNED }, \
.user_data = _user_data, \
.user_data = (_user_data), \
.cb = (_cb), \
}
#define BLE_MESH_MODEL_VND(_company, _id, _op, _pub, _user_data) \
/** @def BLE_MESH_MODEL_VND_CB
*
* @brief Composition data vendor model entry with callback functions.
*
* @param _company Company ID.
* @param _id Model ID.
* @param _op Array of model opcode handlers.
* @param _pub Model publish parameters.
* @param _user_data User data for the model.
* @param _cb Callback structure, or NULL to keep no callbacks.
*/
#define BLE_MESH_MODEL_VND_CB(_company, _id, _op, _pub, _user_data, _cb) \
{ \
.vnd.company = (_company), \
.vnd.id = (_id), \
.op = _op, \
.pub = _pub, \
.op = (_op), \
.pub = (_pub), \
.keys = { [0 ... (CONFIG_BLE_MESH_MODEL_KEY_COUNT - 1)] = \
BLE_MESH_KEY_UNUSED }, \
.groups = { [0 ... (CONFIG_BLE_MESH_MODEL_GROUP_COUNT - 1)] = \
BLE_MESH_ADDR_UNASSIGNED }, \
.user_data = _user_data, \
.user_data = (_user_data), \
.cb = (_cb), \
}
/** @def BLE_MESH_TRANSMIT
@ -278,7 +301,7 @@ struct bt_mesh_model_op {
* @return Mesh transmit value that can be used e.g. for the default
* values of the configuration model data.
*/
#define BLE_MESH_TRANSMIT(count, int_ms) ((count) | (((int_ms / 10) - 1) << 3))
#define BLE_MESH_TRANSMIT(count, int_ms) ((count) | ((((int_ms) / 10) - 1) << 3))
/** @def BLE_MESH_TRANSMIT_COUNT
*
@ -311,7 +334,7 @@ struct bt_mesh_model_op {
* @return Mesh transmit value that can be used e.g. for the default
* values of the configuration model data.
*/
#define BLE_MESH_PUB_TRANSMIT(count, int_ms) BLE_MESH_TRANSMIT(count, (int_ms) / 5)
#define BLE_MESH_PUB_TRANSMIT(count, int_ms) BLE_MESH_TRANSMIT((count), (int_ms) / 5)
/** @def BLE_MESH_PUB_TRANSMIT_COUNT
*
@ -400,6 +423,36 @@ struct bt_mesh_model_pub {
.msg = &bt_mesh_pub_msg_##_name, \
}
/** Model callback functions. */
struct bt_mesh_model_cb {
/** @brief Model init callback.
*
* Called on every model instance during mesh initialization.
*
* If any of the model init callbacks return an error, the mesh
* subsystem initialization will be aborted, and the error will
* be returned to the caller of @ref bt_mesh_init.
*
* @param model Model to be initialized.
*
* @return 0 on success, error otherwise.
*/
int (*const init)(struct bt_mesh_model *model);
/** @brief Model deinit callback.
*
* Called on every model instance during mesh deinitialization.
* All model data is deleted, and the model should clear its state.
*
* If any of the model deinit callbacks return an error, the mesh
* subsystem deinitialization will be aborted, and the error will
* be returned to the caller of @ref bt_mesh_deinit.
*
* @param model Model to be de-initialized.
*/
int (*const deinit)(struct bt_mesh_model *model);
};
/** Abstraction that describes a Mesh Model instance */
struct bt_mesh_model {
union {
@ -427,8 +480,12 @@ struct bt_mesh_model {
/* Subscription List (group or virtual addresses) */
u16_t groups[CONFIG_BLE_MESH_MODEL_GROUP_COUNT];
/** Opcode handler list */
const struct bt_mesh_model_op *const op;
/** Model callback structure. */
const struct bt_mesh_model_cb *const cb;
/* Model-specific user data */
void *user_data;
};
@ -488,6 +545,39 @@ int bt_mesh_model_publish(struct bt_mesh_model *model);
*/
struct bt_mesh_elem *bt_mesh_model_elem(struct bt_mesh_model *mod);
/** @brief Find a SIG model.
*
* @param elem Element to search for the model in.
* @param id Model ID of the model.
*
* @return A pointer to the Mesh model matching the given parameters, or NULL
* if no SIG model with the given ID exists in the given element.
*/
struct bt_mesh_model *bt_mesh_model_find(struct bt_mesh_elem *elem, u16_t id);
/** @brief Find a vendor model.
*
* @param elem Element to search for the model in.
* @param company Company ID of the model.
* @param id Model ID of the model.
*
* @return A pointer to the Mesh model matching the given parameters, or NULL
* if no vendor model with the given ID exists in the given element.
*/
struct bt_mesh_model *bt_mesh_model_find_vnd(struct bt_mesh_elem *elem,
u16_t company, u16_t id);
/** @brief Get whether the model is in the primary element of the device.
*
* @param mod Mesh model.
*
* @return true if the model is on the primary element, false otherwise.
*/
static inline bool bt_mesh_model_in_primary(const struct bt_mesh_model *mod)
{
return (mod->elem_idx == 0);
}
/** Node Composition */
struct bt_mesh_comp {
u16_t cid;

View file

@ -496,6 +496,8 @@ int bt_mesh_deinit(struct bt_mesh_deinit_param *param)
return err;
}
bt_mesh_comp_unprovision();
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
if (param->erase) {
bt_mesh_clear_role();

View file

@ -142,7 +142,7 @@ static bool bt_mesh_client_check_node_in_list(sys_slist_t *list, u16_t tx_dst)
}
static u32_t bt_mesh_client_get_status_op(const bt_mesh_client_op_pair_t *op_pair,
int size, u32_t opcode)
int size, u32_t opcode)
{
if (!op_pair || size == 0) {
return 0;
@ -381,25 +381,20 @@ void bt_mesh_client_model_unlock(void)
int bt_mesh_client_init(struct bt_mesh_model *model)
{
bt_mesh_client_internal_data_t *data = NULL;
bt_mesh_client_user_data_t *cli = NULL;
bt_mesh_client_user_data_t *client = NULL;
if (!model) {
BT_ERR("%s, Invalid parameter", __func__);
if (!model || !model->op) {
BT_ERR("Invalid vendor client model");
return -EINVAL;
}
if (!model->op) {
BT_ERR("Invalid vendor client model op");
client = (bt_mesh_client_user_data_t *)model->user_data;
if (!client) {
BT_ERR("No vendor client context provided");
return -EINVAL;
}
cli = model->user_data;
if (!cli) {
BT_ERR("Invalid vendor client user data");
return -EINVAL;
}
if (!cli->internal_data) {
if (!client->internal_data) {
data = bt_mesh_calloc(sizeof(bt_mesh_client_internal_data_t));
if (!data) {
BT_ERR("%s, Out of memory", __func__);
@ -409,10 +404,10 @@ int bt_mesh_client_init(struct bt_mesh_model *model)
/* Init the client data queue */
sys_slist_init(&data->queue);
cli->model = model;
cli->internal_data = data;
client->model = model;
client->internal_data = data;
} else {
bt_mesh_client_clear_list(cli->internal_data);
bt_mesh_client_clear_list(client->internal_data);
}
bt_mesh_client_model_mutex_new();
@ -425,13 +420,13 @@ int bt_mesh_client_deinit(struct bt_mesh_model *model)
bt_mesh_client_user_data_t *client = NULL;
if (!model) {
BT_ERR("%s, Invalid parameter", __func__);
BT_ERR("Invalid vendor client model");
return -EINVAL;
}
client = (bt_mesh_client_user_data_t *)model->user_data;
if (!client) {
BT_ERR("Invalid vendor client user data");
BT_ERR("No vendor client context provided");
return -EINVAL;
}

View file

@ -636,27 +636,27 @@ static void generic_status(struct bt_mesh_model *model,
return;
}
const struct bt_mesh_model_op gen_onoff_cli_op[] = {
const struct bt_mesh_model_op bt_mesh_gen_onoff_cli_op[] = {
{ BLE_MESH_MODEL_OP_GEN_ONOFF_STATUS, 1, generic_status },
BLE_MESH_MODEL_OP_END,
};
const struct bt_mesh_model_op gen_level_cli_op[] = {
const struct bt_mesh_model_op bt_mesh_gen_level_cli_op[] = {
{ BLE_MESH_MODEL_OP_GEN_LEVEL_STATUS, 2, generic_status },
BLE_MESH_MODEL_OP_END,
};
const struct bt_mesh_model_op gen_def_trans_time_cli_op[] = {
const struct bt_mesh_model_op bt_mesh_gen_def_trans_time_cli_op[] = {
{ BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_STATUS, 1, generic_status },
BLE_MESH_MODEL_OP_END,
};
const struct bt_mesh_model_op gen_power_onoff_cli_op[] = {
const struct bt_mesh_model_op bt_mesh_gen_power_onoff_cli_op[] = {
{ BLE_MESH_MODEL_OP_GEN_ONPOWERUP_STATUS, 1, generic_status },
BLE_MESH_MODEL_OP_END,
};
const struct bt_mesh_model_op gen_power_level_cli_op[] = {
const struct bt_mesh_model_op bt_mesh_gen_power_level_cli_op[] = {
{ BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_STATUS, 2, generic_status },
{ BLE_MESH_MODEL_OP_GEN_POWER_LAST_STATUS, 2, generic_status },
{ BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_STATUS, 2, generic_status },
@ -664,18 +664,18 @@ const struct bt_mesh_model_op gen_power_level_cli_op[] = {
BLE_MESH_MODEL_OP_END,
};
const struct bt_mesh_model_op gen_battery_cli_op[] = {
const struct bt_mesh_model_op bt_mesh_gen_battery_cli_op[] = {
{ BLE_MESH_MODEL_OP_GEN_BATTERY_STATUS, 8, generic_status },
BLE_MESH_MODEL_OP_END,
};
const struct bt_mesh_model_op gen_location_cli_op[] = {
const struct bt_mesh_model_op bt_mesh_gen_location_cli_op[] = {
{ BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_STATUS, 10, generic_status },
{ BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_STATUS, 9, generic_status },
BLE_MESH_MODEL_OP_END,
};
const struct bt_mesh_model_op gen_property_cli_op[] = {
const struct bt_mesh_model_op bt_mesh_gen_property_cli_op[] = {
{ BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_STATUS, 2, generic_status },
{ BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_STATUS, 2, generic_status },
{ BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTIES_STATUS, 2, generic_status },
@ -1134,21 +1134,19 @@ int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void
return gen_set_state(common, set, length, need_ack);
}
static int generic_client_init(struct bt_mesh_model *model, bool primary)
static int generic_client_init(struct bt_mesh_model *model)
{
generic_internal_data_t *internal = NULL;
bt_mesh_generic_client_t *client = NULL;
BT_DBG("primary %u", primary);
if (!model) {
BT_ERR("%s, Invalid parameter", __func__);
BT_ERR("Invalid Generic client model");
return -EINVAL;
}
client = (bt_mesh_generic_client_t *)model->user_data;
if (!client) {
BT_ERR("Invalid Generic client user data");
BT_ERR("No Generic client context provided");
return -EINVAL;
}
@ -1174,58 +1172,18 @@ static int generic_client_init(struct bt_mesh_model *model, bool primary)
return 0;
}
int bt_mesh_gen_onoff_cli_init(struct bt_mesh_model *model, bool primary)
{
return generic_client_init(model, primary);
}
int bt_mesh_gen_level_cli_init(struct bt_mesh_model *model, bool primary)
{
return generic_client_init(model, primary);
}
int bt_mesh_gen_def_trans_time_cli_init(struct bt_mesh_model *model, bool primary)
{
return generic_client_init(model, primary);
}
int bt_mesh_gen_pwr_onoff_cli_init(struct bt_mesh_model *model, bool primary)
{
return generic_client_init(model, primary);
}
int bt_mesh_gen_pwr_level_cli_init(struct bt_mesh_model *model, bool primary)
{
return generic_client_init(model, primary);
}
int bt_mesh_gen_battery_cli_init(struct bt_mesh_model *model, bool primary)
{
return generic_client_init(model, primary);
}
int bt_mesh_gen_location_cli_init(struct bt_mesh_model *model, bool primary)
{
return generic_client_init(model, primary);
}
int bt_mesh_gen_property_cli_init(struct bt_mesh_model *model, bool primary)
{
return generic_client_init(model, primary);
}
static int generic_client_deinit(struct bt_mesh_model *model, bool primary)
static int generic_client_deinit(struct bt_mesh_model *model)
{
bt_mesh_generic_client_t *client = NULL;
if (!model) {
BT_ERR("%s, Invalid parameter", __func__);
BT_ERR("Invalid Generic client model");
return -EINVAL;
}
client = (bt_mesh_generic_client_t *)model->user_data;
if (!client) {
BT_ERR("Invalid Generic client user data");
BT_ERR("No Generic client context provided");
return -EINVAL;
}
@ -1243,42 +1201,7 @@ static int generic_client_deinit(struct bt_mesh_model *model, bool primary)
return 0;
}
int bt_mesh_gen_onoff_cli_deinit(struct bt_mesh_model *model, bool primary)
{
return generic_client_deinit(model, primary);
}
int bt_mesh_gen_level_cli_deinit(struct bt_mesh_model *model, bool primary)
{
return generic_client_deinit(model, primary);
}
int bt_mesh_gen_def_trans_time_cli_deinit(struct bt_mesh_model *model, bool primary)
{
return generic_client_deinit(model, primary);
}
int bt_mesh_gen_pwr_onoff_cli_deinit(struct bt_mesh_model *model, bool primary)
{
return generic_client_deinit(model, primary);
}
int bt_mesh_gen_pwr_level_cli_deinit(struct bt_mesh_model *model, bool primary)
{
return generic_client_deinit(model, primary);
}
int bt_mesh_gen_battery_cli_deinit(struct bt_mesh_model *model, bool primary)
{
return generic_client_deinit(model, primary);
}
int bt_mesh_gen_location_cli_deinit(struct bt_mesh_model *model, bool primary)
{
return generic_client_deinit(model, primary);
}
int bt_mesh_gen_property_cli_deinit(struct bt_mesh_model *model, bool primary)
{
return generic_client_deinit(model, primary);
}
const struct bt_mesh_model_cb bt_mesh_generic_client_cb = {
.init = generic_client_init,
.deinit = generic_client_deinit,
};

View file

@ -29,8 +29,11 @@ extern "C" {
typedef bt_mesh_client_user_data_t bt_mesh_generic_client_t;
typedef bt_mesh_client_internal_data_t generic_internal_data_t;
/* Generic Client Model Callback */
extern const struct bt_mesh_model_cb bt_mesh_generic_client_cb;
/* Generic OnOff Client Model Context */
extern const struct bt_mesh_model_op gen_onoff_cli_op[];
extern const struct bt_mesh_model_op bt_mesh_gen_onoff_cli_op[];
/** @def BLE_MESH_MODEL_GEN_ONOFF_CLI
*
@ -43,8 +46,8 @@ extern const struct bt_mesh_model_op gen_onoff_cli_op[];
* @return New generic onoff client model instance.
*/
#define BLE_MESH_MODEL_GEN_ONOFF_CLI(cli_pub, cli_data) \
BLE_MESH_MODEL(BLE_MESH_MODEL_ID_GEN_ONOFF_CLI, \
gen_onoff_cli_op, cli_pub, cli_data)
BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_GEN_ONOFF_CLI, \
bt_mesh_gen_onoff_cli_op, cli_pub, cli_data, &bt_mesh_generic_client_cb)
typedef bt_mesh_client_user_data_t bt_mesh_gen_onoff_client_t;
@ -64,7 +67,7 @@ struct bt_mesh_gen_onoff_set {
};
/* Generic Level Client Model Context */
extern const struct bt_mesh_model_op gen_level_cli_op[];
extern const struct bt_mesh_model_op bt_mesh_gen_level_cli_op[];
/** @def BLE_MESH_MODEL_GEN_LEVEL_CLI
*
@ -77,8 +80,8 @@ extern const struct bt_mesh_model_op gen_level_cli_op[];
* @return New generic level client model instance.
*/
#define BLE_MESH_MODEL_GEN_LEVEL_CLI(cli_pub, cli_data) \
BLE_MESH_MODEL(BLE_MESH_MODEL_ID_GEN_LEVEL_CLI, \
gen_level_cli_op, cli_pub, cli_data)
BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_GEN_LEVEL_CLI, \
bt_mesh_gen_level_cli_op, cli_pub, cli_data, &bt_mesh_generic_client_cb)
typedef bt_mesh_client_user_data_t bt_mesh_gen_level_client_t;
@ -114,7 +117,7 @@ struct bt_mesh_gen_move_set {
};
/* Generic Default Transition Time Client Model Context */
extern const struct bt_mesh_model_op gen_def_trans_time_cli_op[];
extern const struct bt_mesh_model_op bt_mesh_gen_def_trans_time_cli_op[];
/** @def BLE_MESH_MODEL_GEN_DEF_TRANS_TIME_CLI
*
@ -128,8 +131,8 @@ extern const struct bt_mesh_model_op gen_def_trans_time_cli_op[];
* @return New generic default transition time client model instance.
*/
#define BLE_MESH_MODEL_GEN_DEF_TRANS_TIME_CLI(cli_pub, cli_data) \
BLE_MESH_MODEL(BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI, \
gen_def_trans_time_cli_op, cli_pub, cli_data)
BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI, \
bt_mesh_gen_def_trans_time_cli_op, cli_pub, cli_data, &bt_mesh_generic_client_cb)
typedef bt_mesh_client_user_data_t bt_mesh_gen_def_trans_time_client_t;
@ -142,7 +145,7 @@ struct bt_mesh_gen_def_trans_time_status {
};
/* Generic Power OnOff Client Model Context */
extern const struct bt_mesh_model_op gen_power_onoff_cli_op[];
extern const struct bt_mesh_model_op bt_mesh_gen_power_onoff_cli_op[];
/** @def BLE_MESH_MODEL_GEN_POWER_ONOFF_CLI
*
@ -155,8 +158,8 @@ extern const struct bt_mesh_model_op gen_power_onoff_cli_op[];
* @return New generic power onoff client model instance.
*/
#define BLE_MESH_MODEL_GEN_POWER_ONOFF_CLI(cli_pub, cli_data) \
BLE_MESH_MODEL(BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI, \
gen_power_onoff_cli_op, cli_pub, cli_data)
BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI, \
bt_mesh_gen_power_onoff_cli_op, cli_pub, cli_data, &bt_mesh_generic_client_cb)
typedef bt_mesh_client_user_data_t bt_mesh_gen_power_onoff_client_t;
@ -169,7 +172,7 @@ struct bt_mesh_gen_onpowerup_status {
};
/* Generic Power Level Client Model Context */
extern const struct bt_mesh_model_op gen_power_level_cli_op[];
extern const struct bt_mesh_model_op bt_mesh_gen_power_level_cli_op[];
/** @def BLE_MESH_MODEL_GEN_POWER_LEVEL_CLI
*
@ -182,8 +185,8 @@ extern const struct bt_mesh_model_op gen_power_level_cli_op[];
* @return New generic power level client model instance.
*/
#define BLE_MESH_MODEL_GEN_POWER_LEVEL_CLI(cli_pub, cli_data) \
BLE_MESH_MODEL(BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI, \
gen_power_level_cli_op, cli_pub, cli_data)
BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI, \
bt_mesh_gen_power_level_cli_op, cli_pub, cli_data, &bt_mesh_generic_client_cb)
typedef bt_mesh_client_user_data_t bt_mesh_gen_power_level_client_t;
@ -226,7 +229,7 @@ struct bt_mesh_gen_power_range_set {
};
/* Generic Battery Client Model Context */
extern const struct bt_mesh_model_op gen_battery_cli_op[];
extern const struct bt_mesh_model_op bt_mesh_gen_battery_cli_op[];
/** @def BLE_MESH_MODEL_GEN_BATTERY_CLI
*
@ -239,8 +242,8 @@ extern const struct bt_mesh_model_op gen_battery_cli_op[];
* @return New generic battery client model instance.
*/
#define BLE_MESH_MODEL_GEN_BATTERY_CLI(cli_pub, cli_data) \
BLE_MESH_MODEL(BLE_MESH_MODEL_ID_GEN_BATTERY_CLI, \
gen_battery_cli_op, cli_pub, cli_data)
BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_GEN_BATTERY_CLI, \
bt_mesh_gen_battery_cli_op, cli_pub, cli_data, &bt_mesh_generic_client_cb)
typedef bt_mesh_client_user_data_t bt_mesh_gen_battery_client_t;
@ -252,7 +255,7 @@ struct bt_mesh_gen_battery_status {
};
/* Generic Location Client Model Context */
extern const struct bt_mesh_model_op gen_location_cli_op[];
extern const struct bt_mesh_model_op bt_mesh_gen_location_cli_op[];
/** @def BLE_MESH_MODEL_GEN_LOCATION_CLI
*
@ -265,8 +268,8 @@ extern const struct bt_mesh_model_op gen_location_cli_op[];
* @return New generic location client model instance.
*/
#define BLE_MESH_MODEL_GEN_LOCATION_CLI(cli_pub, cli_data) \
BLE_MESH_MODEL(BLE_MESH_MODEL_ID_GEN_LOCATION_CLI, \
gen_location_cli_op, cli_pub, cli_data)
BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_GEN_LOCATION_CLI, \
bt_mesh_gen_location_cli_op, cli_pub, cli_data, &bt_mesh_generic_client_cb)
typedef bt_mesh_client_user_data_t bt_mesh_gen_location_client_t;
@ -299,7 +302,7 @@ struct bt_mesh_gen_loc_local_set {
};
/* Generic Property Client Model Context */
extern const struct bt_mesh_model_op gen_property_cli_op[];
extern const struct bt_mesh_model_op bt_mesh_gen_property_cli_op[];
/** @def BLE_MESH_MODEL_GEN_LOCATION_CLI
*
@ -312,8 +315,8 @@ extern const struct bt_mesh_model_op gen_property_cli_op[];
* @return New generic location client model instance.
*/
#define BLE_MESH_MODEL_GEN_PROPERTY_CLI(cli_pub, cli_data) \
BLE_MESH_MODEL(BLE_MESH_MODEL_ID_GEN_PROP_CLI, \
gen_property_cli_op, cli_pub, cli_data)
BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_GEN_PROP_CLI, \
bt_mesh_gen_property_cli_op, cli_pub, cli_data, &bt_mesh_generic_client_cb)
typedef bt_mesh_client_user_data_t bt_mesh_gen_property_client_t;
@ -386,168 +389,6 @@ struct bt_mesh_gen_client_properties_get {
u16_t client_property_id; /* A starting Client Property ID present within an element */
};
/**
* @brief This function is called to initialize generic onoff client model user_data.
*
* @param[in] model: Pointer to generic onoff client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_gen_onoff_cli_init(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to initialize generic level client model user_data.
*
* @param[in] model: Pointer to generic level client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_gen_level_cli_init(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to initialize generic default transition time
* client model user_data.
*
* @param[in] model: Pointer to generic default transition time client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_gen_def_trans_time_cli_init(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to initialize generic power onoff client model user_data.
*
* @param[in] model: Pointer to generic power onoff client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_gen_pwr_onoff_cli_init(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to initialize generic power level client model user_data.
*
* @param[in] model: Pointer to generic power level client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_gen_pwr_level_cli_init(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to initialize generic battery client model user_data.
*
* @param[in] model: Pointer to generic battery client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_gen_battery_cli_init(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to initialize generic location client model user_data.
*
* @param[in] model: Pointer to generic location client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_gen_location_cli_init(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to initialize generic property client model user_data.
*
* @param[in] model: Pointer to generic property client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_gen_property_cli_init(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to de-initialize generic onoff client model user_data.
*
* @param[in] model: Pointer to generic onoff client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_gen_onoff_cli_deinit(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to de-initialize generic level client model user_data.
*
* @param[in] model: Pointer to generic level client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_gen_level_cli_deinit(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to de-initialize generic default transition time
* client model user_data.
*
* @param[in] model: Pointer to generic default transition time client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_gen_def_trans_time_cli_deinit(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to de-initialize generic power onoff client model user_data.
*
* @param[in] model: Pointer to generic power onoff client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_gen_pwr_onoff_cli_deinit(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to de-initialize generic power level client model user_data.
*
* @param[in] model: Pointer to generic power level client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_gen_pwr_level_cli_deinit(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to de-initialize generic battery client model user_data.
*
* @param[in] model: Pointer to generic battery client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_gen_battery_cli_deinit(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to de-initialize generic location client model user_data.
*
* @param[in] model: Pointer to generic location client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_gen_location_cli_deinit(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to de-initialize generic property client model user_data.
*
* @param[in] model: Pointer to generic property client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_gen_property_cli_deinit(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to get generic states.
*

View file

@ -29,8 +29,11 @@ extern "C" {
typedef bt_mesh_client_user_data_t bt_mesh_light_client_t;
typedef bt_mesh_client_internal_data_t light_internal_data_t;
/* Lighting Client Model Callback */
extern const struct bt_mesh_model_cb bt_mesh_lighting_client_cb;
/* Light Lightness Client Model Context */
extern const struct bt_mesh_model_op light_lightness_cli_op[];
extern const struct bt_mesh_model_op bt_mesh_light_lightness_cli_op[];
/** @def BLE_MESH_MODEL_LIGHT_LIGHTNESS_CLI
*
@ -43,8 +46,8 @@ extern const struct bt_mesh_model_op light_lightness_cli_op[];
* @return New light lightness client model instance.
*/
#define BLE_MESH_MODEL_LIGHT_LIGHTNESS_CLI(cli_pub, cli_data) \
BLE_MESH_MODEL(BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI, \
light_lightness_cli_op, cli_pub, cli_data)
BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI, \
bt_mesh_light_lightness_cli_op, cli_pub, cli_data, &bt_mesh_lighting_client_cb)
typedef bt_mesh_client_user_data_t bt_mesh_light_lightness_client_t;
@ -102,7 +105,7 @@ struct bt_mesh_light_lightness_range_set {
};
/* Light CTL Client Model Context */
extern const struct bt_mesh_model_op light_ctl_cli_op[];
extern const struct bt_mesh_model_op bt_mesh_light_ctl_cli_op[];
/** @def BLE_MESH_MODEL_LIGHT_CTL_CLI
*
@ -115,8 +118,8 @@ extern const struct bt_mesh_model_op light_ctl_cli_op[];
* @return New light CTL client model instance.
*/
#define BLE_MESH_MODEL_LIGHT_CTL_CLI(cli_pub, cli_data) \
BLE_MESH_MODEL(BLE_MESH_MODEL_ID_LIGHT_CTL_CLI, \
light_ctl_cli_op, cli_pub, cli_data)
BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_LIGHT_CTL_CLI, \
bt_mesh_light_ctl_cli_op, cli_pub, cli_data, &bt_mesh_lighting_client_cb)
typedef bt_mesh_client_user_data_t bt_mesh_light_ctl_client_t;
@ -181,7 +184,7 @@ struct bt_mesh_light_ctl_default_set {
};
/* Light HSL Client Model Context */
extern const struct bt_mesh_model_op light_hsl_cli_op[];
extern const struct bt_mesh_model_op bt_mesh_light_hsl_cli_op[];
/** @def BLE_MESH_MODEL_LIGHT_HSL_CLI
*
@ -194,8 +197,8 @@ extern const struct bt_mesh_model_op light_hsl_cli_op[];
* @return New light HSL client model instance.
*/
#define BLE_MESH_MODEL_LIGHT_HSL_CLI(cli_pub, cli_data) \
BLE_MESH_MODEL(BLE_MESH_MODEL_ID_LIGHT_HSL_CLI, \
light_hsl_cli_op, cli_pub, cli_data)
BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_LIGHT_HSL_CLI, \
bt_mesh_light_hsl_cli_op, cli_pub, cli_data, &bt_mesh_lighting_client_cb)
typedef bt_mesh_client_user_data_t bt_mesh_light_hsl_client_t;
@ -283,7 +286,7 @@ struct bt_mesh_light_hsl_range_set {
};
/* Light xyL Client Model Context */
extern const struct bt_mesh_model_op light_xyl_cli_op[];
extern const struct bt_mesh_model_op bt_mesh_light_xyl_cli_op[];
/** @def BLE_MESH_MODEL_LIGHT_XYL_CLI
*
@ -296,8 +299,8 @@ extern const struct bt_mesh_model_op light_xyl_cli_op[];
* @return New light xyL client model instance.
*/
#define BLE_MESH_MODEL_LIGHT_XYL_CLI(cli_pub, cli_data) \
BLE_MESH_MODEL(BLE_MESH_MODEL_ID_LIGHT_XYL_CLI, \
light_xyl_cli_op, cli_pub, cli_data)
BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_LIGHT_XYL_CLI, \
bt_mesh_light_xyl_cli_op, cli_pub, cli_data, &bt_mesh_lighting_client_cb)
typedef bt_mesh_client_user_data_t bt_mesh_light_xyl_client_t;
@ -355,7 +358,7 @@ struct bt_mesh_light_xyl_range_set {
};
/* Light LC Client Model Context */
extern const struct bt_mesh_model_op light_lc_cli_op[];
extern const struct bt_mesh_model_op bt_mesh_light_lc_cli_op[];
/** @def BLE_MESH_MODEL_LIGHT_LC_CLI
*
@ -368,8 +371,8 @@ extern const struct bt_mesh_model_op light_lc_cli_op[];
* @return New light lc client model instance.
*/
#define BLE_MESH_MODEL_LIGHT_LC_CLI(cli_pub, cli_data) \
BLE_MESH_MODEL(BLE_MESH_MODEL_ID_LIGHT_LC_CLI, \
light_lc_cli_op, cli_pub, cli_data)
BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_LIGHT_LC_CLI, \
bt_mesh_light_lc_cli_op, cli_pub, cli_data, &bt_mesh_lighting_client_cb)
typedef bt_mesh_client_user_data_t bt_mesh_light_lc_client_t;
@ -418,106 +421,6 @@ struct bt_mesh_light_lc_property_set {
struct net_buf_simple *light_lc_property_value; /* Raw value for the Light LC Property */
};
/**
* @brief This function is called to initialize light lightness client model user_data.
*
* @param[in] model: Pointer to light lightness client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_light_lightness_cli_init(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to initialize light ctl client model user_data.
*
* @param[in] model: Pointer to light ctl client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_light_ctl_cli_init(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to initialize light hsl client model user_data.
*
* @param[in] model: Pointer to light hsl client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_light_hsl_cli_init(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to initialize light xyl client model user_data.
*
* @param[in] model: Pointer to light xyl client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_light_xyl_cli_init(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to initialize light lc client model user_data.
*
* @param[in] model: Pointer to light lc client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_light_lc_cli_init(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to de-initialize light lightness client model user_data.
*
* @param[in] model: Pointer to light lightness client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_light_lightness_cli_deinit(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to de-initialize light ctl client model user_data.
*
* @param[in] model: Pointer to light ctl client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_light_ctl_cli_deinit(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to de-initialize light hsl client model user_data.
*
* @param[in] model: Pointer to light hsl client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_light_hsl_cli_deinit(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to de-initialize light xyl client model user_data.
*
* @param[in] model: Pointer to light xyl client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_light_xyl_cli_deinit(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to de-initialize light lc client model user_data.
*
* @param[in] model: Pointer to light lc client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_light_lc_cli_deinit(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to get light states.
*

View file

@ -25,8 +25,11 @@
extern "C" {
#endif
/* Sensor Client Model Callback */
extern const struct bt_mesh_model_cb bt_mesh_sensor_client_cb;
/* Sensor Client Model Context */
extern const struct bt_mesh_model_op sensor_cli_op[];
extern const struct bt_mesh_model_op bt_mesh_sensor_cli_op[];
/** @def BLE_MESH_MODEL_SENSOR_CLI
*
@ -39,8 +42,8 @@ extern const struct bt_mesh_model_op sensor_cli_op[];
* @return New sensor client model instance.
*/
#define BLE_MESH_MODEL_SENSOR_CLI(cli_pub, cli_data) \
BLE_MESH_MODEL(BLE_MESH_MODEL_ID_SENSOR_CLI, \
sensor_cli_op, cli_pub, cli_data)
BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_SENSOR_CLI, \
bt_mesh_sensor_cli_op, cli_pub, cli_data, &bt_mesh_sensor_client_cb)
typedef bt_mesh_client_user_data_t bt_mesh_sensor_client_t;
typedef bt_mesh_client_internal_data_t sensor_internal_data_t;
@ -133,26 +136,6 @@ struct bt_mesh_sensor_series_get {
struct net_buf_simple *raw_value_x2; /* Raw value identifying a ending column (C.1) */
};
/**
* @brief This function is called to initialize sensor client model user_data.
*
* @param[in] model: Pointer to sensor client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_sensor_cli_init(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to de-initialize sensor client model user_data.
*
* @param[in] model: Pointer to sensor client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_sensor_cli_deinit(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to get sensor states.
*

View file

@ -29,8 +29,11 @@ extern "C" {
typedef bt_mesh_client_user_data_t bt_mesh_time_scene_client_t;
typedef bt_mesh_client_internal_data_t time_scene_internal_data_t;
/* Time Scene Client Model Callback */
extern const struct bt_mesh_model_cb bt_mesh_time_scene_client_cb;
/* Time Client Model Context */
extern const struct bt_mesh_model_op time_cli_op[];
extern const struct bt_mesh_model_op bt_mesh_time_cli_op[];
/** @def BLE_MESH_MODEL_TIME_CLI
*
@ -43,8 +46,8 @@ extern const struct bt_mesh_model_op time_cli_op[];
* @return New time client model instance.
*/
#define BLE_MESH_MODEL_TIME_CLI(cli_pub, cli_data) \
BLE_MESH_MODEL(BLE_MESH_MODEL_ID_TIME_CLI, \
time_cli_op, cli_pub, cli_data)
BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_TIME_CLI, \
bt_mesh_time_cli_op, cli_pub, cli_data, &bt_mesh_time_scene_client_cb)
typedef bt_mesh_client_user_data_t bt_mesh_time_client_t;
@ -100,7 +103,7 @@ struct bt_mesh_time_role_set {
};
/* Scene Client Model Context */
extern const struct bt_mesh_model_op scene_cli_op[];
extern const struct bt_mesh_model_op bt_mesh_scene_cli_op[];
/** @def BLE_MESH_MODEL_SCENE_CLI
*
@ -113,8 +116,8 @@ extern const struct bt_mesh_model_op scene_cli_op[];
* @return New scene client model instance.
*/
#define BLE_MESH_MODEL_SCENE_CLI(cli_pub, cli_data) \
BLE_MESH_MODEL(BLE_MESH_MODEL_ID_SCENE_CLI, \
scene_cli_op, cli_pub, cli_data)
BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_SCENE_CLI, \
bt_mesh_scene_cli_op, cli_pub, cli_data, &bt_mesh_time_scene_client_cb)
typedef bt_mesh_client_user_data_t bt_mesh_scene_client_t;
@ -149,7 +152,7 @@ struct bt_mesh_scene_delete {
};
/* Scheduler Client Model Context */
extern const struct bt_mesh_model_op scheduler_cli_op[];
extern const struct bt_mesh_model_op bt_mesh_scheduler_cli_op[];
/** @def BLE_MESH_MODEL_SCHEDULER_CLI
*
@ -162,8 +165,8 @@ extern const struct bt_mesh_model_op scheduler_cli_op[];
* @return New scheduler client model instance.
*/
#define BLE_MESH_MODEL_SCHEDULER_CLI(cli_pub, cli_data) \
BLE_MESH_MODEL(BLE_MESH_MODEL_ID_SCHEDULER_CLI, \
scheduler_cli_op, cli_pub, cli_data)
BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_SCHEDULER_CLI, \
bt_mesh_scheduler_cli_op, cli_pub, cli_data, &bt_mesh_time_scene_client_cb)
typedef bt_mesh_client_user_data_t bt_mesh_scheduler_client_t;
@ -203,66 +206,6 @@ struct bt_mesh_scheduler_act_set {
u16_t scene_number; /* Transition time for this action */
};
/**
* @brief This function is called to initialize time client model user_data.
*
* @param[in] model: Pointer to time client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_time_cli_init(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to initialize scene client model user_data.
*
* @param[in] model: Pointer to scene client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_scene_cli_init(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to initialize scheduler client model user_data.
*
* @param[in] model: Pointer to scheduler client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_scheduler_cli_init(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to de-initialize time client model user_data.
*
* @param[in] model: Pointer to time client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_time_cli_deinit(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to de-initialize scene client model user_data.
*
* @param[in] model: Pointer to scene client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_scene_cli_deinit(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to de-initialize scheduler client model user_data.
*
* @param[in] model: Pointer to scheduler client model
* @param[in] primary: Whether belongs to primary element
*
* @return Zero-success, other-fail
*/
int bt_mesh_scheduler_cli_deinit(struct bt_mesh_model *model, bool primary);
/**
* @brief This function is called to get scene states.
*

View file

@ -726,7 +726,7 @@ static void light_status(struct bt_mesh_model *model,
return;
}
const struct bt_mesh_model_op light_lightness_cli_op[] = {
const struct bt_mesh_model_op bt_mesh_light_lightness_cli_op[] = {
{ BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_STATUS, 2, light_status },
{ BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_STATUS, 2, light_status },
{ BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LAST_STATUS, 2, light_status },
@ -735,7 +735,7 @@ const struct bt_mesh_model_op light_lightness_cli_op[] = {
BLE_MESH_MODEL_OP_END,
};
const struct bt_mesh_model_op light_ctl_cli_op[] = {
const struct bt_mesh_model_op bt_mesh_light_ctl_cli_op[] = {
{ BLE_MESH_MODEL_OP_LIGHT_CTL_STATUS, 4, light_status },
{ BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_STATUS, 4, light_status },
{ BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_STATUS, 5, light_status },
@ -743,7 +743,7 @@ const struct bt_mesh_model_op light_ctl_cli_op[] = {
BLE_MESH_MODEL_OP_END,
};
const struct bt_mesh_model_op light_hsl_cli_op[] = {
const struct bt_mesh_model_op bt_mesh_light_hsl_cli_op[] = {
{ BLE_MESH_MODEL_OP_LIGHT_HSL_STATUS, 6, light_status },
{ BLE_MESH_MODEL_OP_LIGHT_HSL_TARGET_STATUS, 6, light_status },
{ BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_STATUS, 2, light_status },
@ -753,7 +753,7 @@ const struct bt_mesh_model_op light_hsl_cli_op[] = {
BLE_MESH_MODEL_OP_END,
};
const struct bt_mesh_model_op light_xyl_cli_op[] = {
const struct bt_mesh_model_op bt_mesh_light_xyl_cli_op[] = {
{ BLE_MESH_MODEL_OP_LIGHT_XYL_STATUS, 6, light_status },
{ BLE_MESH_MODEL_OP_LIGHT_XYL_TARGET_STATUS, 6, light_status },
{ BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_STATUS, 6, light_status },
@ -761,7 +761,7 @@ const struct bt_mesh_model_op light_xyl_cli_op[] = {
BLE_MESH_MODEL_OP_END,
};
const struct bt_mesh_model_op light_lc_cli_op[] = {
const struct bt_mesh_model_op bt_mesh_light_lc_cli_op[] = {
{ BLE_MESH_MODEL_OP_LIGHT_LC_MODE_STATUS, 1, light_status },
{ BLE_MESH_MODEL_OP_LIGHT_LC_OM_STATUS, 1, light_status },
{ BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_STATUS, 1, light_status },
@ -1324,21 +1324,19 @@ int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void *
return light_set_state(common, set, length, need_ack);
}
static int light_client_init(struct bt_mesh_model *model, bool primary)
static int lighting_client_init(struct bt_mesh_model *model)
{
light_internal_data_t *internal = NULL;
bt_mesh_light_client_t *client = NULL;
BT_DBG("primary %u", primary);
if (!model) {
BT_ERR("%s, Invalid parameter", __func__);
BT_ERR("Invalid Lighting client model");
return -EINVAL;
}
client = (bt_mesh_light_client_t *)model->user_data;
if (!client) {
BT_ERR("Invalid Lighting client user data");
BT_ERR("No Lighting client context provided");
return -EINVAL;
}
@ -1364,43 +1362,18 @@ static int light_client_init(struct bt_mesh_model *model, bool primary)
return 0;
}
int bt_mesh_light_lightness_cli_init(struct bt_mesh_model *model, bool primary)
{
return light_client_init(model, primary);
}
int bt_mesh_light_ctl_cli_init(struct bt_mesh_model *model, bool primary)
{
return light_client_init(model, primary);
}
int bt_mesh_light_hsl_cli_init(struct bt_mesh_model *model, bool primary)
{
return light_client_init(model, primary);
}
int bt_mesh_light_xyl_cli_init(struct bt_mesh_model *model, bool primary)
{
return light_client_init(model, primary);
}
int bt_mesh_light_lc_cli_init(struct bt_mesh_model *model, bool primary)
{
return light_client_init(model, primary);
}
static int light_client_deinit(struct bt_mesh_model *model, bool primary)
static int lighting_client_deinit(struct bt_mesh_model *model)
{
bt_mesh_light_client_t *client = NULL;
if (!model) {
BT_ERR("%s, Invalid parameter", __func__);
BT_ERR("Invalid Lighting client model");
return -EINVAL;
}
client = (bt_mesh_light_client_t *)model->user_data;
if (!client) {
BT_ERR("Invalid Lighting client user data");
BT_ERR("No Lighting client context provided");
return -EINVAL;
}
@ -1418,27 +1391,7 @@ static int light_client_deinit(struct bt_mesh_model *model, bool primary)
return 0;
}
int bt_mesh_light_lightness_cli_deinit(struct bt_mesh_model *model, bool primary)
{
return light_client_deinit(model, primary);
}
int bt_mesh_light_ctl_cli_deinit(struct bt_mesh_model *model, bool primary)
{
return light_client_deinit(model, primary);
}
int bt_mesh_light_hsl_cli_deinit(struct bt_mesh_model *model, bool primary)
{
return light_client_deinit(model, primary);
}
int bt_mesh_light_xyl_cli_deinit(struct bt_mesh_model *model, bool primary)
{
return light_client_deinit(model, primary);
}
int bt_mesh_light_lc_cli_deinit(struct bt_mesh_model *model, bool primary)
{
return light_client_deinit(model, primary);
}
const struct bt_mesh_model_cb bt_mesh_lighting_client_cb = {
.init = lighting_client_init,
.deinit = lighting_client_deinit,
};

View file

@ -341,7 +341,7 @@ static void sensor_status(struct bt_mesh_model *model,
return;
}
const struct bt_mesh_model_op sensor_cli_op[] = {
const struct bt_mesh_model_op bt_mesh_sensor_cli_op[] = {
{ BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_STATUS, 0, sensor_status },
{ BLE_MESH_MODEL_OP_SENSOR_CADENCE_STATUS, 2, sensor_status },
{ BLE_MESH_MODEL_OP_SENSOR_SETTINGS_STATUS, 2, sensor_status },
@ -574,21 +574,19 @@ int bt_mesh_sensor_client_set_state(bt_mesh_client_common_param_t *common, void
return sensor_act_state(common, set, length, need_ack);
}
int bt_mesh_sensor_cli_init(struct bt_mesh_model *model, bool primary)
static int sensor_client_init(struct bt_mesh_model *model)
{
sensor_internal_data_t *internal = NULL;
bt_mesh_sensor_client_t *client = NULL;
BT_DBG("primary %u", primary);
if (!model) {
BT_ERR("%s, Invalid parameter", __func__);
BT_ERR("Invalid Sensor client model");
return -EINVAL;
}
client = (bt_mesh_sensor_client_t *)model->user_data;
if (!client) {
BT_ERR("Invalid Sensor client user data");
BT_ERR("No Sensor client context provided");
return -EINVAL;
}
@ -614,18 +612,18 @@ int bt_mesh_sensor_cli_init(struct bt_mesh_model *model, bool primary)
return 0;
}
int bt_mesh_sensor_cli_deinit(struct bt_mesh_model *model, bool primary)
static int sensor_client_deinit(struct bt_mesh_model *model)
{
bt_mesh_sensor_client_t *client = NULL;
if (!model) {
BT_ERR("%s, Invalid parameter", __func__);
BT_ERR("Invalid Sensor client model");
return -EINVAL;
}
client = (bt_mesh_sensor_client_t *)model->user_data;
if (!client) {
BT_ERR("Invalid Sensor client user data");
BT_ERR("No Sensor client context provided");
return -EINVAL;
}
@ -641,4 +639,9 @@ int bt_mesh_sensor_cli_deinit(struct bt_mesh_model *model, bool primary)
bt_mesh_sensor_client_mutex_free();
return 0;
}
}
const struct bt_mesh_model_cb bt_mesh_sensor_client_cb = {
.init = sensor_client_init,
.deinit = sensor_client_deinit,
};

View file

@ -349,7 +349,7 @@ static void time_scene_status(struct bt_mesh_model *model,
return;
}
const struct bt_mesh_model_op time_cli_op[] = {
const struct bt_mesh_model_op bt_mesh_time_cli_op[] = {
{ BLE_MESH_MODEL_OP_TIME_STATUS, 5, time_scene_status },
{ BLE_MESH_MODEL_OP_TIME_ZONE_STATUS, 7, time_scene_status },
{ BLE_MESH_MODEL_OP_TAI_UTC_DELTA_STATUS, 9, time_scene_status },
@ -357,13 +357,13 @@ const struct bt_mesh_model_op time_cli_op[] = {
BLE_MESH_MODEL_OP_END,
};
const struct bt_mesh_model_op scene_cli_op[] = {
const struct bt_mesh_model_op bt_mesh_scene_cli_op[] = {
{ BLE_MESH_MODEL_OP_SCENE_STATUS, 3, time_scene_status },
{ BLE_MESH_MODEL_OP_SCENE_REGISTER_STATUS, 3, time_scene_status },
BLE_MESH_MODEL_OP_END,
};
const struct bt_mesh_model_op scheduler_cli_op[] = {
const struct bt_mesh_model_op bt_mesh_scheduler_cli_op[] = {
{ BLE_MESH_MODEL_OP_SCHEDULER_STATUS, 2, time_scene_status },
{ BLE_MESH_MODEL_OP_SCHEDULER_ACT_STATUS, 10, time_scene_status },
BLE_MESH_MODEL_OP_END,
@ -630,21 +630,19 @@ int bt_mesh_time_scene_client_set_state(bt_mesh_client_common_param_t *common, v
return time_scene_set_state(common, set, length, need_ack);
}
static int time_scene_client_init(struct bt_mesh_model *model, bool primary)
static int time_scene_client_init(struct bt_mesh_model *model)
{
time_scene_internal_data_t *internal = NULL;
bt_mesh_time_scene_client_t *client = NULL;
BT_DBG("primary %u", primary);
if (!model) {
BT_ERR("%s, Invalid parameter", __func__);
BT_ERR("Invalid Time Scene client model");
return -EINVAL;
}
client = (bt_mesh_time_scene_client_t *)model->user_data;
if (!client) {
BT_ERR("Invalid Time Scene client user data");
BT_ERR("No Time Scene client context provided");
return -EINVAL;
}
@ -670,33 +668,18 @@ static int time_scene_client_init(struct bt_mesh_model *model, bool primary)
return 0;
}
int bt_mesh_time_cli_init(struct bt_mesh_model *model, bool primary)
{
return time_scene_client_init(model, primary);
}
int bt_mesh_scene_cli_init(struct bt_mesh_model *model, bool primary)
{
return time_scene_client_init(model, primary);
}
int bt_mesh_scheduler_cli_init(struct bt_mesh_model *model, bool primary)
{
return time_scene_client_init(model, primary);
}
static int time_scene_client_deinit(struct bt_mesh_model *model, bool primary)
static int time_scene_client_deinit(struct bt_mesh_model *model)
{
bt_mesh_time_scene_client_t *client = NULL;
if (!model) {
BT_ERR("%s, Invalid parameter", __func__);
BT_ERR("Invalid Time Scene client model");
return -EINVAL;
}
client = (bt_mesh_time_scene_client_t *)model->user_data;
if (!client) {
BT_ERR("Invalid Time Scene client user data");
BT_ERR("No Time Scene client context provided");
return -EINVAL;
}
@ -714,17 +697,7 @@ static int time_scene_client_deinit(struct bt_mesh_model *model, bool primary)
return 0;
}
int bt_mesh_time_cli_deinit(struct bt_mesh_model *model, bool primary)
{
return time_scene_client_deinit(model, primary);
}
int bt_mesh_scene_cli_deinit(struct bt_mesh_model *model, bool primary)
{
return time_scene_client_deinit(model, primary);
}
int bt_mesh_scheduler_cli_deinit(struct bt_mesh_model *model, bool primary)
{
return time_scene_client_deinit(model, primary);
}
const struct bt_mesh_model_cb bt_mesh_time_scene_client_cb = {
.init = time_scene_client_init,
.deinit = time_scene_client_deinit,
};

View file

@ -2207,7 +2207,7 @@ static void gen_client_prop_get(struct bt_mesh_model *model,
/* message handlers (End) */
/* Mapping of message handlers for Generic OnOff Server (0x1000) */
const struct bt_mesh_model_op gen_onoff_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_gen_onoff_srv_op[] = {
{ BLE_MESH_MODEL_OP_GEN_ONOFF_GET, 0, gen_onoff_get },
{ BLE_MESH_MODEL_OP_GEN_ONOFF_SET, 2, gen_onoff_set },
{ BLE_MESH_MODEL_OP_GEN_ONOFF_SET_UNACK, 2, gen_onoff_set },
@ -2215,7 +2215,7 @@ const struct bt_mesh_model_op gen_onoff_srv_op[] = {
};
/* Mapping of message handlers for Generic Level Server (0x1002) */
const struct bt_mesh_model_op gen_level_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_gen_level_srv_op[] = {
{ BLE_MESH_MODEL_OP_GEN_LEVEL_GET, 0, gen_level_get },
{ BLE_MESH_MODEL_OP_GEN_LEVEL_SET, 3, gen_level_set },
{ BLE_MESH_MODEL_OP_GEN_LEVEL_SET_UNACK, 3, gen_level_set },
@ -2227,7 +2227,7 @@ const struct bt_mesh_model_op gen_level_srv_op[] = {
};
/* Mapping of message handlers for Generic Default TT Server (0x1004) */
const struct bt_mesh_model_op gen_def_trans_time_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_gen_def_trans_time_srv_op[] = {
{ BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_GET, 0, gen_def_trans_time_get },
{ BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET, 1, gen_def_trans_time_set },
{ BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET_UNACK, 1, gen_def_trans_time_set },
@ -2235,20 +2235,20 @@ const struct bt_mesh_model_op gen_def_trans_time_srv_op[] = {
};
/* Mapping of message handlers for Generic Power OnOff Server (0x1006) */
const struct bt_mesh_model_op gen_power_onoff_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_gen_power_onoff_srv_op[] = {
{ BLE_MESH_MODEL_OP_GEN_ONPOWERUP_GET, 0, gen_onpowerup_get },
BLE_MESH_MODEL_OP_END,
};
/* Mapping of message handlers for Generic Power OnOff Setup Server (0x1007) */
const struct bt_mesh_model_op gen_power_onoff_setup_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_gen_power_onoff_setup_srv_op[] = {
{ BLE_MESH_MODEL_OP_GEN_ONPOWERUP_SET, 1, gen_onpowerup_set },
{ BLE_MESH_MODEL_OP_GEN_ONPOWERUP_SET_UNACK, 1, gen_onpowerup_set },
BLE_MESH_MODEL_OP_END,
};
/* Mapping of message handlers for Generic Power Level Server (0x1009) */
const struct bt_mesh_model_op gen_power_level_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_gen_power_level_srv_op[] = {
{ BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_GET, 0, gen_power_level_get },
{ BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_SET, 3, gen_power_level_set },
{ BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_SET_UNACK, 3, gen_power_level_set },
@ -2259,7 +2259,7 @@ const struct bt_mesh_model_op gen_power_level_srv_op[] = {
};
/* Mapping of message handlers for Generic Power Level Setup Server (0x100A) */
const struct bt_mesh_model_op gen_power_level_setup_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_gen_power_level_setup_srv_op[] = {
{ BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_SET, 2, gen_power_default_set },
{ BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_SET_UNACK, 2, gen_power_default_set },
{ BLE_MESH_MODEL_OP_GEN_POWER_RANGE_SET, 4, gen_power_range_set },
@ -2268,20 +2268,20 @@ const struct bt_mesh_model_op gen_power_level_setup_srv_op[] = {
};
/* Mapping of message handlers for Generic Battery Server (0x100C) */
const struct bt_mesh_model_op gen_battery_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_gen_battery_srv_op[] = {
{ BLE_MESH_MODEL_OP_GEN_BATTERY_GET, 0, gen_battery_get },
BLE_MESH_MODEL_OP_END,
};
/* Mapping of message handlers for Generic Location Server (0x100E) */
const struct bt_mesh_model_op gen_location_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_gen_location_srv_op[] = {
{ BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_GET, 0, gen_location_get },
{ BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_GET, 0, gen_location_get },
BLE_MESH_MODEL_OP_END,
};
/* Mapping of message handlers for Generic Location Setup Server (0x100F) */
const struct bt_mesh_model_op gen_location_setup_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_gen_location_setup_srv_op[] = {
{ BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_SET, 10, gen_location_set },
{ BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_SET_UNACK, 10, gen_location_set },
{ BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_SET, 9, gen_location_set },
@ -2290,7 +2290,7 @@ const struct bt_mesh_model_op gen_location_setup_srv_op[] = {
};
/* Mapping of message handlers for Generic User Property Server (0x1013) */
const struct bt_mesh_model_op gen_user_prop_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_gen_user_prop_srv_op[] = {
{ BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_GET, 0, gen_user_prop_get },
{ BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_GET, 2, gen_user_prop_get },
{ BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET, 3, gen_user_prop_set },
@ -2299,7 +2299,7 @@ const struct bt_mesh_model_op gen_user_prop_srv_op[] = {
};
/* Mapping of message handlers for Generic Admin Property Server (0x1011) */
const struct bt_mesh_model_op gen_admin_prop_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_gen_admin_prop_srv_op[] = {
{ BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTIES_GET, 0, gen_admin_prop_get },
{ BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_GET, 2, gen_admin_prop_get },
{ BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET, 4, gen_admin_prop_set },
@ -2308,7 +2308,7 @@ const struct bt_mesh_model_op gen_admin_prop_srv_op[] = {
};
/* Mapping of message handlers for Generic Manufacturer Property Server (0x1012) */
const struct bt_mesh_model_op gen_manu_prop_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_gen_manu_prop_srv_op[] = {
{ BLE_MESH_MODEL_OP_GEN_MANU_PROPERTIES_GET, 0, gen_manu_prop_get },
{ BLE_MESH_MODEL_OP_GEN_MANU_PROPERTY_GET, 2, gen_manu_prop_get },
{ BLE_MESH_MODEL_OP_GEN_MANU_PROPERTY_SET, 3, gen_manu_prop_set },
@ -2317,7 +2317,7 @@ const struct bt_mesh_model_op gen_manu_prop_srv_op[] = {
};
/* Mapping of message handlers for Generic Client Property Server (0x1014) */
const struct bt_mesh_model_op gen_client_prop_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_gen_client_prop_srv_op[] = {
{ BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_GET, 2, gen_client_prop_get },
BLE_MESH_MODEL_OP_END,
};
@ -2475,7 +2475,7 @@ static int generic_server_init(struct bt_mesh_model *model)
return 0;
}
int bt_mesh_gen_onoff_srv_init(struct bt_mesh_model *model, bool primary)
static int gen_onoff_srv_init(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Generic OnOff Server has no publication support");
@ -2485,7 +2485,7 @@ int bt_mesh_gen_onoff_srv_init(struct bt_mesh_model *model, bool primary)
return generic_server_init(model);
}
int bt_mesh_gen_level_srv_init(struct bt_mesh_model *model, bool primary)
static int gen_level_srv_init(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Generic Level Server has no publication support");
@ -2495,7 +2495,7 @@ int bt_mesh_gen_level_srv_init(struct bt_mesh_model *model, bool primary)
return generic_server_init(model);
}
int bt_mesh_gen_def_trans_time_srv_init(struct bt_mesh_model *model, bool primary)
static int gen_def_trans_time_srv_init(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Generic Default Trans Time Server has no publication support");
@ -2505,7 +2505,7 @@ int bt_mesh_gen_def_trans_time_srv_init(struct bt_mesh_model *model, bool primar
return generic_server_init(model);
}
int bt_mesh_gen_power_onoff_srv_init(struct bt_mesh_model *model, bool primary)
static int gen_power_onoff_srv_init(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Generic Power OnOff Server has no publication support");
@ -2523,12 +2523,12 @@ int bt_mesh_gen_power_onoff_srv_init(struct bt_mesh_model *model, bool primary)
return generic_server_init(model);
}
int bt_mesh_gen_power_onoff_setup_srv_init(struct bt_mesh_model *model, bool primary)
static int gen_power_onoff_setup_srv_init(struct bt_mesh_model *model)
{
return generic_server_init(model);
}
int bt_mesh_gen_power_level_srv_init(struct bt_mesh_model *model, bool primary)
static int gen_power_level_srv_init(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Generic Power Level Server has no publication support");
@ -2546,12 +2546,12 @@ int bt_mesh_gen_power_level_srv_init(struct bt_mesh_model *model, bool primary)
return generic_server_init(model);
}
int bt_mesh_gen_power_level_setup_srv_init(struct bt_mesh_model *model, bool primary)
static int gen_power_level_setup_srv_init(struct bt_mesh_model *model)
{
return generic_server_init(model);
}
int bt_mesh_gen_battery_srv_init(struct bt_mesh_model *model, bool primary)
static int gen_battery_srv_init(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Generic Battery Server has no publication support");
@ -2561,7 +2561,7 @@ int bt_mesh_gen_battery_srv_init(struct bt_mesh_model *model, bool primary)
return generic_server_init(model);
}
int bt_mesh_gen_location_srv_init(struct bt_mesh_model *model, bool primary)
static int gen_location_srv_init(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Generic Location Server has no publication support");
@ -2571,7 +2571,7 @@ int bt_mesh_gen_location_srv_init(struct bt_mesh_model *model, bool primary)
return generic_server_init(model);
}
int bt_mesh_gen_location_setup_srv_init(struct bt_mesh_model *model, bool primary)
static int gen_location_setup_srv_init(struct bt_mesh_model *model)
{
/* When this model is present on an Element, the corresponding Generic
* Location Setup Server model shall also be present.
@ -2584,7 +2584,7 @@ int bt_mesh_gen_location_setup_srv_init(struct bt_mesh_model *model, bool primar
return generic_server_init(model);
}
int bt_mesh_gen_user_prop_srv_init(struct bt_mesh_model *model, bool primary)
static int gen_user_prop_srv_init(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Generic User Property Server has no publication support");
@ -2594,7 +2594,7 @@ int bt_mesh_gen_user_prop_srv_init(struct bt_mesh_model *model, bool primary)
return generic_server_init(model);
}
int bt_mesh_gen_admin_prop_srv_init(struct bt_mesh_model *model, bool primary)
static int gen_admin_prop_srv_init(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Generic Admin Property Server has no publication support");
@ -2604,7 +2604,7 @@ int bt_mesh_gen_admin_prop_srv_init(struct bt_mesh_model *model, bool primary)
return generic_server_init(model);
}
int bt_mesh_gen_manu_prop_srv_init(struct bt_mesh_model *model, bool primary)
static int gen_manu_prop_srv_init(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Generic Manufacturer Property Server has no publication support");
@ -2614,7 +2614,7 @@ int bt_mesh_gen_manu_prop_srv_init(struct bt_mesh_model *model, bool primary)
return generic_server_init(model);
}
int bt_mesh_gen_client_prop_srv_init(struct bt_mesh_model *model, bool primary)
static int gen_client_prop_srv_init(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Generic Client Property Server has no publication support");
@ -2670,7 +2670,7 @@ static int generic_server_deinit(struct bt_mesh_model *model)
return 0;
}
int bt_mesh_gen_onoff_srv_deinit(struct bt_mesh_model *model, bool primary)
static int gen_onoff_srv_deinit(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Generic OnOff Server has no publication support");
@ -2680,7 +2680,7 @@ int bt_mesh_gen_onoff_srv_deinit(struct bt_mesh_model *model, bool primary)
return generic_server_deinit(model);
}
int bt_mesh_gen_level_srv_deinit(struct bt_mesh_model *model, bool primary)
static int gen_level_srv_deinit(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Generic Level Server has no publication support");
@ -2690,7 +2690,7 @@ int bt_mesh_gen_level_srv_deinit(struct bt_mesh_model *model, bool primary)
return generic_server_deinit(model);
}
int bt_mesh_gen_def_trans_time_srv_deinit(struct bt_mesh_model *model, bool primary)
static int gen_def_trans_time_srv_deinit(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Generic Default Trans Time Server has no publication support");
@ -2700,7 +2700,7 @@ int bt_mesh_gen_def_trans_time_srv_deinit(struct bt_mesh_model *model, bool prim
return generic_server_deinit(model);
}
int bt_mesh_gen_power_onoff_srv_deinit(struct bt_mesh_model *model, bool primary)
static int gen_power_onoff_srv_deinit(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Generic Power OnOff Server has no publication support");
@ -2710,12 +2710,12 @@ int bt_mesh_gen_power_onoff_srv_deinit(struct bt_mesh_model *model, bool primary
return generic_server_deinit(model);
}
int bt_mesh_gen_power_onoff_setup_srv_deinit(struct bt_mesh_model *model, bool primary)
static int gen_power_onoff_setup_srv_deinit(struct bt_mesh_model *model)
{
return generic_server_deinit(model);
}
int bt_mesh_gen_power_level_srv_deinit(struct bt_mesh_model *model, bool primary)
static int gen_power_level_srv_deinit(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Generic Power Level Server has no publication support");
@ -2725,12 +2725,12 @@ int bt_mesh_gen_power_level_srv_deinit(struct bt_mesh_model *model, bool primary
return generic_server_deinit(model);
}
int bt_mesh_gen_power_level_setup_srv_deinit(struct bt_mesh_model *model, bool primary)
static int gen_power_level_setup_srv_deinit(struct bt_mesh_model *model)
{
return generic_server_deinit(model);
}
int bt_mesh_gen_battery_srv_deinit(struct bt_mesh_model *model, bool primary)
static int gen_battery_srv_deinit(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Generic Battery Server has no publication support");
@ -2740,7 +2740,7 @@ int bt_mesh_gen_battery_srv_deinit(struct bt_mesh_model *model, bool primary)
return generic_server_deinit(model);
}
int bt_mesh_gen_location_srv_deinit(struct bt_mesh_model *model, bool primary)
static int gen_location_srv_deinit(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Generic Location Server has no publication support");
@ -2750,12 +2750,12 @@ int bt_mesh_gen_location_srv_deinit(struct bt_mesh_model *model, bool primary)
return generic_server_deinit(model);
}
int bt_mesh_gen_location_setup_srv_deinit(struct bt_mesh_model *model, bool primary)
static int gen_location_setup_srv_deinit(struct bt_mesh_model *model)
{
return generic_server_deinit(model);
}
int bt_mesh_gen_user_prop_srv_deinit(struct bt_mesh_model *model, bool primary)
static int gen_user_prop_srv_deinit(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Generic User Property Server has no publication support");
@ -2765,7 +2765,7 @@ int bt_mesh_gen_user_prop_srv_deinit(struct bt_mesh_model *model, bool primary)
return generic_server_deinit(model);
}
int bt_mesh_gen_admin_prop_srv_deinit(struct bt_mesh_model *model, bool primary)
static int gen_admin_prop_srv_deinit(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Generic Admin Property Server has no publication support");
@ -2775,7 +2775,7 @@ int bt_mesh_gen_admin_prop_srv_deinit(struct bt_mesh_model *model, bool primary)
return generic_server_deinit(model);
}
int bt_mesh_gen_manu_prop_srv_deinit(struct bt_mesh_model *model, bool primary)
static int gen_manu_prop_srv_deinit(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Generic Manufacturer Property Server has no publication support");
@ -2785,7 +2785,7 @@ int bt_mesh_gen_manu_prop_srv_deinit(struct bt_mesh_model *model, bool primary)
return generic_server_deinit(model);
}
int bt_mesh_gen_client_prop_srv_deinit(struct bt_mesh_model *model, bool primary)
static int gen_client_prop_srv_deinit(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Generic Client Property Server has no publication support");
@ -2793,4 +2793,74 @@ int bt_mesh_gen_client_prop_srv_deinit(struct bt_mesh_model *model, bool primary
}
return generic_server_deinit(model);
}
}
const struct bt_mesh_model_cb bt_mesh_gen_onoff_srv_cb = {
.init = gen_onoff_srv_init,
.deinit = gen_onoff_srv_deinit,
};
const struct bt_mesh_model_cb bt_mesh_gen_level_srv_cb = {
.init = gen_level_srv_init,
.deinit = gen_level_srv_deinit,
};
const struct bt_mesh_model_cb bt_mesh_gen_def_trans_time_srv_cb = {
.init = gen_def_trans_time_srv_init,
.deinit = gen_def_trans_time_srv_deinit,
};
const struct bt_mesh_model_cb bt_mesh_gen_power_onoff_srv_cb = {
.init = gen_power_onoff_srv_init,
.deinit = gen_power_onoff_srv_deinit,
};
const struct bt_mesh_model_cb bt_mesh_gen_power_onoff_setup_srv_cb = {
.init = gen_power_onoff_setup_srv_init,
.deinit = gen_power_onoff_setup_srv_deinit,
};
const struct bt_mesh_model_cb bt_mesh_gen_power_level_srv_cb = {
.init = gen_power_level_srv_init,
.deinit = gen_power_level_srv_deinit,
};
const struct bt_mesh_model_cb bt_mesh_gen_power_level_setup_srv_cb = {
.init = gen_power_level_setup_srv_init,
.deinit = gen_power_level_setup_srv_deinit,
};
const struct bt_mesh_model_cb bt_mesh_gen_battery_srv_cb = {
.init = gen_battery_srv_init,
.deinit = gen_battery_srv_deinit,
};
const struct bt_mesh_model_cb bt_mesh_gen_location_srv_cb = {
.init = gen_location_srv_init,
.deinit = gen_location_srv_deinit,
};
const struct bt_mesh_model_cb bt_mesh_gen_location_setup_srv_cb = {
.init = gen_location_setup_srv_init,
.deinit = gen_location_setup_srv_deinit,
};
const struct bt_mesh_model_cb bt_mesh_gen_user_prop_srv_cb = {
.init = gen_user_prop_srv_init,
.deinit = gen_user_prop_srv_deinit,
};
const struct bt_mesh_model_cb bt_mesh_gen_admin_prop_srv_cb = {
.init = gen_admin_prop_srv_init,
.deinit = gen_admin_prop_srv_deinit,
};
const struct bt_mesh_model_cb bt_mesh_gen_manu_prop_srv_cb = {
.init = gen_manu_prop_srv_init,
.deinit = gen_manu_prop_srv_deinit,
};
const struct bt_mesh_model_cb bt_mesh_gen_client_prop_srv_cb = {
.init = gen_client_prop_srv_init,
.deinit = gen_client_prop_srv_deinit,
};

View file

@ -360,36 +360,6 @@ void gen_level_publish(struct bt_mesh_model *model);
void gen_onpowerup_publish(struct bt_mesh_model *model);
void gen_power_level_publish(struct bt_mesh_model *model, u16_t opcode);
int bt_mesh_gen_onoff_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_gen_level_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_gen_def_trans_time_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_gen_power_onoff_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_gen_power_onoff_setup_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_gen_power_level_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_gen_power_level_setup_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_gen_battery_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_gen_location_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_gen_location_setup_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_gen_user_prop_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_gen_admin_prop_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_gen_manu_prop_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_gen_client_prop_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_gen_onoff_srv_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_gen_level_srv_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_gen_def_trans_time_srv_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_gen_power_onoff_srv_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_gen_power_onoff_setup_srv_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_gen_power_level_srv_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_gen_power_level_setup_srv_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_gen_battery_srv_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_gen_location_srv_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_gen_location_setup_srv_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_gen_user_prop_srv_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_gen_admin_prop_srv_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_gen_manu_prop_srv_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_gen_client_prop_srv_deinit(struct bt_mesh_model *model, bool primary);
#ifdef __cplusplus
}
#endif

View file

@ -503,34 +503,6 @@ void light_hsl_publish(struct bt_mesh_model *model, u16_t opcode);
void light_xyl_publish(struct bt_mesh_model *model, u16_t opcode);
void light_lc_publish(struct bt_mesh_model *model, u16_t opcode);
int bt_mesh_light_lightness_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_light_lightness_setup_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_light_ctl_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_light_ctl_setup_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_light_ctl_temp_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_light_hsl_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_light_hsl_setup_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_light_hsl_hue_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_light_hsl_sat_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_light_xyl_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_light_xyl_setup_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_light_lc_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_light_lc_setup_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_light_lightness_srv_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_light_lightness_setup_srv_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_light_ctl_srv_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_light_ctl_setup_srv_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_light_ctl_temp_srv_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_light_hsl_srv_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_light_hsl_setup_srv_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_light_hsl_hue_srv_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_light_hsl_sat_srv_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_light_xyl_srv_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_light_xyl_setup_srv_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_light_lc_srv_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_light_lc_setup_srv_deinit(struct bt_mesh_model *model, bool primary);
#ifdef __cplusplus
}
#endif

View file

@ -247,12 +247,6 @@ typedef union {
} sensor_setting_set;
} bt_mesh_sensor_server_recv_set_msg_t;
int bt_mesh_sensor_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_sensor_setup_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_sensor_srv_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_sensor_setup_srv_deinit(struct bt_mesh_model *model, bool primary);
#ifdef __cplusplus
}
#endif

View file

@ -385,20 +385,6 @@ void bt_mesh_time_scene_server_unlock(void);
void scene_publish(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, u16_t opcode);
int bt_mesh_time_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_time_setup_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_scene_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_scene_setup_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_scheduler_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_scheduler_setup_srv_init(struct bt_mesh_model *model, bool primary);
int bt_mesh_time_srv_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_time_setup_srv_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_scene_srv_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_scene_setup_srv_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_scheduler_srv_deinit(struct bt_mesh_model *model, bool primary);
int bt_mesh_scheduler_setup_srv_deinit(struct bt_mesh_model *model, bool primary);
#ifdef __cplusplus
}
#endif

View file

@ -2858,7 +2858,7 @@ static void light_lc_prop_set(struct bt_mesh_model *model,
/* message handlers (End) */
/* Mapping of message handlers for Light Lightness Server (0x1300) */
const struct bt_mesh_model_op light_lightness_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_light_lightness_srv_op[] = {
{ BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_GET, 0, light_lightness_get },
{ BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_SET, 3, light_lightness_set },
{ BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_SET_UNACK, 3, light_lightness_set },
@ -2872,7 +2872,7 @@ const struct bt_mesh_model_op light_lightness_srv_op[] = {
};
/* Mapping of message handlers for Light Lightness Setup Server (0x1301) */
const struct bt_mesh_model_op light_lightness_setup_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_light_lightness_setup_srv_op[] = {
{ BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_SET, 2, light_lightness_default_set },
{ BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_SET_UNACK, 2, light_lightness_default_set },
{ BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_SET, 4, light_lightness_range_set },
@ -2881,7 +2881,7 @@ const struct bt_mesh_model_op light_lightness_setup_srv_op[] = {
};
/* Mapping of message handlers for Light CTL Server (0x1303) */
const struct bt_mesh_model_op light_ctl_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_light_ctl_srv_op[] = {
{ BLE_MESH_MODEL_OP_LIGHT_CTL_GET, 0, light_ctl_get },
{ BLE_MESH_MODEL_OP_LIGHT_CTL_SET, 7, light_ctl_set },
{ BLE_MESH_MODEL_OP_LIGHT_CTL_SET_UNACK, 7, light_ctl_set },
@ -2891,7 +2891,7 @@ const struct bt_mesh_model_op light_ctl_srv_op[] = {
};
/* Mapping of message handlers for Light CTL Setup Server (0x1304) */
const struct bt_mesh_model_op light_ctl_setup_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_light_ctl_setup_srv_op[] = {
{ BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_SET, 6, light_ctl_default_set },
{ BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_SET_UNACK, 6, light_ctl_default_set },
{ BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_SET, 4, light_ctl_temp_range_set },
@ -2900,7 +2900,7 @@ const struct bt_mesh_model_op light_ctl_setup_srv_op[] = {
};
/* Mapping of message handlers for Light CTL Temperature Server (0x1306) */
const struct bt_mesh_model_op light_ctl_temp_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_light_ctl_temp_srv_op[] = {
{ BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_GET, 0, light_ctl_get },
{ BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_SET, 5, light_ctl_temp_set },
{ BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_SET_UNACK, 5, light_ctl_temp_set },
@ -2908,7 +2908,7 @@ const struct bt_mesh_model_op light_ctl_temp_srv_op[] = {
};
/* Mapping of message handlers for Light HSL Server (0x1307) */
const struct bt_mesh_model_op light_hsl_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_light_hsl_srv_op[] = {
{ BLE_MESH_MODEL_OP_LIGHT_HSL_GET, 0, light_hsl_get },
{ BLE_MESH_MODEL_OP_LIGHT_HSL_SET, 7, light_hsl_set },
{ BLE_MESH_MODEL_OP_LIGHT_HSL_SET_UNACK, 7, light_hsl_set },
@ -2919,7 +2919,7 @@ const struct bt_mesh_model_op light_hsl_srv_op[] = {
};
/* Mapping of message handlers for Light HSL Setup Server (0x1308) */
const struct bt_mesh_model_op light_hsl_setup_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_light_hsl_setup_srv_op[] = {
{ BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_SET, 6, light_hsl_default_set },
{ BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_SET_UNACK, 6, light_hsl_default_set },
{ BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_SET, 8, light_hsl_range_set },
@ -2928,7 +2928,7 @@ const struct bt_mesh_model_op light_hsl_setup_srv_op[] = {
};
/* Mapping of message handlers for Light HSL Hue Server (0x130A) */
const struct bt_mesh_model_op light_hsl_hue_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_light_hsl_hue_srv_op[] = {
{ BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_GET, 0, light_hsl_get },
{ BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_SET, 3, light_hsl_hue_set },
{ BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_SET_UNACK, 3, light_hsl_hue_set },
@ -2936,7 +2936,7 @@ const struct bt_mesh_model_op light_hsl_hue_srv_op[] = {
};
/* Mapping of message handlers for Light HSL Saturation Server (0x130B) */
const struct bt_mesh_model_op light_hsl_sat_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_light_hsl_sat_srv_op[] = {
{ BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_GET, 0, light_hsl_get },
{ BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_SET, 3, light_hsl_sat_set },
{ BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_SET_UNACK, 3, light_hsl_sat_set },
@ -2944,7 +2944,7 @@ const struct bt_mesh_model_op light_hsl_sat_srv_op[] = {
};
/* Mapping of message handlers for Light xyL Server (0x130C) */
const struct bt_mesh_model_op light_xyl_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_light_xyl_srv_op[] = {
{ BLE_MESH_MODEL_OP_LIGHT_XYL_GET, 0, light_xyl_get },
{ BLE_MESH_MODEL_OP_LIGHT_XYL_SET, 7, light_xyl_set },
{ BLE_MESH_MODEL_OP_LIGHT_XYL_SET_UNACK, 7, light_xyl_set },
@ -2955,7 +2955,7 @@ const struct bt_mesh_model_op light_xyl_srv_op[] = {
};
/* Mapping of message handlers for Light xyL Setup Server (0x130D) */
const struct bt_mesh_model_op light_xyl_setup_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_light_xyl_setup_srv_op[] = {
{ BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_SET, 6, light_xyl_default_set },
{ BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_SET_UNACK, 6, light_xyl_default_set },
{ BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_SET, 8, light_xyl_range_set },
@ -2964,7 +2964,7 @@ const struct bt_mesh_model_op light_xyl_setup_srv_op[] = {
};
/* Mapping of message handlers for Light LC Server (0x130F) */
const struct bt_mesh_model_op light_lc_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_light_lc_srv_op[] = {
{ BLE_MESH_MODEL_OP_LIGHT_LC_MODE_GET, 0, light_lc_get },
{ BLE_MESH_MODEL_OP_LIGHT_LC_MODE_SET, 1, light_lc_mode_set },
{ BLE_MESH_MODEL_OP_LIGHT_LC_MODE_SET_UNACK, 1, light_lc_mode_set },
@ -2979,7 +2979,7 @@ const struct bt_mesh_model_op light_lc_srv_op[] = {
};
/* Mapping of message handlers for Light LC Setup Server (0x1310) */
const struct bt_mesh_model_op light_lc_setup_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_light_lc_setup_srv_op[] = {
{ BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET, 2, light_lc_prop_get },
{ BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET, 3, light_lc_prop_set },
{ BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK, 3, light_lc_prop_set },
@ -3155,7 +3155,7 @@ static int light_server_init(struct bt_mesh_model *model)
return 0;
}
int bt_mesh_light_lightness_srv_init(struct bt_mesh_model *model, bool primary)
static int light_lightness_srv_init(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Light Lightness Server has no publication support");
@ -3173,12 +3173,12 @@ int bt_mesh_light_lightness_srv_init(struct bt_mesh_model *model, bool primary)
return light_server_init(model);
}
int bt_mesh_light_lightness_setup_srv_init(struct bt_mesh_model *model, bool primary)
static int light_lightness_setup_srv_init(struct bt_mesh_model *model)
{
return light_server_init(model);
}
int bt_mesh_light_ctl_srv_init(struct bt_mesh_model *model, bool primary)
static int light_ctl_srv_init(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Light CTL Server has no publication support");
@ -3205,12 +3205,12 @@ int bt_mesh_light_ctl_srv_init(struct bt_mesh_model *model, bool primary)
return light_server_init(model);
}
int bt_mesh_light_ctl_setup_srv_init(struct bt_mesh_model *model, bool primary)
static int light_ctl_setup_srv_init(struct bt_mesh_model *model)
{
return light_server_init(model);
}
int bt_mesh_light_ctl_temp_srv_init(struct bt_mesh_model *model, bool primary)
static int light_ctl_temp_srv_init(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Light CTL Temperature Server has no publication support");
@ -3220,7 +3220,7 @@ int bt_mesh_light_ctl_temp_srv_init(struct bt_mesh_model *model, bool primary)
return light_server_init(model);
}
int bt_mesh_light_hsl_srv_init(struct bt_mesh_model *model, bool primary)
static int light_hsl_srv_init(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Light HSL Server has no publication support");
@ -3248,12 +3248,12 @@ int bt_mesh_light_hsl_srv_init(struct bt_mesh_model *model, bool primary)
return light_server_init(model);
}
int bt_mesh_light_hsl_setup_srv_init(struct bt_mesh_model *model, bool primary)
static int light_hsl_setup_srv_init(struct bt_mesh_model *model)
{
return light_server_init(model);
}
int bt_mesh_light_hsl_hue_srv_init(struct bt_mesh_model *model, bool primary)
static int light_hsl_hue_srv_init(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Light HSL Hue Server has no publication support");
@ -3263,7 +3263,7 @@ int bt_mesh_light_hsl_hue_srv_init(struct bt_mesh_model *model, bool primary)
return light_server_init(model);
}
int bt_mesh_light_hsl_sat_srv_init(struct bt_mesh_model *model, bool primary)
static int light_hsl_sat_srv_init(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Light HSL Saturation Server has no publication support");
@ -3273,7 +3273,7 @@ int bt_mesh_light_hsl_sat_srv_init(struct bt_mesh_model *model, bool primary)
return light_server_init(model);
}
int bt_mesh_light_xyl_srv_init(struct bt_mesh_model *model, bool primary)
static int light_xyl_srv_init(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Light xyL Server has no publication support");
@ -3292,12 +3292,12 @@ int bt_mesh_light_xyl_srv_init(struct bt_mesh_model *model, bool primary)
return light_server_init(model);
}
int bt_mesh_light_xyl_setup_srv_init(struct bt_mesh_model *model, bool primary)
static int light_xyl_setup_srv_init(struct bt_mesh_model *model)
{
return light_server_init(model);
}
int bt_mesh_light_lc_srv_init(struct bt_mesh_model *model, bool primary)
static int light_lc_srv_init(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Light LC Server has no publication support");
@ -3307,7 +3307,7 @@ int bt_mesh_light_lc_srv_init(struct bt_mesh_model *model, bool primary)
return light_server_init(model);
}
int bt_mesh_light_lc_setup_srv_init(struct bt_mesh_model *model, bool primary)
static int light_lc_setup_srv_init(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Light LC Setup Server has no publication support");
@ -3442,7 +3442,7 @@ static int light_server_deinit(struct bt_mesh_model *model)
return 0;
}
int bt_mesh_light_lightness_srv_deinit(struct bt_mesh_model *model, bool primary)
static int light_lightness_srv_deinit(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Light Lightness Server has no publication support");
@ -3452,12 +3452,12 @@ int bt_mesh_light_lightness_srv_deinit(struct bt_mesh_model *model, bool primary
return light_server_deinit(model);
}
int bt_mesh_light_lightness_setup_srv_deinit(struct bt_mesh_model *model, bool primary)
static int light_lightness_setup_srv_deinit(struct bt_mesh_model *model)
{
return light_server_deinit(model);
}
int bt_mesh_light_ctl_srv_deinit(struct bt_mesh_model *model, bool primary)
static int light_ctl_srv_deinit(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Light CTL Server has no publication support");
@ -3467,12 +3467,12 @@ int bt_mesh_light_ctl_srv_deinit(struct bt_mesh_model *model, bool primary)
return light_server_deinit(model);
}
int bt_mesh_light_ctl_setup_srv_deinit(struct bt_mesh_model *model, bool primary)
static int light_ctl_setup_srv_deinit(struct bt_mesh_model *model)
{
return light_server_deinit(model);
}
int bt_mesh_light_ctl_temp_srv_deinit(struct bt_mesh_model *model, bool primary)
static int light_ctl_temp_srv_deinit(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Light CTL Temperature Server has no publication support");
@ -3482,7 +3482,7 @@ int bt_mesh_light_ctl_temp_srv_deinit(struct bt_mesh_model *model, bool primary)
return light_server_deinit(model);
}
int bt_mesh_light_hsl_srv_deinit(struct bt_mesh_model *model, bool primary)
static int light_hsl_srv_deinit(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Light HSL Server has no publication support");
@ -3492,12 +3492,12 @@ int bt_mesh_light_hsl_srv_deinit(struct bt_mesh_model *model, bool primary)
return light_server_deinit(model);
}
int bt_mesh_light_hsl_setup_srv_deinit(struct bt_mesh_model *model, bool primary)
static int light_hsl_setup_srv_deinit(struct bt_mesh_model *model)
{
return light_server_deinit(model);
}
int bt_mesh_light_hsl_hue_srv_deinit(struct bt_mesh_model *model, bool primary)
static int light_hsl_hue_srv_deinit(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Light HSL Hue Server has no publication support");
@ -3507,7 +3507,7 @@ int bt_mesh_light_hsl_hue_srv_deinit(struct bt_mesh_model *model, bool primary)
return light_server_deinit(model);
}
int bt_mesh_light_hsl_sat_srv_deinit(struct bt_mesh_model *model, bool primary)
static int light_hsl_sat_srv_deinit(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Light HSL Saturation Server has no publication support");
@ -3517,7 +3517,7 @@ int bt_mesh_light_hsl_sat_srv_deinit(struct bt_mesh_model *model, bool primary)
return light_server_deinit(model);
}
int bt_mesh_light_xyl_srv_deinit(struct bt_mesh_model *model, bool primary)
static int light_xyl_srv_deinit(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Light xyL Server has no publication support");
@ -3527,12 +3527,12 @@ int bt_mesh_light_xyl_srv_deinit(struct bt_mesh_model *model, bool primary)
return light_server_deinit(model);
}
int bt_mesh_light_xyl_setup_srv_deinit(struct bt_mesh_model *model, bool primary)
static int light_xyl_setup_srv_deinit(struct bt_mesh_model *model)
{
return light_server_deinit(model);
}
int bt_mesh_light_lc_srv_deinit(struct bt_mesh_model *model, bool primary)
static int light_lc_srv_deinit(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Light LC Server has no publication support");
@ -3542,7 +3542,7 @@ int bt_mesh_light_lc_srv_deinit(struct bt_mesh_model *model, bool primary)
return light_server_deinit(model);
}
int bt_mesh_light_lc_setup_srv_deinit(struct bt_mesh_model *model, bool primary)
static int light_lc_setup_srv_deinit(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Light LC Setup Server has no publication support");
@ -3551,3 +3551,68 @@ int bt_mesh_light_lc_setup_srv_deinit(struct bt_mesh_model *model, bool primary)
return light_server_deinit(model);
}
const struct bt_mesh_model_cb bt_mesh_light_lightness_srv_cb = {
.init = light_lightness_srv_init,
.deinit = light_lightness_srv_deinit,
};
const struct bt_mesh_model_cb bt_mesh_light_lightness_setup_srv_cb = {
.init = light_lightness_setup_srv_init,
.deinit = light_lightness_setup_srv_deinit,
};
const struct bt_mesh_model_cb bt_mesh_light_ctl_srv_cb = {
.init = light_ctl_srv_init,
.deinit = light_ctl_srv_deinit,
};
const struct bt_mesh_model_cb bt_mesh_light_ctl_setup_srv_cb = {
.init = light_ctl_setup_srv_init,
.deinit = light_ctl_setup_srv_deinit,
};
const struct bt_mesh_model_cb bt_mesh_light_ctl_temp_srv_cb = {
.init = light_ctl_temp_srv_init,
.deinit = light_ctl_temp_srv_deinit,
};
const struct bt_mesh_model_cb bt_mesh_light_hsl_srv_cb = {
.init = light_hsl_srv_init,
.deinit = light_hsl_srv_deinit,
};
const struct bt_mesh_model_cb bt_mesh_light_hsl_setup_srv_cb = {
.init = light_hsl_setup_srv_init,
.deinit = light_hsl_setup_srv_deinit,
};
const struct bt_mesh_model_cb bt_mesh_light_hsl_hue_srv_cb = {
.init = light_hsl_hue_srv_init,
.deinit = light_hsl_hue_srv_deinit,
};
const struct bt_mesh_model_cb bt_mesh_light_hsl_sat_srv_cb = {
.init = light_hsl_sat_srv_init,
.deinit = light_hsl_sat_srv_deinit,
};
const struct bt_mesh_model_cb bt_mesh_light_xyl_srv_cb = {
.init = light_xyl_srv_init,
.deinit = light_xyl_srv_deinit,
};
const struct bt_mesh_model_cb bt_mesh_light_xyl_setup_srv_cb = {
.init = light_xyl_setup_srv_init,
.deinit = light_xyl_setup_srv_deinit,
};
const struct bt_mesh_model_cb bt_mesh_light_lc_srv_cb = {
.init = light_lc_srv_init,
.deinit = light_lc_srv_deinit,
};
const struct bt_mesh_model_cb bt_mesh_light_lc_setup_srv_cb = {
.init = light_lc_setup_srv_init,
.deinit = light_lc_setup_srv_deinit,
};

View file

@ -985,7 +985,7 @@ static void sensor_setting_set(struct bt_mesh_model *model,
/* message handlers (End) */
/* Mapping of message handlers for Sensor Server (0x1100) */
const struct bt_mesh_model_op sensor_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_sensor_srv_op[] = {
{ BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_GET, 0, sensor_get },
{ BLE_MESH_MODEL_OP_SENSOR_GET, 0, sensor_get },
{ BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET, 2, sensor_get },
@ -994,7 +994,7 @@ const struct bt_mesh_model_op sensor_srv_op[] = {
};
/* Mapping of message handlers for Sensor Setup Server (0x1101) */
const struct bt_mesh_model_op sensor_setup_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_sensor_setup_srv_op[] = {
{ BLE_MESH_MODEL_OP_SENSOR_CADENCE_GET, 2, sensor_get },
{ BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET, 4, sensor_cadence_set },
{ BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK, 4, sensor_cadence_set },
@ -1099,7 +1099,7 @@ static int sensor_server_init(struct bt_mesh_model *model)
return 0;
}
int bt_mesh_sensor_srv_init(struct bt_mesh_model *model, bool primary)
static int sensor_srv_init(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Sensor Server has no publication support");
@ -1117,7 +1117,7 @@ int bt_mesh_sensor_srv_init(struct bt_mesh_model *model, bool primary)
return sensor_server_init(model);
}
int bt_mesh_sensor_setup_srv_init(struct bt_mesh_model *model, bool primary)
static int sensor_setup_srv_init(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Sensor Setup Server has no publication support");
@ -1137,7 +1137,7 @@ static int sensor_server_deinit(struct bt_mesh_model *model)
return 0;
}
int bt_mesh_sensor_srv_deinit(struct bt_mesh_model *model, bool primary)
static int sensor_srv_deinit(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Sensor Server has no publication support");
@ -1147,7 +1147,7 @@ int bt_mesh_sensor_srv_deinit(struct bt_mesh_model *model, bool primary)
return sensor_server_deinit(model);
}
int bt_mesh_sensor_setup_srv_deinit(struct bt_mesh_model *model, bool primary)
static int sensor_setup_srv_deinit(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Sensor Setup Server has no publication support");
@ -1156,3 +1156,13 @@ int bt_mesh_sensor_setup_srv_deinit(struct bt_mesh_model *model, bool primary)
return sensor_server_deinit(model);
}
const struct bt_mesh_model_cb bt_mesh_sensor_srv_cb = {
.init = sensor_srv_init,
.deinit = sensor_srv_deinit,
};
const struct bt_mesh_model_cb bt_mesh_sensor_setup_srv_cb = {
.init = sensor_setup_srv_init,
.deinit = sensor_setup_srv_deinit,
};

View file

@ -1155,7 +1155,7 @@ static void scheduler_act_set(struct bt_mesh_model *model,
/* message handlers (End) */
/* Mapping of message handlers for Time Server (0x1200) */
const struct bt_mesh_model_op time_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_time_srv_op[] = {
{ BLE_MESH_MODEL_OP_TIME_GET, 0, time_get },
{ BLE_MESH_MODEL_OP_TIME_STATUS, 5, time_get },
{ BLE_MESH_MODEL_OP_TIME_ZONE_GET, 0, time_get },
@ -1164,7 +1164,7 @@ const struct bt_mesh_model_op time_srv_op[] = {
};
/* Mapping of message handlers for Time Setup Server (0x1201) */
const struct bt_mesh_model_op time_setup_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_time_setup_srv_op[] = {
{ BLE_MESH_MODEL_OP_TIME_SET, 10, time_set },
{ BLE_MESH_MODEL_OP_TIME_ZONE_SET, 6, time_set },
{ BLE_MESH_MODEL_OP_TAI_UTC_DELTA_SET, 7, time_set },
@ -1174,7 +1174,7 @@ const struct bt_mesh_model_op time_setup_srv_op[] = {
};
/* Mapping of message handlers for Scene Server (0x1203) */
const struct bt_mesh_model_op scene_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_scene_srv_op[] = {
{ BLE_MESH_MODEL_OP_SCENE_GET, 0, scene_get },
{ BLE_MESH_MODEL_OP_SCENE_RECALL, 3, scene_recall },
{ BLE_MESH_MODEL_OP_SCENE_RECALL_UNACK, 3, scene_recall },
@ -1183,7 +1183,7 @@ const struct bt_mesh_model_op scene_srv_op[] = {
};
/* Mapping of message handlers for Scene Setup Server (0x1204) */
const struct bt_mesh_model_op scene_setup_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_scene_setup_srv_op[] = {
{ BLE_MESH_MODEL_OP_SCENE_STORE, 2, scene_action },
{ BLE_MESH_MODEL_OP_SCENE_STORE_UNACK, 2, scene_action },
{ BLE_MESH_MODEL_OP_SCENE_DELETE, 2, scene_action },
@ -1192,14 +1192,14 @@ const struct bt_mesh_model_op scene_setup_srv_op[] = {
};
/* Mapping of message handlers for Scheduler Server (0x1206) */
const struct bt_mesh_model_op scheduler_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_scheduler_srv_op[] = {
{ BLE_MESH_MODEL_OP_SCHEDULER_GET, 0, scheduler_get },
{ BLE_MESH_MODEL_OP_SCHEDULER_ACT_GET, 1, scheduler_get },
BLE_MESH_MODEL_OP_END,
};
/* Mapping of message handlers for Scheduler Setup Server (0x1207) */
const struct bt_mesh_model_op scheduler_setup_srv_op[] = {
const struct bt_mesh_model_op bt_mesh_scheduler_setup_srv_op[] = {
{ BLE_MESH_MODEL_OP_SCHEDULER_ACT_SET, 10, scheduler_act_set },
{ BLE_MESH_MODEL_OP_SCHEDULER_ACT_SET_UNACK, 10, scheduler_act_set },
BLE_MESH_MODEL_OP_END,
@ -1314,7 +1314,7 @@ static int time_scene_server_init(struct bt_mesh_model *model)
return 0;
}
int bt_mesh_time_srv_init(struct bt_mesh_model *model, bool primary)
static int time_srv_init(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Time Server has no publication support");
@ -1333,7 +1333,7 @@ int bt_mesh_time_srv_init(struct bt_mesh_model *model, bool primary)
return time_scene_server_init(model);
}
int bt_mesh_time_setup_srv_init(struct bt_mesh_model *model, bool primary)
static int time_setup_srv_init(struct bt_mesh_model *model)
{
/* This model does not support subscribing nor publishing */
if (model->pub) {
@ -1344,7 +1344,7 @@ int bt_mesh_time_setup_srv_init(struct bt_mesh_model *model, bool primary)
return time_scene_server_init(model);
}
int bt_mesh_scene_srv_init(struct bt_mesh_model *model, bool primary)
static int scene_srv_init(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Scene Server has no publication support");
@ -1352,7 +1352,7 @@ int bt_mesh_scene_srv_init(struct bt_mesh_model *model, bool primary)
}
/* The model may be present only on the Primary element of a node. */
if (primary == false) {
if (!bt_mesh_model_in_primary(model)) {
BT_WARN("Scene Server not on the Primary element");
/* Just give a warning here, continue with the initialization */
}
@ -1368,17 +1368,17 @@ int bt_mesh_scene_srv_init(struct bt_mesh_model *model, bool primary)
return time_scene_server_init(model);
}
int bt_mesh_scene_setup_srv_init(struct bt_mesh_model *model, bool primary)
static int scene_setup_srv_init(struct bt_mesh_model *model)
{
/* The model may be present only on the Primary element of a node. */
if (primary == false) {
if (!bt_mesh_model_in_primary(model)) {
BT_WARN("Scene Setup Server not on the Primary element");
/* Just give a warning here, continue with the initialization */
}
return time_scene_server_init(model);
}
int bt_mesh_scheduler_srv_init(struct bt_mesh_model *model, bool primary)
static int scheduler_srv_init(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Scheduler Server has no publication support");
@ -1386,7 +1386,7 @@ int bt_mesh_scheduler_srv_init(struct bt_mesh_model *model, bool primary)
}
/* The model may be present only on the Primary element of a node. */
if (primary == false) {
if (!bt_mesh_model_in_primary(model)) {
BT_WARN("Scheduler Server not on the Primary element");
/* Just give a warning here, continue with the initialization */
}
@ -1407,10 +1407,10 @@ int bt_mesh_scheduler_srv_init(struct bt_mesh_model *model, bool primary)
return time_scene_server_init(model);
}
int bt_mesh_scheduler_setup_srv_init(struct bt_mesh_model *model, bool primary)
static int scheduler_setup_srv_init(struct bt_mesh_model *model)
{
/* The model may be present only on the Primary element of a node. */
if (primary == false) {
if (!bt_mesh_model_in_primary(model)) {
BT_WARN("Scheduler Setup Server not on the Primary element");
/* Just give a warning here, continue with the initialization */
}
@ -1450,7 +1450,7 @@ static int time_scene_server_deinit(struct bt_mesh_model *model)
return 0;
}
int bt_mesh_time_srv_deinit(struct bt_mesh_model *model, bool primary)
static int time_srv_deinit(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Time Server has no publication support");
@ -1460,7 +1460,7 @@ int bt_mesh_time_srv_deinit(struct bt_mesh_model *model, bool primary)
return time_scene_server_deinit(model);
}
int bt_mesh_time_setup_srv_deinit(struct bt_mesh_model *model, bool primary)
static int time_setup_srv_deinit(struct bt_mesh_model *model)
{
if (model->pub) {
BT_ERR("Time Setup Server shall not support publication");
@ -1470,7 +1470,7 @@ int bt_mesh_time_setup_srv_deinit(struct bt_mesh_model *model, bool primary)
return time_scene_server_deinit(model);
}
int bt_mesh_scene_srv_deinit(struct bt_mesh_model *model, bool primary)
static int scene_srv_deinit(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Scene Server has no publication support");
@ -1480,12 +1480,12 @@ int bt_mesh_scene_srv_deinit(struct bt_mesh_model *model, bool primary)
return time_scene_server_deinit(model);
}
int bt_mesh_scene_setup_srv_deinit(struct bt_mesh_model *model, bool primary)
static int scene_setup_srv_deinit(struct bt_mesh_model *model)
{
return time_scene_server_deinit(model);
}
int bt_mesh_scheduler_srv_deinit(struct bt_mesh_model *model, bool primary)
static int scheduler_srv_deinit(struct bt_mesh_model *model)
{
if (model->pub == NULL) {
BT_ERR("Scheduler Server has no publication support");
@ -1495,7 +1495,37 @@ int bt_mesh_scheduler_srv_deinit(struct bt_mesh_model *model, bool primary)
return time_scene_server_deinit(model);
}
int bt_mesh_scheduler_setup_srv_deinit(struct bt_mesh_model *model, bool primary)
static int scheduler_setup_srv_deinit(struct bt_mesh_model *model)
{
return time_scene_server_deinit(model);
}
const struct bt_mesh_model_cb bt_mesh_time_srv_cb = {
.init = time_srv_init,
.deinit = time_srv_deinit,
};
const struct bt_mesh_model_cb bt_mesh_time_setup_srv_cb = {
.init = time_setup_srv_init,
.deinit = time_setup_srv_deinit,
};
const struct bt_mesh_model_cb bt_mesh_scene_srv_cb = {
.init = scene_srv_init,
.deinit = scene_srv_deinit,
};
const struct bt_mesh_model_cb bt_mesh_scene_setup_srv_cb = {
.init = scene_setup_srv_init,
.deinit = scene_setup_srv_deinit,
};
const struct bt_mesh_model_cb bt_mesh_scheduler_srv_cb = {
.init = scheduler_srv_init,
.deinit = scheduler_srv_deinit,
};
const struct bt_mesh_model_cb bt_mesh_scheduler_setup_srv_cb = {
.init = scheduler_setup_srv_init,
.deinit = scheduler_setup_srv_deinit,
};