summaryrefslogtreecommitdiff
path: root/lib/bt/esp_ble_mesh/api/models
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-03-28 14:32:49 +1100
committerjacqueline <me@jacqueline.id.au>2024-03-28 14:32:49 +1100
commitee29c25b29eaa4fac4e897442634b69ecc8d8125 (patch)
tree8c5f1a140463f20f104316fa3492984e191154e9 /lib/bt/esp_ble_mesh/api/models
parent239e6d89507a24c849385f4bfa93ac4ad58e5de5 (diff)
downloadtangara-fw-ee29c25b29eaa4fac4e897442634b69ecc8d8125.tar.gz
Fork ESP-IDF's bluetooth component
i want better sbc encoding, and no cla will stop me
Diffstat (limited to 'lib/bt/esp_ble_mesh/api/models')
-rw-r--r--lib/bt/esp_ble_mesh/api/models/esp_ble_mesh_config_model_api.c97
-rw-r--r--lib/bt/esp_ble_mesh/api/models/esp_ble_mesh_generic_model_api.c94
-rw-r--r--lib/bt/esp_ble_mesh/api/models/esp_ble_mesh_health_model_api.c101
-rw-r--r--lib/bt/esp_ble_mesh/api/models/esp_ble_mesh_lighting_model_api.c81
-rw-r--r--lib/bt/esp_ble_mesh/api/models/esp_ble_mesh_sensor_model_api.c80
-rw-r--r--lib/bt/esp_ble_mesh/api/models/esp_ble_mesh_time_scene_model_api.c81
-rw-r--r--lib/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_config_model_api.h832
-rw-r--r--lib/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_generic_model_api.h1296
-rw-r--r--lib/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_health_model_api.h406
-rw-r--r--lib/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_lighting_model_api.h1674
-rw-r--r--lib/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_sensor_model_api.h709
-rw-r--r--lib/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_time_scene_model_api.h911
12 files changed, 6362 insertions, 0 deletions
diff --git a/lib/bt/esp_ble_mesh/api/models/esp_ble_mesh_config_model_api.c b/lib/bt/esp_ble_mesh/api/models/esp_ble_mesh_config_model_api.c
new file mode 100644
index 00000000..98155caf
--- /dev/null
+++ b/lib/bt/esp_ble_mesh/api/models/esp_ble_mesh_config_model_api.c
@@ -0,0 +1,97 @@
+/*
+ * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include <stdint.h>
+
+#include "btc/btc_manage.h"
+
+#include "btc_ble_mesh_config_model.h"
+#include "esp_ble_mesh_config_model_api.h"
+
+#if CONFIG_BLE_MESH_CFG_CLI
+esp_err_t esp_ble_mesh_register_config_client_callback(esp_ble_mesh_cfg_client_cb_t callback)
+{
+ ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
+
+ return (btc_profile_cb_set(BTC_PID_CONFIG_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
+}
+
+static bool config_client_get_need_param(esp_ble_mesh_opcode_t opcode)
+{
+ switch (opcode) {
+ case ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_GET:
+ case ESP_BLE_MESH_MODEL_OP_MODEL_PUB_GET:
+ case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_SUB_GET:
+ case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_SUB_GET:
+ case ESP_BLE_MESH_MODEL_OP_APP_KEY_GET:
+ case ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_GET:
+ case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_APP_GET:
+ case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_APP_GET:
+ case ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_GET:
+ case ESP_BLE_MESH_MODEL_OP_LPN_POLLTIMEOUT_GET:
+ return true;
+ default:
+ return false;
+ }
+}
+
+esp_err_t esp_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_t *params,
+ esp_ble_mesh_cfg_client_get_state_t *get_state)
+{
+ btc_ble_mesh_config_client_args_t arg = {0};
+ btc_msg_t msg = {0};
+
+ if (params == NULL || params->model == NULL ||
+ params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
+ !ESP_BLE_MESH_ADDR_IS_UNICAST(params->ctx.addr) ||
+ (config_client_get_need_param(params->opcode) && get_state == NULL)) {
+ return ESP_ERR_INVALID_ARG;
+ }
+
+ ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
+
+ msg.sig = BTC_SIG_API_CALL;
+ msg.pid = BTC_PID_CONFIG_CLIENT;
+ msg.act = BTC_BLE_MESH_ACT_CONFIG_CLIENT_GET_STATE;
+ arg.cfg_client_get_state.params = params;
+ arg.cfg_client_get_state.get_state = get_state;
+
+ return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_config_client_args_t), btc_ble_mesh_config_client_arg_deep_copy,
+ btc_ble_mesh_config_client_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+}
+
+esp_err_t esp_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_t *params,
+ esp_ble_mesh_cfg_client_set_state_t *set_state)
+{
+ btc_ble_mesh_config_client_args_t arg = {0};
+ btc_msg_t msg = {0};
+
+ if (params == NULL || params->model == NULL ||
+ params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
+ !ESP_BLE_MESH_ADDR_IS_UNICAST(params->ctx.addr) ||
+ (params->opcode != ESP_BLE_MESH_MODEL_OP_NODE_RESET && set_state == NULL)) {
+ return ESP_ERR_INVALID_ARG;
+ }
+
+ ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
+
+ msg.sig = BTC_SIG_API_CALL;
+ msg.pid = BTC_PID_CONFIG_CLIENT;
+ msg.act = BTC_BLE_MESH_ACT_CONFIG_CLIENT_SET_STATE;
+ arg.cfg_client_set_state.params = params;
+ arg.cfg_client_set_state.set_state = set_state;
+
+ return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_config_client_args_t), btc_ble_mesh_config_client_arg_deep_copy,
+ btc_ble_mesh_config_client_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+}
+#endif /* CONFIG_BLE_MESH_CFG_CLI */
+
+esp_err_t esp_ble_mesh_register_config_server_callback(esp_ble_mesh_cfg_server_cb_t callback)
+{
+ ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
+
+ return (btc_profile_cb_set(BTC_PID_CONFIG_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
+}
diff --git a/lib/bt/esp_ble_mesh/api/models/esp_ble_mesh_generic_model_api.c b/lib/bt/esp_ble_mesh/api/models/esp_ble_mesh_generic_model_api.c
new file mode 100644
index 00000000..e404c6a5
--- /dev/null
+++ b/lib/bt/esp_ble_mesh/api/models/esp_ble_mesh_generic_model_api.c
@@ -0,0 +1,94 @@
+/*
+ * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include <stdint.h>
+
+#include "btc/btc_manage.h"
+
+#include "btc_ble_mesh_generic_model.h"
+#include "esp_ble_mesh_generic_model_api.h"
+
+#if CONFIG_BLE_MESH_GENERIC_CLIENT
+esp_err_t esp_ble_mesh_register_generic_client_callback(esp_ble_mesh_generic_client_cb_t callback)
+{
+ ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
+
+ return (btc_profile_cb_set(BTC_PID_GENERIC_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
+}
+
+static bool generic_client_get_need_param(esp_ble_mesh_opcode_t opcode)
+{
+ switch (opcode) {
+ case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_GET:
+ case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_GET:
+ case ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_GET:
+ case ESP_BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_GET:
+ return true;
+ default:
+ return false;
+ }
+}
+
+esp_err_t esp_ble_mesh_generic_client_get_state(esp_ble_mesh_client_common_param_t *params,
+ esp_ble_mesh_generic_client_get_state_t *get_state)
+{
+ btc_ble_mesh_generic_client_args_t arg = {0};
+ btc_msg_t msg = {0};
+
+ if (params == NULL || params->model == NULL ||
+ params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
+ params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
+ params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED ||
+ (generic_client_get_need_param(params->opcode) && get_state == NULL)) {
+ return ESP_ERR_INVALID_ARG;
+ }
+
+ ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
+
+ msg.sig = BTC_SIG_API_CALL;
+ msg.pid = BTC_PID_GENERIC_CLIENT;
+ msg.act = BTC_BLE_MESH_ACT_GENERIC_CLIENT_GET_STATE;
+ arg.generic_client_get_state.params = params;
+ arg.generic_client_get_state.get_state = get_state;
+
+ return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_generic_client_args_t), btc_ble_mesh_generic_client_arg_deep_copy,
+ btc_ble_mesh_generic_client_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+}
+
+esp_err_t esp_ble_mesh_generic_client_set_state(esp_ble_mesh_client_common_param_t *params,
+ esp_ble_mesh_generic_client_set_state_t *set_state)
+{
+ btc_ble_mesh_generic_client_args_t arg = {0};
+ btc_msg_t msg = {0};
+
+ if (params == NULL || params->model == NULL || set_state == NULL ||
+ params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
+ params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
+ params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
+ return ESP_ERR_INVALID_ARG;
+ }
+
+ ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
+
+ msg.sig = BTC_SIG_API_CALL;
+ msg.pid = BTC_PID_GENERIC_CLIENT;
+ msg.act = BTC_BLE_MESH_ACT_GENERIC_CLIENT_SET_STATE;
+ arg.generic_client_set_state.params = params;
+ arg.generic_client_set_state.set_state = set_state;
+
+ return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_generic_client_args_t), btc_ble_mesh_generic_client_arg_deep_copy,
+ btc_ble_mesh_generic_client_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+}
+#endif /* CONFIG_BLE_MESH_GENERIC_CLIENT */
+
+#if CONFIG_BLE_MESH_GENERIC_SERVER
+esp_err_t esp_ble_mesh_register_generic_server_callback(esp_ble_mesh_generic_server_cb_t callback)
+{
+ ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
+
+ return (btc_profile_cb_set(BTC_PID_GENERIC_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
+}
+#endif /* CONFIG_BLE_MESH_GENERIC_SERVER */
diff --git a/lib/bt/esp_ble_mesh/api/models/esp_ble_mesh_health_model_api.c b/lib/bt/esp_ble_mesh/api/models/esp_ble_mesh_health_model_api.c
new file mode 100644
index 00000000..2bdb35a3
--- /dev/null
+++ b/lib/bt/esp_ble_mesh/api/models/esp_ble_mesh_health_model_api.c
@@ -0,0 +1,101 @@
+/*
+ * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include <stdint.h>
+
+#include "btc/btc_manage.h"
+
+#include "btc_ble_mesh_health_model.h"
+#include "esp_ble_mesh_health_model_api.h"
+
+#if CONFIG_BLE_MESH_HEALTH_CLI
+esp_err_t esp_ble_mesh_register_health_client_callback(esp_ble_mesh_health_client_cb_t callback)
+{
+ ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
+
+ return (btc_profile_cb_set(BTC_PID_HEALTH_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
+}
+
+esp_err_t esp_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_t *params,
+ esp_ble_mesh_health_client_get_state_t *get_state)
+{
+ btc_ble_mesh_health_client_args_t arg = {0};
+ btc_msg_t msg = {0};
+
+ if (params == NULL || params->model == NULL ||
+ params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
+ params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
+ params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED ||
+ (params->opcode == ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET && get_state == NULL)) {
+ return ESP_ERR_INVALID_ARG;
+ }
+
+ ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
+
+ msg.sig = BTC_SIG_API_CALL;
+ msg.pid = BTC_PID_HEALTH_CLIENT;
+ msg.act = BTC_BLE_MESH_ACT_HEALTH_CLIENT_GET_STATE;
+ arg.health_client_get_state.params = params;
+ arg.health_client_get_state.get_state = get_state;
+
+ return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_health_client_args_t), btc_ble_mesh_health_client_arg_deep_copy,
+ btc_ble_mesh_health_client_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+}
+
+esp_err_t esp_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_t *params,
+ esp_ble_mesh_health_client_set_state_t *set_state)
+{
+ btc_ble_mesh_health_client_args_t arg = {0};
+ btc_msg_t msg = {0};
+
+ if (params == NULL || params->model == NULL || set_state == NULL ||
+ params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
+ params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
+ params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
+ return ESP_ERR_INVALID_ARG;
+ }
+
+ ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
+
+ msg.sig = BTC_SIG_API_CALL;
+ msg.pid = BTC_PID_HEALTH_CLIENT;
+ msg.act = BTC_BLE_MESH_ACT_HEALTH_CLIENT_SET_STATE;
+ arg.health_client_set_state.params = params;
+ arg.health_client_set_state.set_state = set_state;
+
+ return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_health_client_args_t), btc_ble_mesh_health_client_arg_deep_copy,
+ btc_ble_mesh_health_client_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+}
+#endif /* CONFIG_BLE_MESH_HEALTH_CLI */
+
+#if CONFIG_BLE_MESH_HEALTH_SRV
+esp_err_t esp_ble_mesh_register_health_server_callback(esp_ble_mesh_health_server_cb_t callback)
+{
+ ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
+
+ return (btc_profile_cb_set(BTC_PID_HEALTH_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
+}
+
+esp_err_t esp_ble_mesh_health_server_fault_update(esp_ble_mesh_elem_t *element)
+{
+ btc_ble_mesh_health_server_args_t arg = {0};
+ btc_msg_t msg = {0};
+
+ if (element == NULL) {
+ return ESP_ERR_INVALID_ARG;
+ }
+
+ ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
+
+ msg.sig = BTC_SIG_API_CALL;
+ msg.pid = BTC_PID_HEALTH_SERVER;
+ msg.act = BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE;
+ arg.health_fault_update.element = element;
+
+ return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_health_server_args_t), NULL, NULL)
+ == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+}
+#endif /* CONFIG_BLE_MESH_HEALTH_SRV */
diff --git a/lib/bt/esp_ble_mesh/api/models/esp_ble_mesh_lighting_model_api.c b/lib/bt/esp_ble_mesh/api/models/esp_ble_mesh_lighting_model_api.c
new file mode 100644
index 00000000..80bc62f8
--- /dev/null
+++ b/lib/bt/esp_ble_mesh/api/models/esp_ble_mesh_lighting_model_api.c
@@ -0,0 +1,81 @@
+/*
+ * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include <stdint.h>
+
+#include "btc/btc_manage.h"
+
+#include "btc_ble_mesh_lighting_model.h"
+#include "esp_ble_mesh_lighting_model_api.h"
+
+#if CONFIG_BLE_MESH_LIGHTING_CLIENT
+esp_err_t esp_ble_mesh_register_light_client_callback(esp_ble_mesh_light_client_cb_t callback)
+{
+ ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
+
+ return (btc_profile_cb_set(BTC_PID_LIGHTING_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
+}
+
+esp_err_t esp_ble_mesh_light_client_get_state(esp_ble_mesh_client_common_param_t *params,
+ esp_ble_mesh_light_client_get_state_t *get_state)
+{
+ btc_ble_mesh_lighting_client_args_t arg = {0};
+ btc_msg_t msg = {0};
+
+ if (params == NULL || params->model == NULL ||
+ params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
+ params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
+ params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED ||
+ (params->opcode == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET && get_state == NULL)) {
+ return ESP_ERR_INVALID_ARG;
+ }
+
+ ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
+
+ msg.sig = BTC_SIG_API_CALL;
+ msg.pid = BTC_PID_LIGHTING_CLIENT;
+ msg.act = BTC_BLE_MESH_ACT_LIGHTING_CLIENT_GET_STATE;
+ arg.light_client_get_state.params = params;
+ arg.light_client_get_state.get_state = get_state;
+
+ return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_lighting_client_args_t), btc_ble_mesh_lighting_client_arg_deep_copy,
+ btc_ble_mesh_lighting_client_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+}
+
+esp_err_t esp_ble_mesh_light_client_set_state(esp_ble_mesh_client_common_param_t *params,
+ esp_ble_mesh_light_client_set_state_t *set_state)
+{
+ btc_ble_mesh_lighting_client_args_t arg = {0};
+ btc_msg_t msg = {0};
+
+ if (params == NULL || params->model == NULL || set_state == NULL ||
+ params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
+ params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
+ params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
+ return ESP_ERR_INVALID_ARG;
+ }
+
+ ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
+
+ msg.sig = BTC_SIG_API_CALL;
+ msg.pid = BTC_PID_LIGHTING_CLIENT;
+ msg.act = BTC_BLE_MESH_ACT_LIGHTING_CLIENT_SET_STATE;
+ arg.light_client_set_state.params = params;
+ arg.light_client_set_state.set_state = set_state;
+
+ return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_lighting_client_args_t), btc_ble_mesh_lighting_client_arg_deep_copy,
+ btc_ble_mesh_lighting_client_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+}
+#endif /* CONFIG_BLE_MESH_LIGHTING_CLIENT */
+
+#if CONFIG_BLE_MESH_LIGHTING_SERVER
+esp_err_t esp_ble_mesh_register_lighting_server_callback(esp_ble_mesh_lighting_server_cb_t callback)
+{
+ ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
+
+ return (btc_profile_cb_set(BTC_PID_LIGHTING_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
+}
+#endif /* CONFIG_BLE_MESH_LIGHTING_SERVER */
diff --git a/lib/bt/esp_ble_mesh/api/models/esp_ble_mesh_sensor_model_api.c b/lib/bt/esp_ble_mesh/api/models/esp_ble_mesh_sensor_model_api.c
new file mode 100644
index 00000000..c3c047f1
--- /dev/null
+++ b/lib/bt/esp_ble_mesh/api/models/esp_ble_mesh_sensor_model_api.c
@@ -0,0 +1,80 @@
+/*
+ * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include <stdint.h>
+
+#include "btc/btc_manage.h"
+
+#include "btc_ble_mesh_sensor_model.h"
+#include "esp_ble_mesh_sensor_model_api.h"
+
+#if CONFIG_BLE_MESH_SENSOR_CLI
+esp_err_t esp_ble_mesh_register_sensor_client_callback(esp_ble_mesh_sensor_client_cb_t callback)
+{
+ ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
+
+ return (btc_profile_cb_set(BTC_PID_SENSOR_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
+}
+
+esp_err_t esp_ble_mesh_sensor_client_get_state(esp_ble_mesh_client_common_param_t *params,
+ esp_ble_mesh_sensor_client_get_state_t *get_state)
+{
+ btc_ble_mesh_sensor_client_args_t arg = {0};
+ btc_msg_t msg = {0};
+
+ if (params == NULL || params->model == NULL || get_state == NULL ||
+ params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
+ params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
+ params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
+ return ESP_ERR_INVALID_ARG;
+ }
+
+ ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
+
+ msg.sig = BTC_SIG_API_CALL;
+ msg.pid = BTC_PID_SENSOR_CLIENT;
+ msg.act = BTC_BLE_MESH_ACT_SENSOR_CLIENT_GET_STATE;
+ arg.sensor_client_get_state.params = params;
+ arg.sensor_client_get_state.get_state = get_state;
+
+ return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_sensor_client_args_t), btc_ble_mesh_sensor_client_arg_deep_copy,
+ btc_ble_mesh_sensor_client_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+}
+
+esp_err_t esp_ble_mesh_sensor_client_set_state(esp_ble_mesh_client_common_param_t *params,
+ esp_ble_mesh_sensor_client_set_state_t *set_state)
+{
+ btc_ble_mesh_sensor_client_args_t arg = {0};
+ btc_msg_t msg = {0};
+
+ if (params == NULL || params->model == NULL || set_state == NULL ||
+ params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
+ params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
+ params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
+ return ESP_ERR_INVALID_ARG;
+ }
+
+ ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
+
+ msg.sig = BTC_SIG_API_CALL;
+ msg.pid = BTC_PID_SENSOR_CLIENT;
+ msg.act = BTC_BLE_MESH_ACT_SENSOR_CLIENT_SET_STATE;
+ arg.sensor_client_set_state.params = params;
+ arg.sensor_client_set_state.set_state = set_state;
+
+ return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_sensor_client_args_t), btc_ble_mesh_sensor_client_arg_deep_copy,
+ btc_ble_mesh_sensor_client_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+}
+#endif /* CONFIG_BLE_MESH_SENSOR_CLI */
+
+#if CONFIG_BLE_MESH_SENSOR_SERVER
+esp_err_t esp_ble_mesh_register_sensor_server_callback(esp_ble_mesh_sensor_server_cb_t callback)
+{
+ ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
+
+ return (btc_profile_cb_set(BTC_PID_SENSOR_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
+}
+#endif /* CONFIG_BLE_MESH_SENSOR_SERVER */
diff --git a/lib/bt/esp_ble_mesh/api/models/esp_ble_mesh_time_scene_model_api.c b/lib/bt/esp_ble_mesh/api/models/esp_ble_mesh_time_scene_model_api.c
new file mode 100644
index 00000000..686e3d22
--- /dev/null
+++ b/lib/bt/esp_ble_mesh/api/models/esp_ble_mesh_time_scene_model_api.c
@@ -0,0 +1,81 @@
+/*
+ * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include <stdint.h>
+
+#include "btc/btc_manage.h"
+
+#include "btc_ble_mesh_time_scene_model.h"
+#include "esp_ble_mesh_time_scene_model_api.h"
+
+#if CONFIG_BLE_MESH_TIME_SCENE_CLIENT
+esp_err_t esp_ble_mesh_register_time_scene_client_callback(esp_ble_mesh_time_scene_client_cb_t callback)
+{
+ ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
+
+ return (btc_profile_cb_set(BTC_PID_TIME_SCENE_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
+}
+
+esp_err_t esp_ble_mesh_time_scene_client_get_state(esp_ble_mesh_client_common_param_t *params,
+ esp_ble_mesh_time_scene_client_get_state_t *get_state)
+{
+ btc_ble_mesh_time_scene_client_args_t arg = {0};
+ btc_msg_t msg = {0};
+
+ if (params == NULL || params->model == NULL ||
+ params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
+ params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
+ params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED ||
+ (params->opcode == ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_GET && get_state == NULL)) {
+ return ESP_ERR_INVALID_ARG;
+ }
+
+ ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
+
+ msg.sig = BTC_SIG_API_CALL;
+ msg.pid = BTC_PID_TIME_SCENE_CLIENT;
+ msg.act = BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_GET_STATE;
+ arg.time_scene_client_get_state.params = params;
+ arg.time_scene_client_get_state.get_state = get_state;
+
+ return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_time_scene_client_args_t), btc_ble_mesh_time_scene_client_arg_deep_copy,
+ btc_ble_mesh_time_scene_client_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+}
+
+esp_err_t esp_ble_mesh_time_scene_client_set_state(esp_ble_mesh_client_common_param_t *params,
+ esp_ble_mesh_time_scene_client_set_state_t *set_state)
+{
+ btc_ble_mesh_time_scene_client_args_t arg = {0};
+ btc_msg_t msg = {0};
+
+ if (params == NULL || params->model == NULL || set_state == NULL ||
+ params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
+ params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
+ params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
+ return ESP_ERR_INVALID_ARG;
+ }
+
+ ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
+
+ msg.sig = BTC_SIG_API_CALL;
+ msg.pid = BTC_PID_TIME_SCENE_CLIENT;
+ msg.act = BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_SET_STATE;
+ arg.time_scene_client_set_state.params = params;
+ arg.time_scene_client_set_state.set_state = set_state;
+
+ return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_time_scene_client_args_t), btc_ble_mesh_time_scene_client_arg_deep_copy,
+ btc_ble_mesh_time_scene_client_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+}
+#endif /* CONFIG_BLE_MESH_TIME_SCENE_CLIENT */
+
+#if CONFIG_BLE_MESH_TIME_SCENE_SERVER
+esp_err_t esp_ble_mesh_register_time_scene_server_callback(esp_ble_mesh_time_scene_server_cb_t callback)
+{
+ ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
+
+ return (btc_profile_cb_set(BTC_PID_TIME_SCENE_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
+}
+#endif /* CONFIG_BLE_MESH_TIME_SCENE_SERVER */
diff --git a/lib/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_config_model_api.h b/lib/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_config_model_api.h
new file mode 100644
index 00000000..b444465e
--- /dev/null
+++ b/lib/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_config_model_api.h
@@ -0,0 +1,832 @@
+/*
+ * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#ifndef _ESP_BLE_MESH_CONFIG_MODEL_API_H_
+#define _ESP_BLE_MESH_CONFIG_MODEL_API_H_
+
+#include "esp_ble_mesh_defs.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @def ESP_BLE_MESH_MODEL_CFG_SRV
+ *
+ * @brief Define a new Config Server Model.
+ *
+ * @note The Config Server Model can only be included by a Primary Element.
+ *
+ * @param srv_data Pointer to a unique Config Server Model user_data.
+ *
+ * @return New Config Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_CFG_SRV(srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_CONFIG_SRV, \
+ NULL, NULL, srv_data)
+
+/** @def ESP_BLE_MESH_MODEL_CFG_CLI
+ *
+ * @brief Define a new Config Client Model.
+ *
+ * @note The Config Client Model can only be included by a Primary Element.
+ *
+ * @param cli_data Pointer to a unique struct esp_ble_mesh_client_t.
+ *
+ * @return New Config Client Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_CFG_CLI(cli_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_CONFIG_CLI, \
+ NULL, NULL, cli_data)
+
+/** Configuration Server Model context */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to Configuration Server Model */
+
+ uint8_t net_transmit; /*!< Network Transmit state */
+ uint8_t relay; /*!< Relay Mode state */
+ uint8_t relay_retransmit; /*!< Relay Retransmit state */
+ uint8_t beacon; /*!< Secure Network Beacon state */
+ uint8_t gatt_proxy; /*!< GATT Proxy state */
+ uint8_t friend_state; /*!< Friend state */
+ uint8_t default_ttl; /*!< Default TTL */
+
+ /** Heartbeat Publication */
+ struct {
+ struct k_delayed_work timer; /*!< Heartbeat Publication timer */
+
+ uint16_t dst; /*!< Destination address for Heartbeat messages */
+ uint16_t count; /*!< Number of Heartbeat messages to be sent */
+ uint8_t period; /*!< Period for sending Heartbeat messages */
+ uint8_t ttl; /*!< TTL to be used when sending Heartbeat messages */
+ uint16_t feature; /*!< Bit field indicating features that trigger Heartbeat messages when changed */
+ uint16_t net_idx; /*!< NetKey Index used by Heartbeat Publication */
+ } heartbeat_pub;
+
+ /** Heartbeat Subscription */
+ struct {
+ int64_t expiry; /*!< Timestamp when Heartbeat subscription period is expired */
+
+ uint16_t src; /*!< Source address for Heartbeat messages */
+ uint16_t dst; /*!< Destination address for Heartbeat messages */
+ uint16_t count; /*!< Number of Heartbeat messages received */
+ uint8_t min_hops; /*!< Minimum hops when receiving Heartbeat messages */
+ uint8_t max_hops; /*!< Maximum hops when receiving Heartbeat messages */
+
+ /** Optional heartbeat subscription tracking function */
+ esp_ble_mesh_cb_t heartbeat_recv_cb;
+ } heartbeat_sub;
+} esp_ble_mesh_cfg_srv_t;
+
+/** Parameters of Config Composition Data Get. */
+typedef struct {
+ uint8_t page; /*!< Page number of the Composition Data. */
+} esp_ble_mesh_cfg_composition_data_get_t;
+
+/** Parameters of Config Model Publication Get. */
+typedef struct {
+ uint16_t element_addr; /*!< The element address */
+ uint16_t model_id; /*!< The model id */
+ uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */
+} esp_ble_mesh_cfg_model_pub_get_t;
+
+/** Parameters of Config SIG Model Subscription Get. */
+typedef struct {
+ uint16_t element_addr; /*!< The element address */
+ uint16_t model_id; /*!< The model id */
+} esp_ble_mesh_cfg_sig_model_sub_get_t;
+
+/** Parameters of Config Vendor Model Subscription Get. */
+typedef struct {
+ uint16_t element_addr; /*!< The element address */
+ uint16_t model_id; /*!< The model id */
+ uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */
+} esp_ble_mesh_cfg_vnd_model_sub_get_t;
+
+/** Parameters of Config AppKey Get. */
+typedef struct {
+ uint16_t net_idx; /*!< The network key index */
+} esp_ble_mesh_cfg_app_key_get_t;
+
+/** Parameters of Config Node Identity Get. */
+typedef struct {
+ uint16_t net_idx; /*!< The network key index */
+} esp_ble_mesh_cfg_node_identity_get_t;
+
+/** Parameters of Config SIG Model App Get. */
+typedef struct {
+ uint16_t element_addr; /*!< The element address */
+ uint16_t model_id; /*!< The model id */
+} esp_ble_mesh_cfg_sig_model_app_get_t;
+
+/** Parameters of Config Vendor Model App Get. */
+typedef struct {
+ uint16_t element_addr; /*!< The element address */
+ uint16_t model_id; /*!< The model id */
+ uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */
+} esp_ble_mesh_cfg_vnd_model_app_get_t;
+
+/** Parameters of Config Key Refresh Phase Get. */
+typedef struct {
+ uint16_t net_idx; /*!< The network key index */
+} esp_ble_mesh_cfg_kr_phase_get_t;
+
+/** Parameters of Config Low Power Node PollTimeout Get. */
+typedef struct {
+ uint16_t lpn_addr; /*!< The unicast address of the Low Power node */
+} esp_ble_mesh_cfg_lpn_polltimeout_get_t;
+
+/** Parameters of Config Beacon Set. */
+typedef struct {
+ uint8_t beacon; /*!< New Secure Network Beacon state */
+} esp_ble_mesh_cfg_beacon_set_t;
+
+/** Parameters of Config Default TTL Set. */
+typedef struct {
+ uint8_t ttl; /*!< The default TTL state value */
+} esp_ble_mesh_cfg_default_ttl_set_t;
+
+/** Parameters of Config Friend Set. */
+typedef struct {
+ uint8_t friend_state; /*!< The friend state value */
+} esp_ble_mesh_cfg_friend_set_t;
+
+/** Parameters of Config GATT Proxy Set. */
+typedef struct {
+ uint8_t gatt_proxy; /*!< The GATT Proxy state value */
+} esp_ble_mesh_cfg_gatt_proxy_set_t;
+
+/** Parameters of Config Relay Set. */
+typedef struct {
+ uint8_t relay; /*!< The relay value */
+ uint8_t relay_retransmit; /*!< The relay retransmit value */
+} esp_ble_mesh_cfg_relay_set_t;
+
+/** Parameters of Config NetKey Add. */
+typedef struct {
+ uint16_t net_idx; /*!< The network key index */
+ uint8_t net_key[16]; /*!< The network key value */
+} esp_ble_mesh_cfg_net_key_add_t;
+
+/** Parameters of Config AppKey Add. */
+typedef struct {
+ uint16_t net_idx; /*!< The network key index */
+ uint16_t app_idx; /*!< The app key index */
+ uint8_t app_key[16]; /*!< The app key value */
+} esp_ble_mesh_cfg_app_key_add_t;
+
+/** Parameters of Config Model App Bind. */
+typedef struct {
+ uint16_t element_addr; /*!< The element address */
+ uint16_t model_app_idx; /*!< Index of the app key to bind with the model */
+ uint16_t model_id; /*!< The model id */
+ uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */
+} esp_ble_mesh_cfg_model_app_bind_t;
+
+/** Parameters of Config Model Publication Set. */
+typedef struct {
+ uint16_t element_addr; /*!< The element address */
+ uint16_t publish_addr; /*!< Value of the publish address */
+ uint16_t publish_app_idx; /*!< Index of the application key */
+ bool cred_flag; /*!< Value of the Friendship Credential Flag */
+ uint8_t publish_ttl; /*!< Default TTL value for the publishing messages */
+ uint8_t publish_period; /*!< Period for periodic status publishing */
+ uint8_t publish_retransmit; /*!< Number of retransmissions and number of 50-millisecond steps between retransmissions */
+ uint16_t model_id; /*!< The model id */
+ uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */
+} esp_ble_mesh_cfg_model_pub_set_t;
+
+/** Parameters of Config Model Subscription Add. */
+typedef struct {
+ uint16_t element_addr; /*!< The element address */
+ uint16_t sub_addr; /*!< The address to be added to the Subscription List */
+ uint16_t model_id; /*!< The model id */
+ uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */
+} esp_ble_mesh_cfg_model_sub_add_t;
+
+/** Parameters of Config Model Subscription Delete. */
+typedef struct {
+ uint16_t element_addr; /*!< The element address */
+ uint16_t sub_addr; /*!< The address to be removed from the Subscription List */
+ uint16_t model_id; /*!< The model id */
+ uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */
+} esp_ble_mesh_cfg_model_sub_delete_t;
+
+/** Parameters of Config Model Subscription Overwrite. */
+typedef struct {
+ uint16_t element_addr; /*!< The element address */
+ uint16_t sub_addr; /*!< The address to be added to the Subscription List */
+ uint16_t model_id; /*!< The model id */
+ uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */
+} esp_ble_mesh_cfg_model_sub_overwrite_t;
+
+/** Parameters of Config Model Subscription Virtual Address Add. */
+typedef struct {
+ uint16_t element_addr; /*!< The element address */
+ uint8_t label_uuid[16]; /*!< The Label UUID of the virtual address to be added to the Subscription List */
+ uint16_t model_id; /*!< The model id */
+ uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */
+} esp_ble_mesh_cfg_model_sub_va_add_t;
+
+/** Parameters of Config Model Subscription Virtual Address Delete. */
+typedef struct {
+ uint16_t element_addr; /*!< The element address */
+ uint8_t label_uuid[16]; /*!< The Label UUID of the virtual address to be removed from the Subscription List */
+ uint16_t model_id; /*!< The model id */
+ uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */
+} esp_ble_mesh_cfg_model_sub_va_delete_t;
+
+/** Parameters of Config Model Subscription Virtual Address Overwrite. */
+typedef struct {
+ uint16_t element_addr; /*!< The element address */
+ uint8_t label_uuid[16]; /*!< The Label UUID of the virtual address to be added to the Subscription List */
+ uint16_t model_id; /*!< The model id */
+ uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */
+} esp_ble_mesh_cfg_model_sub_va_overwrite_t;
+
+/** Parameters of Config Model Publication Virtual Address Set. */
+typedef struct {
+ uint16_t element_addr; /*!< The element address */
+ uint8_t label_uuid[16]; /*!< Value of the Label UUID publish address */
+ uint16_t publish_app_idx; /*!< Index of the application key */
+ bool cred_flag; /*!< Value of the Friendship Credential Flag */
+ uint8_t publish_ttl; /*!< Default TTL value for the publishing messages */
+ uint8_t publish_period; /*!< Period for periodic status publishing */
+ uint8_t publish_retransmit; /*!< Number of retransmissions and number of 50-millisecond steps between retransmissions */
+ uint16_t model_id; /*!< The model id */
+ uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */
+} esp_ble_mesh_cfg_model_pub_va_set_t;
+
+/** Parameters of Config Model Subscription Delete All. */
+typedef struct {
+ uint16_t element_addr; /*!< The element address */
+ uint16_t model_id; /*!< The model id */
+ uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */
+} esp_ble_mesh_cfg_model_sub_delete_all_t;
+
+/** Parameters of Config NetKey Update. */
+typedef struct {
+ uint16_t net_idx; /*!< The network key index */
+ uint8_t net_key[16]; /*!< The network key value */
+} esp_ble_mesh_cfg_net_key_update_t;
+
+/** Parameters of Config NetKey Delete. */
+typedef struct {
+ uint16_t net_idx; /*!< The network key index */
+} esp_ble_mesh_cfg_net_key_delete_t;
+
+/** Parameters of Config AppKey Update. */
+typedef struct {
+ uint16_t net_idx; /*!< The network key index */
+ uint16_t app_idx; /*!< The app key index */
+ uint8_t app_key[16]; /*!< The app key value */
+} esp_ble_mesh_cfg_app_key_update_t;
+
+/** Parameters of Config AppKey Delete. */
+typedef struct {
+ uint16_t net_idx; /*!< The network key index */
+ uint16_t app_idx; /*!< The app key index */
+} esp_ble_mesh_cfg_app_key_delete_t;
+
+/** Parameters of Config Node Identity Set. */
+typedef struct {
+ uint16_t net_idx; /*!< The network key index */
+ uint8_t identity; /*!< New Node Identity state */
+} esp_ble_mesh_cfg_node_identity_set_t;
+
+/** Parameters of Config Model App Unbind. */
+typedef struct {
+ uint16_t element_addr; /*!< The element address */
+ uint16_t model_app_idx; /*!< Index of the app key to bind with the model */
+ uint16_t model_id; /*!< The model id */
+ uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */
+} esp_ble_mesh_cfg_model_app_unbind_t;
+
+/** Parameters of Config Key Refresh Phase Set. */
+typedef struct {
+ uint16_t net_idx; /*!< The network key index */
+ uint8_t transition; /*!< New Key Refresh Phase Transition */
+} esp_ble_mesh_cfg_kr_phase_set_t;
+
+/** Parameters of Config Network Transmit Set. */
+typedef struct {
+ uint8_t net_transmit; /*!< Network Transmit State */
+} esp_ble_mesh_cfg_net_transmit_set_t;
+
+/** Parameters of Config Model Heartbeat Publication Set. */
+typedef struct {
+ uint16_t dst; /*!< Destination address for Heartbeat messages */
+ uint8_t count; /*!< Number of Heartbeat messages to be sent */
+ uint8_t period; /*!< Period for sending Heartbeat messages */
+ uint8_t ttl; /*!< TTL to be used when sending Heartbeat messages */
+ uint16_t feature; /*!< Bit field indicating features that trigger Heartbeat messages when changed */
+ uint16_t net_idx; /*!< NetKey Index */
+} esp_ble_mesh_cfg_heartbeat_pub_set_t;
+
+/** Parameters of Config Model Heartbeat Subscription Set. */
+typedef struct {
+ uint16_t src; /*!< Source address for Heartbeat messages */
+ uint16_t dst; /*!< Destination address for Heartbeat messages */
+ uint8_t period; /*!< Period for receiving Heartbeat messages */
+} esp_ble_mesh_cfg_heartbeat_sub_set_t;
+
+/**
+ * @brief For ESP_BLE_MESH_MODEL_OP_BEACON_GET
+ * ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_GET
+ * ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_GET
+ * ESP_BLE_MESH_MODEL_OP_GATT_PROXY_GET
+ * ESP_BLE_MESH_MODEL_OP_RELAY_GET
+ * ESP_BLE_MESH_MODEL_OP_MODEL_PUB_GET
+ * ESP_BLE_MESH_MODEL_OP_FRIEND_GET
+ * ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_GET
+ * ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_GET
+ * the get_state parameter in the esp_ble_mesh_config_client_get_state function should not be set to NULL.
+ */
+typedef union {
+ esp_ble_mesh_cfg_model_pub_get_t model_pub_get; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_PUB_GET. */
+ esp_ble_mesh_cfg_composition_data_get_t comp_data_get; /*!< For ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_GET. */
+ esp_ble_mesh_cfg_sig_model_sub_get_t sig_model_sub_get; /*!< For ESP_BLE_MESH_MODEL_OP_SIG_MODEL_SUB_GET */
+ esp_ble_mesh_cfg_vnd_model_sub_get_t vnd_model_sub_get; /*!< For ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_SUB_GET */
+ esp_ble_mesh_cfg_app_key_get_t app_key_get; /*!< For ESP_BLE_MESH_MODEL_OP_APP_KEY_GET. */
+ esp_ble_mesh_cfg_node_identity_get_t node_identity_get; /*!< For ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_GET. */
+ esp_ble_mesh_cfg_sig_model_app_get_t sig_model_app_get; /*!< For ESP_BLE_MESH_MODEL_OP_SIG_MODEL_APP_GET */
+ esp_ble_mesh_cfg_vnd_model_app_get_t vnd_model_app_get; /*!< For ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_APP_GET */
+ esp_ble_mesh_cfg_kr_phase_get_t kr_phase_get; /*!< For ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_GET */
+ esp_ble_mesh_cfg_lpn_polltimeout_get_t lpn_pollto_get; /*!< For ESP_BLE_MESH_MODEL_OP_LPN_POLLTIMEOUT_GET */
+} esp_ble_mesh_cfg_client_get_state_t;
+
+/**
+ * @brief For ESP_BLE_MESH_MODEL_OP_BEACON_SET
+ * ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_SET
+ * ESP_BLE_MESH_MODEL_OP_GATT_PROXY_SET
+ * ESP_BLE_MESH_MODEL_OP_RELAY_SET
+ * ESP_BLE_MESH_MODEL_OP_MODEL_PUB_SET
+ * ESP_BLE_MESH_MODEL_OP_MODEL_SUB_ADD
+ * ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_ADD
+ * ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE
+ * ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_DELETE
+ * ESP_BLE_MESH_MODEL_OP_MODEL_SUB_OVERWRITE
+ * ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_OVERWRITE
+ * ESP_BLE_MESH_MODEL_OP_NET_KEY_ADD
+ * ESP_BLE_MESH_MODEL_OP_APP_KEY_ADD
+ * ESP_BLE_MESH_MODEL_OP_MODEL_APP_BIND
+ * ESP_BLE_MESH_MODEL_OP_NODE_RESET
+ * ESP_BLE_MESH_MODEL_OP_FRIEND_SET
+ * ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_SET
+ * ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_SET
+ * the set_state parameter in the esp_ble_mesh_config_client_set_state function should not be set to NULL.
+ */
+typedef union {
+ esp_ble_mesh_cfg_beacon_set_t beacon_set; /*!< For ESP_BLE_MESH_MODEL_OP_BEACON_SET */
+ esp_ble_mesh_cfg_default_ttl_set_t default_ttl_set; /*!< For ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_SET */
+ esp_ble_mesh_cfg_friend_set_t friend_set; /*!< For ESP_BLE_MESH_MODEL_OP_FRIEND_SET */
+ esp_ble_mesh_cfg_gatt_proxy_set_t gatt_proxy_set; /*!< For ESP_BLE_MESH_MODEL_OP_GATT_PROXY_SET */
+ esp_ble_mesh_cfg_relay_set_t relay_set; /*!< For ESP_BLE_MESH_MODEL_OP_RELAY_SET */
+ esp_ble_mesh_cfg_net_key_add_t net_key_add; /*!< For ESP_BLE_MESH_MODEL_OP_NET_KEY_ADD */
+ esp_ble_mesh_cfg_app_key_add_t app_key_add; /*!< For ESP_BLE_MESH_MODEL_OP_APP_KEY_ADD */
+ esp_ble_mesh_cfg_model_app_bind_t model_app_bind; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_APP_BIND */
+ esp_ble_mesh_cfg_model_pub_set_t model_pub_set; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_PUB_SET */
+ esp_ble_mesh_cfg_model_sub_add_t model_sub_add; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_SUB_ADD */
+ esp_ble_mesh_cfg_model_sub_delete_t model_sub_delete; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE */
+ esp_ble_mesh_cfg_model_sub_overwrite_t model_sub_overwrite; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_SUB_OVERWRITE */
+ esp_ble_mesh_cfg_model_sub_va_add_t model_sub_va_add; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_ADD */
+ esp_ble_mesh_cfg_model_sub_va_delete_t model_sub_va_delete; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_DELETE */
+ esp_ble_mesh_cfg_model_sub_va_overwrite_t model_sub_va_overwrite; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_OVERWRITE */
+ esp_ble_mesh_cfg_heartbeat_pub_set_t heartbeat_pub_set; /*!< For ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_SET */
+ esp_ble_mesh_cfg_heartbeat_sub_set_t heartbeat_sub_set; /*!< For ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_SET */
+ esp_ble_mesh_cfg_model_pub_va_set_t model_pub_va_set; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_PUB_VIRTUAL_ADDR_SET */
+ esp_ble_mesh_cfg_model_sub_delete_all_t model_sub_delete_all; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE_ALL */
+ esp_ble_mesh_cfg_net_key_update_t net_key_update; /*!< For ESP_BLE_MESH_MODEL_OP_NET_KEY_UPDATE */
+ esp_ble_mesh_cfg_net_key_delete_t net_key_delete; /*!< For ESP_BLE_MESH_MODEL_OP_NET_KEY_DELETE */
+ esp_ble_mesh_cfg_app_key_update_t app_key_update; /*!< For ESP_BLE_MESH_MODEL_OP_APP_KEY_UPDATE */
+ esp_ble_mesh_cfg_app_key_delete_t app_key_delete; /*!< For ESP_BLE_MESH_MODEL_OP_APP_KEY_DELETE */
+ esp_ble_mesh_cfg_node_identity_set_t node_identity_set; /*!< For ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_SET */
+ esp_ble_mesh_cfg_model_app_unbind_t model_app_unbind; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_APP_UNBIND */
+ esp_ble_mesh_cfg_kr_phase_set_t kr_phase_set; /*!< For ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_SET */
+ esp_ble_mesh_cfg_net_transmit_set_t net_transmit_set; /*!< For ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_SET */
+} esp_ble_mesh_cfg_client_set_state_t;
+
+/** Parameter of Config Beacon Status */
+typedef struct {
+ uint8_t beacon; /*!< Secure Network Beacon state value */
+} esp_ble_mesh_cfg_beacon_status_cb_t;
+
+/** Parameters of Config Composition Data Status */
+typedef struct {
+ uint8_t page; /*!< Page number of the Composition Data */
+ struct net_buf_simple *composition_data; /*!< Pointer to Composition Data for the identified page */
+} esp_ble_mesh_cfg_comp_data_status_cb_t;
+
+/** Parameter of Config Default TTL Status */
+typedef struct {
+ uint8_t default_ttl; /*!< Default TTL state value */
+} esp_ble_mesh_cfg_default_ttl_status_cb_t;
+
+/** Parameter of Config GATT Proxy Status */
+typedef struct {
+ uint8_t gatt_proxy; /*!< GATT Proxy state value */
+} esp_ble_mesh_cfg_gatt_proxy_status_cb_t;
+
+/** Parameters of Config Relay Status */
+typedef struct {
+ uint8_t relay; /*!< Relay state value */
+ uint8_t retransmit; /*!< Relay retransmit value(number of retransmissions and number of 10-millisecond steps between retransmissions) */
+} esp_ble_mesh_cfg_relay_status_cb_t;
+
+/** Parameters of Config Model Publication Status */
+typedef struct {
+ uint8_t status; /*!< Status Code for the request message */
+ uint16_t element_addr; /*!< Address of the element */
+ uint16_t publish_addr; /*!< Value of the publish address */
+ uint16_t app_idx; /*!< Index of the application key */
+ bool cred_flag; /*!< Value of the Friendship Credential Flag */
+ uint8_t ttl; /*!< Default TTL value for the outgoing messages */
+ uint8_t period; /*!< Period for periodic status publishing */
+ uint8_t transmit; /*!< Number of retransmissions and number of 50-millisecond steps between retransmissions */
+ uint16_t company_id; /*!< Company ID */
+ uint16_t model_id; /*!< Model ID */
+} esp_ble_mesh_cfg_model_pub_status_cb_t;
+
+/** Parameters of Config Model Subscription Status */
+typedef struct {
+ uint8_t status; /*!< Status Code for the request message */
+ uint16_t element_addr; /*!< Address of the element */
+ uint16_t sub_addr; /*!< Value of the address */
+ uint16_t company_id; /*!< Company ID */
+ uint16_t model_id; /*!< Model ID */
+} esp_ble_mesh_cfg_model_sub_status_cb_t;
+
+/** Parameters of Config NetKey Status */
+typedef struct {
+ uint8_t status; /*!< Status Code for the request message */
+ uint16_t net_idx; /*!< Index of the NetKey */
+} esp_ble_mesh_cfg_net_key_status_cb_t;
+
+/** Parameters of Config AppKey Status */
+typedef struct {
+ uint8_t status; /*!< Status Code for the request message */
+ uint16_t net_idx; /*!< Index of the NetKey */
+ uint16_t app_idx; /*!< Index of the application key */
+} esp_ble_mesh_cfg_app_key_status_cb_t;
+
+/** Parameters of Config Model App Status */
+typedef struct {
+ uint8_t status; /*!< Status Code for the request message */
+ uint16_t element_addr; /*!< Address of the element */
+ uint16_t app_idx; /*!< Index of the application key */
+ uint16_t company_id; /*!< Company ID */
+ uint16_t model_id; /*!< Model ID */
+} esp_ble_mesh_cfg_mod_app_status_cb_t;
+
+/** Parameter of Config Friend Status */
+typedef struct {
+ uint8_t friend_state; /*!< Friend state value */
+} esp_ble_mesh_cfg_friend_status_cb_t;
+
+/** Parameters of Config Heartbeat Publication Status */
+typedef struct {
+ uint8_t status; /*!< Status Code for the request message */
+ uint16_t dst; /*!< Destination address for Heartbeat messages */
+ uint8_t count; /*!< Number of Heartbeat messages remaining to be sent */
+ uint8_t period; /*!< Period for sending Heartbeat messages */
+ uint8_t ttl; /*!< TTL to be used when sending Heartbeat messages */
+ uint16_t features; /*!< Features that trigger Heartbeat messages when changed */
+ uint16_t net_idx; /*!< Index of the NetKey */
+} esp_ble_mesh_cfg_hb_pub_status_cb_t;
+
+/** Parameters of Config Heartbeat Subscription Status */
+typedef struct {
+ uint8_t status; /*!< Status Code for the request message */
+ uint16_t src; /*!< Source address for Heartbeat messages */
+ uint16_t dst; /*!< Destination address for Heartbeat messages */
+ uint8_t period; /*!< Remaining Period for processing Heartbeat messages */
+ uint8_t count; /*!< Number of Heartbeat messages received */
+ uint8_t min_hops; /*!< Minimum hops when receiving Heartbeat messages */
+ uint8_t max_hops; /*!< Maximum hops when receiving Heartbeat messages */
+} esp_ble_mesh_cfg_hb_sub_status_cb_t;
+
+/** Parameters of Config Network Transmit Status */
+typedef struct {
+ uint8_t net_trans_count: 3; /*!< Number of transmissions for each Network PDU originating from the node */
+ uint8_t net_trans_step : 5; /*!< Maximum hops when receiving Heartbeat messages */
+} esp_ble_mesh_cfg_net_trans_status_cb_t;
+
+/** Parameters of Config SIG/Vendor Subscription List */
+typedef struct {
+ uint8_t status; /*!< Status Code for the request message */
+ uint16_t element_addr; /*!< Address of the element */
+ uint16_t company_id; /*!< Company ID */
+ uint16_t model_id; /*!< Model ID */
+ struct net_buf_simple *sub_addr; /*!< A block of all addresses from the Subscription List */
+} esp_ble_mesh_cfg_model_sub_list_cb_t;
+
+/** Parameter of Config NetKey List */
+typedef struct {
+ struct net_buf_simple *net_idx; /*!< A list of NetKey Indexes known to the node */
+} esp_ble_mesh_cfg_net_key_list_cb_t;
+
+/** Parameters of Config AppKey List */
+typedef struct {
+ uint8_t status; /*!< Status Code for the request message */
+ uint16_t net_idx; /*!< NetKey Index of the NetKey that the AppKeys are bound to */
+ struct net_buf_simple *app_idx; /*!< A list of AppKey indexes that are bound to the NetKey identified by NetKeyIndex */
+} esp_ble_mesh_cfg_app_key_list_cb_t;
+
+/** Parameters of Config Node Identity Status */
+typedef struct {
+ uint8_t status; /*!< Status Code for the request message */
+ uint16_t net_idx; /*!< Index of the NetKey */
+ uint8_t identity; /*!< Node Identity state */
+} esp_ble_mesh_cfg_node_id_status_cb_t;
+
+/** Parameters of Config SIG/Vendor Model App List */
+typedef struct {
+ uint8_t status; /*!< Status Code for the request message */
+ uint16_t element_addr; /*!< Address of the element */
+ uint16_t company_id; /*!< Company ID */
+ uint16_t model_id; /*!< Model ID */
+ struct net_buf_simple *app_idx; /*!< All AppKey indexes bound to the Model */
+} esp_ble_mesh_cfg_model_app_list_cb_t;
+
+/** Parameters of Config Key Refresh Phase Status */
+typedef struct {
+ uint8_t status; /*!< Status Code for the request message */
+ uint16_t net_idx; /*!< Index of the NetKey */
+ uint8_t phase; /*!< Key Refresh Phase state */
+} esp_ble_mesh_cfg_kr_phase_status_cb_t;
+
+/** Parameters of Config Low Power Node PollTimeout Status */
+typedef struct {
+ uint16_t lpn_addr; /*!< The unicast address of the Low Power node */
+ int32_t poll_timeout; /*!< The current value of the PollTimeout timer of the Low Power node */
+} esp_ble_mesh_cfg_lpn_pollto_status_cb_t;
+
+/**
+ * @brief Configuration Client Model received message union
+ */
+typedef union {
+ esp_ble_mesh_cfg_beacon_status_cb_t beacon_status; /*!< The beacon status value */
+ esp_ble_mesh_cfg_comp_data_status_cb_t comp_data_status; /*!< The composition data status value */
+ esp_ble_mesh_cfg_default_ttl_status_cb_t default_ttl_status; /*!< The default_ttl status value */
+ esp_ble_mesh_cfg_gatt_proxy_status_cb_t gatt_proxy_status; /*!< The gatt_proxy status value */
+ esp_ble_mesh_cfg_relay_status_cb_t relay_status; /*!< The relay status value */
+ esp_ble_mesh_cfg_model_pub_status_cb_t model_pub_status; /*!< The model publication status value */
+ esp_ble_mesh_cfg_model_sub_status_cb_t model_sub_status; /*!< The model subscription status value */
+ esp_ble_mesh_cfg_net_key_status_cb_t netkey_status; /*!< The netkey status value */
+ esp_ble_mesh_cfg_app_key_status_cb_t appkey_status; /*!< The appkey status value */
+ esp_ble_mesh_cfg_mod_app_status_cb_t model_app_status; /*!< The model app status value */
+ esp_ble_mesh_cfg_friend_status_cb_t friend_status; /*!< The friend status value */
+ esp_ble_mesh_cfg_hb_pub_status_cb_t heartbeat_pub_status; /*!< The heartbeat publication status value */
+ esp_ble_mesh_cfg_hb_sub_status_cb_t heartbeat_sub_status; /*!< The heartbeat subscription status value */
+ esp_ble_mesh_cfg_net_trans_status_cb_t net_transmit_status; /*!< The network transmit status value */
+ esp_ble_mesh_cfg_model_sub_list_cb_t model_sub_list; /*!< The model subscription list value */
+ esp_ble_mesh_cfg_net_key_list_cb_t netkey_list; /*!< The network key index list value */
+ esp_ble_mesh_cfg_app_key_list_cb_t appkey_list; /*!< The application key index list value */
+ esp_ble_mesh_cfg_node_id_status_cb_t node_identity_status; /*!< The node identity status value */
+ esp_ble_mesh_cfg_model_app_list_cb_t model_app_list; /*!< The model application key index list value */
+ esp_ble_mesh_cfg_kr_phase_status_cb_t kr_phase_status; /*!< The key refresh phase status value */
+ esp_ble_mesh_cfg_lpn_pollto_status_cb_t lpn_timeout_status; /*!< The low power node poll timeout status value */
+} esp_ble_mesh_cfg_client_common_cb_param_t;
+
+/** Configuration Client Model callback parameters */
+typedef struct {
+ int error_code; /*!< Appropriate error code */
+ esp_ble_mesh_client_common_param_t *params; /*!< The client common parameters */
+ esp_ble_mesh_cfg_client_common_cb_param_t status_cb; /*!< The config status message callback values */
+} esp_ble_mesh_cfg_client_cb_param_t;
+
+/** This enum value is the event of Configuration Client Model */
+typedef enum {
+ ESP_BLE_MESH_CFG_CLIENT_GET_STATE_EVT,
+ ESP_BLE_MESH_CFG_CLIENT_SET_STATE_EVT,
+ ESP_BLE_MESH_CFG_CLIENT_PUBLISH_EVT,
+ ESP_BLE_MESH_CFG_CLIENT_TIMEOUT_EVT,
+ ESP_BLE_MESH_CFG_CLIENT_EVT_MAX,
+} esp_ble_mesh_cfg_client_cb_event_t;
+
+/**
+ * @brief Configuration Server model related context.
+ */
+
+/** Parameters of Config Model Publication Set */
+typedef struct {
+ uint16_t element_addr; /*!< Element Address */
+ uint16_t pub_addr; /*!< Publish Address */
+ uint16_t app_idx; /*!< AppKey Index */
+ bool cred_flag; /*!< Friendship Credential Flag */
+ uint8_t pub_ttl; /*!< Publish TTL */
+ uint8_t pub_period; /*!< Publish Period */
+ uint8_t pub_retransmit; /*!< Publish Retransmit */
+ uint16_t company_id; /*!< Company ID */
+ uint16_t model_id; /*!< Model ID */
+} esp_ble_mesh_state_change_cfg_mod_pub_set_t;
+
+/** Parameters of Config Model Publication Virtual Address Set */
+typedef struct {
+ uint16_t element_addr; /*!< Element Address */
+ uint8_t label_uuid[16]; /*!< Label UUID */
+ uint16_t app_idx; /*!< AppKey Index */
+ bool cred_flag; /*!< Friendship Credential Flag */
+ uint8_t pub_ttl; /*!< Publish TTL */
+ uint8_t pub_period; /*!< Publish Period */
+ uint8_t pub_retransmit; /*!< Publish Retransmit */
+ uint16_t company_id; /*!< Company ID */
+ uint16_t model_id; /*!< Model ID */
+} esp_ble_mesh_state_change_cfg_mod_pub_va_set_t;
+
+/** Parameters of Config Model Subscription Add */
+typedef struct {
+ uint16_t element_addr; /*!< Element Address */
+ uint16_t sub_addr; /*!< Subscription Address */
+ uint16_t company_id; /*!< Company ID */
+ uint16_t model_id; /*!< Model ID */
+} esp_ble_mesh_state_change_cfg_model_sub_add_t;
+
+/** Parameters of Config Model Subscription Delete */
+typedef struct {
+ uint16_t element_addr; /*!< Element Address */
+ uint16_t sub_addr; /*!< Subscription Address */
+ uint16_t company_id; /*!< Company ID */
+ uint16_t model_id; /*!< Model ID */
+} esp_ble_mesh_state_change_cfg_model_sub_delete_t;
+
+/** Parameters of Config NetKey Add */
+typedef struct {
+ uint16_t net_idx; /*!< NetKey Index */
+ uint8_t net_key[16]; /*!< NetKey */
+} esp_ble_mesh_state_change_cfg_netkey_add_t;
+
+/** Parameters of Config NetKey Update */
+typedef struct {
+ uint16_t net_idx; /*!< NetKey Index */
+ uint8_t net_key[16]; /*!< NetKey */
+} esp_ble_mesh_state_change_cfg_netkey_update_t;
+
+/** Parameter of Config NetKey Delete */
+typedef struct {
+ uint16_t net_idx; /*!< NetKey Index */
+} esp_ble_mesh_state_change_cfg_netkey_delete_t;
+
+/** Parameters of Config AppKey Add */
+typedef struct {
+ uint16_t net_idx; /*!< NetKey Index */
+ uint16_t app_idx; /*!< AppKey Index */
+ uint8_t app_key[16]; /*!< AppKey */
+} esp_ble_mesh_state_change_cfg_appkey_add_t;
+
+/** Parameters of Config AppKey Update */
+typedef struct {
+ uint16_t net_idx; /*!< NetKey Index */
+ uint16_t app_idx; /*!< AppKey Index */
+ uint8_t app_key[16]; /*!< AppKey */
+} esp_ble_mesh_state_change_cfg_appkey_update_t;
+
+/** Parameters of Config AppKey Delete */
+typedef struct {
+ uint16_t net_idx; /*!< NetKey Index */
+ uint16_t app_idx; /*!< AppKey Index */
+} esp_ble_mesh_state_change_cfg_appkey_delete_t;
+
+/** Parameters of Config Model App Bind */
+typedef struct {
+ uint16_t element_addr; /*!< Element Address */
+ uint16_t app_idx; /*!< AppKey Index */
+ uint16_t company_id; /*!< Company ID */
+ uint16_t model_id; /*!< Model ID */
+} esp_ble_mesh_state_change_cfg_model_app_bind_t;
+
+/** Parameters of Config Model App Unbind */
+typedef struct {
+ uint16_t element_addr; /*!< Element Address */
+ uint16_t app_idx; /*!< AppKey Index */
+ uint16_t company_id; /*!< Company ID */
+ uint16_t model_id; /*!< Model ID */
+} esp_ble_mesh_state_change_cfg_model_app_unbind_t;
+
+/** Parameters of Config Key Refresh Phase Set */
+typedef struct {
+ uint16_t net_idx; /*!< NetKey Index */
+ uint8_t kr_phase; /*!< New Key Refresh Phase Transition */
+} esp_ble_mesh_state_change_cfg_kr_phase_set_t;
+
+/**
+ * @brief Configuration Server model state change value union
+ */
+typedef union {
+ /**
+ * The recv_op in ctx can be used to decide which state is changed.
+ */
+ esp_ble_mesh_state_change_cfg_mod_pub_set_t mod_pub_set; /*!< Config Model Publication Set */
+ esp_ble_mesh_state_change_cfg_mod_pub_va_set_t mod_pub_va_set; /*!< Config Model Publication Virtual Address Set */
+ esp_ble_mesh_state_change_cfg_model_sub_add_t mod_sub_add; /*!< Config Model Subscription Add */
+ esp_ble_mesh_state_change_cfg_model_sub_delete_t mod_sub_delete; /*!< Config Model Subscription Delete */
+ esp_ble_mesh_state_change_cfg_netkey_add_t netkey_add; /*!< Config NetKey Add */
+ esp_ble_mesh_state_change_cfg_netkey_update_t netkey_update; /*!< Config NetKey Update */
+ esp_ble_mesh_state_change_cfg_netkey_delete_t netkey_delete; /*!< Config NetKey Delete */
+ esp_ble_mesh_state_change_cfg_appkey_add_t appkey_add; /*!< Config AppKey Add */
+ esp_ble_mesh_state_change_cfg_appkey_update_t appkey_update; /*!< Config AppKey Update */
+ esp_ble_mesh_state_change_cfg_appkey_delete_t appkey_delete; /*!< Config AppKey Delete */
+ esp_ble_mesh_state_change_cfg_model_app_bind_t mod_app_bind; /*!< Config Model App Bind */
+ esp_ble_mesh_state_change_cfg_model_app_unbind_t mod_app_unbind; /*!< Config Model App Unbind */
+ esp_ble_mesh_state_change_cfg_kr_phase_set_t kr_phase_set; /*!< Config Key Refresh Phase Set */
+} esp_ble_mesh_cfg_server_state_change_t;
+
+/**
+ * @brief Configuration Server model callback value union
+ */
+typedef union {
+ esp_ble_mesh_cfg_server_state_change_t state_change; /*!< ESP_BLE_MESH_CFG_SERVER_STATE_CHANGE_EVT */
+} esp_ble_mesh_cfg_server_cb_value_t;
+
+/** Configuration Server model callback parameters */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the server model structure */
+ esp_ble_mesh_msg_ctx_t ctx; /*!< Context of the received message */
+ esp_ble_mesh_cfg_server_cb_value_t value; /*!< Value of the received configuration messages */
+} esp_ble_mesh_cfg_server_cb_param_t;
+
+/** This enum value is the event of Configuration Server model */
+typedef enum {
+ ESP_BLE_MESH_CFG_SERVER_STATE_CHANGE_EVT,
+ ESP_BLE_MESH_CFG_SERVER_EVT_MAX,
+} esp_ble_mesh_cfg_server_cb_event_t;
+
+/**
+ * @brief Bluetooth Mesh Config Client and Server Model functions.
+ */
+
+/**
+ * @brief Configuration Client Model callback function type
+ * @param event: Event type
+ * @param param: Pointer to callback parameter
+ */
+typedef void (* esp_ble_mesh_cfg_client_cb_t)(esp_ble_mesh_cfg_client_cb_event_t event,
+ esp_ble_mesh_cfg_client_cb_param_t *param);
+
+/**
+ * @brief Configuration Server Model callback function type
+ * @param event: Event type
+ * @param param: Pointer to callback parameter
+ */
+typedef void (* esp_ble_mesh_cfg_server_cb_t)(esp_ble_mesh_cfg_server_cb_event_t event,
+ esp_ble_mesh_cfg_server_cb_param_t *param);
+
+/**
+ * @brief Register BLE Mesh Config Client Model callback.
+ *
+ * @param[in] callback: Pointer to the callback function.
+ *
+ * @return ESP_OK on success or error code otherwise.
+ *
+ */
+esp_err_t esp_ble_mesh_register_config_client_callback(esp_ble_mesh_cfg_client_cb_t callback);
+
+/**
+ * @brief Register BLE Mesh Config Server Model callback.
+ *
+ * @param[in] callback: Pointer to the callback function.
+ *
+ * @return ESP_OK on success or error code otherwise.
+ *
+ */
+esp_err_t esp_ble_mesh_register_config_server_callback(esp_ble_mesh_cfg_server_cb_t callback);
+
+/**
+ * @brief Get the value of Config Server Model states using the Config Client Model get messages.
+ *
+ * @note If you want to find the opcodes and corresponding meanings accepted by this API,
+ * please refer to esp_ble_mesh_opcode_config_client_get_t in esp_ble_mesh_defs.h
+ *
+ * @param[in] params: Pointer to BLE Mesh common client parameters.
+ * @param[in] get_state: Pointer to a union, each kind of opcode corresponds to one structure inside.
+ * Shall not be set to NULL.
+ *
+ * @return ESP_OK on success or error code otherwise.
+ *
+ */
+esp_err_t esp_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_t *params,
+ esp_ble_mesh_cfg_client_get_state_t *get_state);
+
+/**
+ * @brief Set the value of the Configuration Server Model states using the Config Client Model set messages.
+ *
+ * @note If you want to find the opcodes and corresponding meanings accepted by this API,
+ * please refer to esp_ble_mesh_opcode_config_client_set_t in esp_ble_mesh_defs.h
+ *
+ * @param[in] params: Pointer to BLE Mesh common client parameters.
+ * @param[in] set_state: Pointer to a union, each kind of opcode corresponds to one structure inside.
+ * Shall not be set to NULL.
+ *
+ * @return ESP_OK on success or error code otherwise.
+ *
+ */
+esp_err_t esp_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_t *params,
+ esp_ble_mesh_cfg_client_set_state_t *set_state);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ESP_BLE_MESH_CONFIG_MODEL_API_H_ */
diff --git a/lib/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_generic_model_api.h b/lib/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_generic_model_api.h
new file mode 100644
index 00000000..fc4808af
--- /dev/null
+++ b/lib/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_generic_model_api.h
@@ -0,0 +1,1296 @@
+/*
+ * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/** @file
+ * @brief Bluetooth Mesh Generic Client Model APIs.
+ */
+
+#ifndef _ESP_BLE_MESH_GENERIC_MODEL_API_H_
+#define _ESP_BLE_MESH_GENERIC_MODEL_API_H_
+
+#include "esp_ble_mesh_defs.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @def ESP_BLE_MESH_MODEL_GEN_ONOFF_CLI
+ *
+ * @brief Define a new Generic OnOff Client Model.
+ *
+ * @note This API needs to be called for each element on which
+ * the application needs to have a Generic OnOff Client Model.
+ *
+ * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t.
+ *
+ * @return New Generic OnOff Client Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_GEN_ONOFF_CLI(cli_pub, cli_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_CLI, \
+ NULL, cli_pub, cli_data)
+
+/** @def ESP_BLE_MESH_MODEL_GEN_LEVEL_CLI
+ *
+ * @brief Define a new Generic Level Client Model.
+ *
+ * @note This API needs to be called for each element on which
+ * the application needs to have a Generic Level Client Model.
+ *
+ * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t.
+ *
+ * @return New Generic Level Client Model instance.
+ */
+
+#define ESP_BLE_MESH_MODEL_GEN_LEVEL_CLI(cli_pub, cli_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_LEVEL_CLI, \
+ NULL, cli_pub, cli_data)
+
+/** @def ESP_BLE_MESH_MODEL_GEN_DEF_TRANS_TIME_CLI
+ *
+ * @brief Define a new Generic Default Transition Time Client Model.
+ *
+ * @note This API needs to be called for each element on which
+ * the application needs to have a Generic Default Transition
+ * Time Client Model.
+ *
+ * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t.
+ *
+ * @return New Generic Default Transition Time Client Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_GEN_DEF_TRANS_TIME_CLI(cli_pub, cli_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI, \
+ NULL, cli_pub, cli_data)
+
+/** @def ESP_BLE_MESH_MODEL_GEN_POWER_ONOFF_CLI
+ *
+ * @brief Define a new Generic Power OnOff Client Model.
+ *
+ * @note This API needs to be called for each element on which
+ * the application needs to have a Generic Power OnOff Client Model.
+ *
+ * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t.
+ *
+ * @return New Generic Power OnOff Client Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_GEN_POWER_ONOFF_CLI(cli_pub, cli_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI, \
+ NULL, cli_pub, cli_data)
+
+/** @def ESP_BLE_MESH_MODEL_GEN_POWER_LEVEL_CLI
+ *
+ * @brief Define a new Generic Power Level Client Model.
+ *
+ * @note This API needs to be called for each element on which
+ * the application needs to have a Generic Power Level Client Model.
+ *
+ * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t.
+ *
+ * @return New Generic Power Level Client Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_GEN_POWER_LEVEL_CLI(cli_pub, cli_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI, \
+ NULL, cli_pub, cli_data)
+
+/** @def ESP_BLE_MESH_MODEL_GEN_BATTERY_CLI
+ *
+ * @brief Define a new Generic Battery Client Model.
+ *
+ * @note This API needs to be called for each element on which
+ * the application needs to have a Generic Battery Client Model.
+ *
+ * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t.
+ *
+ * @return New Generic Battery Client Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_GEN_BATTERY_CLI(cli_pub, cli_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_BATTERY_CLI, \
+ NULL, cli_pub, cli_data)
+
+/** @def ESP_BLE_MESH_MODEL_GEN_LOCATION_CLI
+ *
+ * @brief Define a new Generic Location Client Model.
+ *
+ * @note This API needs to be called for each element on which
+ * the application needs to have a Generic Location Client Model.
+ *
+ * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t.
+ *
+ * @return New Generic Location Client Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_GEN_LOCATION_CLI(cli_pub, cli_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_CLI, \
+ NULL, cli_pub, cli_data)
+
+/** @def ESP_BLE_MESH_MODEL_GEN_PROPERTY_CLI
+ *
+ * @brief Define a new Generic Property Client Model.
+ *
+ * @note This API needs to be called for each element on which
+ * the application needs to have a Generic Property Client Model.
+ *
+ * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t.
+ *
+ * @return New Generic Location Client Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_GEN_PROPERTY_CLI(cli_pub, cli_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_PROP_CLI, \
+ NULL, cli_pub, cli_data)
+
+/**
+ * @brief Bluetooth Mesh Generic Client Model Get and Set parameters structure.
+ */
+
+/** Parameters of Generic OnOff Set. */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint8_t onoff; /*!< Target value of Generic OnOff state */
+ uint8_t tid; /*!< Transaction ID */
+ uint8_t trans_time; /*!< Time to complete state transition (optional) */
+ uint8_t delay; /*!< Indicate message execution delay (C.1) */
+} esp_ble_mesh_gen_onoff_set_t;
+
+/** Parameters of Generic Level Set. */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ int16_t level; /*!< Target value of Generic Level state */
+ uint8_t tid; /*!< Transaction ID */
+ uint8_t trans_time; /*!< Time to complete state transition (optional) */
+ uint8_t delay; /*!< Indicate message execution delay (C.1) */
+} esp_ble_mesh_gen_level_set_t;
+
+/** Parameters of Generic Delta Set. */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ int32_t level; /*!< Delta change of Generic Level state */
+ uint8_t tid; /*!< Transaction ID */
+ uint8_t trans_time; /*!< Time to complete state transition (optional) */
+ uint8_t delay; /*!< Indicate message execution delay (C.1) */
+} esp_ble_mesh_gen_delta_set_t;
+
+/** Parameters of Generic Move Set. */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ int16_t delta_level; /*!< Delta Level step to calculate Move speed for Generic Level state */
+ uint8_t tid; /*!< Transaction ID */
+ uint8_t trans_time; /*!< Time to complete state transition (optional) */
+ uint8_t delay; /*!< Indicate message execution delay (C.1) */
+} esp_ble_mesh_gen_move_set_t;
+
+/** Parameter of Generic Default Transition Time Set. */
+typedef struct {
+ uint8_t trans_time; /*!< The value of the Generic Default Transition Time state */
+} esp_ble_mesh_gen_def_trans_time_set_t;
+
+/** Parameter of Generic OnPowerUp Set. */
+typedef struct {
+ uint8_t onpowerup; /*!< The value of the Generic OnPowerUp state */
+} esp_ble_mesh_gen_onpowerup_set_t;
+
+/** Parameters of Generic Power Level Set. */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t power; /*!< Target value of Generic Power Actual state */
+ uint8_t tid; /*!< Transaction ID */
+ uint8_t trans_time; /*!< Time to complete state transition (optional) */
+ uint8_t delay; /*!< Indicate message execution delay (C.1) */
+} esp_ble_mesh_gen_power_level_set_t;
+
+/** Parameter of Generic Power Default Set. */
+typedef struct {
+ uint16_t power; /*!< The value of the Generic Power Default state */
+} esp_ble_mesh_gen_power_default_set_t;
+
+/** Parameters of Generic Power Range Set. */
+typedef struct {
+ uint16_t range_min; /*!< Value of Range Min field of Generic Power Range state */
+ uint16_t range_max; /*!< Value of Range Max field of Generic Power Range state */
+} esp_ble_mesh_gen_power_range_set_t;
+
+/** Parameters of Generic Location Global Set. */
+typedef struct {
+ int32_t global_latitude; /*!< Global Coordinates (Latitude) */
+ int32_t global_longitude; /*!< Global Coordinates (Longitude) */
+ int16_t global_altitude; /*!< Global Altitude */
+} esp_ble_mesh_gen_loc_global_set_t;
+
+/** Parameters of Generic Location Local Set. */
+typedef struct {
+ int16_t local_north; /*!< Local Coordinates (North) */
+ int16_t local_east; /*!< Local Coordinates (East) */
+ int16_t local_altitude; /*!< Local Altitude */
+ uint8_t floor_number; /*!< Floor Number */
+ uint16_t uncertainty; /*!< Uncertainty */
+} esp_ble_mesh_gen_loc_local_set_t;
+
+/** Parameter of Generic User Property Get. */
+typedef struct {
+ uint16_t property_id; /*!< Property ID identifying a Generic User Property */
+} esp_ble_mesh_gen_user_property_get_t;
+
+/** Parameters of Generic User Property Set. */
+typedef struct {
+ uint16_t property_id; /*!< Property ID identifying a Generic User Property */
+ struct net_buf_simple *property_value; /*!< Raw value for the User Property */
+} esp_ble_mesh_gen_user_property_set_t;
+
+/** Parameter of Generic Admin Property Get. */
+typedef struct {
+ uint16_t property_id; /*!< Property ID identifying a Generic Admin Property */
+} esp_ble_mesh_gen_admin_property_get_t;
+
+/** Parameters of Generic Admin Property Set. */
+typedef struct {
+ uint16_t property_id; /*!< Property ID identifying a Generic Admin Property */
+ uint8_t user_access; /*!< Enumeration indicating user access */
+ struct net_buf_simple *property_value; /*!< Raw value for the Admin Property */
+} esp_ble_mesh_gen_admin_property_set_t;
+
+/** Parameter of Generic Manufacturer Property Get. */
+typedef struct {
+ uint16_t property_id; /*!< Property ID identifying a Generic Manufacturer Property */
+} esp_ble_mesh_gen_manufacturer_property_get_t;
+
+/** Parameters of Generic Manufacturer Property Set. */
+typedef struct {
+ uint16_t property_id; /*!< Property ID identifying a Generic Manufacturer Property */
+ uint8_t user_access; /*!< Enumeration indicating user access */
+} esp_ble_mesh_gen_manufacturer_property_set_t;
+
+/** Parameter of Generic Client Properties Get. */
+typedef struct {
+ uint16_t property_id; /*!< A starting Client Property ID present within an element */
+} esp_ble_mesh_gen_client_properties_get_t;
+
+/**
+ * @brief Generic Client Model get message union
+ */
+typedef union {
+ esp_ble_mesh_gen_user_property_get_t user_property_get; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_GET */
+ esp_ble_mesh_gen_admin_property_get_t admin_property_get; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_GET*/
+ esp_ble_mesh_gen_manufacturer_property_get_t manufacturer_property_get; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_SET */
+ esp_ble_mesh_gen_client_properties_get_t client_properties_get; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_GET */
+} esp_ble_mesh_generic_client_get_state_t;
+
+/**
+ * @brief Generic Client Model set message union
+ */
+typedef union {
+ esp_ble_mesh_gen_onoff_set_t onoff_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET & ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET_UNACK */
+ esp_ble_mesh_gen_level_set_t level_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_LEVEL_SET & ESP_BLE_MESH_MODEL_OP_GEN_LEVEL_SET_UNACK */
+ esp_ble_mesh_gen_delta_set_t delta_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_DELTA_SET & ESP_BLE_MESH_MODEL_OP_GEN_DELTA_SET_UNACK */
+ esp_ble_mesh_gen_move_set_t move_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_MOVE_SET & ESP_BLE_MESH_MODEL_OP_GEN_MOVE_SET_UNACK */
+ esp_ble_mesh_gen_def_trans_time_set_t def_trans_time_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET & ESP_BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET_UNACK */
+ esp_ble_mesh_gen_onpowerup_set_t power_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_ONPOWERUP_SET & ESP_BLE_MESH_MODEL_OP_GEN_ONPOWERUP_SET_UNACK */
+ esp_ble_mesh_gen_power_level_set_t power_level_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_SET & ESP_BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_SET_UNACK */
+ esp_ble_mesh_gen_power_default_set_t power_default_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_SET & ESP_BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_SET_UNACK */
+ esp_ble_mesh_gen_power_range_set_t power_range_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_POWER_RANGE_SET & ESP_BLE_MESH_MODEL_OP_GEN_POWER_RANGE_SET_UNACK */
+ esp_ble_mesh_gen_loc_global_set_t loc_global_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_SET & ESP_BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_SET_UNACK */
+ esp_ble_mesh_gen_loc_local_set_t loc_local_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_SET & ESP_BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_SET_UNACK */
+ esp_ble_mesh_gen_user_property_set_t user_property_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET & ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET_UNACK */
+ esp_ble_mesh_gen_admin_property_set_t admin_property_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET & ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET_UNACK */
+ esp_ble_mesh_gen_manufacturer_property_set_t manufacturer_property_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_SET & ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_SET_UNACK */
+} esp_ble_mesh_generic_client_set_state_t;
+
+/**
+ * @brief Bluetooth Mesh Generic Client Model Get and Set callback parameters structure.
+ */
+
+/** Parameters of Generic OnOff Status. */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint8_t present_onoff; /*!< Current value of Generic OnOff state */
+ uint8_t target_onoff; /*!< Target value of Generic OnOff state (optional) */
+ uint8_t remain_time; /*!< Time to complete state transition (C.1) */
+} esp_ble_mesh_gen_onoff_status_cb_t;
+
+/** Parameters of Generic Level Status. */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ int16_t present_level; /*!< Current value of Generic Level state */
+ int16_t target_level; /*!< Target value of the Generic Level state (optional) */
+ uint8_t remain_time; /*!< Time to complete state transition (C.1) */
+} esp_ble_mesh_gen_level_status_cb_t;
+
+/** Parameter of Generic Default Transition Time Status. */
+typedef struct {
+ uint8_t trans_time; /*!< The value of the Generic Default Transition Time state */
+} esp_ble_mesh_gen_def_trans_time_status_cb_t;
+
+/** Parameter of Generic OnPowerUp Status. */
+typedef struct {
+ uint8_t onpowerup; /*!< The value of the Generic OnPowerUp state */
+} esp_ble_mesh_gen_onpowerup_status_cb_t;
+
+/** Parameters of Generic Power Level Status. */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t present_power; /*!< Current value of Generic Power Actual state */
+ uint16_t target_power; /*!< Target value of Generic Power Actual state (optional) */
+ uint8_t remain_time; /*!< Time to complete state transition (C.1) */
+} esp_ble_mesh_gen_power_level_status_cb_t;
+
+/** Parameter of Generic Power Last Status. */
+typedef struct {
+ uint16_t power; /*!< The value of the Generic Power Last state */
+} esp_ble_mesh_gen_power_last_status_cb_t;
+
+/** Parameter of Generic Power Default Status. */
+typedef struct {
+ uint16_t power; /*!< The value of the Generic Default Last state */
+} esp_ble_mesh_gen_power_default_status_cb_t;
+
+/** Parameters of Generic Power Range Status. */
+typedef struct {
+ uint8_t status_code; /*!< Status Code for the request message */
+ uint16_t range_min; /*!< Value of Range Min field of Generic Power Range state */
+ uint16_t range_max; /*!< Value of Range Max field of Generic Power Range state */
+} esp_ble_mesh_gen_power_range_status_cb_t;
+
+/** Parameters of Generic Battery Status. */
+typedef struct {
+ uint32_t battery_level : 8; /*!< Value of Generic Battery Level state */
+ uint32_t time_to_discharge : 24; /*!< Value of Generic Battery Time to Discharge state */
+ uint32_t time_to_charge : 24; /*!< Value of Generic Battery Time to Charge state */
+ uint32_t flags : 8; /*!< Value of Generic Battery Flags state */
+} esp_ble_mesh_gen_battery_status_cb_t;
+
+/** Parameters of Generic Location Global Status. */
+typedef struct {
+ int32_t global_latitude; /*!< Global Coordinates (Latitude) */
+ int32_t global_longitude; /*!< Global Coordinates (Longitude) */
+ int16_t global_altitude; /*!< Global Altitude */
+} esp_ble_mesh_gen_loc_global_status_cb_t;
+
+/** Parameters of Generic Location Local Status. */
+typedef struct {
+ int16_t local_north; /*!< Local Coordinates (North) */
+ int16_t local_east; /*!< Local Coordinates (East) */
+ int16_t local_altitude; /*!< Local Altitude */
+ uint8_t floor_number; /*!< Floor Number */
+ uint16_t uncertainty; /*!< Uncertainty */
+} esp_ble_mesh_gen_loc_local_status_cb_t;
+
+/** Parameter of Generic User Properties Status. */
+typedef struct {
+ struct net_buf_simple *property_ids; /*!< Buffer contains a sequence of N User Property IDs */
+} esp_ble_mesh_gen_user_properties_status_cb_t;
+
+/** Parameters of Generic User Property Status. */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t property_id; /*!< Property ID identifying a Generic User Property */
+ uint8_t user_access; /*!< Enumeration indicating user access (optional) */
+ struct net_buf_simple *property_value; /*!< Raw value for the User Property (C.1) */
+} esp_ble_mesh_gen_user_property_status_cb_t;
+
+/** Parameter of Generic Admin Properties Status. */
+typedef struct {
+ struct net_buf_simple *property_ids; /*!< Buffer contains a sequence of N Admin Property IDs */
+} esp_ble_mesh_gen_admin_properties_status_cb_t;
+
+/** Parameters of Generic Admin Property Status. */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t property_id; /*!< Property ID identifying a Generic Admin Property */
+ uint8_t user_access; /*!< Enumeration indicating user access (optional) */
+ struct net_buf_simple *property_value; /*!< Raw value for the Admin Property (C.1) */
+} esp_ble_mesh_gen_admin_property_status_cb_t;
+
+/** Parameter of Generic Manufacturer Properties Status. */
+typedef struct {
+ struct net_buf_simple *property_ids; /*!< Buffer contains a sequence of N Manufacturer Property IDs */
+} esp_ble_mesh_gen_manufacturer_properties_status_cb_t;
+
+/** Parameters of Generic Manufacturer Property Status. */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t property_id; /*!< Property ID identifying a Generic Manufacturer Property */
+ uint8_t user_access; /*!< Enumeration indicating user access (optional) */
+ struct net_buf_simple *property_value; /*!< Raw value for the Manufacturer Property (C.1) */
+} esp_ble_mesh_gen_manufacturer_property_status_cb_t;
+
+/** Parameter of Generic Client Properties Status. */
+typedef struct {
+ struct net_buf_simple *property_ids; /*!< Buffer contains a sequence of N Client Property IDs */
+} esp_ble_mesh_gen_client_properties_status_cb_t;
+
+/**
+ * @brief Generic Client Model received message union
+ */
+typedef union {
+ esp_ble_mesh_gen_onoff_status_cb_t onoff_status; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_STATUS */
+ esp_ble_mesh_gen_level_status_cb_t level_status; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_LEVEL_STATUS */
+ esp_ble_mesh_gen_def_trans_time_status_cb_t def_trans_time_status; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_STATUS */
+ esp_ble_mesh_gen_onpowerup_status_cb_t onpowerup_status; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_ONPOWERUP_STATUS */
+ esp_ble_mesh_gen_power_level_status_cb_t power_level_status; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_STATUS */
+ esp_ble_mesh_gen_power_last_status_cb_t power_last_status; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_POWER_LAST_STATUS */
+ esp_ble_mesh_gen_power_default_status_cb_t power_default_status; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_STATUS */
+ esp_ble_mesh_gen_power_range_status_cb_t power_range_status; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_POWER_RANGE_STATUS */
+ esp_ble_mesh_gen_battery_status_cb_t battery_status; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_BATTERY_STATUS */
+ esp_ble_mesh_gen_loc_global_status_cb_t location_global_status; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_STATUS */
+ esp_ble_mesh_gen_loc_local_status_cb_t location_local_status; /*!< ESP_BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_STATUS */
+ esp_ble_mesh_gen_user_properties_status_cb_t user_properties_status; /*!< ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_STATUS */
+ esp_ble_mesh_gen_user_property_status_cb_t user_property_status; /*!< ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_STATUS */
+ esp_ble_mesh_gen_admin_properties_status_cb_t admin_properties_status; /*!< ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTIES_STATUS */
+ esp_ble_mesh_gen_admin_property_status_cb_t admin_property_status; /*!< ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_STATUS */
+ esp_ble_mesh_gen_manufacturer_properties_status_cb_t manufacturer_properties_status; /*!< ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTIES_STATUS */
+ esp_ble_mesh_gen_manufacturer_property_status_cb_t manufacturer_property_status; /*!< ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_STATUS */
+ esp_ble_mesh_gen_client_properties_status_cb_t client_properties_status; /*!< ESP_BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_STATUS */
+} esp_ble_mesh_gen_client_status_cb_t;
+
+/** Generic Client Model callback parameters */
+typedef struct {
+ int error_code; /*!< Appropriate error code */
+ esp_ble_mesh_client_common_param_t *params; /*!< The client common parameters. */
+ esp_ble_mesh_gen_client_status_cb_t status_cb; /*!< The generic status message callback values */
+} esp_ble_mesh_generic_client_cb_param_t;
+
+/** This enum value is the event of Generic Client Model */
+typedef enum {
+ ESP_BLE_MESH_GENERIC_CLIENT_GET_STATE_EVT,
+ ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT,
+ ESP_BLE_MESH_GENERIC_CLIENT_PUBLISH_EVT,
+ ESP_BLE_MESH_GENERIC_CLIENT_TIMEOUT_EVT,
+ ESP_BLE_MESH_GENERIC_CLIENT_EVT_MAX,
+} esp_ble_mesh_generic_client_cb_event_t;
+
+/**
+ * @brief Bluetooth Mesh Generic Client Model function.
+ */
+
+/**
+ * @brief Generic Client Model callback function type
+ * @param event: Event type
+ * @param param: Pointer to callback parameter
+ */
+typedef void (* esp_ble_mesh_generic_client_cb_t)(esp_ble_mesh_generic_client_cb_event_t event,
+ esp_ble_mesh_generic_client_cb_param_t *param);
+
+/**
+ * @brief Register BLE Mesh Generic Client Model callback.
+ *
+ * @param[in] callback: Pointer to the callback function.
+ *
+ * @return ESP_OK on success or error code otherwise.
+ *
+ */
+esp_err_t esp_ble_mesh_register_generic_client_callback(esp_ble_mesh_generic_client_cb_t callback);
+
+/**
+ * @brief Get the value of Generic Server Model states using the Generic Client Model get messages.
+ *
+ * @note If you want to find the opcodes and corresponding meanings accepted by this API,
+ * please refer to esp_ble_mesh_generic_message_opcode_t in esp_ble_mesh_defs.h
+ *
+ * @param[in] params: Pointer to BLE Mesh common client parameters.
+ * @param[in] get_state: Pointer to generic get message value.
+ * Shall not be set to NULL.
+ *
+ * @return ESP_OK on success or error code otherwise.
+ *
+ */
+esp_err_t esp_ble_mesh_generic_client_get_state(esp_ble_mesh_client_common_param_t *params,
+ esp_ble_mesh_generic_client_get_state_t *get_state);
+
+/**
+ * @brief Set the value of Generic Server Model states using the Generic Client Model set messages.
+ *
+ * @note If you want to find the opcodes and corresponding meanings accepted by this API,
+ * please refer to esp_ble_mesh_generic_message_opcode_t in esp_ble_mesh_defs.h
+ *
+ * @param[in] params: Pointer to BLE Mesh common client parameters.
+ * @param[in] set_state: Pointer to generic set message value.
+ * Shall not be set to NULL.
+ *
+ * @return ESP_OK on success or error code otherwise.
+ *
+ */
+esp_err_t esp_ble_mesh_generic_client_set_state(esp_ble_mesh_client_common_param_t *params,
+ esp_ble_mesh_generic_client_set_state_t *set_state);
+
+/**
+ * @brief Generic Server Models related context.
+ */
+
+/** @def ESP_BLE_MESH_MODEL_GEN_ONOFF_SRV
+ *
+ * @brief Define a new Generic OnOff Server Model.
+ *
+ * @note 1. The Generic OnOff Server Model is a root model.
+ * 2. This model shall support model publication and model subscription.
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_gen_onoff_srv_t.
+ *
+ * @return New Generic OnOff Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_GEN_ONOFF_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_SRV, \
+ NULL, srv_pub, srv_data)
+
+/** @def ESP_BLE_MESH_MODEL_GEN_LEVEL_SRV
+ *
+ * @brief Define a new Generic Level Server Model.
+ *
+ * @note 1. The Generic Level Server Model is a root model.
+ * 2. This model shall support model publication and model subscription.
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_gen_level_srv_t.
+ *
+ * @return New Generic Level Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_GEN_LEVEL_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_LEVEL_SRV, \
+ NULL, srv_pub, srv_data)
+
+/** @def ESP_BLE_MESH_MODEL_GEN_DEF_TRANS_TIME_SRV
+ *
+ * @brief Define a new Generic Default Transition Time Server Model.
+ *
+ * @note 1. The Generic Default Transition Time Server Model is a root model.
+ * 2. This model shall support model publication and model subscription.
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_gen_def_trans_time_srv_t.
+ *
+ * @return New Generic Default Transition Time Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_GEN_DEF_TRANS_TIME_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_SRV, \
+ NULL, srv_pub, srv_data)
+
+/** @def ESP_BLE_MESH_MODEL_GEN_POWER_ONOFF_SRV
+ *
+ * @brief Define a new Generic Power OnOff Server Model.
+ *
+ * @note 1. The Generic Power OnOff Server model extends the Generic OnOff Server
+ * model. When this model is present on an element, the corresponding
+ * Generic Power OnOff Setup Server model shall also be present.
+ * 2. This model may be used to represent a variety of devices that do not
+ * fit any of the model descriptions that have been defined but support
+ * the generic properties of On/Off.
+ * 3. This model shall support model publication and model subscription.
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_gen_power_onoff_srv_t.
+ *
+ * @return New Generic Power OnOff Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_GEN_POWER_ONOFF_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SRV, \
+ NULL, srv_pub, srv_data)
+
+/** @def ESP_BLE_MESH_MODEL_GEN_POWER_ONOFF_SETUP_SRV
+ *
+ * @brief Define a new Generic Power OnOff Setup Server Model.
+ *
+ * @note 1. The Generic Power OnOff Setup Server model extends the Generic Power
+ * OnOff Server model and the Generic Default Transition Time Server model.
+ * 2. This model shall support model subscription.
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_gen_power_onoff_setup_srv_t.
+ *
+ * @return New Generic Power OnOff Setup Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_GEN_POWER_ONOFF_SETUP_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SETUP_SRV, \
+ NULL, srv_pub, srv_data)
+
+/** @def ESP_BLE_MESH_MODEL_GEN_POWER_LEVEL_SRV
+ *
+ * @brief Define a new Generic Power Level Server Model.
+ *
+ * @note 1. The Generic Power Level Server model extends the Generic Power OnOff
+ * Server model and the Generic Level Server model. When this model is
+ * present on an Element, the corresponding Generic Power Level Setup
+ * Server model shall also be present.
+ * 2. This model shall support model publication and model subscription.
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_gen_power_level_srv_t.
+ *
+ * @return New Generic Power Level Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_GEN_POWER_LEVEL_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV, \
+ NULL, srv_pub, srv_data)
+
+/** @def ESP_BLE_MESH_MODEL_GEN_POWER_LEVEL_SETUP_SRV
+ *
+ * @brief Define a new Generic Power Level Setup Server Model.
+ *
+ * @note 1. The Generic Power Level Setup Server model extends the Generic Power
+ * Level Server model and the Generic Power OnOff Setup Server model.
+ * 2. This model shall support model subscription.
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_gen_power_level_setup_srv_t.
+ *
+ * @return New Generic Power Level Setup Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_GEN_POWER_LEVEL_SETUP_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV, \
+ NULL, srv_pub, srv_data)
+
+/** @def ESP_BLE_MESH_MODEL_GEN_BATTERY_SRV
+ *
+ * @brief Define a new Generic Battery Server Model.
+ *
+ * @note 1. The Generic Battery Server Model is a root model.
+ * 2. This model shall support model publication and model subscription.
+ * 3. The model may be used to represent an element that is powered by a battery.
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_gen_battery_srv_t.
+ *
+ * @return New Generic Battery Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_GEN_BATTERY_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_BATTERY_SRV, \
+ NULL, srv_pub, srv_data)
+
+/** @def ESP_BLE_MESH_MODEL_GEN_LOCATION_SRV
+ *
+ * @brief Define a new Generic Location Server Model.
+ *
+ * @note 1. The Generic Location Server model is a root model. When this model
+ * is present on an Element, the corresponding Generic Location Setup
+ * Server model shall also be present.
+ * 2. This model shall support model publication and model subscription.
+ * 3. The model may be used to represent an element that knows its
+ * location (global or local).
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_gen_location_srv_t.
+ *
+ * @return New Generic Location Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_GEN_LOCATION_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_SRV, \
+ NULL, srv_pub, srv_data)
+
+/** @def ESP_BLE_MESH_MODEL_GEN_LOCATION_SETUP_SRV
+ *
+ * @brief Define a new Generic Location Setup Server Model.
+ *
+ * @note 1. The Generic Location Setup Server model extends the Generic Location
+ * Server model.
+ * 2. This model shall support model subscription.
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_gen_location_setup_srv_t.
+ *
+ * @return New Generic Location Setup Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_GEN_LOCATION_SETUP_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_SETUP_SRV, \
+ NULL, srv_pub, srv_data)
+
+/** @def ESP_BLE_MESH_MODEL_GEN_USER_PROP_SRV
+ *
+ * @brief Define a new Generic User Property Server Model.
+ *
+ * @note 1. The Generic User Property Server model is a root model.
+ * 2. This model shall support model publication and model subscription.
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_gen_user_prop_srv_t.
+ *
+ * @return New Generic User Property Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_GEN_USER_PROP_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_USER_PROP_SRV, \
+ NULL, srv_pub, srv_data)
+
+/** @def ESP_BLE_MESH_MODEL_GEN_ADMIN_PROP_SRV
+ *
+ * @brief Define a new Generic Admin Property Server Model.
+ *
+ * @note 1. The Generic Admin Property Server model extends the Generic User
+ * Property Server model.
+ * 2. This model shall support model publication and model subscription.
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_gen_admin_prop_srv_t.
+ *
+ * @return New Generic Admin Property Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_GEN_ADMIN_PROP_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV, \
+ NULL, srv_pub, srv_data)
+
+/** @def ESP_BLE_MESH_MODEL_GEN_MANUFACTURER_PROP_SRV
+ *
+ * @brief Define a new Generic Manufacturer Property Server Model.
+ *
+ * @note 1. The Generic Manufacturer Property Server model extends the Generic
+ * User Property Server model.
+ * 2. This model shall support model publication and model subscription.
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_gen_manu_prop_srv_t.
+ *
+ * @return New Generic Manufacturer Property Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_GEN_MANUFACTURER_PROP_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV, \
+ NULL, srv_pub, srv_data)
+
+/** @def ESP_BLE_MESH_MODEL_GEN_CLIENT_PROP_SRV
+ *
+ * @brief Define a new Generic User Property Server Model.
+ *
+ * @note 1. The Generic Client Property Server model is a root model.
+ * 2. This model shall support model publication and model subscription.
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_gen_client_prop_srv_t.
+ *
+ * @return New Generic Client Property Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_GEN_CLIENT_PROP_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_CLIENT_PROP_SRV, \
+ NULL, srv_pub, srv_data)
+
+/** Parameters of Generic OnOff state */
+typedef struct {
+ uint8_t onoff; /*!< The present value of the Generic OnOff state */
+ uint8_t target_onoff; /*!< The target value of the Generic OnOff state */
+} esp_ble_mesh_gen_onoff_state_t;
+
+/** User data of Generic OnOff Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Generic OnOff Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ esp_ble_mesh_gen_onoff_state_t state; /*!< Parameters of the Generic OnOff state */
+ esp_ble_mesh_last_msg_info_t last; /*!< Parameters of the last received set message */
+ esp_ble_mesh_state_transition_t transition; /*!< Parameters of state transition */
+} esp_ble_mesh_gen_onoff_srv_t;
+
+/** Parameters of Generic Level state */
+typedef struct {
+ int16_t level; /*!< The present value of the Generic Level state */
+ int16_t target_level; /*!< The target value of the Generic Level state */
+
+ /**
+ * When a new transaction starts, level should be set to last_last, and use
+ * "level + incoming delta" to calculate the target level. In another word,
+ * "last_level" is used to record "level" of the last transaction, and
+ * "last_delta" is used to record the previously received delta_level value.
+ */
+ int16_t last_level; /*!< The last value of the Generic Level state */
+ int32_t last_delta; /*!< The last delta change of the Generic Level state */
+
+ bool move_start; /*!< Indicate if the transition of the Generic Level state has been started */
+ bool positive; /*!< Indicate if the transition is positive or negative */
+} esp_ble_mesh_gen_level_state_t;
+
+/** User data of Generic Level Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Level Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ esp_ble_mesh_gen_level_state_t state; /*!< Parameters of the Generic Level state */
+ esp_ble_mesh_last_msg_info_t last; /*!< Parameters of the last received set message */
+ esp_ble_mesh_state_transition_t transition; /*!< Parameters of state transition */
+ int32_t tt_delta_level; /*!< Delta change value of level state transition */
+} esp_ble_mesh_gen_level_srv_t;
+
+/** Parameter of Generic Default Transition Time state */
+typedef struct {
+ uint8_t trans_time; /*!< The value of the Generic Default Transition Time state */
+} esp_ble_mesh_gen_def_trans_time_state_t;
+
+/** User data of Generic Default Transition Time Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Default Transition Time Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ esp_ble_mesh_gen_def_trans_time_state_t state; /*!< Parameters of the Generic Default Transition Time state */
+} esp_ble_mesh_gen_def_trans_time_srv_t;
+
+/** Parameter of Generic OnPowerUp state */
+typedef struct {
+ uint8_t onpowerup; /*!< The value of the Generic OnPowerUp state */
+} esp_ble_mesh_gen_onpowerup_state_t;
+
+/** User data of Generic Power OnOff Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Power OnOff Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ esp_ble_mesh_gen_onpowerup_state_t *state; /*!< Parameters of the Generic OnPowerUp state */
+} esp_ble_mesh_gen_power_onoff_srv_t;
+
+/** User data of Generic Power OnOff Setup Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Power OnOff Setup Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ esp_ble_mesh_gen_onpowerup_state_t *state; /*!< Parameters of the Generic OnPowerUp state */
+} esp_ble_mesh_gen_power_onoff_setup_srv_t;
+
+/** Parameters of Generic Power Level state */
+typedef struct {
+ uint16_t power_actual; /*!< The present value of the Generic Power Actual state */
+ uint16_t target_power_actual; /*!< The target value of the Generic Power Actual state */
+
+ uint16_t power_last; /*!< The value of the Generic Power Last state */
+ uint16_t power_default; /*!< The value of the Generic Power Default state */
+
+ uint8_t status_code; /*!< The status code of setting Generic Power Range state */
+ uint16_t power_range_min; /*!< The minimum value of the Generic Power Range state */
+ uint16_t power_range_max; /*!< The maximum value of the Generic Power Range state */
+} esp_ble_mesh_gen_power_level_state_t;
+
+/** User data of Generic Power Level Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Power Level Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ esp_ble_mesh_gen_power_level_state_t *state; /*!< Parameters of the Generic Power Level state */
+ esp_ble_mesh_last_msg_info_t last; /*!< Parameters of the last received set message */
+ esp_ble_mesh_state_transition_t transition; /*!< Parameters of state transition */
+ int32_t tt_delta_level; /*!< Delta change value of level state transition */
+} esp_ble_mesh_gen_power_level_srv_t;
+
+/** User data of Generic Power Level Setup Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Power Level Setup Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ esp_ble_mesh_gen_power_level_state_t *state; /*!< Parameters of the Generic Power Level state */
+} esp_ble_mesh_gen_power_level_setup_srv_t;
+
+/** Parameters of Generic Battery state */
+typedef struct {
+ uint32_t battery_level : 8, /*!< The value of the Generic Battery Level state */
+ time_to_discharge : 24; /*!< The value of the Generic Battery Time to Discharge state */
+ uint32_t time_to_charge : 24, /*!< The value of the Generic Battery Time to Charge state */
+ battery_flags : 8; /*!< The value of the Generic Battery Flags state */
+} esp_ble_mesh_gen_battery_state_t;
+
+/** User data of Generic Battery Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Battery Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ esp_ble_mesh_gen_battery_state_t state; /*!< Parameters of the Generic Battery state */
+} esp_ble_mesh_gen_battery_srv_t;
+
+/** Parameters of Generic Location state */
+typedef struct {
+ int32_t global_latitude; /*!< The value of the Global Latitude field */
+ int32_t global_longitude; /*!< The value of the Global Longitude field */
+ int16_t global_altitude; /*!< The value of the Global Altitude field */
+ int16_t local_north; /*!< The value of the Local North field */
+ int16_t local_east; /*!< The value of the Local East field */
+ int16_t local_altitude; /*!< The value of the Local Altitude field */
+ uint8_t floor_number; /*!< The value of the Floor Number field */
+ uint16_t uncertainty; /*!< The value of the Uncertainty field */
+} esp_ble_mesh_gen_location_state_t;
+
+/** User data of Generic Location Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Location Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ esp_ble_mesh_gen_location_state_t *state; /*!< Parameters of the Generic Location state */
+} esp_ble_mesh_gen_location_srv_t;
+
+/** User data of Generic Location Setup Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Location Setup Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ esp_ble_mesh_gen_location_state_t *state; /*!< Parameters of the Generic Location state */
+} esp_ble_mesh_gen_location_setup_srv_t;
+
+/** This enum value is the access value of Generic User Property */
+typedef enum {
+ ESP_BLE_MESH_GEN_USER_ACCESS_PROHIBIT,
+ ESP_BLE_MESH_GEN_USER_ACCESS_READ,
+ ESP_BLE_MESH_GEN_USER_ACCESS_WRITE,
+ ESP_BLE_MESH_GEN_USER_ACCESS_READ_WRITE,
+} esp_ble_mesh_gen_user_prop_access_t;
+
+/** This enum value is the access value of Generic Admin Property */
+typedef enum {
+ ESP_BLE_MESH_GEN_ADMIN_NOT_USER_PROP,
+ ESP_BLE_MESH_GEN_ADMIN_ACCESS_READ,
+ ESP_BLE_MESH_GEN_ADMIN_ACCESS_WRITE,
+ ESP_BLE_MESH_GEN_ADMIN_ACCESS_READ_WRITE,
+} esp_ble_mesh_gen_admin_prop_access_t;
+
+/** This enum value is the access value of Generic Manufacturer Property */
+typedef enum {
+ ESP_BLE_MESH_GEN_MANU_NOT_USER_PROP,
+ ESP_BLE_MESH_GEN_MANU_ACCESS_READ,
+} esp_ble_mesh_gen_manu_prop_access_t;
+
+/** Parameters of Generic Property states */
+typedef struct {
+ uint16_t id; /*!< The value of User/Admin/Manufacturer Property ID */
+ uint8_t user_access; /*!< The value of User Access field */
+ uint8_t admin_access; /*!< The value of Admin Access field */
+ uint8_t manu_access; /*!< The value of Manufacturer Access field */
+ struct net_buf_simple *val; /*!< The value of User/Admin/Manufacturer Property */
+} esp_ble_mesh_generic_property_t;
+
+/** User data of Generic User Property Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Generic User Property Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ uint8_t property_count; /*!< Generic User Property count */
+ esp_ble_mesh_generic_property_t *properties; /*!< Parameters of the Generic User Property state */
+} esp_ble_mesh_gen_user_prop_srv_t;
+
+/** User data of Generic Admin Property Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Admin Property Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ uint8_t property_count; /*!< Generic Admin Property count */
+ esp_ble_mesh_generic_property_t *properties; /*!< Parameters of the Generic Admin Property state */
+} esp_ble_mesh_gen_admin_prop_srv_t;
+
+/** User data of Generic Manufacturer Property Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Manufacturer Property Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ uint8_t property_count; /*!< Generic Manufacturer Property count */
+ esp_ble_mesh_generic_property_t *properties; /*!< Parameters of the Generic Manufacturer Property state */
+} esp_ble_mesh_gen_manu_prop_srv_t;
+
+/** User data of Generic Client Property Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Client Property Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ uint8_t id_count; /*!< Generic Client Property ID count */
+ uint16_t *property_ids; /*!< Parameters of the Generic Client Property state */
+} esp_ble_mesh_gen_client_prop_srv_t;
+
+/** Parameter of Generic OnOff Set state change event */
+typedef struct {
+ uint8_t onoff; /*!< The value of Generic OnOff state */
+} esp_ble_mesh_state_change_gen_onoff_set_t;
+
+/** Parameter of Generic Level Set state change event */
+typedef struct {
+ int16_t level; /*!< The value of Generic Level state */
+} esp_ble_mesh_state_change_gen_level_set_t;
+
+/** Parameter of Generic Delta Set state change event */
+typedef struct {
+ int16_t level; /*!< The value of Generic Level state */
+} esp_ble_mesh_state_change_gen_delta_set_t;
+
+/** Parameter of Generic Move Set state change event */
+typedef struct {
+ int16_t level; /*!< The value of Generic Level state */
+} esp_ble_mesh_state_change_gen_move_set_t;
+
+/** Parameter of Generic Default Transition Time Set state change event */
+typedef struct {
+ uint8_t trans_time; /*!< The value of Generic Default Transition Time state */
+} esp_ble_mesh_state_change_gen_def_trans_time_set_t;
+
+/** Parameter of Generic OnPowerUp Set state change event */
+typedef struct {
+ uint8_t onpowerup; /*!< The value of Generic OnPowerUp state */
+} esp_ble_mesh_state_change_gen_onpowerup_set_t;
+
+/** Parameter of Generic Power Level Set state change event */
+typedef struct {
+ uint16_t power; /*!< The value of Generic Power Actual state */
+} esp_ble_mesh_state_change_gen_power_level_set_t;
+
+/** Parameter of Generic Power Default Set state change event */
+typedef struct {
+ uint16_t power; /*!< The value of Generic Power Default state */
+} esp_ble_mesh_state_change_gen_power_default_set_t;
+
+/** Parameters of Generic Power Range Set state change event */
+typedef struct {
+ uint16_t range_min; /*!< The minimum value of Generic Power Range state */
+ uint16_t range_max; /*!< The maximum value of Generic Power Range state */
+} esp_ble_mesh_state_change_gen_power_range_set_t;
+
+/** Parameters of Generic Location Global Set state change event */
+typedef struct {
+ int32_t latitude; /*!< The Global Latitude value of Generic Location state */
+ int32_t longitude; /*!< The Global Longitude value of Generic Location state */
+ int16_t altitude; /*!< The Global Altitude value of Generic Location state */
+} esp_ble_mesh_state_change_gen_loc_global_set_t;
+
+/** Parameters of Generic Location Local Set state change event */
+typedef struct {
+ int16_t north; /*!< The Local North value of Generic Location state */
+ int16_t east; /*!< The Local East value of Generic Location state */
+ int16_t altitude; /*!< The Local Altitude value of Generic Location state */
+ uint8_t floor_number; /*!< The Floor Number value of Generic Location state */
+ uint16_t uncertainty; /*!< The Uncertainty value of Generic Location state */
+} esp_ble_mesh_state_change_gen_loc_local_set_t;
+
+/** Parameters of Generic User Property Set state change event */
+typedef struct {
+ uint16_t id; /*!< The property id of Generic User Property state */
+ struct net_buf_simple *value; /*!< The property value of Generic User Property state */
+} esp_ble_mesh_state_change_gen_user_property_set_t;
+
+/** Parameters of Generic Admin Property Set state change event */
+typedef struct {
+ uint16_t id; /*!< The property id of Generic Admin Property state */
+ uint8_t access; /*!< The property access of Generic Admin Property state */
+ struct net_buf_simple *value; /*!< The property value of Generic Admin Property state */
+} esp_ble_mesh_state_change_gen_admin_property_set_t;
+
+/** Parameters of Generic Manufacturer Property Set state change event */
+typedef struct {
+ uint16_t id; /*!< The property id of Generic Manufacturer Property state */
+ uint8_t access; /*!< The property value of Generic Manufacturer Property state */
+} esp_ble_mesh_state_change_gen_manu_property_set_t;
+
+/**
+ * @brief Generic Server Model state change value union
+ */
+typedef union {
+ /**
+ * The recv_op in ctx can be used to decide which state is changed.
+ */
+ esp_ble_mesh_state_change_gen_onoff_set_t onoff_set; /*!< Generic OnOff Set */
+ esp_ble_mesh_state_change_gen_level_set_t level_set; /*!< Generic Level Set */
+ esp_ble_mesh_state_change_gen_delta_set_t delta_set; /*!< Generic Delta Set */
+ esp_ble_mesh_state_change_gen_move_set_t move_set; /*!< Generic Move Set */
+ esp_ble_mesh_state_change_gen_def_trans_time_set_t def_trans_time_set; /*!< Generic Default Transition Time Set */
+ esp_ble_mesh_state_change_gen_onpowerup_set_t onpowerup_set; /*!< Generic OnPowerUp Set */
+ esp_ble_mesh_state_change_gen_power_level_set_t power_level_set; /*!< Generic Power Level Set */
+ esp_ble_mesh_state_change_gen_power_default_set_t power_default_set; /*!< Generic Power Default Set */
+ esp_ble_mesh_state_change_gen_power_range_set_t power_range_set; /*!< Generic Power Range Set */
+ esp_ble_mesh_state_change_gen_loc_global_set_t loc_global_set; /*!< Generic Location Global Set */
+ esp_ble_mesh_state_change_gen_loc_local_set_t loc_local_set; /*!< Generic Location Local Set */
+ esp_ble_mesh_state_change_gen_user_property_set_t user_property_set; /*!< Generic User Property Set */
+ esp_ble_mesh_state_change_gen_admin_property_set_t admin_property_set; /*!< Generic Admin Property Set */
+ esp_ble_mesh_state_change_gen_manu_property_set_t manu_property_set; /*!< Generic Manufacturer Property Set */
+} esp_ble_mesh_generic_server_state_change_t;
+
+/** Context of the received Generic User Property Get message */
+typedef struct {
+ uint16_t property_id; /*!< Property ID identifying a Generic User Property */
+} esp_ble_mesh_server_recv_gen_user_property_get_t;
+
+/** Context of the received Generic Admin Property Get message */
+typedef struct {
+ uint16_t property_id; /*!< Property ID identifying a Generic Admin Property */
+} esp_ble_mesh_server_recv_gen_admin_property_get_t;
+
+/** Context of the received Generic Manufacturer Property message */
+typedef struct {
+ uint16_t property_id; /*!< Property ID identifying a Generic Manufacturer Property */
+} esp_ble_mesh_server_recv_gen_manufacturer_property_get_t;
+
+/** Context of the received Generic Client Properties Get message */
+typedef struct {
+ uint16_t property_id; /*!< A starting Client Property ID present within an element */
+} esp_ble_mesh_server_recv_gen_client_properties_get_t;
+
+/**
+ * @brief Generic Server Model received get message union
+ */
+typedef union {
+ esp_ble_mesh_server_recv_gen_user_property_get_t user_property; /*!< Generic User Property Get */
+ esp_ble_mesh_server_recv_gen_admin_property_get_t admin_property; /*!< Generic Admin Property Get */
+ esp_ble_mesh_server_recv_gen_manufacturer_property_get_t manu_property; /*!< Generic Manufacturer Property Get */
+ esp_ble_mesh_server_recv_gen_client_properties_get_t client_properties; /*!< Generic Client Properties Get */
+} esp_ble_mesh_generic_server_recv_get_msg_t;
+
+/** Context of the received Generic OnOff Set message */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint8_t onoff; /*!< Target value of Generic OnOff state */
+ uint8_t tid; /*!< Transaction ID */
+ uint8_t trans_time; /*!< Time to complete state transition (optional) */
+ uint8_t delay; /*!< Indicate message execution delay (C.1) */
+} esp_ble_mesh_server_recv_gen_onoff_set_t;
+
+/** Context of the received Generic Level Set message */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ int16_t level; /*!< Target value of Generic Level state */
+ uint8_t tid; /*!< Transaction ID */
+ uint8_t trans_time; /*!< Time to complete state transition (optional) */
+ uint8_t delay; /*!< Indicate message execution delay (C.1) */
+} esp_ble_mesh_server_recv_gen_level_set_t;
+
+/** Context of the received Generic Delta Set message */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ int32_t delta_level; /*!< Delta change of Generic Level state */
+ uint8_t tid; /*!< Transaction ID */
+ uint8_t trans_time; /*!< Time to complete state transition (optional) */
+ uint8_t delay; /*!< Indicate message execution delay (C.1) */
+} esp_ble_mesh_server_recv_gen_delta_set_t;
+
+/** Context of the received Generic Move Set message */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ int16_t delta_level; /*!< Delta Level step to calculate Move speed for Generic Level state */
+ uint8_t tid; /*!< Transaction ID */
+ uint8_t trans_time; /*!< Time to complete state transition (optional) */
+ uint8_t delay; /*!< Indicate message execution delay (C.1) */
+} esp_ble_mesh_server_recv_gen_move_set_t;
+
+/** Context of the received Generic Default Transition Time Set message */
+typedef struct {
+ uint8_t trans_time; /*!< The value of the Generic Default Transition Time state */
+} esp_ble_mesh_server_recv_gen_def_trans_time_set_t;
+
+/** Context of the received Generic OnPowerUp Set message */
+typedef struct {
+ uint8_t onpowerup; /*!< The value of the Generic OnPowerUp state */
+} esp_ble_mesh_server_recv_gen_onpowerup_set_t;
+
+/** Context of the received Generic Power Level Set message */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t power; /*!< Target value of Generic Power Actual state */
+ uint8_t tid; /*!< Transaction ID */
+ uint8_t trans_time; /*!< Time to complete state transition (optional) */
+ uint8_t delay; /*!< Indicate message execution delay (C.1) */
+} esp_ble_mesh_server_recv_gen_power_level_set_t;
+
+/** Context of the received Generic Power Default Set message */
+typedef struct {
+ uint16_t power; /*!< The value of the Generic Power Default state */
+} esp_ble_mesh_server_recv_gen_power_default_set_t;
+
+/** Context of the received Generic Power Range Set message */
+typedef struct {
+ uint16_t range_min; /*!< Value of Range Min field of Generic Power Range state */
+ uint16_t range_max; /*!< Value of Range Max field of Generic Power Range state */
+} esp_ble_mesh_server_recv_gen_power_range_set_t;
+
+/** Context of the received Generic Location Global Set message */
+typedef struct {
+ int32_t global_latitude; /*!< Global Coordinates (Latitude) */
+ int32_t global_longitude; /*!< Global Coordinates (Longitude) */
+ int16_t global_altitude; /*!< Global Altitude */
+} esp_ble_mesh_server_recv_gen_loc_global_set_t;
+
+/** Context of the received Generic Location Local Set message */
+typedef struct {
+ int16_t local_north; /*!< Local Coordinates (North) */
+ int16_t local_east; /*!< Local Coordinates (East) */
+ int16_t local_altitude; /*!< Local Altitude */
+ uint8_t floor_number; /*!< Floor Number */
+ uint16_t uncertainty; /*!< Uncertainty */
+} esp_ble_mesh_server_recv_gen_loc_local_set_t;
+
+/** Context of the received Generic User Property Set message */
+typedef struct {
+ uint16_t property_id; /*!< Property ID identifying a Generic User Property */
+ struct net_buf_simple *property_value; /*!< Raw value for the User Property */
+} esp_ble_mesh_server_recv_gen_user_property_set_t;
+
+/** Context of the received Generic Admin Property Set message */
+typedef struct {
+ uint16_t property_id; /*!< Property ID identifying a Generic Admin Property */
+ uint8_t user_access; /*!< Enumeration indicating user access */
+ struct net_buf_simple *property_value; /*!< Raw value for the Admin Property */
+} esp_ble_mesh_server_recv_gen_admin_property_set_t;
+
+/** Context of the received Generic Manufacturer Property Set message */
+typedef struct {
+ uint16_t property_id; /*!< Property ID identifying a Generic Manufacturer Property */
+ uint8_t user_access; /*!< Enumeration indicating user access */
+} esp_ble_mesh_server_recv_gen_manufacturer_property_set_t;
+
+/**
+ * @brief Generic Server Model received set message union
+ */
+typedef union {
+ esp_ble_mesh_server_recv_gen_onoff_set_t onoff; /*!< Generic OnOff Set/Generic OnOff Set Unack */
+ esp_ble_mesh_server_recv_gen_level_set_t level; /*!< Generic Level Set/Generic Level Set Unack */
+ esp_ble_mesh_server_recv_gen_delta_set_t delta; /*!< Generic Delta Set/Generic Delta Set Unack */
+ esp_ble_mesh_server_recv_gen_move_set_t move; /*!< Generic Move Set/Generic Move Set Unack */
+ esp_ble_mesh_server_recv_gen_def_trans_time_set_t def_trans_time; /*!< Generic Default Transition Time Set/Generic Default Transition Time Set Unack */
+ esp_ble_mesh_server_recv_gen_onpowerup_set_t onpowerup; /*!< Generic OnPowerUp Set/Generic OnPowerUp Set Unack */
+ esp_ble_mesh_server_recv_gen_power_level_set_t power_level; /*!< Generic Power Level Set/Generic Power Level Set Unack */
+ esp_ble_mesh_server_recv_gen_power_default_set_t power_default; /*!< Generic Power Default Set/Generic Power Default Set Unack */
+ esp_ble_mesh_server_recv_gen_power_range_set_t power_range; /*!< Generic Power Range Set/Generic Power Range Set Unack */
+ esp_ble_mesh_server_recv_gen_loc_global_set_t location_global; /*!< Generic Location Global Set/Generic Location Global Set Unack */
+ esp_ble_mesh_server_recv_gen_loc_local_set_t location_local; /*!< Generic Location Local Set/Generic Location Local Set Unack */
+ esp_ble_mesh_server_recv_gen_user_property_set_t user_property; /*!< Generic User Property Set/Generic User Property Set Unack */
+ esp_ble_mesh_server_recv_gen_admin_property_set_t admin_property; /*!< Generic Admin Property Set/Generic Admin Property Set Unack */
+ esp_ble_mesh_server_recv_gen_manufacturer_property_set_t manu_property; /*!< Generic Manufacturer Property Set/Generic Manufacturer Property Set Unack */
+} esp_ble_mesh_generic_server_recv_set_msg_t;
+
+/**
+ * @brief Generic Server Model callback value union
+ */
+typedef union {
+ esp_ble_mesh_generic_server_state_change_t state_change; /*!< ESP_BLE_MESH_GENERIC_SERVER_STATE_CHANGE_EVT */
+ esp_ble_mesh_generic_server_recv_get_msg_t get; /*!< ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT */
+ esp_ble_mesh_generic_server_recv_set_msg_t set; /*!< ESP_BLE_MESH_GENERIC_SERVER_RECV_SET_MSG_EVT */
+} esp_ble_mesh_generic_server_cb_value_t;
+
+/** Generic Server Model callback parameters */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to Generic Server Models */
+ esp_ble_mesh_msg_ctx_t ctx; /*!< Context of the received messages */
+ esp_ble_mesh_generic_server_cb_value_t value; /*!< Value of the received Generic Messages */
+} esp_ble_mesh_generic_server_cb_param_t;
+
+/** This enum value is the event of Generic Server Model */
+typedef enum {
+ /**
+ * 1. When get_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, no event will be
+ * callback to the application layer when Generic Get messages are received.
+ * 2. When set_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, this event will
+ * be callback to the application layer when Generic Set/Set Unack messages
+ * are received.
+ */
+ ESP_BLE_MESH_GENERIC_SERVER_STATE_CHANGE_EVT,
+ /**
+ * When get_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be
+ * callback to the application layer when Generic Get messages are received.
+ */
+ ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT,
+ /**
+ * When set_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be
+ * callback to the application layer when Generic Set/Set Unack messages are received.
+ */
+ ESP_BLE_MESH_GENERIC_SERVER_RECV_SET_MSG_EVT,
+ ESP_BLE_MESH_GENERIC_SERVER_EVT_MAX,
+} esp_ble_mesh_generic_server_cb_event_t;
+
+/**
+ * @brief Bluetooth Mesh Generic Server Model function.
+ */
+
+/**
+ * @brief Generic Server Model callback function type
+ * @param event: Event type
+ * @param param: Pointer to callback parameter
+ */
+typedef void (* esp_ble_mesh_generic_server_cb_t)(esp_ble_mesh_generic_server_cb_event_t event,
+ esp_ble_mesh_generic_server_cb_param_t *param);
+
+/**
+ * @brief Register BLE Mesh Generic Server Model callback.
+ *
+ * @param[in] callback: Pointer to the callback function.
+ *
+ * @return ESP_OK on success or error code otherwise.
+ *
+ */
+esp_err_t esp_ble_mesh_register_generic_server_callback(esp_ble_mesh_generic_server_cb_t callback);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ESP_BLE_MESH_GENERIC_MODEL_API_H_ */
diff --git a/lib/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_health_model_api.h b/lib/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_health_model_api.h
new file mode 100644
index 00000000..3a636ce1
--- /dev/null
+++ b/lib/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_health_model_api.h
@@ -0,0 +1,406 @@
+/*
+ * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#ifndef _ESP_BLE_MESH_HEALTH_MODEL_API_H_
+#define _ESP_BLE_MESH_HEALTH_MODEL_API_H_
+
+#include "esp_ble_mesh_defs.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @def ESP_BLE_MESH_MODEL_HEALTH_SRV
+ *
+ * @brief Define a new Health Server Model.
+ *
+ * @note The Health Server Model can only be included by a Primary Element.
+ *
+ * @param srv Pointer to the unique struct esp_ble_mesh_health_srv_t.
+ * @param pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ *
+ * @return New Health Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_HEALTH_SRV(srv, pub) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_HEALTH_SRV, \
+ NULL, pub, srv)
+
+/** @def ESP_BLE_MESH_MODEL_HEALTH_CLI
+ *
+ * @brief Define a new Health Client Model.
+ *
+ * @note This API needs to be called for each element on which
+ * the application needs to have a Health Client Model.
+ *
+ * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t.
+ *
+ * @return New Health Client Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_HEALTH_CLI(cli_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_HEALTH_CLI, \
+ NULL, NULL, cli_data)
+
+/** @def ESP_BLE_MESH_HEALTH_PUB_DEFINE
+ *
+ * A helper to define a health publication context
+ *
+ * @param _name Name given to the publication context variable.
+ * @param _max Maximum number of faults the element can have.
+ * @param _role Role of the device which contains the model.
+ */
+#define ESP_BLE_MESH_HEALTH_PUB_DEFINE(_name, _max, _role) \
+ ESP_BLE_MESH_MODEL_PUB_DEFINE(_name, (1 + 3 + (_max)), _role)
+
+/**
+ * SIG identifier of Health Fault Test.
+ * 0x01 ~ 0xFF: Vendor Specific Test.
+ */
+#define ESP_BLE_MESH_HEALTH_STANDARD_TEST 0x00
+
+/**
+ * Fault values of Health Fault Test.
+ * 0x33 ~ 0x7F: Reserved for Future Use.
+ * 0x80 ~ 0xFF: Vendor Specific Warning/Error.
+ */
+#define ESP_BLE_MESH_NO_FAULT 0x00
+#define ESP_BLE_MESH_BATTERY_LOW_WARNING 0x01
+#define ESP_BLE_MESH_BATTERY_LOW_ERROR 0x02
+#define ESP_BLE_MESH_SUPPLY_VOLTAGE_TOO_LOW_WARNING 0x03
+#define ESP_BLE_MESH_SUPPLY_VOLTAGE_TOO_LOW_ERROR 0x04
+#define ESP_BLE_MESH_SUPPLY_VOLTAGE_TOO_HIGH_WARNING 0x05
+#define ESP_BLE_MESH_SUPPLY_VOLTAGE_TOO_HIGH_ERROR 0x06
+#define ESP_BLE_MESH_POWER_SUPPLY_INTERRUPTED_WARNING 0x07
+#define ESP_BLE_MESH_POWER_SUPPLY_INTERRUPTED_ERROR 0x08
+#define ESP_BLE_MESH_NO_LOAD_WARNING 0x09
+#define ESP_BLE_MESH_NO_LOAD_ERROR 0x0A
+#define ESP_BLE_MESH_OVERLOAD_WARNING 0x0B
+#define ESP_BLE_MESH_OVERLOAD_ERROR 0x0C
+#define ESP_BLE_MESH_OVERHEAT_WARNING 0x0D
+#define ESP_BLE_MESH_OVERHEAT_ERROR 0x0E
+#define ESP_BLE_MESH_CONDENSATION_WARNING 0x0F
+#define ESP_BLE_MESH_CONDENSATION_ERROR 0x10
+#define ESP_BLE_MESH_VIBRATION_WARNING 0x11
+#define ESP_BLE_MESH_VIBRATION_ERROR 0x12
+#define ESP_BLE_MESH_CONFIGURATION_WARNING 0x13
+#define ESP_BLE_MESH_CONFIGURATION_ERROR 0x14
+#define ESP_BLE_MESH_ELEMENT_NOT_CALIBRATED_WARNING 0x15
+#define ESP_BLE_MESH_ELEMENT_NOT_CALIBRATED_ERROR 0x16
+#define ESP_BLE_MESH_MEMORY_WARNING 0x17
+#define ESP_BLE_MESH_MEMORY_ERROR 0x18
+#define ESP_BLE_MESH_SELF_TEST_WARNING 0x19
+#define ESP_BLE_MESH_SELF_TEST_ERROR 0x1A
+#define ESP_BLE_MESH_INPUT_TOO_LOW_WARNING 0x1B
+#define ESP_BLE_MESH_INPUT_TOO_LOW_ERROR 0x1C
+#define ESP_BLE_MESH_INPUT_TOO_HIGH_WARNING 0x1D
+#define ESP_BLE_MESH_INPUT_TOO_HIGH_ERROR 0x1E
+#define ESP_BLE_MESH_INPUT_NO_CHANGE_WARNING 0x1F
+#define ESP_BLE_MESH_INPUT_NO_CHANGE_ERROR 0x20
+#define ESP_BLE_MESH_ACTUATOR_BLOCKED_WARNING 0x21
+#define ESP_BLE_MESH_ACTUATOR_BLOCKED_ERROR 0x22
+#define ESP_BLE_MESH_HOUSING_OPENED_WARNING 0x23
+#define ESP_BLE_MESH_HOUSING_OPENED_ERROR 0x24
+#define ESP_BLE_MESH_TAMPER_WARNING 0x25
+#define ESP_BLE_MESH_TAMPER_ERROR 0x26
+#define ESP_BLE_MESH_DEVICE_MOVED_WARNING 0x27
+#define ESP_BLE_MESH_DEVICE_MOVED_ERROR 0x28
+#define ESP_BLE_MESH_DEVICE_DROPPED_WARNING 0x29
+#define ESP_BLE_MESH_DEVICE_DROPPED_ERROR 0x2A
+#define ESP_BLE_MESH_OVERFLOW_WARNING 0x2B
+#define ESP_BLE_MESH_OVERFLOW_ERROR 0x2C
+#define ESP_BLE_MESH_EMPTY_WARNING 0x2D
+#define ESP_BLE_MESH_EMPTY_ERROR 0x2E
+#define ESP_BLE_MESH_INTERNAL_BUS_WARNING 0x2F
+#define ESP_BLE_MESH_INTERNAL_BUS_ERROR 0x30
+#define ESP_BLE_MESH_MECHANISM_JAMMED_WARNING 0x31
+#define ESP_BLE_MESH_MECHANISM_JAMMED_ERROR 0x32
+
+/** ESP BLE Mesh Health Server callback */
+typedef struct {
+ /** Clear health registered faults. Initialized by the stack. */
+ esp_ble_mesh_cb_t fault_clear;
+
+ /** Run a specific health test. Initialized by the stack. */
+ esp_ble_mesh_cb_t fault_test;
+
+ /** Health attention on callback. Initialized by the stack. */
+ esp_ble_mesh_cb_t attention_on;
+
+ /** Health attention off callback. Initialized by the stack. */
+ esp_ble_mesh_cb_t attention_off;
+} esp_ble_mesh_health_srv_cb_t;
+
+#define ESP_BLE_MESH_HEALTH_FAULT_ARRAY_SIZE 32
+
+/** ESP BLE Mesh Health Server test Context */
+typedef struct {
+ uint8_t id_count; /*!< Number of Health self-test ID */
+ const uint8_t *test_ids; /*!< Array of Health self-test IDs */
+ uint16_t company_id; /*!< Company ID used to identify the Health Fault state */
+ uint8_t prev_test_id; /*!< Current test ID of the health fault test */
+ uint8_t current_faults[ESP_BLE_MESH_HEALTH_FAULT_ARRAY_SIZE]; /*!< Array of current faults */
+ uint8_t registered_faults[ESP_BLE_MESH_HEALTH_FAULT_ARRAY_SIZE]; /*!< Array of registered faults */
+} __attribute__((packed)) esp_ble_mesh_health_test_t;
+
+/** ESP BLE Mesh Health Server Model Context */
+typedef struct {
+ /** Pointer to Health Server Model */
+ esp_ble_mesh_model_t *model;
+
+ /** Health callback struct */
+ esp_ble_mesh_health_srv_cb_t health_cb;
+
+ /** Attention Timer state */
+ struct k_delayed_work attention_timer;
+
+ /** Attention Timer start flag */
+ bool attention_timer_start;
+
+ /** Health Server fault test */
+ esp_ble_mesh_health_test_t health_test;
+} esp_ble_mesh_health_srv_t;
+
+/** Parameter of Health Fault Get */
+typedef struct {
+ uint16_t company_id; /*!< Bluetooth assigned 16-bit Company ID */
+} esp_ble_mesh_health_fault_get_t;
+
+/** Parameter of Health Attention Set */
+typedef struct {
+ uint8_t attention; /*!< Value of the Attention Timer state */
+} esp_ble_mesh_health_attention_set_t;
+
+/** Parameter of Health Period Set */
+typedef struct {
+ uint8_t fast_period_divisor; /*!< Divider for the Publish Period */
+} esp_ble_mesh_health_period_set_t;
+
+/** Parameter of Health Fault Test */
+typedef struct {
+ uint16_t company_id; /*!< Bluetooth assigned 16-bit Company ID */
+ uint8_t test_id; /*!< ID of a specific test to be performed */
+} esp_ble_mesh_health_fault_test_t;
+
+/** Parameter of Health Fault Clear */
+typedef struct {
+ uint16_t company_id; /*!< Bluetooth assigned 16-bit Company ID */
+} esp_ble_mesh_health_fault_clear_t;
+
+/**
+ * @brief For ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET
+ * ESP_BLE_MESH_MODEL_OP_ATTENTION_GET
+ * ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_GET
+ * the get_state parameter in the esp_ble_mesh_health_client_get_state function should not be set to NULL.
+ */
+typedef union {
+ esp_ble_mesh_health_fault_get_t fault_get; /*!< For ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET. */
+} esp_ble_mesh_health_client_get_state_t;
+
+/**
+ * @brief For ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR
+ * ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR_UNACK
+ * ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST
+ * ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST_UNACK
+ * ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET
+ * ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET_UNACK
+ * ESP_BLE_MESH_MODEL_OP_ATTENTION_SET
+ * ESP_BLE_MESH_MODEL_OP_ATTENTION_SET_UNACK
+ * the set_state parameter in the esp_ble_mesh_health_client_set_state function should not be set to NULL.
+ */
+typedef union {
+ esp_ble_mesh_health_attention_set_t attention_set; /*!< For ESP_BLE_MESH_MODEL_OP_ATTENTION_SET or ESP_BLE_MESH_MODEL_OP_ATTENTION_SET_UNACK. */
+ esp_ble_mesh_health_period_set_t period_set; /*!< For ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET or ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET_UNACK. */
+ esp_ble_mesh_health_fault_test_t fault_test; /*!< For ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST or ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST_UNACK. */
+ esp_ble_mesh_health_fault_clear_t fault_clear; /*!< For ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR or ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR_UNACK. */
+} esp_ble_mesh_health_client_set_state_t;
+
+/** Parameters of Health Current Status */
+typedef struct {
+ uint8_t test_id; /*!< ID of a most recently performed test */
+ uint16_t company_id; /*!< Bluetooth assigned 16-bit Company ID */
+ struct net_buf_simple *fault_array; /*!< FaultArray field contains a sequence of 1-octet fault values */
+} esp_ble_mesh_health_current_status_cb_t;
+
+/** Parameters of Health Fault Status */
+typedef struct {
+ uint8_t test_id; /*!< ID of a most recently performed test */
+ uint16_t company_id; /*!< Bluetooth assigned 16-bit Company ID */
+ struct net_buf_simple *fault_array; /*!< FaultArray field contains a sequence of 1-octet fault values */
+} esp_ble_mesh_health_fault_status_cb_t;
+
+/** Parameter of Health Period Status */
+typedef struct {
+ uint8_t fast_period_divisor; /*!< Divider for the Publish Period */
+} esp_ble_mesh_health_period_status_cb_t;
+
+/** Parameter of Health Attention Status */
+typedef struct {
+ uint8_t attention; /*!< Value of the Attention Timer state */
+} esp_ble_mesh_health_attention_status_cb_t;
+
+/**
+ * @brief Health Client Model received message union
+ */
+typedef union {
+ esp_ble_mesh_health_current_status_cb_t current_status; /*!< The health current status value */
+ esp_ble_mesh_health_fault_status_cb_t fault_status; /*!< The health fault status value */
+ esp_ble_mesh_health_period_status_cb_t period_status; /*!< The health period status value */
+ esp_ble_mesh_health_attention_status_cb_t attention_status; /*!< The health attention status value */
+} esp_ble_mesh_health_client_common_cb_param_t;
+
+/** Health Client Model callback parameters */
+typedef struct {
+ int error_code; /*!< Appropriate error code */
+ esp_ble_mesh_client_common_param_t *params; /*!< The client common parameters. */
+ esp_ble_mesh_health_client_common_cb_param_t status_cb; /*!< The health message status callback values */
+} esp_ble_mesh_health_client_cb_param_t;
+
+/** This enum value is the event of Health Client Model */
+typedef enum {
+ ESP_BLE_MESH_HEALTH_CLIENT_GET_STATE_EVT,
+ ESP_BLE_MESH_HEALTH_CLIENT_SET_STATE_EVT,
+ ESP_BLE_MESH_HEALTH_CLIENT_PUBLISH_EVT,
+ ESP_BLE_MESH_HEALTH_CLIENT_TIMEOUT_EVT,
+ ESP_BLE_MESH_HEALTH_CLIENT_EVT_MAX,
+} esp_ble_mesh_health_client_cb_event_t;
+
+/** Parameter of publishing Health Current Status completion event */
+typedef struct {
+ int error_code; /*!< The result of publishing Health Current Status */
+ esp_ble_mesh_elem_t *element; /*!< Pointer to the element which contains the Health Server Model */
+} esp_ble_mesh_health_fault_update_comp_cb_t;
+
+/** Parameters of Health Fault Clear event */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Health Server Model */
+ uint16_t company_id; /*!< Bluetooth assigned 16-bit Company ID */
+} esp_ble_mesh_health_fault_clear_cb_t;
+
+/** Parameters of Health Fault Test event */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Health Server Model */
+ uint8_t test_id; /*!< ID of a specific test to be performed */
+ uint16_t company_id; /*!< Bluetooth assigned 16-bit Company ID */
+} esp_ble_mesh_health_fault_test_cb_t;
+
+/** Parameter of Health Attention On event */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Health Server Model */
+ uint8_t time; /*!< Duration of attention timer on (in seconds) */
+} esp_ble_mesh_health_attention_on_cb_t;
+
+/** Parameter of Health Attention Off event */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Health Server Model */
+} esp_ble_mesh_health_attention_off_cb_t;
+
+/**
+ * @brief Health Server Model callback parameters union
+ */
+typedef union {
+ esp_ble_mesh_health_fault_update_comp_cb_t fault_update_comp; /*!< ESP_BLE_MESH_HEALTH_SERVER_FAULT_UPDATE_COMP_EVT */
+ esp_ble_mesh_health_fault_clear_cb_t fault_clear; /*!< ESP_BLE_MESH_HEALTH_SERVER_FAULT_CLEAR_EVT */
+ esp_ble_mesh_health_fault_test_cb_t fault_test; /*!< ESP_BLE_MESH_HEALTH_SERVER_FAULT_TEST_EVT */
+ esp_ble_mesh_health_attention_on_cb_t attention_on; /*!< ESP_BLE_MESH_HEALTH_SERVER_ATTENTION_ON_EVT */
+ esp_ble_mesh_health_attention_off_cb_t attention_off; /*!< ESP_BLE_MESH_HEALTH_SERVER_ATTENTION_OFF_EVT */
+} esp_ble_mesh_health_server_cb_param_t;
+
+/** This enum value is the event of Health Server Model */
+typedef enum {
+ ESP_BLE_MESH_HEALTH_SERVER_FAULT_UPDATE_COMP_EVT,
+ ESP_BLE_MESH_HEALTH_SERVER_FAULT_CLEAR_EVT,
+ ESP_BLE_MESH_HEALTH_SERVER_FAULT_TEST_EVT,
+ ESP_BLE_MESH_HEALTH_SERVER_ATTENTION_ON_EVT,
+ ESP_BLE_MESH_HEALTH_SERVER_ATTENTION_OFF_EVT,
+ ESP_BLE_MESH_HEALTH_SERVER_EVT_MAX,
+} esp_ble_mesh_health_server_cb_event_t;
+
+/**
+ * @brief Bluetooth Mesh Health Client and Server Model function.
+ */
+
+/**
+ * @brief Health Client Model callback function type
+ * @param event: Event type
+ * @param param: Pointer to callback parameter
+ */
+typedef void (* esp_ble_mesh_health_client_cb_t)(esp_ble_mesh_health_client_cb_event_t event,
+ esp_ble_mesh_health_client_cb_param_t *param);
+
+/**
+ * @brief Health Server Model callback function type
+ * @param event: Event type
+ * @param param: Pointer to callback parameter
+ */
+typedef void (* esp_ble_mesh_health_server_cb_t)(esp_ble_mesh_health_server_cb_event_t event,
+ esp_ble_mesh_health_server_cb_param_t *param);
+
+/**
+ * @brief Register BLE Mesh Health Model callback, the callback will report Health Client & Server Model events.
+ *
+ * @param[in] callback: Pointer to the callback function.
+ *
+ * @return ESP_OK on success or error code otherwise.
+ *
+ */
+esp_err_t esp_ble_mesh_register_health_client_callback(esp_ble_mesh_health_client_cb_t callback);
+
+/**
+ * @brief Register BLE Mesh Health Server Model callback.
+ *
+ * @param[in] callback: Pointer to the callback function.
+ *
+ * @return ESP_OK on success or error code otherwise.
+ *
+ */
+esp_err_t esp_ble_mesh_register_health_server_callback(esp_ble_mesh_health_server_cb_t callback);
+
+/**
+ * @brief This function is called to get the Health Server states using the Health Client Model get messages.
+ *
+ * @note If you want to find the opcodes and corresponding meanings accepted by this API,
+ * please refer to esp_ble_mesh_opcode_health_client_get_t in esp_ble_mesh_defs.h
+ *
+ * @param[in] params: Pointer to BLE Mesh common client parameters.
+ * @param[in] get_state: Pointer to a union, each kind of opcode corresponds to one structure inside.
+ * Shall not be set to NULL.
+ *
+ * @return ESP_OK on success or error code otherwise.
+ *
+ */
+esp_err_t esp_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_t *params,
+ esp_ble_mesh_health_client_get_state_t *get_state);
+
+/**
+ * @brief This function is called to set the Health Server states using the Health Client Model set messages.
+ *
+ * @note If you want to find the opcodes and corresponding meanings accepted by this API,
+ * please refer to esp_ble_mesh_opcode_health_client_set_t in esp_ble_mesh_defs.h
+ *
+ * @param[in] params: Pointer to BLE Mesh common client parameters.
+ * @param[in] set_state: Pointer to a union, each kind of opcode corresponds to one structure inside.
+ * Shall not be set to NULL.
+ *
+ * @return ESP_OK on success or error code otherwise.
+ *
+ */
+esp_err_t esp_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_t *params,
+ esp_ble_mesh_health_client_set_state_t *set_state);
+
+/**
+ * @brief This function is called by the Health Server Model to update the context of its Health Current status.
+ *
+ * @param[in] element: The element to which the Health Server Model belongs.
+ *
+ * @return ESP_OK on success or error code otherwise.
+ *
+ */
+esp_err_t esp_ble_mesh_health_server_fault_update(esp_ble_mesh_elem_t *element);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ESP_BLE_MESH_HEALTH_MODEL_API_H_ */
diff --git a/lib/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_lighting_model_api.h b/lib/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_lighting_model_api.h
new file mode 100644
index 00000000..c610c77a
--- /dev/null
+++ b/lib/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_lighting_model_api.h
@@ -0,0 +1,1674 @@
+/*
+ * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/** @file
+ * @brief Bluetooth Mesh Light Client Model APIs.
+ */
+
+#ifndef _ESP_BLE_MESH_LIGHTING_MODEL_API_H_
+#define _ESP_BLE_MESH_LIGHTING_MODEL_API_H_
+
+#include "esp_ble_mesh_defs.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @def ESP_BLE_MESH_MODEL_LIGHT_LIGHTNESS_CLI
+ *
+ * @brief Define a new Light Lightness Client Model.
+ *
+ * @note This API needs to be called for each element on which
+ * the application needs to have a Light Lightness Client Model.
+ *
+ * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t.
+ *
+ * @return New Light Lightness Client Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_LIGHT_LIGHTNESS_CLI(cli_pub, cli_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI, \
+ NULL, cli_pub, cli_data)
+
+/** @def ESP_BLE_MESH_MODEL_LIGHT_CTL_CLI
+ *
+ * @brief Define a new Light CTL Client Model.
+ *
+ * @note This API needs to be called for each element on which
+ * the application needs to have a Light CTL Client Model.
+ *
+ * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t.
+ *
+ * @return New Light CTL Client Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_LIGHT_CTL_CLI(cli_pub, cli_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_CTL_CLI, \
+ NULL, cli_pub, cli_data)
+
+/** @def ESP_BLE_MESH_MODEL_LIGHT_HSL_CLI
+ *
+ * @brief Define a new Light HSL Client Model.
+ *
+ * @note This API needs to be called for each element on which
+ * the application needs to have a Light HSL Client Model.
+ *
+ * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t.
+ *
+ * @return New Light HSL Client Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_LIGHT_HSL_CLI(cli_pub, cli_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_CLI, \
+ NULL, cli_pub, cli_data)
+
+/** @def ESP_BLE_MESH_MODEL_LIGHT_XYL_CLI
+ *
+ * @brief Define a new Light xyL Client Model.
+ *
+ * @note This API needs to be called for each element on which
+ * the application needs to have a Light xyL Client Model.
+ *
+ * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t.
+ *
+ * @return New Light xyL Client Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_LIGHT_XYL_CLI(cli_pub, cli_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_XYL_CLI, \
+ NULL, cli_pub, cli_data)
+
+/** @def ESP_BLE_MESH_MODEL_LIGHT_LC_CLI
+ *
+ * @brief Define a new Light LC Client Model.
+ *
+ * @note This API needs to be called for each element on which
+ * the application needs to have a Light LC Client Model.
+ *
+ * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t.
+ *
+ * @return New Light LC Client Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_LIGHT_LC_CLI(cli_pub, cli_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_LC_CLI, \
+ NULL, cli_pub, cli_data)
+
+/**
+ * @brief Bluetooth Mesh Light Lightness Client Model Get and Set parameters structure.
+ */
+
+/** Parameters of Light Lightness Set */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t lightness; /*!< Target value of light lightness actual state */
+ uint8_t tid; /*!< Transaction ID */
+ uint8_t trans_time; /*!< Time to complete state transition (optional) */
+ uint8_t delay; /*!< Indicate message execution delay (C.1) */
+} esp_ble_mesh_light_lightness_set_t;
+
+/** Parameters of Light Lightness Linear Set */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t lightness; /*!< Target value of light lightness linear state */
+ uint8_t tid; /*!< Transaction ID */
+ uint8_t trans_time; /*!< Time to complete state transition (optional) */
+ uint8_t delay; /*!< Indicate message execution delay (C.1) */
+} esp_ble_mesh_light_lightness_linear_set_t;
+
+/** Parameter of Light Lightness Default Set */
+typedef struct {
+ uint16_t lightness; /*!< The value of the Light Lightness Default state */
+} esp_ble_mesh_light_lightness_default_set_t;
+
+/** Parameters of Light Lightness Range Set */
+typedef struct {
+ uint16_t range_min; /*!< Value of range min field of light lightness range state */
+ uint16_t range_max; /*!< Value of range max field of light lightness range state */
+} esp_ble_mesh_light_lightness_range_set_t;
+
+/** Parameters of Light CTL Set */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t ctl_lightness; /*!< Target value of light ctl lightness state */
+ uint16_t ctl_temperature; /*!< Target value of light ctl temperature state */
+ int16_t ctl_delta_uv; /*!< Target value of light ctl delta UV state */
+ uint8_t tid; /*!< Transaction ID */
+ uint8_t trans_time; /*!< Time to complete state transition (optional) */
+ uint8_t delay; /*!< Indicate message execution delay (C.1) */
+} esp_ble_mesh_light_ctl_set_t;
+
+/** Parameters of Light CTL Temperature Set */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t ctl_temperature; /*!< Target value of light ctl temperature state */
+ int16_t ctl_delta_uv; /*!< Target value of light ctl delta UV state */
+ uint8_t tid; /*!< Transaction ID */
+ uint8_t trans_time; /*!< Time to complete state transition (optional) */
+ uint8_t delay; /*!< Indicate message execution delay (C.1) */
+} esp_ble_mesh_light_ctl_temperature_set_t;
+
+/** Parameters of Light CTL Temperature Range Set */
+typedef struct {
+ uint16_t range_min; /*!< Value of temperature range min field of light ctl temperature range state */
+ uint16_t range_max; /*!< Value of temperature range max field of light ctl temperature range state */
+} esp_ble_mesh_light_ctl_temperature_range_set_t;
+
+/** Parameters of Light CTL Default Set */
+typedef struct {
+ uint16_t lightness; /*!< Value of light lightness default state */
+ uint16_t temperature; /*!< Value of light temperature default state */
+ int16_t delta_uv; /*!< Value of light delta UV default state */
+} esp_ble_mesh_light_ctl_default_set_t;
+
+/** Parameters of Light HSL Set */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t hsl_lightness; /*!< Target value of light hsl lightness state */
+ uint16_t hsl_hue; /*!< Target value of light hsl hue state */
+ uint16_t hsl_saturation; /*!< Target value of light hsl saturation state */
+ uint8_t tid; /*!< Transaction ID */
+ uint8_t trans_time; /*!< Time to complete state transition (optional) */
+ uint8_t delay; /*!< Indicate message execution delay (C.1) */
+} esp_ble_mesh_light_hsl_set_t;
+
+/** Parameters of Light HSL Hue Set */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t hue; /*!< Target value of light hsl hue state */
+ uint8_t tid; /*!< Transaction ID */
+ uint8_t trans_time; /*!< Time to complete state transition (optional) */
+ uint8_t delay; /*!< Indicate message execution delay (C.1) */
+} esp_ble_mesh_light_hsl_hue_set_t;
+
+/** Parameters of Light HSL Saturation Set */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t saturation; /*!< Target value of light hsl hue state */
+ uint8_t tid; /*!< Transaction ID */
+ uint8_t trans_time; /*!< Time to complete state transition (optional) */
+ uint8_t delay; /*!< Indicate message execution delay (C.1) */
+} esp_ble_mesh_light_hsl_saturation_set_t;
+
+/** Parameters of Light HSL Default Set */
+typedef struct {
+ uint16_t lightness; /*!< Value of light lightness default state */
+ uint16_t hue; /*!< Value of light hue default state */
+ uint16_t saturation; /*!< Value of light saturation default state */
+} esp_ble_mesh_light_hsl_default_set_t;
+
+/** Parameters of Light HSL Range Set */
+typedef struct {
+ uint16_t hue_range_min; /*!< Value of hue range min field of light hsl hue range state */
+ uint16_t hue_range_max; /*!< Value of hue range max field of light hsl hue range state */
+ uint16_t saturation_range_min; /*!< Value of saturation range min field of light hsl saturation range state */
+ uint16_t saturation_range_max; /*!< Value of saturation range max field of light hsl saturation range state */
+} esp_ble_mesh_light_hsl_range_set_t;
+
+/** Parameters of Light xyL Set */
+typedef struct {
+ bool op_en; /*!< Indicate whether optional parameters included */
+ uint16_t xyl_lightness; /*!< The target value of the Light xyL Lightness state */
+ uint16_t xyl_x; /*!< The target value of the Light xyL x state */
+ uint16_t xyl_y; /*!< The target value of the Light xyL y state */
+ uint8_t tid; /*!< Transaction Identifier */
+ uint8_t trans_time; /*!< Time to complete state transition (optional) */
+ uint8_t delay; /*!< Indicate message execution delay (C.1) */
+} esp_ble_mesh_light_xyl_set_t;
+
+/** Parameters of Light xyL Default Set */
+typedef struct {
+ uint16_t lightness; /*!< The value of the Light Lightness Default state */
+ uint16_t xyl_x; /*!< The value of the Light xyL x Default state */
+ uint16_t xyl_y; /*!< The value of the Light xyL y Default state */
+} esp_ble_mesh_light_xyl_default_set_t;
+
+/** Parameters of Light xyL Range Set */
+typedef struct {
+ uint16_t xyl_x_range_min; /*!< The value of the xyL x Range Min field of the Light xyL x Range state */
+ uint16_t xyl_x_range_max; /*!< The value of the xyL x Range Max field of the Light xyL x Range state */
+ uint16_t xyl_y_range_min; /*!< The value of the xyL y Range Min field of the Light xyL y Range state */
+ uint16_t xyl_y_range_max; /*!< The value of the xyL y Range Max field of the Light xyL y Range state */
+} esp_ble_mesh_light_xyl_range_set_t;
+
+/** Parameter of Light LC Mode Set */
+typedef struct {
+ uint8_t mode; /*!< The target value of the Light LC Mode state */
+} esp_ble_mesh_light_lc_mode_set_t;
+
+/** Parameter of Light LC OM Set */
+typedef struct {
+ uint8_t mode; /*!< The target value of the Light LC Occupancy Mode state */
+} esp_ble_mesh_light_lc_om_set_t;
+
+/** Parameters of Light LC Light OnOff Set */
+typedef struct {
+ bool op_en; /*!< Indicate whether optional parameters included */
+ uint8_t light_onoff; /*!< The target value of the Light LC Light OnOff state */
+ uint8_t tid; /*!< Transaction Identifier */
+ uint8_t trans_time; /*!< Time to complete state transition (optional) */
+ uint8_t delay; /*!< Indicate message execution delay (C.1) */
+} esp_ble_mesh_light_lc_light_onoff_set_t;
+
+/** Parameter of Light LC Property Get */
+typedef struct {
+ uint16_t property_id; /*!< Property ID identifying a Light LC Property */
+} esp_ble_mesh_light_lc_property_get_t;
+
+/** Parameters of Light LC Property Set */
+typedef struct {
+ uint16_t property_id; /*!< Property ID identifying a Light LC Property */
+ struct net_buf_simple *property_value; /*!< Raw value for the Light LC Property */
+} esp_ble_mesh_light_lc_property_set_t;
+
+/**
+ * @brief Lighting Client Model get message union
+ */
+typedef union {
+ esp_ble_mesh_light_lc_property_get_t lc_property_get; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET */
+} esp_ble_mesh_light_client_get_state_t;
+
+/**
+ * @brief Lighting Client Model set message union
+ */
+typedef union {
+ esp_ble_mesh_light_lightness_set_t lightness_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_SET_UNACK */
+ esp_ble_mesh_light_lightness_linear_set_t lightness_linear_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_SET_UNACK */
+ esp_ble_mesh_light_lightness_default_set_t lightness_default_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_SET_UNACK */
+ esp_ble_mesh_light_lightness_range_set_t lightness_range_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_SET_UNACK */
+ esp_ble_mesh_light_ctl_set_t ctl_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_SET_UNACK */
+ esp_ble_mesh_light_ctl_temperature_set_t ctl_temperature_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_SET_UNACK */
+ esp_ble_mesh_light_ctl_temperature_range_set_t ctl_temperature_range_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_SET_UNACK */
+ esp_ble_mesh_light_ctl_default_set_t ctl_default_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_SET_UNACK */
+ esp_ble_mesh_light_hsl_set_t hsl_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SET_UNACK */
+ esp_ble_mesh_light_hsl_hue_set_t hsl_hue_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_SET_UNACK */
+ esp_ble_mesh_light_hsl_saturation_set_t hsl_saturation_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_SET_UNACK */
+ esp_ble_mesh_light_hsl_default_set_t hsl_default_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_SET_UNACK */
+ esp_ble_mesh_light_hsl_range_set_t hsl_range_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_SET_UNACK */
+ esp_ble_mesh_light_xyl_set_t xyl_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_SET_UNACK */
+ esp_ble_mesh_light_xyl_default_set_t xyl_default_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_SET_UNACK */
+ esp_ble_mesh_light_xyl_range_set_t xyl_range_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_SET_UNACK */
+ esp_ble_mesh_light_lc_mode_set_t lc_mode_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LC_MODE_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_LC_MODE_SET_UNACK */
+ esp_ble_mesh_light_lc_om_set_t lc_om_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LC_OM_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_LC_OM_SET_UNACK */
+ esp_ble_mesh_light_lc_light_onoff_set_t lc_light_onoff_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_SET_UNACK */
+ esp_ble_mesh_light_lc_property_set_t lc_property_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK */
+} esp_ble_mesh_light_client_set_state_t;
+
+/**
+ * @brief Bluetooth Mesh Light Lightness Client Model Get and Set callback parameters structure.
+ */
+
+/** Parameters of Light Lightness Status */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t present_lightness; /*!< Current value of light lightness actual state */
+ uint16_t target_lightness; /*!< Target value of light lightness actual state (optional) */
+ uint8_t remain_time; /*!< Time to complete state transition (C.1) */
+} esp_ble_mesh_light_lightness_status_cb_t;
+
+/** Parameters of Light Lightness Linear Status */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t present_lightness; /*!< Current value of light lightness linear state */
+ uint16_t target_lightness; /*!< Target value of light lightness linear state (optional) */
+ uint8_t remain_time; /*!< Time to complete state transition (C.1) */
+} esp_ble_mesh_light_lightness_linear_status_cb_t;
+
+/** Parameter of Light Lightness Last Status */
+typedef struct {
+ uint16_t lightness; /*!< The value of the Light Lightness Last state */
+} esp_ble_mesh_light_lightness_last_status_cb_t;
+
+/** Parameter of Light Lightness Default Status */
+typedef struct {
+ uint16_t lightness; /*!< The value of the Light Lightness default State */
+} esp_ble_mesh_light_lightness_default_status_cb_t;
+
+/** Parameters of Light Lightness Range Status */
+typedef struct {
+ uint8_t status_code; /*!< Status Code for the request message */
+ uint16_t range_min; /*!< Value of range min field of light lightness range state */
+ uint16_t range_max; /*!< Value of range max field of light lightness range state */
+} esp_ble_mesh_light_lightness_range_status_cb_t;
+
+/** Parameters of Light CTL Status */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t present_ctl_lightness; /*!< Current value of light ctl lightness state */
+ uint16_t present_ctl_temperature; /*!< Current value of light ctl temperature state */
+ uint16_t target_ctl_lightness; /*!< Target value of light ctl lightness state (optional) */
+ uint16_t target_ctl_temperature; /*!< Target value of light ctl temperature state (C.1) */
+ uint8_t remain_time; /*!< Time to complete state transition (C.1) */
+} esp_ble_mesh_light_ctl_status_cb_t;
+
+/** Parameters of Light CTL Temperature Status */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t present_ctl_temperature; /*!< Current value of light ctl temperature state */
+ uint16_t present_ctl_delta_uv; /*!< Current value of light ctl delta UV state */
+ uint16_t target_ctl_temperature; /*!< Target value of light ctl temperature state (optional) */
+ uint16_t target_ctl_delta_uv; /*!< Target value of light ctl delta UV state (C.1) */
+ uint8_t remain_time; /*!< Time to complete state transition (C.1) */
+} esp_ble_mesh_light_ctl_temperature_status_cb_t;
+
+/** Parameters of Light CTL Temperature Range Status */
+typedef struct {
+ uint8_t status_code; /*!< Status code for the request message */
+ uint16_t range_min; /*!< Value of temperature range min field of light ctl temperature range state */
+ uint16_t range_max; /*!< Value of temperature range max field of light ctl temperature range state */
+} esp_ble_mesh_light_ctl_temperature_range_status_cb_t;
+
+/** Parameters of Light CTL Default Status */
+typedef struct {
+ uint16_t lightness; /*!< Value of light lightness default state */
+ uint16_t temperature; /*!< Value of light temperature default state */
+ int16_t delta_uv; /*!< Value of light delta UV default state */
+} esp_ble_mesh_light_ctl_default_status_cb_t;
+
+/** Parameters of Light HSL Status */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t hsl_lightness; /*!< Current value of light hsl lightness state */
+ uint16_t hsl_hue; /*!< Current value of light hsl hue state */
+ uint16_t hsl_saturation; /*!< Current value of light hsl saturation state */
+ uint8_t remain_time; /*!< Time to complete state transition (optional) */
+} esp_ble_mesh_light_hsl_status_cb_t;
+
+/** Parameters of Light HSL Target Status */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t hsl_lightness_target; /*!< Target value of light hsl lightness state */
+ uint16_t hsl_hue_target; /*!< Target value of light hsl hue state */
+ uint16_t hsl_saturation_target; /*!< Target value of light hsl saturation state */
+ uint8_t remain_time; /*!< Time to complete state transition (optional) */
+} esp_ble_mesh_light_hsl_target_status_cb_t;
+
+/** Parameters of Light HSL Hue Status */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t present_hue; /*!< Current value of light hsl hue state */
+ uint16_t target_hue; /*!< Target value of light hsl hue state (optional) */
+ uint8_t remain_time; /*!< Time to complete state transition (C.1) */
+} esp_ble_mesh_light_hsl_hue_status_cb_t;
+
+/** Parameters of Light HSL Saturation Status */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t present_saturation; /*!< Current value of light hsl saturation state */
+ uint16_t target_saturation; /*!< Target value of light hsl saturation state (optional) */
+ uint8_t remain_time; /*!< Time to complete state transition (C.1) */
+} esp_ble_mesh_light_hsl_saturation_status_cb_t;
+
+/** Parameters of Light HSL Default Status */
+typedef struct {
+ uint16_t lightness; /*!< Value of light lightness default state */
+ uint16_t hue; /*!< Value of light hue default state */
+ uint16_t saturation; /*!< Value of light saturation default state */
+} esp_ble_mesh_light_hsl_default_status_cb_t;
+
+/** Parameters of Light HSL Range Status */
+typedef struct {
+ uint8_t status_code; /*!< Status code for the request message */
+ uint16_t hue_range_min; /*!< Value of hue range min field of light hsl hue range state */
+ uint16_t hue_range_max; /*!< Value of hue range max field of light hsl hue range state */
+ uint16_t saturation_range_min; /*!< Value of saturation range min field of light hsl saturation range state */
+ uint16_t saturation_range_max; /*!< Value of saturation range max field of light hsl saturation range state */
+} esp_ble_mesh_light_hsl_range_status_cb_t;
+
+/** Parameters of Light xyL Status */
+typedef struct {
+ bool op_en; /*!< Indicate whether optional parameters included */
+ uint16_t xyl_lightness; /*!< The present value of the Light xyL Lightness state */
+ uint16_t xyl_x; /*!< The present value of the Light xyL x state */
+ uint16_t xyl_y; /*!< The present value of the Light xyL y state */
+ uint8_t remain_time; /*!< Time to complete state transition (optional) */
+} esp_ble_mesh_light_xyl_status_cb_t;
+
+/** Parameters of Light xyL Target Status */
+typedef struct {
+ bool op_en; /*!< Indicate whether optional parameters included */
+ uint16_t target_xyl_lightness; /*!< The target value of the Light xyL Lightness state */
+ uint16_t target_xyl_x; /*!< The target value of the Light xyL x state */
+ uint16_t target_xyl_y; /*!< The target value of the Light xyL y state */
+ uint8_t remain_time; /*!< Time to complete state transition (optional) */
+} esp_ble_mesh_light_xyl_target_status_cb_t;
+
+/** Parameters of Light xyL Default Status */
+typedef struct {
+ uint16_t lightness; /*!< The value of the Light Lightness Default state */
+ uint16_t xyl_x; /*!< The value of the Light xyL x Default state */
+ uint16_t xyl_y; /*!< The value of the Light xyL y Default state */
+} esp_ble_mesh_light_xyl_default_status_cb_t;
+
+/** Parameters of Light xyL Range Status */
+typedef struct {
+ uint8_t status_code; /*!< Status Code for the requesting message */
+ uint16_t xyl_x_range_min; /*!< The value of the xyL x Range Min field of the Light xyL x Range state */
+ uint16_t xyl_x_range_max; /*!< The value of the xyL x Range Max field of the Light xyL x Range state */
+ uint16_t xyl_y_range_min; /*!< The value of the xyL y Range Min field of the Light xyL y Range state */
+ uint16_t xyl_y_range_max; /*!< The value of the xyL y Range Max field of the Light xyL y Range state */
+} esp_ble_mesh_light_xyl_range_status_cb_t;
+
+/** Parameter of Light LC Mode Status */
+typedef struct {
+ uint8_t mode; /*!< The present value of the Light LC Mode state */
+} esp_ble_mesh_light_lc_mode_status_cb_t;
+
+/** Parameter of Light LC OM Status */
+typedef struct {
+ uint8_t mode; /*!< The present value of the Light LC Occupancy Mode state */
+} esp_ble_mesh_light_lc_om_status_cb_t;
+
+/** Parameters of Light LC Light OnOff Status */
+typedef struct {
+ bool op_en; /*!< Indicate whether optional parameters included */
+ uint8_t present_light_onoff; /*!< The present value of the Light LC Light OnOff state */
+ uint8_t target_light_onoff; /*!< The target value of the Light LC Light OnOff state (Optional) */
+ uint8_t remain_time; /*!< Time to complete state transition (C.1) */
+} esp_ble_mesh_light_lc_light_onoff_status_cb_t;
+
+/** Parameters of Light LC Property Status */
+typedef struct {
+ uint16_t property_id; /*!< Property ID identifying a Light LC Property */
+ struct net_buf_simple *property_value; /*!< Raw value for the Light LC Property */
+} esp_ble_mesh_light_lc_property_status_cb_t;
+
+/**
+ * @brief Lighting Client Model received message union
+ */
+typedef union {
+ esp_ble_mesh_light_lightness_status_cb_t lightness_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_STATUS */
+ esp_ble_mesh_light_lightness_linear_status_cb_t lightness_linear_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_STATUS */
+ esp_ble_mesh_light_lightness_last_status_cb_t lightness_last_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LAST_STATUS */
+ esp_ble_mesh_light_lightness_default_status_cb_t lightness_default_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_STATUS */
+ esp_ble_mesh_light_lightness_range_status_cb_t lightness_range_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_STATUS */
+ esp_ble_mesh_light_ctl_status_cb_t ctl_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_STATUS */
+ esp_ble_mesh_light_ctl_temperature_status_cb_t ctl_temperature_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_STATUS */
+ esp_ble_mesh_light_ctl_temperature_range_status_cb_t ctl_temperature_range_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_STATUS */
+ esp_ble_mesh_light_ctl_default_status_cb_t ctl_default_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_STATUS */
+ esp_ble_mesh_light_hsl_status_cb_t hsl_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_STATUS */
+ esp_ble_mesh_light_hsl_target_status_cb_t hsl_target_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_TARGET_STATUS */
+ esp_ble_mesh_light_hsl_hue_status_cb_t hsl_hue_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_STATUS */
+ esp_ble_mesh_light_hsl_saturation_status_cb_t hsl_saturation_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_STATUS */
+ esp_ble_mesh_light_hsl_default_status_cb_t hsl_default_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_STATUS */
+ esp_ble_mesh_light_hsl_range_status_cb_t hsl_range_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_STATUS */
+ esp_ble_mesh_light_xyl_status_cb_t xyl_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_STATUS */
+ esp_ble_mesh_light_xyl_target_status_cb_t xyl_target_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_TARGET_STATUS */
+ esp_ble_mesh_light_xyl_default_status_cb_t xyl_default_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_STATUS */
+ esp_ble_mesh_light_xyl_range_status_cb_t xyl_range_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_STATUS */
+ esp_ble_mesh_light_lc_mode_status_cb_t lc_mode_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LC_MODE_STATUS */
+ esp_ble_mesh_light_lc_om_status_cb_t lc_om_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LC_OM_STATUS */
+ esp_ble_mesh_light_lc_light_onoff_status_cb_t lc_light_onoff_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_STATUS */
+ esp_ble_mesh_light_lc_property_status_cb_t lc_property_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_STATUS */
+} esp_ble_mesh_light_client_status_cb_t;
+
+/** Lighting Client Model callback parameters */
+typedef struct {
+ int error_code; /*!< Appropriate error code */
+ esp_ble_mesh_client_common_param_t *params; /*!< The client common parameters. */
+ esp_ble_mesh_light_client_status_cb_t status_cb; /*!< The light status message callback values */
+} esp_ble_mesh_light_client_cb_param_t;
+
+/** This enum value is the event of Lighting Client Model */
+typedef enum {
+ ESP_BLE_MESH_LIGHT_CLIENT_GET_STATE_EVT,
+ ESP_BLE_MESH_LIGHT_CLIENT_SET_STATE_EVT,
+ ESP_BLE_MESH_LIGHT_CLIENT_PUBLISH_EVT,
+ ESP_BLE_MESH_LIGHT_CLIENT_TIMEOUT_EVT,
+ ESP_BLE_MESH_LIGHT_CLIENT_EVT_MAX,
+} esp_ble_mesh_light_client_cb_event_t;
+
+/**
+ * @brief Bluetooth Mesh Light Client Model function.
+ */
+
+/**
+ * @brief Lighting Client Model callback function type
+ * @param event: Event type
+ * @param param: Pointer to callback parameter
+ */
+typedef void (* esp_ble_mesh_light_client_cb_t)(esp_ble_mesh_light_client_cb_event_t event,
+ esp_ble_mesh_light_client_cb_param_t *param);
+
+/**
+ * @brief Register BLE Mesh Light Client Model callback.
+ *
+ * @param[in] callback: pointer to the callback function.
+ *
+ * @return ESP_OK on success or error code otherwise.
+ *
+ */
+esp_err_t esp_ble_mesh_register_light_client_callback(esp_ble_mesh_light_client_cb_t callback);
+
+/**
+ * @brief Get the value of Light Server Model states using the Light Client Model get messages.
+ *
+ * @note If you want to know the opcodes and corresponding meanings accepted by this API,
+ * please refer to esp_ble_mesh_light_message_opcode_t in esp_ble_mesh_defs.h
+ *
+ * @param[in] params: Pointer to BLE Mesh common client parameters.
+ * @param[in] get_state: Pointer of light get message value.
+ * Shall not be set to NULL.
+ *
+ * @return ESP_OK on success or error code otherwise.
+ *
+ */
+esp_err_t esp_ble_mesh_light_client_get_state(esp_ble_mesh_client_common_param_t *params,
+ esp_ble_mesh_light_client_get_state_t *get_state);
+
+/**
+ * @brief Set the value of Light Server Model states using the Light Client Model set messages.
+ *
+ * @note If you want to know the opcodes and corresponding meanings accepted by this API,
+ * please refer to esp_ble_mesh_light_message_opcode_t in esp_ble_mesh_defs.h
+ *
+ * @param[in] params: Pointer to BLE Mesh common client parameters.
+ * @param[in] set_state: Pointer of light set message value.
+ * Shall not be set to NULL.
+ *
+ * @return ESP_OK on success or error code otherwise.
+ *
+ */
+esp_err_t esp_ble_mesh_light_client_set_state(esp_ble_mesh_client_common_param_t *params,
+ esp_ble_mesh_light_client_set_state_t *set_state);
+
+/**
+ * @brief Lighting Server Models related context.
+ */
+
+/** @def ESP_BLE_MESH_MODEL_LIGHT_LIGHTNESS_SRV
+ *
+ * @brief Define a new Light Lightness Server Model.
+ *
+ * @note 1. The Light Lightness Server model extends the Generic Power OnOff
+ * Server model and the Generic Level Server model. When this model
+ * is present on an Element, the corresponding Light Lightness Setup
+ * Server model shall also be present.
+ * 2. This model shall support model publication and model subscription.
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_light_lightness_srv_t.
+ *
+ * @return New Light Lightness Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_LIGHT_LIGHTNESS_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV, \
+ NULL, srv_pub, srv_data)
+
+/** @def ESP_BLE_MESH_MODEL_LIGHT_LIGHTNESS_SETUP_SRV
+ *
+ * @brief Define a new Light Lightness Setup Server Model.
+ *
+ * @note 1. The Light Lightness Setup Server model extends the Light Lightness
+ * Server model and the Generic Power OnOff Setup Server model.
+ * 2. This model shall support model subscription.
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_light_lightness_setup_srv_t.
+ *
+ * @return New Light Lightness Setup Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_LIGHT_LIGHTNESS_SETUP_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SETUP_SRV, \
+ NULL, srv_pub, srv_data)
+
+/** @def ESP_BLE_MESH_MODEL_LIGHT_CTL_SRV
+ *
+ * @brief Define a new Light CTL Server Model.
+ *
+ * @note 1. The Light CTL Server model extends the Light Lightness Server model.
+ * When this model is present on an Element, the corresponding Light
+ * CTL Temperature Server model and the corresponding Light CTL Setup
+ * Server model shall also be present.
+ * 2. This model shall support model publication and model subscription.
+ * 3. The model requires two elements: the main element and the Temperature
+ * element. The Temperature element contains the corresponding Light CTL
+ * Temperature Server model and an instance of a Generic Level state
+ * bound to the Light CTL Temperature state on the Temperature element.
+ * The Light CTL Temperature state on the Temperature element is bound to
+ * the Light CTL state on the main element.
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_light_ctl_srv_t.
+ *
+ * @return New Light CTL Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_LIGHT_CTL_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_CTL_SRV, \
+ NULL, srv_pub, srv_data)
+
+/** @def ESP_BLE_MESH_MODEL_LIGHT_CTL_SETUP_SRV
+ *
+ * @brief Define a new Light CTL Setup Server Model.
+ *
+ * @note 1. The Light CTL Setup Server model extends the Light CTL Server and
+ * the Light Lightness Setup Server.
+ * 2. This model shall support model subscription.
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_light_ctl_setup_srv_t.
+ *
+ * @return New Light CTL Setup Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_LIGHT_CTL_SETUP_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_CTL_SETUP_SRV, \
+ NULL, srv_pub, srv_data)
+
+/** @def ESP_BLE_MESH_MODEL_LIGHT_CTL_TEMP_SRV
+ *
+ * @brief Define a new Light CTL Temperature Server Model.
+ *
+ * @note 1. The Light CTL Temperature Server model extends the Generic Level
+ * Server model.
+ * 2. This model shall support model publication and model subscription.
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_light_ctl_temp_srv_t.
+ *
+ * @return New Light CTL Temperature Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_LIGHT_CTL_TEMP_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_CTL_TEMP_SRV, \
+ NULL, srv_pub, srv_data)
+
+/** @def ESP_BLE_MESH_MODEL_LIGHT_HSL_SRV
+ *
+ * @brief Define a new Light HSL Server Model.
+ *
+ * @note 1. The Light HSL Server model extends the Light Lightness Server model. When
+ * this model is present on an Element, the corresponding Light HSL Hue
+ * Server model and the corresponding Light HSL Saturation Server model and
+ * the corresponding Light HSL Setup Server model shall also be present.
+ * 2. This model shall support model publication and model subscription.
+ * 3. The model requires three elements: the main element and the Hue element
+ * and the Saturation element. The Hue element contains the corresponding
+ * Light HSL Hue Server model and an instance of a Generic Level state bound
+ * to the Light HSL Hue state on the Hue element. The Saturation element
+ * contains the corresponding Light HSL Saturation Server model and an
+ * instance of a Generic Level state bound to the Light HSL Saturation state
+ * on the Saturation element. The Light HSL Hue state on the Hue element is
+ * bound to the Light HSL state on the main element and the Light HSL
+ * Saturation state on the Saturation element is bound to the Light HSL state
+ * on the main element.
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_light_hsl_srv_t.
+ *
+ * @return New Light HSL Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_LIGHT_HSL_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_SRV, \
+ NULL, srv_pub, srv_data)
+
+/** @def ESP_BLE_MESH_MODEL_LIGHT_HSL_SETUP_SRV
+ *
+ * @brief Define a new Light HSL Setup Server Model.
+ *
+ * @note 1. The Light HSL Setup Server model extends the Light HSL Server and
+ * the Light Lightness Setup Server.
+ * 2. This model shall support model subscription.
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_light_hsl_setup_srv_t.
+ *
+ * @return New Light HSL Setup Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_LIGHT_HSL_SETUP_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_SETUP_SRV, \
+ NULL, srv_pub, srv_data)
+
+/** @def ESP_BLE_MESH_MODEL_LIGHT_HSL_HUE_SRV
+ *
+ * @brief Define a new Light HSL Hue Server Model.
+ *
+ * @note 1. The Light HSL Hue Server model extends the Generic Level Server model.
+ * This model is associated with the Light HSL Server model.
+ * 2. This model shall support model publication and model subscription.
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_light_hsl_hue_srv_t.
+ *
+ * @return New Light HSL Hue Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_LIGHT_HSL_HUE_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_HUE_SRV, \
+ NULL, srv_pub, srv_data)
+
+/** @def ESP_BLE_MESH_MODEL_LIGHT_HSL_SAT_SRV
+ *
+ * @brief Define a new Light HSL Saturation Server Model.
+ *
+ * @note 1. The Light HSL Saturation Server model extends the Generic Level Server
+ * model. This model is associated with the Light HSL Server model.
+ * 2. This model shall support model publication and model subscription.
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_light_hsl_sat_srv_t.
+ *
+ * @return New Light HSL Saturation Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_LIGHT_HSL_SAT_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_SAT_SRV, \
+ NULL, srv_pub, srv_data)
+
+/** @def ESP_BLE_MESH_MODEL_LIGHT_XYL_SRV
+ *
+ * @brief Define a new Light xyL Server Model.
+ *
+ * @note 1. The Light xyL Server model extends the Light Lightness Server model.
+ * When this model is present on an Element, the corresponding Light xyL
+ * Setup Server model shall also be present.
+ * 2. This model shall support model publication and model subscription.
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_light_xyl_srv_t.
+ *
+ * @return New Light xyL Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_LIGHT_XYL_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_XYL_SRV, \
+ NULL, srv_pub, srv_data)
+
+/** @def ESP_BLE_MESH_MODEL_LIGHT_XYL_SETUP_SRV
+ *
+ * @brief Define a new Light xyL Setup Server Model.
+ *
+ * @note 1. The Light xyL Setup Server model extends the Light xyL Server and
+ * the Light Lightness Setup Server.
+ * 2. This model shall support model subscription.
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_light_xyl_setup_srv_t.
+ *
+ * @return New Light xyL Setup Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_LIGHT_XYL_SETUP_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV, \
+ NULL, srv_pub, srv_data)
+
+/** @def ESP_BLE_MESH_MODEL_LIGHT_LC_SRV
+ *
+ * @brief Define a new Light LC Server Model.
+ *
+ * @note 1. The Light LC (Lightness Control) Server model extends the Light
+ * Lightness Server model and the Generic OnOff Server model. When
+ * this model is present on an Element, the corresponding Light LC
+ * Setup Server model shall also be present.
+ * 2. This model shall support model publication and model subscription.
+ * 3. This model may be used to represent an element that is a client to
+ * a Sensor Server model and controls the Light Lightness Actual state
+ * via defined state bindings.
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_light_lc_srv_t.
+ *
+ * @return New Light LC Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_LIGHT_LC_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_LC_SRV, \
+ NULL, srv_pub, srv_data)
+
+/** @def ESP_BLE_MESH_MODEL_LIGHT_LC_SETUP_SRV
+ *
+ * @brief Define a new Light LC Setup Server Model.
+ *
+ * @note 1. The Light LC (Lightness Control) Setup model extends the Light LC
+ * Server model.
+ * 2. This model shall support model publication and model subscription.
+ * 3. This model may be used to configure setup parameters for the Light
+ * LC Server model.
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_light_lc_setup_srv_t.
+ *
+ * @return New Light LC Setup Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_LIGHT_LC_SETUP_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_LC_SETUP_SRV, \
+ NULL, srv_pub, srv_data)
+
+/** Parameters of Light Lightness state */
+typedef struct {
+ uint16_t lightness_linear; /*!< The present value of Light Lightness Linear state */
+ uint16_t target_lightness_linear; /*!< The target value of Light Lightness Linear state */
+
+ uint16_t lightness_actual; /*!< The present value of Light Lightness Actual state */
+ uint16_t target_lightness_actual; /*!< The target value of Light Lightness Actual state */
+
+ uint16_t lightness_last; /*!< The value of Light Lightness Last state */
+ uint16_t lightness_default; /*!< The value of Light Lightness Default state */
+
+ uint8_t status_code; /*!< The status code of setting Light Lightness Range state */
+ uint16_t lightness_range_min; /*!< The minimum value of Light Lightness Range state */
+ uint16_t lightness_range_max; /*!< The maximum value of Light Lightness Range state */
+} esp_ble_mesh_light_lightness_state_t;
+
+/** User data of Light Lightness Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting Lightness Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ esp_ble_mesh_light_lightness_state_t *state; /*!< Parameters of the Light Lightness state */
+ esp_ble_mesh_last_msg_info_t last; /*!< Parameters of the last received set message */
+ esp_ble_mesh_state_transition_t actual_transition; /*!< Parameters of state transition */
+ esp_ble_mesh_state_transition_t linear_transition; /*!< Parameters of state transition */
+ int32_t tt_delta_lightness_actual; /*!< Delta change value of lightness actual state transition */
+ int32_t tt_delta_lightness_linear; /*!< Delta change value of lightness linear state transition */
+} esp_ble_mesh_light_lightness_srv_t;
+
+/** User data of Light Lightness Setup Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting Lightness Setup Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ esp_ble_mesh_light_lightness_state_t *state; /*!< Parameters of the Light Lightness state */
+} esp_ble_mesh_light_lightness_setup_srv_t;
+
+/** Parameters of Light CTL state */
+typedef struct {
+ uint16_t lightness; /*!< The present value of Light CTL Lightness state */
+ uint16_t target_lightness; /*!< The target value of Light CTL Lightness state */
+
+ uint16_t temperature; /*!< The present value of Light CTL Temperature state */
+ uint16_t target_temperature; /*!< The target value of Light CTL Temperature state */
+
+ int16_t delta_uv; /*!< The present value of Light CTL Delta UV state */
+ int16_t target_delta_uv; /*!< The target value of Light CTL Delta UV state */
+
+ uint8_t status_code; /*!< The statue code of setting Light CTL Temperature Range state */
+ uint16_t temperature_range_min; /*!< The minimum value of Light CTL Temperature Range state */
+ uint16_t temperature_range_max; /*!< The maximum value of Light CTL Temperature Range state */
+
+ uint16_t lightness_default; /*!< The value of Light Lightness Default state */
+ uint16_t temperature_default; /*!< The value of Light CTL Temperature Default state */
+ int16_t delta_uv_default; /*!< The value of Light CTL Delta UV Default state */
+} esp_ble_mesh_light_ctl_state_t;
+
+/** User data of Light CTL Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting CTL Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ esp_ble_mesh_light_ctl_state_t *state; /*!< Parameters of the Light CTL state */
+ esp_ble_mesh_last_msg_info_t last; /*!< Parameters of the last received set message */
+ esp_ble_mesh_state_transition_t transition; /*!< Parameters of state transition */
+ int32_t tt_delta_lightness; /*!< Delta change value of lightness state transition */
+ int32_t tt_delta_temperature; /*!< Delta change value of temperature state transition */
+ int32_t tt_delta_delta_uv; /*!< Delta change value of delta uv state transition */
+} esp_ble_mesh_light_ctl_srv_t;
+
+/** User data of Light CTL Setup Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting CTL Setup Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ esp_ble_mesh_light_ctl_state_t *state; /*!< Parameters of the Light CTL state */
+} esp_ble_mesh_light_ctl_setup_srv_t;
+
+/** User data of Light CTL Temperature Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting CTL Temperature Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ esp_ble_mesh_light_ctl_state_t *state; /*!< Parameters of the Light CTL state */
+ esp_ble_mesh_last_msg_info_t last; /*!< Parameters of the last received set message */
+ esp_ble_mesh_state_transition_t transition; /*!< Parameters of state transition */
+ int32_t tt_delta_temperature; /*!< Delta change value of temperature state transition */
+ int32_t tt_delta_delta_uv; /*!< Delta change value of delta uv state transition */
+} esp_ble_mesh_light_ctl_temp_srv_t;
+
+/** Parameters of Light HSL state */
+typedef struct {
+ uint16_t lightness; /*!< The present value of Light HSL Lightness state */
+ uint16_t target_lightness; /*!< The target value of Light HSL Lightness state */
+
+ uint16_t hue; /*!< The present value of Light HSL Hue state */
+ uint16_t target_hue; /*!< The target value of Light HSL Hue state */
+
+ uint16_t saturation; /*!< The present value of Light HSL Saturation state */
+ uint16_t target_saturation; /*!< The target value of Light HSL Saturation state */
+
+ uint16_t lightness_default; /*!< The value of Light Lightness Default state */
+ uint16_t hue_default; /*!< The value of Light HSL Hue Default state */
+ uint16_t saturation_default; /*!< The value of Light HSL Saturation Default state */
+
+ uint8_t status_code; /*!< The status code of setting Light HSL Hue & Saturation Range state */
+ uint16_t hue_range_min; /*!< The minimum value of Light HSL Hue Range state */
+ uint16_t hue_range_max; /*!< The maximum value of Light HSL Hue Range state */
+ uint16_t saturation_range_min; /*!< The minimum value of Light HSL Saturation state */
+ uint16_t saturation_range_max; /*!< The maximum value of Light HSL Saturation state */
+} esp_ble_mesh_light_hsl_state_t;
+
+/** User data of Light HSL Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting HSL Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ esp_ble_mesh_light_hsl_state_t *state; /*!< Parameters of the Light HSL state */
+ esp_ble_mesh_last_msg_info_t last; /*!< Parameters of the last received set message */
+ esp_ble_mesh_state_transition_t transition; /*!< Parameters of state transition */
+ int32_t tt_delta_lightness; /*!< Delta change value of lightness state transition */
+ int32_t tt_delta_hue; /*!< Delta change value of hue state transition */
+ int32_t tt_delta_saturation; /*!< Delta change value of saturation state transition */
+} esp_ble_mesh_light_hsl_srv_t;
+
+/** User data of Light HSL Setup Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting HSL Setup Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ esp_ble_mesh_light_hsl_state_t *state; /*!< Parameters of the Light HSL state */
+} esp_ble_mesh_light_hsl_setup_srv_t;
+
+/** User data of Light HSL Hue Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting HSL Hue Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ esp_ble_mesh_light_hsl_state_t *state; /*!< Parameters of the Light HSL state */
+ esp_ble_mesh_last_msg_info_t last; /*!< Parameters of the last received set message */
+ esp_ble_mesh_state_transition_t transition; /*!< Parameters of state transition */
+ int32_t tt_delta_hue; /*!< Delta change value of hue state transition */
+} esp_ble_mesh_light_hsl_hue_srv_t;
+
+/** User data of Light HSL Saturation Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting HSL Saturation Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ esp_ble_mesh_light_hsl_state_t *state; /*!< Parameters of the Light HSL state */
+ esp_ble_mesh_last_msg_info_t last; /*!< Parameters of the last received set message */
+ esp_ble_mesh_state_transition_t transition; /*!< Parameters of state transition */
+ int32_t tt_delta_saturation; /*!< Delta change value of saturation state transition */
+} esp_ble_mesh_light_hsl_sat_srv_t;
+
+/** Parameters of Light xyL state */
+typedef struct {
+ uint16_t lightness; /*!< The present value of Light xyL Lightness state */
+ uint16_t target_lightness; /*!< The target value of Light xyL Lightness state */
+
+ uint16_t x; /*!< The present value of Light xyL x state */
+ uint16_t target_x; /*!< The target value of Light xyL x state */
+
+ uint16_t y; /*!< The present value of Light xyL y state */
+ uint16_t target_y; /*!< The target value of Light xyL y state */
+
+ uint16_t lightness_default; /*!< The value of Light Lightness Default state */
+ uint16_t x_default; /*!< The value of Light xyL x Default state */
+ uint16_t y_default; /*!< The value of Light xyL y Default state */
+
+ uint8_t status_code; /*!< The status code of setting Light xyL x & y Range state */
+ uint16_t x_range_min; /*!< The minimum value of Light xyL x Range state */
+ uint16_t x_range_max; /*!< The maximum value of Light xyL x Range state */
+ uint16_t y_range_min; /*!< The minimum value of Light xyL y Range state */
+ uint16_t y_range_max; /*!< The maximum value of Light xyL y Range state */
+} esp_ble_mesh_light_xyl_state_t;
+
+/** User data of Light xyL Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting xyL Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ esp_ble_mesh_light_xyl_state_t *state; /*!< Parameters of the Light xyL state */
+ esp_ble_mesh_last_msg_info_t last; /*!< Parameters of the last received set message */
+ esp_ble_mesh_state_transition_t transition; /*!< Parameters of state transition */
+ int32_t tt_delta_lightness; /*!< Delta change value of lightness state transition */
+ int32_t tt_delta_x; /*!< Delta change value of x state transition */
+ int32_t tt_delta_y; /*!< Delta change value of y state transition */
+} esp_ble_mesh_light_xyl_srv_t;
+
+/** User data of Light xyL Setup Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting xyL Setup Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ esp_ble_mesh_light_xyl_state_t *state; /*!< Parameters of the Light xyL state */
+} esp_ble_mesh_light_xyl_setup_srv_t;
+
+/** Parameters of Light LC states */
+typedef struct {
+ /**
+ * 0b0 The controller is turned off.
+ * - The binding with the Light Lightness state is disabled.
+ * 0b1 The controller is turned on.
+ * - The binding with the Light Lightness state is enabled.
+ */
+ uint32_t mode : 1, /*!< The value of Light LC Mode state */
+ occupancy_mode : 1, /*!< The value of Light LC Occupancy Mode state */
+ light_onoff : 1, /*!< The present value of Light LC Light OnOff state */
+ target_light_onoff : 1, /*!< The target value of Light LC Light OnOff state */
+ occupancy : 1, /*!< The value of Light LC Occupancy state */
+ ambient_luxlevel : 24; /*!< The value of Light LC Ambient LuxLevel state */
+
+ /**
+ * 1. Light LC Linear Output = max((Lightness Out)^2/65535, Regulator Output)
+ * 2. If the Light LC Mode state is set to 0b1, the binding is enabled and upon
+ * a change of the Light LC Linear Output state, the following operation
+ * shall be performed:
+ * Light Lightness Linear = Light LC Linear Output
+ * 3. If the Light LC Mode state is set to 0b0, the binding is disabled (i.e.,
+ * upon a change of the Light LC Linear Output state, no operation on the
+ * Light Lightness Linear state is performed).
+ */
+ uint16_t linear_output; /*!< The value of Light LC Linear Output state */
+} esp_ble_mesh_light_lc_state_t;
+
+/**
+ * Parameters of Light Property states.
+ * The Light LC Property states are read / write states that determine the
+ * configuration of a Light Lightness Controller. Each state is represented
+ * by a device property and is controlled by Light LC Property messages.
+ */
+typedef struct {
+ /**
+ * A timing state that determines the delay for changing the Light LC
+ * Occupancy state upon receiving a Sensor Status message from an
+ * occupancy sensor.
+ */
+ uint32_t time_occupancy_delay; /*!< The value of Light LC Time Occupancy Delay state */
+ /**
+ * A timing state that determines the time the controlled lights fade
+ * to the level determined by the Light LC Lightness On state.
+ */
+ uint32_t time_fade_on; /*!< The value of Light LC Time Fade On state */
+ /**
+ * A timing state that determines the time the controlled lights stay
+ * at the level determined by the Light LC Lightness On state.
+ */
+ uint32_t time_run_on; /*!< The value of Light LC Time Run On state */
+ /**
+ * A timing state that determines the time the controlled lights fade
+ * from the level determined by the Light LC Lightness On state to the
+ * level determined by the Light Lightness Prolong state.
+ */
+ uint32_t time_fade; /*!< The value of Light LC Time Fade state */
+ /**
+ * A timing state that determines the time the controlled lights stay at
+ * the level determined by the Light LC Lightness Prolong state.
+ */
+ uint32_t time_prolong; /*!< The value of Light LC Time Prolong state */
+ /**
+ * A timing state that determines the time the controlled lights fade from
+ * the level determined by the Light LC Lightness Prolong state to the level
+ * determined by the Light LC Lightness Standby state when the transition is
+ * automatic.
+ */
+ uint32_t time_fade_standby_auto; /*!< The value of Light LC Time Fade Standby Auto state */
+ /**
+ * A timing state that determines the time the controlled lights fade from
+ * the level determined by the Light LC Lightness Prolong state to the level
+ * determined by the Light LC Lightness Standby state when the transition is
+ * triggered by a change in the Light LC Light OnOff state.
+ */
+ uint32_t time_fade_standby_manual; /*!< The value of Light LC Time Fade Standby Manual state */
+
+ /**
+ * A lightness state that determines the perceptive light lightness at the
+ * Occupancy and Run internal controller states.
+ */
+ uint16_t lightness_on; /*!< The value of Light LC Lightness On state */
+ /**
+ * A lightness state that determines the light lightness at the Prolong
+ * internal controller state.
+ */
+ uint16_t lightness_prolong; /*!< The value of Light LC Lightness Prolong state */
+ /**
+ * A lightness state that determines the light lightness at the Standby
+ * internal controller state.
+ */
+ uint16_t lightness_standby; /*!< The value of Light LC Lightness Standby state */
+
+ /**
+ * A uint16 state representing the Ambient LuxLevel level that determines
+ * if the controller transitions from the Light Control Standby state.
+ */
+ uint16_t ambient_luxlevel_on; /*!< The value of Light LC Ambient LuxLevel On state */
+ /**
+ * A uint16 state representing the required Ambient LuxLevel level in the
+ * Prolong state.
+ */
+ uint16_t ambient_luxlevel_prolong; /*!< The value of Light LC Ambient LuxLevel Prolong state */
+ /**
+ * A uint16 state representing the required Ambient LuxLevel level in the
+ * Standby state.
+ */
+ uint16_t ambient_luxlevel_standby; /*!< The value of Light LC Ambient LuxLevel Standby state */
+
+ /**
+ * A float32 state representing the integral coefficient that determines the
+ * integral part of the equation defining the output of the Light LC PI
+ * Feedback Regulator, when Light LC Ambient LuxLevel is less than LuxLevel
+ * Out. Valid range: 0.0 ~ 1000.0. The default value is 250.0.
+ */
+ float regulator_kiu; /*!< The value of Light LC Regulator Kiu state */
+ /**
+ * A float32 state representing the integral coefficient that determines the
+ * integral part of the equation defining the output of the Light LC PI
+ * Feedback Regulator, when Light LC Ambient LuxLevel is greater than or equal
+ * to the value of the LuxLevel Out state. Valid range: 0.0 ~ 1000.0. The
+ * default value is 25.0.
+ */
+ float regulator_kid; /*!< The value of Light LC Regulator Kid state */
+ /**
+ * A float32 state representing the proportional coefficient that determines
+ * the proportional part of the equation defining the output of the Light LC
+ * PI Feedback Regulator, when Light LC Ambient LuxLevel is less than the value
+ * of the LuxLevel Out state. Valid range: 0.0 ~ 1000.0. The default value is 80.0.
+ */
+ float regulator_kpu; /*!< The value of Light LC Regulator Kpu state */
+ /**
+ * A float32 state representing the proportional coefficient that determines
+ * the proportional part of the equation defining the output of the Light LC PI
+ * Feedback Regulator, when Light LC Ambient LuxLevel is greater than or equal
+ * to the value of the LuxLevel Out state. Valid range: 0.0 ~ 1000.0. The default
+ * value is 80.0.
+ */
+ float regulator_kpd; /*!< The value of Light LC Regulator Kpd state */
+ /**
+ * A int8 state representing the percentage accuracy of the Light LC PI Feedback
+ * Regulator. Valid range: 0.0 ~ 100.0. The default value is 2.0.
+ */
+ int8_t regulator_accuracy; /*!< The value of Light LC Regulator Accuracy state */
+
+ /**
+ * If the message Raw field contains a Raw Value for the Time Since Motion
+ * Sensed device property, which represents a value less than or equal to
+ * the value of the Light LC Occupancy Delay state, it shall delay setting
+ * the Light LC Occupancy state to 0b1 by the difference between the value
+ * of the Light LC Occupancy Delay state and the received Time Since Motion
+ * value.
+ */
+ uint32_t set_occupancy_to_1_delay; /*!< The value of the difference between value of the
+ Light LC Occupancy Delay state and the received
+ Time Since Motion value */
+} esp_ble_mesh_light_lc_property_state_t;
+
+/** This enum value is the Light LC State Machine states */
+typedef enum {
+ ESP_BLE_MESH_LC_OFF,
+ ESP_BLE_MESH_LC_STANDBY,
+ ESP_BLE_MESH_LC_FADE_ON,
+ ESP_BLE_MESH_LC_RUN,
+ ESP_BLE_MESH_LC_FADE,
+ ESP_BLE_MESH_LC_PROLONG,
+ ESP_BLE_MESH_LC_FADE_STANDBY_AUTO,
+ ESP_BLE_MESH_LC_FADE_STANDBY_MANUAL,
+} esp_ble_mesh_lc_state_t;
+
+/** Parameters of Light LC state machine */
+typedef struct {
+ /**
+ * The Fade On, Fade, Fade Standby Auto, and Fade Standby Manual states are
+ * transition states that define the transition of the Lightness Out and
+ * LuxLevel Out states. This transition can be started as a result of the
+ * Light LC State Machine change or as a result of receiving the Light LC
+ * Light OnOff Set or Light LC Light Set Unacknowledged message.
+ */
+ struct {
+ uint8_t fade_on; /*!< The value of transition time of Light LC Time Fade On */
+ uint8_t fade; /*!< The value of transition time of Light LC Time Fade */
+ uint8_t fade_standby_auto; /*!< The value of transition time of Light LC Time Fade Standby Auto */
+ uint8_t fade_standby_manual; /*!< The value of transition time of Light LC Time Fade Standby Manual */
+ } trans_time; /*!< The value of transition time */
+ esp_ble_mesh_lc_state_t state; /*!< The value of Light LC state machine state */
+ struct k_delayed_work timer; /*!< Timer of Light LC state machine */
+} esp_ble_mesh_light_lc_state_machine_t;
+
+/** Parameters of Light Lightness controller */
+typedef struct {
+ esp_ble_mesh_light_lc_state_t state; /*!< Parameters of Light LC state */
+ esp_ble_mesh_light_lc_property_state_t prop_state; /*!< Parameters of Light LC Property state */
+ esp_ble_mesh_light_lc_state_machine_t state_machine; /*!< Parameters of Light LC state machine */
+} esp_ble_mesh_light_control_t;
+
+/** User data of Light LC Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting LC Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ esp_ble_mesh_light_control_t *lc; /*!< Parameters of the Light controller */
+ esp_ble_mesh_last_msg_info_t last; /*!< Parameters of the last received set message */
+ esp_ble_mesh_state_transition_t transition; /*!< Parameters of state transition */
+} esp_ble_mesh_light_lc_srv_t;
+
+/** User data of Light LC Setup Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting LC Setup Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ esp_ble_mesh_light_control_t *lc; /*!< Parameters of the Light controller */
+} esp_ble_mesh_light_lc_setup_srv_t;
+
+/** Parameter of Light Lightness Actual state change event */
+typedef struct {
+ uint16_t lightness; /*!< The value of Light Lightness Actual state */
+} esp_ble_mesh_state_change_light_lightness_set_t;
+
+/** Parameter of Light Lightness Linear state change event */
+typedef struct {
+ uint16_t lightness; /*!< The value of Light Lightness Linear state */
+} esp_ble_mesh_state_change_light_lightness_linear_set_t;
+
+/** Parameter of Light Lightness Default state change event */
+typedef struct {
+ uint16_t lightness; /*!< The value of Light Lightness Default state */
+} esp_ble_mesh_state_change_light_lightness_default_set_t;
+
+/** Parameters of Light Lightness Range state change event */
+typedef struct {
+ uint16_t range_min; /*!< The minimum value of Light Lightness Range state */
+ uint16_t range_max; /*!< The maximum value of Light Lightness Range state */
+} esp_ble_mesh_state_change_light_lightness_range_set_t;
+
+/** Parameters of Light CTL state change event */
+typedef struct {
+ uint16_t lightness; /*!< The value of Light CTL Lightness state */
+ uint16_t temperature; /*!< The value of Light CTL Temperature state */
+ int16_t delta_uv; /*!< The value of Light CTL Delta UV state */
+} esp_ble_mesh_state_change_light_ctl_set_t;
+
+/** Parameters of Light CTL Temperature state change event */
+typedef struct {
+ uint16_t temperature; /*!< The value of Light CTL Temperature state */
+ int16_t delta_uv; /*!< The value of Light CTL Delta UV state */
+} esp_ble_mesh_state_change_light_ctl_temperature_set_t;
+
+/** Parameters of Light CTL Temperature Range state change event */
+typedef struct {
+ uint16_t range_min; /*!< The minimum value of Light CTL Temperature Range state */
+ uint16_t range_max; /*!< The maximum value of Light CTL Temperature Range state */
+} esp_ble_mesh_state_change_light_ctl_temperature_range_set_t;
+
+/** Parameters of Light CTL Default state change event */
+typedef struct {
+ uint16_t lightness; /*!< The value of Light Lightness Default state */
+ uint16_t temperature; /*!< The value of Light CTL Temperature Default state */
+ int16_t delta_uv; /*!< The value of Light CTL Delta UV Default state */
+} esp_ble_mesh_state_change_light_ctl_default_set_t;
+
+/** Parameters of Light HSL state change event */
+typedef struct {
+ uint16_t lightness; /*!< The value of Light HSL Lightness state */
+ uint16_t hue; /*!< The value of Light HSL Hue state */
+ uint16_t saturation; /*!< The value of Light HSL Saturation state */
+} esp_ble_mesh_state_change_light_hsl_set_t;
+
+/** Parameter of Light HSL Hue state change event */
+typedef struct {
+ uint16_t hue; /*!< The value of Light HSL Hue state */
+} esp_ble_mesh_state_change_light_hsl_hue_set_t;
+
+/** Parameter of Light HSL Saturation state change event */
+typedef struct {
+ uint16_t saturation; /*!< The value of Light HSL Saturation state */
+} esp_ble_mesh_state_change_light_hsl_saturation_set_t;
+
+/** Parameters of Light HSL Default state change event */
+typedef struct {
+ uint16_t lightness; /*!< The value of Light HSL Lightness Default state */
+ uint16_t hue; /*!< The value of Light HSL Hue Default state */
+ uint16_t saturation; /*!< The value of Light HSL Saturation Default state */
+} esp_ble_mesh_state_change_light_hsl_default_set_t;
+
+/** Parameters of Light HSL Range state change event */
+typedef struct {
+ uint16_t hue_range_min; /*!< The minimum hue value of Light HSL Range state */
+ uint16_t hue_range_max; /*!< The maximum hue value of Light HSL Range state */
+ uint16_t saturation_range_min; /*!< The minimum saturation value of Light HSL Range state */
+ uint16_t saturation_range_max; /*!< The maximum saturation value of Light HSL Range state */
+} esp_ble_mesh_state_change_light_hsl_range_set_t;
+
+/** Parameters of Light xyL state change event */
+typedef struct {
+ uint16_t lightness; /*!< The value of Light xyL Lightness state */
+ uint16_t x; /*!< The value of Light xyL x state */
+ uint16_t y; /*!< The value of Light xyL y state */
+} esp_ble_mesh_state_change_light_xyl_set_t;
+
+/** Parameters of Light xyL Default state change event */
+typedef struct {
+ uint16_t lightness; /*!< The value of Light Lightness Default state */
+ uint16_t x; /*!< The value of Light xyL x Default state */
+ uint16_t y; /*!< The value of Light xyL y Default state */
+} esp_ble_mesh_state_change_light_xyl_default_set_t;
+
+/** Parameters of Light xyL Range state change event */
+typedef struct {
+ uint16_t x_range_min; /*!< The minimum value of Light xyL x Range state */
+ uint16_t x_range_max; /*!< The maximum value of Light xyL x Range state */
+ uint16_t y_range_min; /*!< The minimum value of Light xyL y Range state */
+ uint16_t y_range_max; /*!< The maximum value of Light xyL y Range state */
+} esp_ble_mesh_state_change_light_xyl_range_set_t;
+
+/** Parameter of Light LC Mode state change event */
+typedef struct {
+ uint8_t mode; /*!< The value of Light LC Mode state */
+} esp_ble_mesh_state_change_light_lc_mode_set_t;
+
+/** Parameter of Light LC Occupancy Mode state change event */
+typedef struct {
+ uint8_t mode; /*!< The value of Light LC Occupancy Mode state */
+} esp_ble_mesh_state_change_light_lc_om_set_t;
+
+/** Parameter of Light LC Light OnOff state change event */
+typedef struct {
+ uint8_t onoff; /*!< The value of Light LC Light OnOff state */
+} esp_ble_mesh_state_change_light_lc_light_onoff_set_t;
+
+/** Parameters of Light LC Property state change event */
+typedef struct {
+ uint16_t property_id; /*!< The property id of Light LC Property state */
+ struct net_buf_simple *property_value; /*!< The property value of Light LC Property state */
+} esp_ble_mesh_state_change_light_lc_property_set_t;
+
+/** Parameters of Sensor Status state change event */
+typedef struct {
+ uint16_t property_id; /*!< The value of Sensor Property ID */
+ /** Parameters of Sensor Status related state */
+ union {
+ uint8_t occupancy; /*!< The value of Light LC Occupancy state */
+ uint32_t set_occupancy_to_1_delay; /*!< The value of Light LC Set Occupancy to 1 Delay state */
+ uint32_t ambient_luxlevel; /*!< The value of Light LC Ambient Luxlevel state */
+ } state;
+} esp_ble_mesh_state_change_sensor_status_t;
+
+/**
+ * @brief Lighting Server Model state change value union
+ */
+typedef union {
+ /**
+ * The recv_op in ctx can be used to decide which state is changed.
+ */
+ esp_ble_mesh_state_change_light_lightness_set_t lightness_set; /*!< Light Lightness Set */
+ esp_ble_mesh_state_change_light_lightness_linear_set_t lightness_linear_set; /*!< Light Lightness Linear Set */
+ esp_ble_mesh_state_change_light_lightness_default_set_t lightness_default_set; /*!< Light Lightness Default Set */
+ esp_ble_mesh_state_change_light_lightness_range_set_t lightness_range_set; /*!< Light Lightness Range Set */
+ esp_ble_mesh_state_change_light_ctl_set_t ctl_set; /*!< Light CTL Set */
+ esp_ble_mesh_state_change_light_ctl_temperature_set_t ctl_temp_set; /*!< Light CTL Temperature Set */
+ esp_ble_mesh_state_change_light_ctl_temperature_range_set_t ctl_temp_range_set; /*!< Light CTL Temperature Range Set */
+ esp_ble_mesh_state_change_light_ctl_default_set_t ctl_default_set; /*!< Light CTL Default Set */
+ esp_ble_mesh_state_change_light_hsl_set_t hsl_set; /*!< Light HSL Set */
+ esp_ble_mesh_state_change_light_hsl_hue_set_t hsl_hue_set; /*!< Light HSL Hue Set */
+ esp_ble_mesh_state_change_light_hsl_saturation_set_t hsl_saturation_set; /*!< Light HSL Saturation Set */
+ esp_ble_mesh_state_change_light_hsl_default_set_t hsl_default_set; /*!< Light HSL Default Set */
+ esp_ble_mesh_state_change_light_hsl_range_set_t hsl_range_set; /*!< Light HSL Range Set */
+ esp_ble_mesh_state_change_light_xyl_set_t xyl_set; /*!< Light xyL Set */
+ esp_ble_mesh_state_change_light_xyl_default_set_t xyl_default_set; /*!< Light xyL Default Set */
+ esp_ble_mesh_state_change_light_xyl_range_set_t xyl_range_set; /*!< Light xyL Range Set */
+ esp_ble_mesh_state_change_light_lc_mode_set_t lc_mode_set; /*!< Light LC Mode Set */
+ esp_ble_mesh_state_change_light_lc_om_set_t lc_om_set; /*!< Light LC Occupancy Mode Set */
+ esp_ble_mesh_state_change_light_lc_light_onoff_set_t lc_light_onoff_set; /*!< Light LC Light OnOff Set */
+ esp_ble_mesh_state_change_light_lc_property_set_t lc_property_set; /*!< Light LC Property Set */
+ esp_ble_mesh_state_change_sensor_status_t sensor_status; /*!< Sensor Status */
+} esp_ble_mesh_lighting_server_state_change_t;
+
+/** Context of the received Light LC Property Get message */
+typedef struct {
+ uint16_t property_id; /*!< Property ID identifying a Light LC Property */
+} esp_ble_mesh_server_recv_light_lc_property_get_t;
+
+/**
+ * @brief Lighting Server Model received get message union
+ */
+typedef union {
+ esp_ble_mesh_server_recv_light_lc_property_get_t lc_property; /*!< Light LC Property Get */
+} esp_ble_mesh_lighting_server_recv_get_msg_t;
+
+/** Context of the received Light Lightness Set message */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t lightness; /*!< Target value of light lightness actual state */
+ uint8_t tid; /*!< Transaction ID */
+ uint8_t trans_time; /*!< Time to complete state transition (optional) */
+ uint8_t delay; /*!< Indicate message execution delay (C.1) */
+} esp_ble_mesh_server_recv_light_lightness_set_t;
+
+/** Context of the received Light Lightness Linear Set message */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t lightness; /*!< Target value of light lightness linear state */
+ uint8_t tid; /*!< Transaction ID */
+ uint8_t trans_time; /*!< Time to complete state transition (optional) */
+ uint8_t delay; /*!< Indicate message execution delay (C.1) */
+} esp_ble_mesh_server_recv_light_lightness_linear_set_t;
+
+/** Context of the received Light Lightness Default Set message */
+typedef struct {
+ uint16_t lightness; /*!< The value of the Light Lightness Default state */
+} esp_ble_mesh_server_recv_light_lightness_default_set_t;
+
+/** Context of the received Light Lightness Range Set message */
+typedef struct {
+ uint16_t range_min; /*!< Value of range min field of light lightness range state */
+ uint16_t range_max; /*!< Value of range max field of light lightness range state */
+} esp_ble_mesh_server_recv_light_lightness_range_set_t;
+
+/** Context of the received Light CTL Set message */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t lightness; /*!< Target value of light ctl lightness state */
+ uint16_t temperature; /*!< Target value of light ctl temperature state */
+ int16_t delta_uv; /*!< Target value of light ctl delta UV state */
+ uint8_t tid; /*!< Transaction ID */
+ uint8_t trans_time; /*!< Time to complete state transition (optional) */
+ uint8_t delay; /*!< Indicate message execution delay (C.1) */
+} esp_ble_mesh_server_recv_light_ctl_set_t;
+
+/** Context of the received Light CTL Temperature Set message */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t temperature; /*!< Target value of light ctl temperature state */
+ int16_t delta_uv; /*!< Target value of light ctl delta UV state */
+ uint8_t tid; /*!< Transaction ID */
+ uint8_t trans_time; /*!< Time to complete state transition (optional) */
+ uint8_t delay; /*!< Indicate message execution delay (C.1) */
+} esp_ble_mesh_server_recv_light_ctl_temperature_set_t;
+
+/** Context of the received Light CTL Temperature Range Set message */
+typedef struct {
+ uint16_t range_min; /*!< Value of temperature range min field of light ctl temperature range state */
+ uint16_t range_max; /*!< Value of temperature range max field of light ctl temperature range state */
+} esp_ble_mesh_server_recv_light_ctl_temperature_range_set_t;
+
+/** Context of the received Light CTL Default Set message */
+typedef struct {
+ uint16_t lightness; /*!< Value of light lightness default state */
+ uint16_t temperature; /*!< Value of light temperature default state */
+ int16_t delta_uv; /*!< Value of light delta UV default state */
+} esp_ble_mesh_server_recv_light_ctl_default_set_t;
+
+/** Context of the received Light HSL Set message */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t lightness; /*!< Target value of light hsl lightness state */
+ uint16_t hue; /*!< Target value of light hsl hue state */
+ uint16_t saturation; /*!< Target value of light hsl saturation state */
+ uint8_t tid; /*!< Transaction ID */
+ uint8_t trans_time; /*!< Time to complete state transition (optional) */
+ uint8_t delay; /*!< Indicate message execution delay (C.1) */
+} esp_ble_mesh_server_recv_light_hsl_set_t;
+
+/** Context of the received Light HSL Hue Set message */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t hue; /*!< Target value of light hsl hue state */
+ uint8_t tid; /*!< Transaction ID */
+ uint8_t trans_time; /*!< Time to complete state transition (optional) */
+ uint8_t delay; /*!< Indicate message execution delay (C.1) */
+} esp_ble_mesh_server_recv_light_hsl_hue_set_t;
+
+/** Context of the received Light HSL Saturation Set message */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t saturation; /*!< Target value of light hsl hue state */
+ uint8_t tid; /*!< Transaction ID */
+ uint8_t trans_time; /*!< Time to complete state transition (optional) */
+ uint8_t delay; /*!< Indicate message execution delay (C.1) */
+} esp_ble_mesh_server_recv_light_hsl_saturation_set_t;
+
+/** Context of the received Light HSL Default Set message */
+typedef struct {
+ uint16_t lightness; /*!< Value of light lightness default state */
+ uint16_t hue; /*!< Value of light hue default state */
+ uint16_t saturation; /*!< Value of light saturation default state */
+} esp_ble_mesh_server_recv_light_hsl_default_set_t;
+
+/** Context of the received Light HSL Range Set message */
+typedef struct {
+ uint16_t hue_range_min; /*!< Value of hue range min field of light hsl hue range state */
+ uint16_t hue_range_max; /*!< Value of hue range max field of light hsl hue range state */
+ uint16_t saturation_range_min; /*!< Value of saturation range min field of light hsl saturation range state */
+ uint16_t saturation_range_max; /*!< Value of saturation range max field of light hsl saturation range state */
+} esp_ble_mesh_server_recv_light_hsl_range_set_t;
+
+/** Context of the received Light xyL Set message */
+typedef struct {
+ bool op_en; /*!< Indicate whether optional parameters included */
+ uint16_t lightness; /*!< The target value of the Light xyL Lightness state */
+ uint16_t x; /*!< The target value of the Light xyL x state */
+ uint16_t y; /*!< The target value of the Light xyL y state */
+ uint8_t tid; /*!< Transaction Identifier */
+ uint8_t trans_time; /*!< Time to complete state transition (optional) */
+ uint8_t delay; /*!< Indicate message execution delay (C.1) */
+} esp_ble_mesh_server_recv_light_xyl_set_t;
+
+/** Context of the received Light xyL Default Set message */
+typedef struct {
+ uint16_t lightness; /*!< The value of the Light Lightness Default state */
+ uint16_t x; /*!< The value of the Light xyL x Default state */
+ uint16_t y; /*!< The value of the Light xyL y Default state */
+} esp_ble_mesh_server_recv_light_xyl_default_set_t;
+
+/** Context of the received Light xyl Range Set message */
+typedef struct {
+ uint16_t x_range_min; /*!< The value of the xyL x Range Min field of the Light xyL x Range state */
+ uint16_t x_range_max; /*!< The value of the xyL x Range Max field of the Light xyL x Range state */
+ uint16_t y_range_min; /*!< The value of the xyL y Range Min field of the Light xyL y Range state */
+ uint16_t y_range_max; /*!< The value of the xyL y Range Max field of the Light xyL y Range state */
+} esp_ble_mesh_server_recv_light_xyl_range_set_t;
+
+/** Context of the received Light LC Mode Set message */
+typedef struct {
+ uint8_t mode; /*!< The target value of the Light LC Mode state */
+} esp_ble_mesh_server_recv_light_lc_mode_set_t;
+
+/** Context of the received Light OM Set message */
+typedef struct {
+ uint8_t mode; /*!< The target value of the Light LC Occupancy Mode state */
+} esp_ble_mesh_server_recv_light_lc_om_set_t;
+
+/** Context of the received Light LC Light OnOff Set message */
+typedef struct {
+ bool op_en; /*!< Indicate whether optional parameters included */
+ uint8_t light_onoff; /*!< The target value of the Light LC Light OnOff state */
+ uint8_t tid; /*!< Transaction Identifier */
+ uint8_t trans_time; /*!< Time to complete state transition (optional) */
+ uint8_t delay; /*!< Indicate message execution delay (C.1) */
+} esp_ble_mesh_server_recv_light_lc_light_onoff_set_t;
+
+/** Context of the received Light LC Property Set message */
+typedef struct {
+ uint16_t property_id; /*!< Property ID identifying a Light LC Property */
+ struct net_buf_simple *property_value; /*!< Raw value for the Light LC Property */
+} esp_ble_mesh_server_recv_light_lc_property_set_t;
+
+/**
+ * @brief Lighting Server Model received set message union
+ */
+typedef union {
+ esp_ble_mesh_server_recv_light_lightness_set_t lightness; /*!< Light Lightness Set/Light Lightness Set Unack */
+ esp_ble_mesh_server_recv_light_lightness_linear_set_t lightness_linear; /*!< Light Lightness Linear Set/Light Lightness Linear Set Unack */
+ esp_ble_mesh_server_recv_light_lightness_default_set_t lightness_default; /*!< Light Lightness Default Set/Light Lightness Default Set Unack */
+ esp_ble_mesh_server_recv_light_lightness_range_set_t lightness_range; /*!< Light Lightness Range Set/Light Lightness Range Set Unack */
+ esp_ble_mesh_server_recv_light_ctl_set_t ctl; /*!< Light CTL Set/Light CTL Set Unack */
+ esp_ble_mesh_server_recv_light_ctl_temperature_set_t ctl_temp; /*!< Light CTL Temperature Set/Light CTL Temperature Set Unack */
+ esp_ble_mesh_server_recv_light_ctl_temperature_range_set_t ctl_temp_range; /*!< Light CTL Temperature Range Set/Light CTL Temperature Range Set Unack */
+ esp_ble_mesh_server_recv_light_ctl_default_set_t ctl_default; /*!< Light CTL Default Set/Light CTL Default Set Unack */
+ esp_ble_mesh_server_recv_light_hsl_set_t hsl; /*!< Light HSL Set/Light HSL Set Unack */
+ esp_ble_mesh_server_recv_light_hsl_hue_set_t hsl_hue; /*!< Light HSL Hue Set/Light HSL Hue Set Unack */
+ esp_ble_mesh_server_recv_light_hsl_saturation_set_t hsl_saturation; /*!< Light HSL Saturation Set/Light HSL Saturation Set Unack */
+ esp_ble_mesh_server_recv_light_hsl_default_set_t hsl_default; /*!< Light HSL Default Set/Light HSL Default Set Unack */
+ esp_ble_mesh_server_recv_light_hsl_range_set_t hsl_range; /*!< Light HSL Range Set/Light HSL Range Set Unack */
+ esp_ble_mesh_server_recv_light_xyl_set_t xyl; /*!< Light xyL Set/Light xyL Set Unack */
+ esp_ble_mesh_server_recv_light_xyl_default_set_t xyl_default; /*!< Light xyL Default Set/Light xyL Default Set Unack */
+ esp_ble_mesh_server_recv_light_xyl_range_set_t xyl_range; /*!< Light xyL Range Set/Light xyL Range Set Unack */
+ esp_ble_mesh_server_recv_light_lc_mode_set_t lc_mode; /*!< Light LC Mode Set/Light LC Mode Set Unack */
+ esp_ble_mesh_server_recv_light_lc_om_set_t lc_om; /*!< Light LC OM Set/Light LC OM Set Unack */
+ esp_ble_mesh_server_recv_light_lc_light_onoff_set_t lc_light_onoff; /*!< Light LC Light OnOff Set/Light LC Light OnOff Set Unack */
+ esp_ble_mesh_server_recv_light_lc_property_set_t lc_property; /*!< Light LC Property Set/Light LC Property Set Unack */
+} esp_ble_mesh_lighting_server_recv_set_msg_t;
+
+/** Context of the received Sensor Status message */
+typedef struct {
+ struct net_buf_simple *data; /*!< Value of sensor data state (optional) */
+} esp_ble_mesh_server_recv_sensor_status_t;
+
+/**
+ * @brief Lighting Server Model received status message union
+ */
+typedef union {
+ esp_ble_mesh_server_recv_sensor_status_t sensor_status; /*!< Sensor Status */
+} esp_ble_mesh_lighting_server_recv_status_msg_t;
+
+/**
+ * @brief Lighting Server Model callback value union
+ */
+typedef union {
+ esp_ble_mesh_lighting_server_state_change_t state_change; /*!< ESP_BLE_MESH_LIGHTING_SERVER_STATE_CHANGE_EVT */
+ esp_ble_mesh_lighting_server_recv_get_msg_t get; /*!< ESP_BLE_MESH_LIGHTING_SERVER_RECV_GET_MSG_EVT */
+ esp_ble_mesh_lighting_server_recv_set_msg_t set; /*!< ESP_BLE_MESH_LIGHTING_SERVER_RECV_SET_MSG_EVT */
+ esp_ble_mesh_lighting_server_recv_status_msg_t status; /*!< ESP_BLE_MESH_LIGHTING_SERVER_RECV_STATUS_MSG_EVT */
+} esp_ble_mesh_lighting_server_cb_value_t;
+
+/** Lighting Server Model callback parameters */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to Lighting Server Models */
+ esp_ble_mesh_msg_ctx_t ctx; /*!< Context of the received messages */
+ esp_ble_mesh_lighting_server_cb_value_t value; /*!< Value of the received Lighting Messages */
+} esp_ble_mesh_lighting_server_cb_param_t;
+
+/** This enum value is the event of Lighting Server Model */
+typedef enum {
+ /**
+ * 1. When get_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, no event will be
+ * callback to the application layer when Lighting Get messages are received.
+ * 2. When set_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, this event will
+ * be callback to the application layer when Lighting Set/Set Unack messages
+ * are received.
+ */
+ ESP_BLE_MESH_LIGHTING_SERVER_STATE_CHANGE_EVT,
+ /**
+ * When get_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be
+ * callback to the application layer when Lighting Get messages are received.
+ */
+ ESP_BLE_MESH_LIGHTING_SERVER_RECV_GET_MSG_EVT,
+ /**
+ * When set_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be
+ * callback to the application layer when Lighting Set/Set Unack messages are received.
+ */
+ ESP_BLE_MESH_LIGHTING_SERVER_RECV_SET_MSG_EVT,
+ /**
+ * When status_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will
+ * be callback to the application layer when Sensor Status message is received.
+ */
+ ESP_BLE_MESH_LIGHTING_SERVER_RECV_STATUS_MSG_EVT,
+ ESP_BLE_MESH_LIGHTING_SERVER_EVT_MAX,
+} esp_ble_mesh_lighting_server_cb_event_t;
+
+/**
+ * @brief Bluetooth Mesh Lighting Server Model function.
+ */
+
+/**
+ * @brief Lighting Server Model callback function type
+ * @param event: Event type
+ * @param param: Pointer to callback parameter
+ */
+typedef void (* esp_ble_mesh_lighting_server_cb_t)(esp_ble_mesh_lighting_server_cb_event_t event,
+ esp_ble_mesh_lighting_server_cb_param_t *param);
+
+/**
+ * @brief Register BLE Mesh Lighting Server Model callback.
+ *
+ * @param[in] callback: Pointer to the callback function.
+ *
+ * @return ESP_OK on success or error code otherwise.
+ *
+ */
+esp_err_t esp_ble_mesh_register_lighting_server_callback(esp_ble_mesh_lighting_server_cb_t callback);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ESP_BLE_MESH_LIGHTING_MODEL_API_H_ */
diff --git a/lib/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_sensor_model_api.h b/lib/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_sensor_model_api.h
new file mode 100644
index 00000000..ba72c223
--- /dev/null
+++ b/lib/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_sensor_model_api.h
@@ -0,0 +1,709 @@
+/*
+ * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/** @file
+ * @brief Bluetooth Mesh Sensor Client Model APIs.
+ */
+
+#ifndef _ESP_BLE_MESH_SENSOR_MODEL_API_H_
+#define _ESP_BLE_MESH_SENSOR_MODEL_API_H_
+
+#include "esp_ble_mesh_defs.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @def ESP_BLE_MESH_MODEL_SENSOR_CLI
+ *
+ * @brief Define a new Sensor Client Model.
+ *
+ * @note This API needs to be called for each element on which
+ * the application needs to have a Sensor Client Model.
+ *
+ * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t.
+ *
+ * @return New Sensor Client Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_SENSOR_CLI(cli_pub, cli_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SENSOR_CLI, \
+ NULL, cli_pub, cli_data)
+
+/**
+ * @brief Bluetooth Mesh Sensor Client Model Get and Set parameters structure.
+ */
+
+/** Parameters of Sensor Descriptor Get */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t property_id; /*!< Property ID of a sensor (optional) */
+} esp_ble_mesh_sensor_descriptor_get_t;
+
+/** Parameter of Sensor Cadence Get */
+typedef struct {
+ uint16_t property_id; /*!< Property ID of a sensor */
+} esp_ble_mesh_sensor_cadence_get_t;
+
+/** Parameters of Sensor Cadence Set */
+typedef struct {
+ uint16_t property_id; /*!< Property ID for the sensor */
+ uint8_t fast_cadence_period_divisor : 7, /*!< Divisor for the publish period */
+ status_trigger_type : 1; /*!< The unit and format of the Status Trigger Delta fields */
+ struct net_buf_simple *status_trigger_delta_down; /*!< Delta down value that triggers a status message */
+ struct net_buf_simple *status_trigger_delta_up; /*!< Delta up value that triggers a status message */
+ uint8_t status_min_interval; /*!< Minimum interval between two consecutive Status messages */
+ struct net_buf_simple *fast_cadence_low; /*!< Low value for the fast cadence range */
+ struct net_buf_simple *fast_cadence_high; /*!< Fast value for the fast cadence range */
+} esp_ble_mesh_sensor_cadence_set_t;
+
+/** Parameter of Sensor Settings Get */
+typedef struct {
+ uint16_t sensor_property_id; /*!< Property ID of a sensor */
+} esp_ble_mesh_sensor_settings_get_t;
+
+/** Parameters of Sensor Setting Get */
+typedef struct {
+ uint16_t sensor_property_id; /*!< Property ID of a sensor */
+ uint16_t sensor_setting_property_id; /*!< Setting ID identifying a setting within a sensor */
+} esp_ble_mesh_sensor_setting_get_t;
+
+/** Parameters of Sensor Setting Set */
+typedef struct {
+ uint16_t sensor_property_id; /*!< Property ID identifying a sensor */
+ uint16_t sensor_setting_property_id; /*!< Setting ID identifying a setting within a sensor */
+ struct net_buf_simple *sensor_setting_raw; /*!< Raw value for the setting */
+} esp_ble_mesh_sensor_setting_set_t;
+
+/** Parameters of Sensor Get */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t property_id; /*!< Property ID for the sensor (optional) */
+} esp_ble_mesh_sensor_get_t;
+
+/** Parameters of Sensor Column Get */
+typedef struct {
+ uint16_t property_id; /*!< Property identifying a sensor */
+ struct net_buf_simple *raw_value_x; /*!< Raw value identifying a column */
+} esp_ble_mesh_sensor_column_get_t;
+
+/** Parameters of Sensor Series Get */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t property_id; /*!< Property identifying a sensor */
+ struct net_buf_simple *raw_value_x1; /*!< Raw value identifying a starting column (optional) */
+ struct net_buf_simple *raw_value_x2; /*!< Raw value identifying an ending column (C.1) */
+} esp_ble_mesh_sensor_series_get_t;
+
+/**
+ * @brief Sensor Client Model get message union
+ */
+typedef union {
+ esp_ble_mesh_sensor_descriptor_get_t descriptor_get; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_GET */
+ esp_ble_mesh_sensor_cadence_get_t cadence_get; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_GET */
+ esp_ble_mesh_sensor_settings_get_t settings_get; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_SETTINGS_GET */
+ esp_ble_mesh_sensor_setting_get_t setting_get; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_GET */
+ esp_ble_mesh_sensor_get_t sensor_get; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_GET */
+ esp_ble_mesh_sensor_column_get_t column_get; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET */
+ esp_ble_mesh_sensor_series_get_t series_get; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_SERIES_GET */
+} esp_ble_mesh_sensor_client_get_state_t;
+
+/**
+ * @brief Sensor Client Model set message union
+ */
+typedef union {
+ esp_ble_mesh_sensor_cadence_set_t cadence_set; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET & ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK */
+ esp_ble_mesh_sensor_setting_set_t setting_set; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET & ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK */
+} esp_ble_mesh_sensor_client_set_state_t;
+
+/**
+ * @brief Bluetooth Mesh Sensor Client Model Get and Set callback parameters structure.
+ */
+
+/** Parameter of Sensor Descriptor Status */
+typedef struct {
+ struct net_buf_simple *descriptor; /*!< Sequence of 8-octet sensor descriptors (optional) */
+} esp_ble_mesh_sensor_descriptor_status_cb_t;
+
+/** Parameters of Sensor Cadence Status */
+typedef struct {
+ uint16_t property_id; /*!< Property for the sensor */
+ struct net_buf_simple *sensor_cadence_value; /*!< Value of sensor cadence state */
+} esp_ble_mesh_sensor_cadence_status_cb_t;
+
+/** Parameters of Sensor Settings Status */
+typedef struct {
+ uint16_t sensor_property_id; /*!< Property ID identifying a sensor */
+ struct net_buf_simple *sensor_setting_property_ids; /*!< A sequence of N sensor setting property IDs (optional) */
+} esp_ble_mesh_sensor_settings_status_cb_t;
+
+/** Parameters of Sensor Setting Status */
+typedef struct {
+ bool op_en; /*!< Indicate id optional parameters are included */
+ uint16_t sensor_property_id; /*!< Property ID identifying a sensor */
+ uint16_t sensor_setting_property_id; /*!< Setting ID identifying a setting within a sensor */
+ uint8_t sensor_setting_access; /*!< Read/Write access rights for the setting (optional) */
+ struct net_buf_simple *sensor_setting_raw; /*!< Raw value for the setting */
+} esp_ble_mesh_sensor_setting_status_cb_t;
+
+/** Parameter of Sensor Status */
+typedef struct {
+ struct net_buf_simple *marshalled_sensor_data; /*!< Value of sensor data state (optional) */
+} esp_ble_mesh_sensor_status_cb_t;
+
+/** Parameters of Sensor Column Status */
+typedef struct {
+ uint16_t property_id; /*!< Property identifying a sensor and the Y axis */
+ struct net_buf_simple *sensor_column_value; /*!< Left values of sensor column status */
+} esp_ble_mesh_sensor_column_status_cb_t;
+
+/** Parameters of Sensor Series Status */
+typedef struct {
+ uint16_t property_id; /*!< Property identifying a sensor and the Y axis */
+ struct net_buf_simple *sensor_series_value; /*!< Left values of sensor series status */
+} esp_ble_mesh_sensor_series_status_cb_t;
+
+/**
+ * @brief Sensor Client Model received message union
+ */
+typedef union {
+ esp_ble_mesh_sensor_descriptor_status_cb_t descriptor_status; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_STATUS */
+ esp_ble_mesh_sensor_cadence_status_cb_t cadence_status; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_STATUS */
+ esp_ble_mesh_sensor_settings_status_cb_t settings_status; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_SETTINGS_STATUS */
+ esp_ble_mesh_sensor_setting_status_cb_t setting_status; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_STATUS */
+ esp_ble_mesh_sensor_status_cb_t sensor_status; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_STATUS */
+ esp_ble_mesh_sensor_column_status_cb_t column_status; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_STATUS */
+ esp_ble_mesh_sensor_series_status_cb_t series_status; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_SERIES_STATUS */
+} esp_ble_mesh_sensor_client_status_cb_t;
+
+/** Sensor Client Model callback parameters */
+typedef struct {
+ int error_code; /*!< 0: success,
+ * otherwise failure. For the error code values please refer to errno.h file.
+ * A negative sign is added to the standard error codes in errno.h. */
+ esp_ble_mesh_client_common_param_t *params; /*!< The client common parameters. */
+ esp_ble_mesh_sensor_client_status_cb_t status_cb; /*!< The sensor status message callback values */
+} esp_ble_mesh_sensor_client_cb_param_t;
+
+/** This enum value is the event of Sensor Client Model */
+typedef enum {
+ ESP_BLE_MESH_SENSOR_CLIENT_GET_STATE_EVT,
+ ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT,
+ ESP_BLE_MESH_SENSOR_CLIENT_PUBLISH_EVT,
+ ESP_BLE_MESH_SENSOR_CLIENT_TIMEOUT_EVT,
+ ESP_BLE_MESH_SENSOR_CLIENT_EVT_MAX,
+} esp_ble_mesh_sensor_client_cb_event_t;
+
+/**
+ * @brief Bluetooth Mesh Sensor Client Model function.
+ */
+
+/**
+ * @brief Sensor Client Model callback function type
+ * @param event: Event type
+ * @param param: Pointer to callback parameter
+ */
+typedef void (* esp_ble_mesh_sensor_client_cb_t)(esp_ble_mesh_sensor_client_cb_event_t event,
+ esp_ble_mesh_sensor_client_cb_param_t *param);
+
+/**
+ * @brief Register BLE Mesh Sensor Client Model callback.
+ *
+ * @param[in] callback: Pointer to the callback function.
+ *
+ * @return ESP_OK on success or error code otherwise.
+ *
+ */
+esp_err_t esp_ble_mesh_register_sensor_client_callback(esp_ble_mesh_sensor_client_cb_t callback);
+
+/**
+ * @brief Get the value of Sensor Server Model states using the Sensor Client Model get messages.
+ *
+ * @note If you want to know the opcodes and corresponding meanings accepted by this API,
+ * please refer to esp_ble_mesh_sensor_message_opcode_t in esp_ble_mesh_defs.h
+ *
+ * @param[in] params: Pointer to BLE Mesh common client parameters.
+ * @param[in] get_state: Pointer to sensor get message value.
+ * Shall not be set to NULL.
+ *
+ * @return ESP_OK on success or error code otherwise.
+ *
+ */
+esp_err_t esp_ble_mesh_sensor_client_get_state(esp_ble_mesh_client_common_param_t *params,
+ esp_ble_mesh_sensor_client_get_state_t *get_state);
+
+/**
+ * @brief Set the value of Sensor Server Model states using the Sensor Client Model set messages.
+ *
+ * @note If you want to know the opcodes and corresponding meanings accepted by this API,
+ * please refer to esp_ble_mesh_sensor_message_opcode_t in esp_ble_mesh_defs.h
+ *
+ * @param[in] params: Pointer to BLE Mesh common client parameters.
+ * @param[in] set_state: Pointer to sensor set message value.
+ * Shall not be set to NULL.
+ *
+ * @return ESP_OK on success or error code otherwise.
+ *
+ */
+esp_err_t esp_ble_mesh_sensor_client_set_state(esp_ble_mesh_client_common_param_t *params,
+ esp_ble_mesh_sensor_client_set_state_t *set_state);
+
+/**
+ * @brief Sensor Server Models related context.
+ */
+
+/** @def ESP_BLE_MESH_MODEL_SENSOR_SRV
+ *
+ * @brief Define a new Sensor Server Model.
+ *
+ * @note 1. The Sensor Server model is a root model. When this model is present
+ * on an element, the corresponding Sensor Setup Server model shall
+ * also be present.
+ * 2. This model shall support model publication and model subscription.
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_sensor_srv_t.
+ *
+ * @return New Sensor Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_SENSOR_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SENSOR_SRV, \
+ NULL, srv_pub, srv_data)
+
+/** @def ESP_BLE_MESH_MODEL_SENSOR_SETUP_SRV
+ *
+ * @brief Define a new Sensor Setup Server Model.
+ *
+ * @note 1. The Sensor Setup Server model extends the Sensor Server model.
+ * 2. This model shall support model publication and model subscription.
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_sensor_setup_srv_t.
+ *
+ * @return New Sensor Setup Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_SENSOR_SETUP_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SENSOR_SETUP_SRV, \
+ NULL, srv_pub, srv_data)
+
+#define ESP_BLE_MESH_INVALID_SENSOR_PROPERTY_ID 0x0000 /*!< Invalid Sensor Property ID */
+
+#define ESP_BLE_MESH_SENSOR_PROPERTY_ID_LEN 0x02 /*!< Length of Sensor Property ID */
+
+#define ESP_BLE_MESH_SENSOR_DESCRIPTOR_LEN 0x08 /*!< Length of Sensor Descriptor state */
+
+#define ESP_BLE_MESH_SENSOR_UNSPECIFIED_POS_TOLERANCE 0x000 /*!< Unspecified Sensor Positive Tolerance */
+#define ESP_BLE_MESH_SENSOR_UNSPECIFIED_NEG_TOLERANCE 0x000 /*!< Unspecified Sensor Negative Tolerance */
+
+#define ESP_BLE_MESH_SENSOR_NOT_APPL_MEASURE_PERIOD 0x00 /*!< Not applicable Sensor Measurement Period */
+
+#define ESP_BLE_MESH_SENSOR_NOT_APPL_UPDATE_INTERVAL 0x00 /*!< Not applicable Sensor Update Interval */
+
+#define ESP_BLE_MESH_INVALID_SENSOR_SETTING_PROPERTY_ID 0x0000 /*!< Invalid Sensor Setting Property ID */
+
+#define ESP_BLE_MESH_SENSOR_SETTING_PROPERTY_ID_LEN 0x02 /*!< Length of Sensor Setting Property ID */
+#define ESP_BLE_MESH_SENSOR_SETTING_ACCESS_LEN 0x01 /*!< Length of Sensor Setting Access */
+
+#define ESP_BLE_MESH_SENSOR_SETTING_ACCESS_READ 0x01 /*!< Sensor Setting Access - Read */
+#define ESP_BLE_MESH_SENSOR_SETTING_ACCESS_READ_WRITE 0x03 /*!< Sensor Setting Access - Read & Write */
+
+#define ESP_BLE_MESH_SENSOR_DIVISOR_TRIGGER_TYPE_LEN 0x01 /*!< Length of Sensor Divisor Trigger Type */
+#define ESP_BLE_MESH_SENSOR_STATUS_MIN_INTERVAL_LEN 0x01 /*!< Length of Sensor Status Min Interval */
+
+#define ESP_BLE_MESH_SENSOR_PERIOD_DIVISOR_MAX_VALUE 15 /*!< Maximum value of Sensor Period Divisor */
+
+#define ESP_BLE_MESH_SENSOR_STATUS_MIN_INTERVAL_MAX 26 /*!< Maximum value of Sensor Status Min Interval */
+
+/**
+ * Sensor Status Trigger Type - Format Type of the characteristic
+ * that the Sensor Property ID state references
+ */
+#define ESP_BLE_MESH_SENSOR_STATUS_TRIGGER_TYPE_CHAR 0
+/** Sensor Status Trigger Type - Format Type "uint16" */
+#define ESP_BLE_MESH_SENSOR_STATUS_TRIGGER_TYPE_UINT16 1
+
+#define ESP_BLE_MESH_SENSOR_DATA_FORMAT_A 0x00 /*!< Sensor Data Format A */
+#define ESP_BLE_MESH_SENSOR_DATA_FORMAT_B 0x01 /*!< Sensor Data Format B */
+
+#define ESP_BLE_MESH_SENSOR_DATA_FORMAT_A_MPID_LEN 0x02 /*!< MPID length of Sensor Data Format A */
+#define ESP_BLE_MESH_SENSOR_DATA_FORMAT_B_MPID_LEN 0x03 /*!< MPID length of Sensor Data Format B */
+
+/**
+ * Zero length of Sensor Data.
+ *
+ * Note:
+ * The Length field is a 1-based uint7 value (valid range 0x0–0x7F,
+ * representing range of 1–127). The value 0x7F represents a length
+ * of zero.
+ */
+#define ESP_BLE_MESH_SENSOR_DATA_ZERO_LEN 0x7F
+
+/** @def ESP_BLE_MESH_GET_SENSOR_DATA_FORMAT
+ *
+ * @brief Get format of the sensor data.
+ *
+ * @note Multiple sensor data may be concatenated. Make sure the _data pointer is
+ * updated before getting the format of the corresponding sensor data.
+ *
+ * @param _data Pointer to the start of the sensor data.
+ *
+ * @return Format of the sensor data.
+ */
+#define ESP_BLE_MESH_GET_SENSOR_DATA_FORMAT(_data) (((_data)[0]) & BIT_MASK(1))
+
+/** @def ESP_BLE_MESH_GET_SENSOR_DATA_LENGTH
+ *
+ * @brief Get length of the sensor data.
+ *
+ * @note Multiple sensor data may be concatenated. Make sure the _data pointer is
+ * updated before getting the length of the corresponding sensor data.
+ *
+ * @param _data Pointer to the start of the sensor data.
+ * @param _fmt Format of the sensor data.
+ *
+ * @return Length (zero-based) of the sensor data.
+ */
+#define ESP_BLE_MESH_GET_SENSOR_DATA_LENGTH(_data, _fmt) \
+ (((_fmt) == ESP_BLE_MESH_SENSOR_DATA_FORMAT_A) ? ((((_data)[0]) >> 1) & BIT_MASK(4)) : ((((_data)[0]) >> 1) & BIT_MASK(7)))
+
+/** @def ESP_BLE_MESH_GET_SENSOR_DATA_PROPERTY_ID
+ *
+ * @brief Get Sensor Property ID of the sensor data.
+ *
+ * @note Multiple sensor data may be concatenated. Make sure the _data pointer is
+ * updated before getting Sensor Property ID of the corresponding sensor data.
+ *
+ * @param _data Pointer to the start of the sensor data.
+ * @param _fmt Format of the sensor data.
+ *
+ * @return Sensor Property ID of the sensor data.
+ */
+#define ESP_BLE_MESH_GET_SENSOR_DATA_PROPERTY_ID(_data, _fmt) \
+ (((_fmt) == ESP_BLE_MESH_SENSOR_DATA_FORMAT_A) ? ((((_data)[1]) << 3) | (((_data)[0]) >> 5)) : ((((_data)[2]) << 8) | ((_data)[1])))
+
+/** @def ESP_BLE_MESH_SENSOR_DATA_FORMAT_A_MPID
+ *
+ * @brief Generate a MPID value for sensor data with Format A.
+ *
+ * @note 1. The Format field is 0b0 and indicates that Format A is used.
+ * 2. The Length field is a 1-based uint4 value (valid range 0x0–0xF,
+ * representing range of 1–16).
+ * 3. The Property ID is an 11-bit bit field representing 11 LSb of a Property ID.
+ * 4. This format may be used for Property Values that are not longer than 16
+ * octets and for Property IDs less than 0x0800.
+ *
+ * @param _len Length of Sensor Raw value.
+ * @param _id Sensor Property ID.
+ *
+ * @return 2-octet MPID value for sensor data with Format A.
+ *
+ */
+#define ESP_BLE_MESH_SENSOR_DATA_FORMAT_A_MPID(_len, _id) \
+ ((((_id) & BIT_MASK(11)) << 5) | (((_len) & BIT_MASK(4)) << 1) | ESP_BLE_MESH_SENSOR_DATA_FORMAT_A)
+
+/** @def ESP_BLE_MESH_SENSOR_DATA_FORMAT_B_MPID
+ *
+ * @brief Generate a MPID value for sensor data with Format B.
+ *
+ * @note 1. The Format field is 0b1 and indicates Format B is used.
+ * 2. The Length field is a 1-based uint7 value (valid range 0x0–0x7F, representing
+ * range of 1–127). The value 0x7F represents a length of zero.
+ * 3. The Property ID is a 16-bit bit field representing a Property ID.
+ * 4. This format may be used for Property Values not longer than 128 octets and for
+ * any Property IDs. Property values longer than 128 octets are not supported by
+ * the Sensor Status message.
+ * 5. Exclude the generated 1-octet value, the 2-octet Sensor Property ID
+ *
+ * @param _len Length of Sensor Raw value.
+ * @param _id Sensor Property ID.
+ *
+ * @return 3-octet MPID value for sensor data with Format B.
+ *
+ */
+#define ESP_BLE_MESH_SENSOR_DATA_FORMAT_B_MPID(_len, _id) \
+ (((_id) << 8) | (((_len) & BIT_MASK(7)) << 1) | ESP_BLE_MESH_SENSOR_DATA_FORMAT_B)
+
+/** This enum value is value of Sensor Sampling Function */
+enum esp_ble_mesh_sensor_sample_func {
+ ESP_BLE_MESH_SAMPLE_FUNC_UNSPECIFIED,
+ ESP_BLE_MESH_SAMPLE_FUNC_INSTANTANEOUS,
+ ESP_BLE_MESH_SAMPLE_FUNC_ARITHMETIC_MEAN,
+ ESP_BLE_MESH_SAMPLE_FUNC_RMS,
+ ESP_BLE_MESH_SAMPLE_FUNC_MAXIMUM,
+ ESP_BLE_MESH_SAMPLE_FUNC_MINIMUM,
+ ESP_BLE_MESH_SAMPLE_FUNC_ACCUMULATED,
+ ESP_BLE_MESH_SAMPLE_FUNC_COUNT,
+};
+
+/** Parameters of Sensor Descriptor state */
+typedef struct {
+ uint32_t positive_tolerance : 12, /*!< The value of Sensor Positive Tolerance field */
+ negative_tolerance : 12, /*!< The value of Sensor Negative Tolerance field */
+ sampling_function : 8; /*!< The value of Sensor Sampling Function field */
+ uint8_t measure_period; /*!< The value of Sensor Measurement Period field */
+ uint8_t update_interval; /*!< The value of Sensor Update Interval field */
+} esp_ble_mesh_sensor_descriptor_t;
+
+/** Parameters of Sensor Setting state */
+typedef struct {
+ uint16_t property_id; /*!< The value of Sensor Setting Property ID field */
+ uint8_t access; /*!< The value of Sensor Setting Access field */
+ struct net_buf_simple *raw; /*!< The value of Sensor Setting Raw field */
+} esp_ble_mesh_sensor_setting_t;
+
+/** Parameters of Sensor Cadence state */
+typedef struct {
+ uint8_t period_divisor : 7, /*!< The value of Fast Cadence Period Divisor field */
+ trigger_type : 1; /*!< The value of Status Trigger Type field */
+ /**
+ * Note:
+ * The parameter "size" in trigger_delta_down, trigger_delta_up, fast_cadence_low &
+ * fast_cadence_high indicates the exact length of these four parameters, and they
+ * are associated with the Sensor Property ID. Users need to initialize the "size"
+ * precisely.
+ */
+ struct net_buf_simple *trigger_delta_down; /*!< The value of Status Trigger Delta Down field */
+ struct net_buf_simple *trigger_delta_up; /*!< The value of Status Trigger Delta Up field */
+ uint8_t min_interval; /*!< The value of Status Min Interval field */
+ struct net_buf_simple *fast_cadence_low; /*!< The value of Fast Cadence Low field */
+ struct net_buf_simple *fast_cadence_high; /*!< The value of Fast Cadence High field */
+} esp_ble_mesh_sensor_cadence_t;
+
+/** Parameters of Sensor Data state */
+typedef struct {
+ /**
+ * Format A: The Length field is a 1-based uint4 value (valid range 0x0–0xF,
+ * representing range of 1 – 16).
+ * Format B: The Length field is a 1-based uint7 value (valid range 0x0–0x7F,
+ * representing range of 1 – 127). The value 0x7F represents a
+ * length of zero.
+ */
+ uint8_t format : 1, /*!< The value of the Sensor Data format */
+ length : 7; /*!< The value of the Sensor Data length */
+ struct net_buf_simple *raw_value; /*!< The value of Sensor Data raw value */
+} esp_ble_mesh_sensor_data_t;
+
+/** Parameters of Sensor Series Column state */
+typedef struct {
+ struct net_buf_simple *raw_value_x; /*!< The value of Sensor Raw Value X field */
+ struct net_buf_simple *column_width; /*!< The value of Sensor Column Width field */
+ struct net_buf_simple *raw_value_y; /*!< The value of Sensor Raw Value Y field */
+} esp_ble_mesh_sensor_series_column_t;
+
+/** Parameters of Sensor states */
+typedef struct {
+ uint16_t sensor_property_id; /*!< The value of Sensor Property ID field */
+
+ /* Constant throughout the lifetime of an element */
+ esp_ble_mesh_sensor_descriptor_t descriptor; /*!< Parameters of the Sensor Descriptor state */
+
+ /**
+ * Multiple Sensor Setting states may be present for each sensor.
+ * The Sensor Setting Property ID values shall be unique for each
+ * Sensor Property ID that identifies a sensor within an element.
+ */
+ const uint8_t setting_count; /*!< */
+ esp_ble_mesh_sensor_setting_t *settings; /*!< Parameters of the Sensor Setting state */
+
+ /**
+ * The Sensor Cadence state may be not supported by sensors based
+ * on device properties referencing "non-scalar characteristics"
+ * such as "histograms" or "composite characteristics".
+ */
+ esp_ble_mesh_sensor_cadence_t *cadence; /*!< Parameters of the Sensor Cadence state */
+
+ esp_ble_mesh_sensor_data_t sensor_data; /*!< Parameters of the Sensor Data state */
+
+ esp_ble_mesh_sensor_series_column_t series_column; /*!< Parameters of the Sensor Series Column state */
+} esp_ble_mesh_sensor_state_t;
+
+/** User data of Sensor Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Sensor Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ const uint8_t state_count; /*!< Sensor state count */
+ esp_ble_mesh_sensor_state_t *states; /*!< Parameters of the Sensor states */
+} esp_ble_mesh_sensor_srv_t;
+
+/** User data of Sensor Setup Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Sensor Setup Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ const uint8_t state_count; /*!< Sensor state count */
+ esp_ble_mesh_sensor_state_t *states; /*!< Parameters of the Sensor states */
+} esp_ble_mesh_sensor_setup_srv_t;
+
+/** Parameters of Sensor Cadence Set state change event */
+typedef struct {
+ uint16_t property_id; /*!< The value of Sensor Property ID state */
+ uint8_t period_divisor : 7, /*!< The value of Fast Cadence Period Divisor state */
+ trigger_type : 1; /*!< The value of Status Trigger Type state */
+ struct net_buf_simple *trigger_delta_down; /*!< The value of Status Trigger Delta Down state */
+ struct net_buf_simple *trigger_delta_up; /*!< The value of Status Trigger Delta Up state */
+ uint8_t min_interval; /*!< The value of Status Min Interval state */
+ struct net_buf_simple *fast_cadence_low; /*!< The value of Fast Cadence Low state */
+ struct net_buf_simple *fast_cadence_high; /*!< The value of Fast Cadence High state */
+} esp_ble_mesh_state_change_sensor_cadence_set_t;
+
+/** Parameters of Sensor Setting Set state change event */
+typedef struct {
+ uint16_t property_id; /*!< The value of Sensor Property ID state */
+ uint16_t setting_property_id; /*!< The value of Sensor Setting Property ID state */
+ struct net_buf_simple *setting_value; /*!< The value of Sensor Property Value state */
+} esp_ble_mesh_state_change_sensor_setting_set_t;
+
+/**
+ * @brief Sensor Server Model state change value union
+ */
+typedef union {
+ /**
+ * The recv_op in ctx can be used to decide which state is changed.
+ */
+ esp_ble_mesh_state_change_sensor_cadence_set_t sensor_cadence_set; /*!< Sensor Cadence Set */
+ esp_ble_mesh_state_change_sensor_setting_set_t sensor_setting_set; /*!< Sensor Setting Set */
+} esp_ble_mesh_sensor_server_state_change_t;
+
+/** Context of the received Sensor Descriptor Get message */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t property_id; /*!< Property ID of a sensor (optional) */
+} esp_ble_mesh_server_recv_sensor_descriptor_get_t;
+
+/** Context of the received Sensor Cadence Get message */
+typedef struct {
+ uint16_t property_id; /*!< Property ID of a sensor */
+} esp_ble_mesh_server_recv_sensor_cadence_get_t;
+
+/** Context of the received Sensor Settings Get message */
+typedef struct {
+ uint16_t property_id; /*!< Property ID of a sensor */
+} esp_ble_mesh_server_recv_sensor_settings_get_t;
+
+/** Context of the received Sensor Setting Get message */
+typedef struct {
+ uint16_t property_id; /*!< Property ID of a sensor */
+ uint16_t setting_property_id; /*!< Setting ID identifying a setting within a sensor */
+} esp_ble_mesh_server_recv_sensor_setting_get_t;
+
+/** Context of the received Sensor Get message */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t property_id; /*!< Property ID for the sensor (optional) */
+} esp_ble_mesh_server_recv_sensor_get_t;
+
+/** Context of the received Sensor Column Get message */
+typedef struct {
+ uint16_t property_id; /*!< Property identifying a sensor */
+ struct net_buf_simple *raw_value_x; /*!< Raw value identifying a column */
+} esp_ble_mesh_server_recv_sensor_column_get_t;
+
+/** Context of the received Sensor Series Get message */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t property_id; /*!< Property identifying a sensor */
+ struct net_buf_simple *raw_value; /*!< Raw value containing X1 and X2 (optional) */
+} esp_ble_mesh_server_recv_sensor_series_get_t;
+
+/**
+ * @brief Sensor Server Model received get message union
+ */
+typedef union {
+ esp_ble_mesh_server_recv_sensor_descriptor_get_t sensor_descriptor; /*!< Sensor Descriptor Get */
+ esp_ble_mesh_server_recv_sensor_cadence_get_t sensor_cadence; /*!< Sensor Cadence Get */
+ esp_ble_mesh_server_recv_sensor_settings_get_t sensor_settings; /*!< Sensor Settings Get */
+ esp_ble_mesh_server_recv_sensor_setting_get_t sensor_setting; /*!< Sensor Setting Get */
+ esp_ble_mesh_server_recv_sensor_get_t sensor_data; /*!< Sensor Get */
+ esp_ble_mesh_server_recv_sensor_column_get_t sensor_column; /*!< Sensor Column Get */
+ esp_ble_mesh_server_recv_sensor_series_get_t sensor_series; /*!< Sensor Series Get */
+} esp_ble_mesh_sensor_server_recv_get_msg_t;
+
+/** Context of the received Sensor Cadence Set message */
+typedef struct {
+ uint16_t property_id; /*!< Property ID for the sensor */
+ struct net_buf_simple *cadence; /*!< Value of Sensor Cadence state */
+} esp_ble_mesh_server_recv_sensor_cadence_set_t;
+
+/** Context of the received Sensor Setting Set message */
+typedef struct {
+ uint16_t property_id; /*!< Property ID identifying a sensor */
+ uint16_t setting_property_id; /*!< Setting ID identifying a setting within a sensor */
+ struct net_buf_simple *setting_raw; /*!< Raw value for the setting */
+} esp_ble_mesh_server_recv_sensor_setting_set_t;
+
+/**
+ * @brief Sensor Server Model received set message union
+ */
+typedef union {
+ esp_ble_mesh_server_recv_sensor_cadence_set_t sensor_cadence; /*!< Sensor Cadence Set */
+ esp_ble_mesh_server_recv_sensor_setting_set_t sensor_setting; /*!< Sensor Setting Set */
+} esp_ble_mesh_sensor_server_recv_set_msg_t;
+
+/**
+ * @brief Sensor Server Model callback value union
+ */
+typedef union {
+ esp_ble_mesh_sensor_server_state_change_t state_change; /*!< ESP_BLE_MESH_SENSOR_SERVER_STATE_CHANGE_EVT */
+ esp_ble_mesh_sensor_server_recv_get_msg_t get; /*!< ESP_BLE_MESH_SENSOR_SERVER_RECV_GET_MSG_EVT */
+ esp_ble_mesh_sensor_server_recv_set_msg_t set; /*!< ESP_BLE_MESH_SENSOR_SERVER_RECV_SET_MSG_EVT */
+} esp_ble_mesh_sensor_server_cb_value_t;
+
+/** Sensor Server Model callback parameters */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to Sensor Server Models */
+ esp_ble_mesh_msg_ctx_t ctx; /*!< Context of the received messages */
+ esp_ble_mesh_sensor_server_cb_value_t value; /*!< Value of the received Sensor Messages */
+} esp_ble_mesh_sensor_server_cb_param_t;
+
+/** This enum value is the event of Sensor Server Model */
+typedef enum {
+ /**
+ * 1. When get_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, no event will be
+ * callback to the application layer when Sensor Get messages are received.
+ * 2. When set_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, this event will
+ * be callback to the application layer when Sensor Set/Set Unack messages
+ * are received.
+ */
+ ESP_BLE_MESH_SENSOR_SERVER_STATE_CHANGE_EVT,
+ /**
+ * When get_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be
+ * callback to the application layer when Sensor Get messages are received.
+ */
+ ESP_BLE_MESH_SENSOR_SERVER_RECV_GET_MSG_EVT,
+ /**
+ * When set_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be
+ * callback to the application layer when Sensor Set/Set Unack messages are received.
+ */
+ ESP_BLE_MESH_SENSOR_SERVER_RECV_SET_MSG_EVT,
+ ESP_BLE_MESH_SENSOR_SERVER_EVT_MAX,
+} esp_ble_mesh_sensor_server_cb_event_t;
+
+/**
+ * @brief Bluetooth Mesh Sensor Server Model function.
+ */
+
+/**
+ * @brief Sensor Server Model callback function type
+ * @param event: Event type
+ * @param param: Pointer to callback parameter
+ */
+typedef void (* esp_ble_mesh_sensor_server_cb_t)(esp_ble_mesh_sensor_server_cb_event_t event,
+ esp_ble_mesh_sensor_server_cb_param_t *param);
+
+/**
+ * @brief Register BLE Mesh Sensor Server Model callback.
+ *
+ * @param[in] callback: Pointer to the callback function.
+ *
+ * @return ESP_OK on success or error code otherwise.
+ *
+ */
+esp_err_t esp_ble_mesh_register_sensor_server_callback(esp_ble_mesh_sensor_server_cb_t callback);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ESP_BLE_MESH_SENSOR_MODEL_API_H_ */
diff --git a/lib/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_time_scene_model_api.h b/lib/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_time_scene_model_api.h
new file mode 100644
index 00000000..34700f8b
--- /dev/null
+++ b/lib/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_time_scene_model_api.h
@@ -0,0 +1,911 @@
+/*
+ * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/** @file
+ * @brief Bluetooth Mesh Time and Scene Client Model APIs.
+ */
+
+#ifndef _ESP_BLE_MESH_TIME_SCENE_MODEL_API_H_
+#define _ESP_BLE_MESH_TIME_SCENE_MODEL_API_H_
+
+#include "esp_ble_mesh_defs.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @def ESP_BLE_MESH_MODEL_TIME_CLI
+ *
+ * @brief Define a new Time Client Model.
+ *
+ * @note This API needs to be called for each element on which
+ * the application needs to have a Time Client Model.
+ *
+ * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t.
+ *
+ * @return New Time Client Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_TIME_CLI(cli_pub, cli_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_TIME_CLI, \
+ NULL, cli_pub, cli_data)
+
+/** @def ESP_BLE_MESH_MODEL_SCENE_CLI
+ *
+ * @brief Define a new Scene Client Model.
+ *
+ * @note This API needs to be called for each element on which
+ * the application needs to have a Scene Client Model.
+ *
+ * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t.
+ *
+ * @return New Scene Client Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_SCENE_CLI(cli_pub, cli_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCENE_CLI, \
+ NULL, cli_pub, cli_data)
+
+/** @def ESP_BLE_MESH_MODEL_SCHEDULER_CLI
+ *
+ * @brief Define a new Scheduler Client Model.
+ *
+ * @note This API needs to be called for each element on which
+ * the application needs to have a Scheduler Client Model.
+ *
+ * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t.
+ *
+ * @return New Scheduler Client Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_SCHEDULER_CLI(cli_pub, cli_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCHEDULER_CLI, \
+ NULL, cli_pub, cli_data)
+
+/**
+ * @brief Bluetooth Mesh Time Scene Client Model Get and Set parameters structure.
+ */
+
+/** Parameters of Time Set */
+typedef struct {
+ uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */
+ uint8_t sub_second; /*!< The sub-second time in units of 1/256 second */
+ uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
+ uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
+ uint16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */
+ uint8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */
+} esp_ble_mesh_time_set_t;
+
+/** Parameters of Time Zone Set */
+typedef struct {
+ uint8_t time_zone_offset_new; /*!< Upcoming local time zone offset */
+ uint8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */
+} esp_ble_mesh_time_zone_set_t;
+
+/** Parameters of TAI-UTC Delta Set */
+typedef struct {
+ uint16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */
+ uint16_t padding : 1; /*!< Always 0b0. Other values are Prohibited. */
+ uint8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */
+} esp_ble_mesh_tai_utc_delta_set_t;
+
+/** Parameter of Time Role Set */
+typedef struct {
+ uint8_t time_role; /*!< The Time Role for the element */
+} esp_ble_mesh_time_role_set_t;
+
+/** Parameter of Scene Store */
+typedef struct {
+ uint16_t scene_number; /*!< The number of scenes to be stored */
+} esp_ble_mesh_scene_store_t;
+
+/** Parameters of Scene Recall */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t scene_number; /*!< The number of scenes to be recalled */
+ uint8_t tid; /*!< Transaction ID */
+ uint8_t trans_time; /*!< Time to complete state transition (optional) */
+ uint8_t delay; /*!< Indicate message execution delay (C.1) */
+} esp_ble_mesh_scene_recall_t;
+
+/** Parameter of Scene Delete */
+typedef struct {
+ uint16_t scene_number; /*!< The number of scenes to be deleted */
+} esp_ble_mesh_scene_delete_t;
+
+/** Parameter of Scheduler Action Get */
+typedef struct {
+ uint8_t index; /*!< Index of the Schedule Register entry to get */
+} esp_ble_mesh_scheduler_act_get_t;
+
+/** Parameters of Scheduler Action Set */
+typedef struct {
+ uint64_t index : 4; /*!< Index of the Schedule Register entry to set */
+ uint64_t year : 7; /*!< Scheduled year for the action */
+ uint64_t month : 12; /*!< Scheduled month for the action */
+ uint64_t day : 5; /*!< Scheduled day of the month for the action */
+ uint64_t hour : 5; /*!< Scheduled hour for the action */
+ uint64_t minute : 6; /*!< Scheduled minute for the action */
+ uint64_t second : 6; /*!< Scheduled second for the action */
+ uint64_t day_of_week : 7; /*!< Schedule days of the week for the action */
+ uint64_t action : 4; /*!< Action to be performed at the scheduled time */
+ uint64_t trans_time : 8; /*!< Transition time for this action */
+ uint16_t scene_number; /*!< Transition time for this action */
+} esp_ble_mesh_scheduler_act_set_t;
+
+/**
+ * @brief Time Scene Client Model get message union
+ */
+typedef union {
+ esp_ble_mesh_scheduler_act_get_t scheduler_act_get; /*!< For ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_GET */
+} esp_ble_mesh_time_scene_client_get_state_t;
+
+/**
+ * @brief Time Scene Client Model set message union
+ */
+typedef union {
+ esp_ble_mesh_time_set_t time_set; /*!< For ESP_BLE_MESH_MODEL_OP_TIME_SET */
+ esp_ble_mesh_time_zone_set_t time_zone_set; /*!< For ESP_BLE_MESH_MODEL_OP_TIME_ZONE_SET */
+ esp_ble_mesh_tai_utc_delta_set_t tai_utc_delta_set; /*!< For ESP_BLE_MESH_MODEL_OP_TAI_UTC_DELTA_SET */
+ esp_ble_mesh_time_role_set_t time_role_set; /*!< For ESP_BLE_MESH_MODEL_OP_TIME_ROLE_SET */
+ esp_ble_mesh_scene_store_t scene_store; /*!< For ESP_BLE_MESH_MODEL_OP_SCENE_STORE & ESP_BLE_MESH_MODEL_OP_SCENE_STORE_UNACK */
+ esp_ble_mesh_scene_recall_t scene_recall; /*!< For ESP_BLE_MESH_MODEL_OP_SCENE_RECALL & ESP_BLE_MESH_MODEL_OP_SCENE_RECALL_UNACK */
+ esp_ble_mesh_scene_delete_t scene_delete; /*!< For ESP_BLE_MESH_MODEL_OP_SCENE_DELETE & ESP_BLE_MESH_MODEL_OP_SCENE_DELETE_UNACK */
+ esp_ble_mesh_scheduler_act_set_t scheduler_act_set; /*!< For ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_SET & ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_SET_UNACK */
+} esp_ble_mesh_time_scene_client_set_state_t;
+
+/**
+ * @brief Bluetooth Mesh Time Scene Client Model Get and Set callback parameters structure.
+ */
+
+/** Parameters of Time Status */
+typedef struct {
+ uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */
+ uint8_t sub_second; /*!< The sub-second time in units of 1/256 second */
+ uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
+ uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
+ uint16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */
+ uint8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */
+} esp_ble_mesh_time_status_cb_t;
+
+/** Parameters of Time Zone Status */
+typedef struct {
+ uint8_t time_zone_offset_curr; /*!< Current local time zone offset */
+ uint8_t time_zone_offset_new; /*!< Upcoming local time zone offset */
+ uint8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */
+} esp_ble_mesh_time_zone_status_cb_t;
+
+/** Parameters of TAI-UTC Delta Status */
+typedef struct {
+ uint16_t tai_utc_delta_curr : 15; /*!< Current difference between TAI and UTC in seconds */
+ uint16_t padding_1 : 1; /*!< Always 0b0. Other values are Prohibited. */
+ uint16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */
+ uint16_t padding_2 : 1; /*!< Always 0b0. Other values are Prohibited. */
+ uint8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */
+} esp_ble_mesh_tai_utc_delta_status_cb_t;
+
+/** Parameter of Time Role Status */
+typedef struct {
+ uint8_t time_role; /*!< The Time Role for the element */
+} esp_ble_mesh_time_role_status_cb_t;
+
+/** Parameters of Scene Status */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint8_t status_code; /*!< Status code of the last operation */
+ uint16_t current_scene; /*!< Scene Number of the current scene */
+ uint16_t target_scene; /*!< Scene Number of the target scene (optional) */
+ uint8_t remain_time; /*!< Time to complete state transition (C.1) */
+} esp_ble_mesh_scene_status_cb_t;
+
+/** Parameters of Scene Register Status */
+typedef struct {
+ uint8_t status_code; /*!< Status code for the previous operation */
+ uint16_t current_scene; /*!< Scene Number of the current scene */
+ struct net_buf_simple *scenes; /*!< A list of scenes stored within an element */
+} esp_ble_mesh_scene_register_status_cb_t;
+
+/** Parameter of Scheduler Status */
+typedef struct {
+ uint16_t schedules; /*!< Bit field indicating defined Actions in the Schedule Register */
+} esp_ble_mesh_scheduler_status_cb_t;
+
+/** Parameters of Scheduler Action Status */
+typedef struct {
+ uint64_t index : 4; /*!< Enumerates (selects) a Schedule Register entry */
+ uint64_t year : 7; /*!< Scheduled year for the action */
+ uint64_t month : 12; /*!< Scheduled month for the action */
+ uint64_t day : 5; /*!< Scheduled day of the month for the action */
+ uint64_t hour : 5; /*!< Scheduled hour for the action */
+ uint64_t minute : 6; /*!< Scheduled minute for the action */
+ uint64_t second : 6; /*!< Scheduled second for the action */
+ uint64_t day_of_week : 7; /*!< Schedule days of the week for the action */
+ uint64_t action : 4; /*!< Action to be performed at the scheduled time */
+ uint64_t trans_time : 8; /*!< Transition time for this action */
+ uint16_t scene_number; /*!< Transition time for this action */
+} esp_ble_mesh_scheduler_act_status_cb_t;
+
+/**
+ * @brief Time Scene Client Model received message union
+ */
+typedef union {
+ esp_ble_mesh_time_status_cb_t time_status; /*!< For ESP_BLE_MESH_MODEL_OP_TIME_STATUS */
+ esp_ble_mesh_time_zone_status_cb_t time_zone_status; /*!< For ESP_BLE_MESH_MODEL_OP_TIME_ZONE_STATUS */
+ esp_ble_mesh_tai_utc_delta_status_cb_t tai_utc_delta_status; /*!< For ESP_BLE_MESH_MODEL_OP_TAI_UTC_DELTA_STATUS */
+ esp_ble_mesh_time_role_status_cb_t time_role_status; /*!< For ESP_BLE_MESH_MODEL_OP_TIME_ROLE_STATUS */
+ esp_ble_mesh_scene_status_cb_t scene_status; /*!< For ESP_BLE_MESH_MODEL_OP_SCENE_STATUS */
+ esp_ble_mesh_scene_register_status_cb_t scene_register_status; /*!< For ESP_BLE_MESH_MODEL_OP_SCENE_REGISTER_STATUS */
+ esp_ble_mesh_scheduler_status_cb_t scheduler_status; /*!< For ESP_BLE_MESH_MODEL_OP_SCHEDULER_STATUS */
+ esp_ble_mesh_scheduler_act_status_cb_t scheduler_act_status; /*!< For ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_STATUS */
+} esp_ble_mesh_time_scene_client_status_cb_t;
+
+/** Time Scene Client Model callback parameters */
+typedef struct {
+ int error_code; /*!< Appropriate error code */
+ esp_ble_mesh_client_common_param_t *params; /*!< The client common parameters. */
+ esp_ble_mesh_time_scene_client_status_cb_t status_cb; /*!< The scene status message callback values */
+} esp_ble_mesh_time_scene_client_cb_param_t;
+
+/** This enum value is the event of Time Scene Client Model */
+typedef enum {
+ ESP_BLE_MESH_TIME_SCENE_CLIENT_GET_STATE_EVT,
+ ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT,
+ ESP_BLE_MESH_TIME_SCENE_CLIENT_PUBLISH_EVT,
+ ESP_BLE_MESH_TIME_SCENE_CLIENT_TIMEOUT_EVT,
+ ESP_BLE_MESH_TIME_SCENE_CLIENT_EVT_MAX,
+} esp_ble_mesh_time_scene_client_cb_event_t;
+
+/**
+ * @brief Bluetooth Mesh Time Scene Client Model function.
+ */
+
+/**
+ * @brief Time Scene Client Model callback function type
+ * @param event: Event type
+ * @param param: Pointer to callback parameter
+ */
+typedef void (* esp_ble_mesh_time_scene_client_cb_t)(esp_ble_mesh_time_scene_client_cb_event_t event,
+ esp_ble_mesh_time_scene_client_cb_param_t *param);
+
+/**
+ * @brief Register BLE Mesh Time Scene Client Model callback.
+ *
+ * @param[in] callback: Pointer to the callback function.
+ *
+ * @return ESP_OK on success or error code otherwise.
+ *
+ */
+esp_err_t esp_ble_mesh_register_time_scene_client_callback(esp_ble_mesh_time_scene_client_cb_t callback);
+
+/**
+ * @brief Get the value of Time Scene Server Model states using the Time Scene Client Model get messages.
+ *
+ * @note If you want to know the opcodes and corresponding meanings accepted by this API,
+ * please refer to esp_ble_mesh_time_scene_message_opcode_t in esp_ble_mesh_defs.h
+ *
+ * @param[in] params: Pointer to BLE Mesh common client parameters.
+ * @param[in] get_state: Pointer to time scene get message value.
+ * Shall not be set to NULL.
+ *
+ * @return ESP_OK on success or error code otherwise.
+ */
+esp_err_t esp_ble_mesh_time_scene_client_get_state(esp_ble_mesh_client_common_param_t *params,
+ esp_ble_mesh_time_scene_client_get_state_t *get_state);
+
+/**
+ * @brief Set the value of Time Scene Server Model states using the Time Scene Client Model set messages.
+ *
+ * @note If you want to know the opcodes and corresponding meanings accepted by this API,
+ * please refer to esp_ble_mesh_time_scene_message_opcode_t in esp_ble_mesh_defs.h
+ *
+ * @param[in] params: Pointer to BLE Mesh common client parameters.
+ * @param[in] set_state: Pointer to time scene set message value.
+ * Shall not be set to NULL.
+ *
+ * @return ESP_OK on success or error code otherwise.
+ */
+esp_err_t esp_ble_mesh_time_scene_client_set_state(esp_ble_mesh_client_common_param_t *params,
+ esp_ble_mesh_time_scene_client_set_state_t *set_state);
+
+/**
+ * @brief Time Scene Server Models related context.
+ */
+
+/** @def ESP_BLE_MESH_MODEL_TIME_SRV
+ *
+ * @brief Define a new Time Server Model.
+ *
+ * @note 1. The Time Server model is a root model. When this model is present on an
+ * Element, the corresponding Time Setup Server model shall also be present.
+ * 2. This model shall support model publication and model subscription.
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_time_srv_t.
+ *
+ * @return New Time Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_TIME_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_TIME_SRV, \
+ NULL, srv_pub, srv_data)
+
+/** @def ESP_BLE_MESH_MODEL_TIME_SETUP_SRV
+ *
+ * @brief Define a new Time Setup Server Model.
+ *
+ * @note 1. The Time Setup Server model extends the Time Server model. Time is
+ * sensitive information that is propagated across a mesh network.
+ * 2. Only an authorized Time Client should be allowed to change the Time
+ * and Time Role states. A dedicated application key Bluetooth SIG
+ * Proprietary should be used on the Time Setup Server to restrict
+ * access to the server to only authorized Time Clients.
+ * 3. This model does not support subscribing nor publishing.
+ *
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_time_setup_srv_t.
+ *
+ * @return New Time Setup Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_TIME_SETUP_SRV(srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_TIME_SETUP_SRV, \
+ NULL, NULL, srv_data)
+
+/** @def ESP_BLE_MESH_MODEL_SCENE_SRV
+ *
+ * @brief Define a new Scene Server Model.
+ *
+ * @note 1. The Scene Server model is a root model. When this model is present
+ * on an Element, the corresponding Scene Setup Server model shall
+ * also be present.
+ * 2. This model shall support model publication and model subscription.
+ * 3. The model may be present only on the Primary element of a node.
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_scene_srv_t.
+ *
+ * @return New Scene Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_SCENE_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCENE_SRV, \
+ NULL, srv_pub, srv_data)
+
+/** @def ESP_BLE_MESH_MODEL_SCENE_SETUP_SRV
+ *
+ * @brief Define a new Scene Setup Server Model.
+ *
+ * @note 1. The Scene Setup Server model extends the Scene Server model and
+ * the Generic Default Transition Time Server model.
+ * 2. This model shall support model subscription.
+ * 3. The model may be present only on the Primary element of a node.
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_scene_setup_srv_t.
+ *
+ * @return New Scene Setup Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_SCENE_SETUP_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCENE_SETUP_SRV, \
+ NULL, srv_pub, srv_data)
+
+/** @def ESP_BLE_MESH_MODEL_SCHEDULER_SRV
+ *
+ * @brief Define a new Scheduler Server Model.
+ *
+ * @note 1. The Scheduler Server model extends the Scene Server model. When
+ * this model is present on an Element, the corresponding Scheduler
+ * Setup Server model shall also be present.
+ * 2. This model shall support model publication and model subscription.
+ * 3. The model may be present only on the Primary element of a node.
+ * 4. The model requires the Time Server model shall be present on the element.
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_scheduler_srv_t.
+ *
+ * @return New Scheduler Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_SCHEDULER_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCHEDULER_SRV, \
+ NULL, srv_pub, srv_data)
+
+/** @def ESP_BLE_MESH_MODEL_SCHEDULER_SETUP_SRV
+ *
+ * @brief Define a new Scheduler Setup Server Model.
+ *
+ * @note 1. The Scheduler Setup Server model extends the Scheduler Server and
+ * the Scene Setup Server models.
+ * 2. This model shall support model subscription.
+ * 3. The model may be present only on the Primary element of a node.
+ *
+ * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
+ * @param srv_data Pointer to the unique struct esp_ble_mesh_scheduler_setup_srv_t.
+ *
+ * @return New Scheduler Setup Server Model instance.
+ */
+#define ESP_BLE_MESH_MODEL_SCHEDULER_SETUP_SRV(srv_pub, srv_data) \
+ ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCHEDULER_SETUP_SRV, \
+ NULL, srv_pub, srv_data)
+
+#define ESP_BLE_MESH_UNKNOWN_TAI_SECONDS 0x0000000000 /*!< Unknown TAI Seconds */
+#define ESP_BLE_MESH_UNKNOWN_TAI_ZONE_CHANGE 0x0000000000 /*!< Unknown TAI of Zone Change */
+#define ESP_BLE_MESH_UNKNOWN_TAI_DELTA_CHANGE 0x0000000000 /*!< Unknown TAI of Delta Change */
+
+#define ESP_BLE_MESH_TAI_UTC_DELTA_MAX_VALUE 0x7FFF /*!< Maximum TAI-UTC Delta value */
+
+#define ESP_BLE_MESH_TAI_SECONDS_LEN 0x05 /*!< Length of TAI Seconds */
+#define ESP_BLE_MESH_TAI_OF_ZONE_CHANGE_LEN 0x05 /*!< Length of TAI of Zone Change */
+#define ESP_BLE_MESH_TAI_OF_DELTA_CHANGE_LEN 0x05 /*!< Length of TAI of Delta Change */
+
+#define ESP_BLE_MESH_INVALID_SCENE_NUMBER 0x0000 /*!< Invalid Scene Number */
+#define ESP_BLE_MESH_SCENE_NUMBER_LEN 0x02 /*!< Length of the Scene Number */
+
+#define ESP_BLE_MESH_SCHEDULE_YEAR_ANY_YEAR 0x64 /*!< Any year of the Scheduled year */
+
+#define ESP_BLE_MESH_SCHEDULE_DAY_ANY_DAY 0x00 /*!< Any day of the Scheduled day */
+
+#define ESP_BLE_MESH_SCHEDULE_HOUR_ANY_HOUR 0x18 /*!< Any hour of the Scheduled hour */
+#define ESP_BLE_MESH_SCHEDULE_HOUR_ONCE_A_DAY 0x19 /*!< Any hour of the Scheduled Day */
+
+#define ESP_BLE_MESH_SCHEDULE_SEC_ANY_OF_HOUR 0x3C /*!< Any minute of the Scheduled hour */
+#define ESP_BLE_MESH_SCHEDULE_SEC_EVERY_15_MIN 0x3D /*!< Every 15 minutes of the Scheduled hour */
+#define ESP_BLE_MESH_SCHEDULE_SEC_EVERY_20_MIN 0x3E /*!< Every 20 minutes of the Scheduled hour */
+#define ESP_BLE_MESH_SCHEDULE_SEC_ONCE_AN_HOUR 0x3F /*!< Once of the Scheduled hour */
+
+#define ESP_BLE_MESH_SCHEDULE_SEC_ANY_OF_MIN 0x3C /*!< Any second of the Scheduled minute */
+#define ESP_BLE_MESH_SCHEDULE_SEC_EVERY_15_SEC 0x3D /*!< Every 15 seconds of the Scheduled minute */
+#define ESP_BLE_MESH_SCHEDULE_SEC_EVERY_20_SEC 0x3E /*!< Every 20 seconds of the Scheduled minute */
+#define ESP_BLE_MESH_SCHEDULE_SEC_ONCE_AN_MIN 0x3F /*!< Once of the Scheduled minute */
+
+#define ESP_BLE_MESH_SCHEDULE_ACT_TURN_OFF 0x00 /*!< Scheduled Action - Turn Off */
+#define ESP_BLE_MESH_SCHEDULE_ACT_TURN_ON 0x01 /*!< Scheduled Action - Turn On */
+#define ESP_BLE_MESH_SCHEDULE_ACT_SCENE_RECALL 0x02 /*!< Scheduled Action - Scene Recall */
+#define ESP_BLE_MESH_SCHEDULE_ACT_NO_ACTION 0x0F /*!< Scheduled Action - No Action */
+
+#define ESP_BLE_MESH_SCHEDULE_SCENE_NO_SCENE 0x0000 /*!< Scheduled Scene - No Scene */
+
+#define ESP_BLE_MESH_SCHEDULE_ENTRY_MAX_INDEX 0x0F /*!< Maximum number of Scheduled entries */
+
+#define ESP_BLE_MESH_TIME_NONE 0x00 /*!< Time Role - None */
+#define ESP_BLE_MESH_TIME_AUTHORITY 0x01 /*!< Time Role - Mesh Time Authority */
+#define ESP_BLE_MESH_TIME_RELAY 0x02 /*!< Time Role - Mesh Time Relay */
+#define ESP_BLE_MESH_TIME_CLIENT 0x03 /*!< Time Role - Mesh Time Client */
+
+#define ESP_BLE_MESH_SCENE_SUCCESS 0x00 /*!< Scene operation - Success */
+#define ESP_BLE_MESH_SCENE_REG_FULL 0x01 /*!< Scene operation - Scene Register Full */
+#define ESP_BLE_MESH_SCENE_NOT_FOUND 0x02 /*!< Scene operation - Scene Not Found */
+
+/** Parameters of Time state */
+typedef struct {
+ struct {
+ uint8_t tai_seconds[5]; /*!< The value of the TAI Seconds state */
+ uint8_t subsecond; /*!< The value of the Subsecond field */
+ uint8_t uncertainty; /*!< The value of the Uncertainty field */
+ uint8_t time_zone_offset_curr; /*!< The value of the Time Zone Offset Current field */
+ uint8_t time_zone_offset_new; /*!< The value of the Time Zone Offset New state */
+ uint8_t tai_zone_change[5]; /*!< The value of the TAI of Zone Change field */
+ uint16_t time_authority : 1, /*!< The value of the Time Authority bit */
+ tai_utc_delta_curr : 15; /*!< The value of the TAI-UTC Delta Current state */
+ uint16_t tai_utc_delta_new : 15; /*!< The value of the TAI-UTC Delta New state */
+ uint8_t tai_delta_change[5]; /*!< The value of the TAI of Delta Change field */
+ } time; /*!< Parameters of the Time state */
+ uint8_t time_role; /*!< The value of the Time Role state */
+} esp_ble_mesh_time_state_t;
+
+/** User data of Time Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Time Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ esp_ble_mesh_time_state_t *state; /*!< Parameters of the Time state */
+} esp_ble_mesh_time_srv_t;
+
+/** User data of Time Setup Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Time Setup Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ esp_ble_mesh_time_state_t *state; /*!< Parameters of the Time state */
+} esp_ble_mesh_time_setup_srv_t;
+
+/**
+ * 1. Scene Store is an operation of storing values of a present state of an element.
+ * 2. The structure and meaning of the stored state is determined by a model. States
+ * to be stored are specified by each model.
+ * 3. The Scene Store operation shall persistently store all values of all states
+ * marked as Stored with Scene for all models present on all elements of a node.
+ * 4. If a model is extending another model, the extending model shall determine the
+ * Stored with Scene behavior of that model.
+ */
+
+/** Parameters of Scene Register state */
+typedef struct {
+ uint16_t scene_number; /*!< The value of the Scene Number */
+ uint8_t scene_type; /*!< The value of the Scene Type */
+ /**
+ * Scene value may use a union to represent later, the union contains
+ * structures of all the model states which can be stored in a scene.
+ */
+ struct net_buf_simple *scene_value; /*!< The value of the Scene Value */
+} esp_ble_mesh_scene_register_t;
+
+/**
+ * Parameters of Scenes state.
+ *
+ * Scenes serve as memory banks for storage of states (e.g., a power level
+ * or a light level/color). Values of states of an element can be stored
+ * as a scene and can be recalled later from the scene memory.
+ *
+ * A scene is represented by a Scene Number, which is a 16-bit non-zero,
+ * mesh-wide value. (There can be a maximum of 65535 scenes in a mesh
+ * network.) The meaning of a scene, as well as the state storage container
+ * associated with it, are determined by a model.
+ *
+ * The Scenes state change may start numerous parallel model transitions.
+ * In that case, each individual model handles the transition internally.
+ *
+ * The scene transition is defined as a group of individual model transitions
+ * started by a Scene Recall operation. The scene transition is in progress
+ * when at least one transition from the group of individual model transitions
+ * is in progress.
+ */
+typedef struct {
+ const uint16_t scene_count; /*!< The Scenes state's scene count */
+ esp_ble_mesh_scene_register_t *scenes; /*!< Parameters of the Scenes state */
+
+ /**
+ * The Current Scene state is a 16-bit value that contains either the Scene
+ * Number of the currently active scene or a value of 0x0000 when no scene
+ * is active.
+ *
+ * When a Scene Store operation or a Scene Recall operation completes with
+ * success, the Current Scene state value shall be to the Scene Number used
+ * during that operation.
+ *
+ * When the Current Scene Number is deleted from a Scene Register state as a
+ * result of Scene Delete operation, the Current Scene state shall be set to
+ * 0x0000.
+ *
+ * When any of the element's state that is marked as “Stored with Scene” has
+ * changed not as a result of a Scene Recall operation, the value of the
+ * Current Scene state shall be set to 0x0000.
+ *
+ * When a scene transition is in progress, the value of the Current Scene
+ * state shall be set to 0x0000.
+ */
+ uint16_t current_scene; /*!< The value of the Current Scene state */
+
+ /**
+ * The Target Scene state is a 16-bit value that contains the target Scene
+ * Number when a scene transition is in progress.
+ *
+ * When the scene transition is in progress and the target Scene Number is
+ * deleted from a Scene Register state as a result of Scene Delete operation,
+ * the Target Scene state shall be set to 0x0000.
+ *
+ * When the scene transition is in progress and a new Scene Number is stored
+ * in the Scene Register as a result of Scene Store operation, the Target
+ * Scene state shall be set to the new Scene Number.
+ *
+ * When the scene transition is not in progress, the value of the Target Scene
+ * state shall be set to 0x0000.
+ */
+ uint16_t target_scene; /*!< The value of the Target Scene state */
+
+ /* Indicate the status code for the last operation */
+ uint8_t status_code; /*!< The status code of the last scene operation */
+
+ /* Indicate if scene transition is in progress */
+ bool in_progress; /*!< Indicate if the scene transition is in progress */
+} esp_ble_mesh_scenes_state_t;
+
+/** User data of Scene Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Scene Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ esp_ble_mesh_scenes_state_t *state; /*!< Parameters of the Scenes state */
+ esp_ble_mesh_last_msg_info_t last; /*!< Parameters of the last received set message */
+ esp_ble_mesh_state_transition_t transition; /*!< Parameters of state transition */
+} esp_ble_mesh_scene_srv_t;
+
+/** User data of Scene Setup Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Scene Setup Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ esp_ble_mesh_scenes_state_t *state; /*!< Parameters of the Scenes state */
+} esp_ble_mesh_scene_setup_srv_t;
+
+/** Parameters of Scheduler Register state */
+typedef struct {
+ bool in_use; /*!< Indicate if the registered schedule is in use */
+ uint64_t year : 7, /*!< The value of Scheduled year for the action */
+ month : 12, /*!< The value of Scheduled month for the action */
+ day : 5, /*!< The value of Scheduled day of the month for the action */
+ hour : 5, /*!< The value of Scheduled hour for the action */
+ minute : 6, /*!< The value of Scheduled minute for the action */
+ second : 6, /*!< The value of Scheduled second for the action */
+ day_of_week : 7, /*!< The value of Schedule days of the week for the action */
+ action : 4, /*!< The value of Action to be performed at the scheduled time */
+ trans_time : 8; /*!< The value of Transition time for this action */
+ uint16_t scene_number; /*!< The value of Scene Number to be used for some actions */
+} esp_ble_mesh_schedule_register_t;
+
+/** Parameters of Scheduler state */
+typedef struct {
+ const uint8_t schedule_count; /*!< Scheduler count */
+ esp_ble_mesh_schedule_register_t *schedules; /*!< Up to 16 scheduled entries */
+} esp_ble_mesh_scheduler_state_t;
+
+/** User data of Scheduler Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Scheduler Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ esp_ble_mesh_scheduler_state_t *state; /*!< Parameters of the Scheduler state */
+} esp_ble_mesh_scheduler_srv_t;
+
+/** User data of Scheduler Setup Server Model */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to the Scheduler Setup Server Model. Initialized internally. */
+ esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
+ esp_ble_mesh_scheduler_state_t *state; /*!< Parameters of the Scheduler state */
+} esp_ble_mesh_scheduler_setup_srv_t;
+
+/** Parameters of Time Set state change event */
+typedef struct {
+ uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */
+ uint8_t subsecond; /*!< The sub-second time in units of 1/256 second */
+ uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
+ uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
+ uint16_t tai_utc_delta_curr : 15; /*!< Current difference between TAI and UTC in seconds */
+ uint8_t time_zone_offset_curr; /*!< The local time zone offset in 15-minute increments */
+} esp_ble_mesh_state_change_time_set_t;
+
+/** Parameters of Time Status state change event */
+typedef struct {
+ uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */
+ uint8_t subsecond; /*!< The sub-second time in units of 1/256 second */
+ uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
+ uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
+ uint16_t tai_utc_delta_curr : 15; /*!< Current difference between TAI and UTC in seconds */
+ uint8_t time_zone_offset_curr; /*!< The local time zone offset in 15-minute increments */
+} esp_ble_mesh_state_change_time_status_t;
+
+/** Parameters of Time Zone Set state change event */
+typedef struct {
+ uint8_t time_zone_offset_new; /*!< Upcoming local time zone offset */
+ uint8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */
+} esp_ble_mesh_state_change_time_zone_set_t;
+
+/** Parameters of TAI UTC Delta Set state change event */
+typedef struct {
+ uint16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */
+ uint8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */
+} esp_ble_mesh_state_change_tai_utc_delta_set_t;
+
+/** Parameter of Time Role Set state change event */
+typedef struct {
+ uint8_t time_role; /*!< The Time Role for the element */
+} esp_ble_mesh_state_change_time_role_set_t;
+
+/** Parameter of Scene Store state change event */
+typedef struct {
+ uint16_t scene_number; /*!< The number of scenes to be stored */
+} esp_ble_mesh_state_change_scene_store_t;
+
+/** Parameter of Scene Recall state change event */
+typedef struct {
+ uint16_t scene_number; /*!< The number of scenes to be recalled */
+} esp_ble_mesh_state_change_scene_recall_t;
+
+/** Parameter of Scene Delete state change event */
+typedef struct {
+ uint16_t scene_number; /*!< The number of scenes to be deleted */
+} esp_ble_mesh_state_change_scene_delete_t;
+
+/** Parameter of Scheduler Action Set state change event */
+typedef struct {
+ uint64_t index : 4; /*!< Index of the Schedule Register entry to set */
+ uint64_t year : 7; /*!< Scheduled year for the action */
+ uint64_t month : 12; /*!< Scheduled month for the action */
+ uint64_t day : 5; /*!< Scheduled day of the month for the action */
+ uint64_t hour : 5; /*!< Scheduled hour for the action */
+ uint64_t minute : 6; /*!< Scheduled minute for the action */
+ uint64_t second : 6; /*!< Scheduled second for the action */
+ uint64_t day_of_week : 7; /*!< Schedule days of the week for the action */
+ uint64_t action : 4; /*!< Action to be performed at the scheduled time */
+ uint64_t trans_time : 8; /*!< Transition time for this action */
+ uint16_t scene_number; /*!< Scene number to be used for some actions */
+} esp_ble_mesh_state_change_scheduler_act_set_t;
+
+/**
+ * @brief Time Scene Server Model state change value union
+ */
+typedef union {
+ /**
+ * The recv_op in ctx can be used to decide which state is changed.
+ */
+ esp_ble_mesh_state_change_time_set_t time_set; /*!< Time Set */
+ esp_ble_mesh_state_change_time_status_t time_status; /*!< Time Status */
+ esp_ble_mesh_state_change_time_zone_set_t time_zone_set; /*!< Time Zone Set */
+ esp_ble_mesh_state_change_tai_utc_delta_set_t tai_utc_delta_set; /*!< TAI UTC Delta Set */
+ esp_ble_mesh_state_change_time_role_set_t time_role_set; /*!< Time Role Set */
+ esp_ble_mesh_state_change_scene_store_t scene_store; /*!< Scene Store */
+ esp_ble_mesh_state_change_scene_recall_t scene_recall; /*!< Scene Recall */
+ esp_ble_mesh_state_change_scene_delete_t scene_delete; /*!< Scene Delete */
+ esp_ble_mesh_state_change_scheduler_act_set_t scheduler_act_set; /*!< Scheduler Action Set */
+} esp_ble_mesh_time_scene_server_state_change_t;
+
+/** Context of the received Scheduler Action Get message */
+typedef struct {
+ uint8_t index; /*!< Index of the Schedule Register entry to get */
+} esp_ble_mesh_server_recv_scheduler_act_get_t;
+
+/**
+ * @brief Time Scene Server Model received get message union
+ */
+typedef union {
+ esp_ble_mesh_server_recv_scheduler_act_get_t scheduler_act; /*!< Scheduler Action Get */
+} esp_ble_mesh_time_scene_server_recv_get_msg_t;
+
+/** Context of the received Time Set message */
+typedef struct {
+ uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */
+ uint8_t subsecond; /*!< The sub-second time in units of 1/256 second */
+ uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
+ uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
+ uint16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */
+ uint8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */
+} esp_ble_mesh_server_recv_time_set_t;
+
+/** Context of the received Time Zone Set message */
+typedef struct {
+ uint8_t time_zone_offset_new; /*!< Upcoming local time zone offset */
+ uint8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */
+} esp_ble_mesh_server_recv_time_zone_set_t;
+
+/** Context of the received TAI UTC Delta Set message */
+typedef struct {
+ uint16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */
+ uint16_t padding : 1; /*!< Always 0b0. Other values are Prohibited. */
+ uint8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */
+} esp_ble_mesh_server_recv_tai_utc_delta_set_t;
+
+/** Context of the received Time Role Set message */
+typedef struct {
+ uint8_t time_role; /*!< The Time Role for the element */
+} esp_ble_mesh_server_recv_time_role_set_t;
+
+/** Context of the received Scene Store message */
+typedef struct {
+ uint16_t scene_number; /*!< The number of scenes to be stored */
+} esp_ble_mesh_server_recv_scene_store_t;
+
+/** Context of the received Scene Recall message */
+typedef struct {
+ bool op_en; /*!< Indicate if optional parameters are included */
+ uint16_t scene_number; /*!< The number of scenes to be recalled */
+ uint8_t tid; /*!< Transaction ID */
+ uint8_t trans_time; /*!< Time to complete state transition (optional) */
+ uint8_t delay; /*!< Indicate message execution delay (C.1) */
+} esp_ble_mesh_server_recv_scene_recall_t;
+
+/** Context of the received Scene Delete message */
+typedef struct {
+ uint16_t scene_number; /*!< The number of scenes to be deleted */
+} esp_ble_mesh_server_recv_scene_delete_t;
+
+/** Context of the received Scheduler Action Set message */
+typedef struct {
+ uint64_t index : 4; /*!< Index of the Schedule Register entry to set */
+ uint64_t year : 7; /*!< Scheduled year for the action */
+ uint64_t month : 12; /*!< Scheduled month for the action */
+ uint64_t day : 5; /*!< Scheduled day of the month for the action */
+ uint64_t hour : 5; /*!< Scheduled hour for the action */
+ uint64_t minute : 6; /*!< Scheduled minute for the action */
+ uint64_t second : 6; /*!< Scheduled second for the action */
+ uint64_t day_of_week : 7; /*!< Schedule days of the week for the action */
+ uint64_t action : 4; /*!< Action to be performed at the scheduled time */
+ uint64_t trans_time : 8; /*!< Transition time for this action */
+ uint16_t scene_number; /*!< Scene number to be used for some actions */
+} esp_ble_mesh_server_recv_scheduler_act_set_t;
+
+/**
+ * @brief Time Scene Server Model received set message union
+ */
+typedef union {
+ esp_ble_mesh_server_recv_time_set_t time; /*!< Time Set */
+ esp_ble_mesh_server_recv_time_zone_set_t time_zone; /*!< Time Zone Set */
+ esp_ble_mesh_server_recv_tai_utc_delta_set_t tai_utc_delta; /*!< TAI-UTC Delta Set */
+ esp_ble_mesh_server_recv_time_role_set_t time_role; /*!< Time Role Set */
+ esp_ble_mesh_server_recv_scene_store_t scene_store; /*!< Scene Store/Scene Store Unack */
+ esp_ble_mesh_server_recv_scene_recall_t scene_recall; /*!< Scene Recall/Scene Recall Unack */
+ esp_ble_mesh_server_recv_scene_delete_t scene_delete; /*!< Scene Delete/Scene Delete Unack */
+ esp_ble_mesh_server_recv_scheduler_act_set_t scheduler_act; /*!< Scheduler Action Set/Scheduler Action Set Unack */
+} esp_ble_mesh_time_scene_server_recv_set_msg_t;
+
+/** Context of the received Time Status message */
+typedef struct {
+ uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */
+ uint8_t subsecond; /*!< The sub-second time in units of 1/256 second */
+ uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
+ uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
+ uint16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */
+ uint8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */
+} esp_ble_mesh_server_recv_time_status_t;
+
+/**
+ * @brief Time Scene Server Model received status message union
+ */
+typedef union {
+ esp_ble_mesh_server_recv_time_status_t time_status; /*!< Time Status */
+} esp_ble_mesh_time_scene_server_recv_status_msg_t;
+
+/**
+ * @brief Time Scene Server Model callback value union
+ */
+typedef union {
+ esp_ble_mesh_time_scene_server_state_change_t state_change; /*!< ESP_BLE_MESH_TIME_SCENE_SERVER_STATE_CHANGE_EVT */
+ esp_ble_mesh_time_scene_server_recv_get_msg_t get; /*!< ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_GET_MSG_EVT */
+ esp_ble_mesh_time_scene_server_recv_set_msg_t set; /*!< ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_SET_MSG_EVT */
+ esp_ble_mesh_time_scene_server_recv_status_msg_t status; /*!< ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_STATUS_MSG_EVT */
+} esp_ble_mesh_time_scene_server_cb_value_t;
+
+/** Time Scene Server Model callback parameters */
+typedef struct {
+ esp_ble_mesh_model_t *model; /*!< Pointer to Time and Scenes Server Models */
+ esp_ble_mesh_msg_ctx_t ctx; /*!< Context of the received messages */
+ esp_ble_mesh_time_scene_server_cb_value_t value; /*!< Value of the received Time and Scenes Messages */
+} esp_ble_mesh_time_scene_server_cb_param_t;
+
+/** This enum value is the event of Time Scene Server Model */
+typedef enum {
+ /**
+ * 1. When get_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, no event will be
+ * callback to the application layer when Time Scene Get messages are received.
+ * 2. When set_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, this event will
+ * be callback to the application layer when Time Scene Set/Set Unack messages
+ * are received.
+ */
+ ESP_BLE_MESH_TIME_SCENE_SERVER_STATE_CHANGE_EVT,
+ /**
+ * When get_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be
+ * callback to the application layer when Time Scene Get messages are received.
+ */
+ ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_GET_MSG_EVT,
+ /**
+ * When set_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be
+ * callback to the application layer when Time Scene Set/Set Unack messages are received.
+ */
+ ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_SET_MSG_EVT,
+ /**
+ * When status_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will
+ * be callback to the application layer when TIme Status message is received.
+ */
+ ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_STATUS_MSG_EVT,
+ ESP_BLE_MESH_TIME_SCENE_SERVER_EVT_MAX,
+} esp_ble_mesh_time_scene_server_cb_event_t;
+
+/**
+ * @brief Bluetooth Mesh Time and Scenes Server Model function.
+ */
+
+/**
+ * @brief Time Scene Server Model callback function type
+ * @param event: Event type
+ * @param param: Pointer to callback parameter
+ */
+typedef void (* esp_ble_mesh_time_scene_server_cb_t)(esp_ble_mesh_time_scene_server_cb_event_t event,
+ esp_ble_mesh_time_scene_server_cb_param_t *param);
+
+/**
+ * @brief Register BLE Mesh Time and Scenes Server Model callback.
+ *
+ * @param[in] callback: Pointer to the callback function.
+ *
+ * @return ESP_OK on success or error code otherwise.
+ *
+ */
+esp_err_t esp_ble_mesh_register_time_scene_server_callback(esp_ble_mesh_time_scene_server_cb_t callback);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ESP_BLE_MESH_TIME_SCENE_MODEL_API_H_ */