1 /* 2 * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 /** @file 8 * @brief Bluetooth Mesh Time and Scene Client Model APIs. 9 */ 10 11 #ifndef _ESP_BLE_MESH_TIME_SCENE_MODEL_API_H_ 12 #define _ESP_BLE_MESH_TIME_SCENE_MODEL_API_H_ 13 14 #include "esp_ble_mesh_defs.h" 15 16 #ifdef __cplusplus 17 extern "C" { 18 #endif 19 20 /** @def ESP_BLE_MESH_MODEL_TIME_CLI 21 * 22 * @brief Define a new Time Client Model. 23 * 24 * @note This API needs to be called for each element on which 25 * the application needs to have a Time Client Model. 26 * 27 * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. 28 * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. 29 * 30 * @return New Time Client Model instance. 31 */ 32 #define ESP_BLE_MESH_MODEL_TIME_CLI(cli_pub, cli_data) \ 33 ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_TIME_CLI, \ 34 NULL, cli_pub, cli_data) 35 36 /** @def ESP_BLE_MESH_MODEL_SCENE_CLI 37 * 38 * @brief Define a new Scene Client Model. 39 * 40 * @note This API needs to be called for each element on which 41 * the application needs to have a Scene Client Model. 42 * 43 * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. 44 * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. 45 * 46 * @return New Scene Client Model instance. 47 */ 48 #define ESP_BLE_MESH_MODEL_SCENE_CLI(cli_pub, cli_data) \ 49 ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCENE_CLI, \ 50 NULL, cli_pub, cli_data) 51 52 /** @def ESP_BLE_MESH_MODEL_SCHEDULER_CLI 53 * 54 * @brief Define a new Scheduler Client Model. 55 * 56 * @note This API needs to be called for each element on which 57 * the application needs to have a Scheduler Client Model. 58 * 59 * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. 60 * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. 61 * 62 * @return New Scheduler Client Model instance. 63 */ 64 #define ESP_BLE_MESH_MODEL_SCHEDULER_CLI(cli_pub, cli_data) \ 65 ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCHEDULER_CLI, \ 66 NULL, cli_pub, cli_data) 67 68 /** 69 * @brief Bluetooth Mesh Time Scene Client Model Get and Set parameters structure. 70 */ 71 72 /** Parameters of Time Set */ 73 typedef struct { 74 uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */ 75 uint8_t sub_second; /*!< The sub-second time in units of 1/256 second */ 76 uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */ 77 uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */ 78 uint16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */ 79 uint8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */ 80 } esp_ble_mesh_time_set_t; 81 82 /** Parameters of Time Zone Set */ 83 typedef struct { 84 uint8_t time_zone_offset_new; /*!< Upcoming local time zone offset */ 85 uint8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */ 86 } esp_ble_mesh_time_zone_set_t; 87 88 /** Parameters of TAI-UTC Delta Set */ 89 typedef struct { 90 uint16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */ 91 uint16_t padding : 1; /*!< Always 0b0. Other values are Prohibited. */ 92 uint8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */ 93 } esp_ble_mesh_tai_utc_delta_set_t; 94 95 /** Parameter of Time Role Set */ 96 typedef struct { 97 uint8_t time_role; /*!< The Time Role for the element */ 98 } esp_ble_mesh_time_role_set_t; 99 100 /** Parameter of Scene Store */ 101 typedef struct { 102 uint16_t scene_number; /*!< The number of scenes to be stored */ 103 } esp_ble_mesh_scene_store_t; 104 105 /** Parameters of Scene Recall */ 106 typedef struct { 107 bool op_en; /*!< Indicate if optional parameters are included */ 108 uint16_t scene_number; /*!< The number of scenes to be recalled */ 109 uint8_t tid; /*!< Transaction ID */ 110 uint8_t trans_time; /*!< Time to complete state transition (optional) */ 111 uint8_t delay; /*!< Indicate message execution delay (C.1) */ 112 } esp_ble_mesh_scene_recall_t; 113 114 /** Parameter of Scene Delete */ 115 typedef struct { 116 uint16_t scene_number; /*!< The number of scenes to be deleted */ 117 } esp_ble_mesh_scene_delete_t; 118 119 /** Parameter of Scheduler Action Get */ 120 typedef struct { 121 uint8_t index; /*!< Index of the Schedule Register entry to get */ 122 } esp_ble_mesh_scheduler_act_get_t; 123 124 /** Parameters of Scheduler Action Set */ 125 typedef struct { 126 uint64_t index : 4; /*!< Index of the Schedule Register entry to set */ 127 uint64_t year : 7; /*!< Scheduled year for the action */ 128 uint64_t month : 12; /*!< Scheduled month for the action */ 129 uint64_t day : 5; /*!< Scheduled day of the month for the action */ 130 uint64_t hour : 5; /*!< Scheduled hour for the action */ 131 uint64_t minute : 6; /*!< Scheduled minute for the action */ 132 uint64_t second : 6; /*!< Scheduled second for the action */ 133 uint64_t day_of_week : 7; /*!< Schedule days of the week for the action */ 134 uint64_t action : 4; /*!< Action to be performed at the scheduled time */ 135 uint64_t trans_time : 8; /*!< Transition time for this action */ 136 uint16_t scene_number; /*!< Transition time for this action */ 137 } esp_ble_mesh_scheduler_act_set_t; 138 139 /** 140 * @brief Time Scene Client Model get message union 141 */ 142 typedef union { 143 esp_ble_mesh_scheduler_act_get_t scheduler_act_get; /*!< For ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_GET */ 144 } esp_ble_mesh_time_scene_client_get_state_t; 145 146 /** 147 * @brief Time Scene Client Model set message union 148 */ 149 typedef union { 150 esp_ble_mesh_time_set_t time_set; /*!< For ESP_BLE_MESH_MODEL_OP_TIME_SET */ 151 esp_ble_mesh_time_zone_set_t time_zone_set; /*!< For ESP_BLE_MESH_MODEL_OP_TIME_ZONE_SET */ 152 esp_ble_mesh_tai_utc_delta_set_t tai_utc_delta_set; /*!< For ESP_BLE_MESH_MODEL_OP_TAI_UTC_DELTA_SET */ 153 esp_ble_mesh_time_role_set_t time_role_set; /*!< For ESP_BLE_MESH_MODEL_OP_TIME_ROLE_SET */ 154 esp_ble_mesh_scene_store_t scene_store; /*!< For ESP_BLE_MESH_MODEL_OP_SCENE_STORE & ESP_BLE_MESH_MODEL_OP_SCENE_STORE_UNACK */ 155 esp_ble_mesh_scene_recall_t scene_recall; /*!< For ESP_BLE_MESH_MODEL_OP_SCENE_RECALL & ESP_BLE_MESH_MODEL_OP_SCENE_RECALL_UNACK */ 156 esp_ble_mesh_scene_delete_t scene_delete; /*!< For ESP_BLE_MESH_MODEL_OP_SCENE_DELETE & ESP_BLE_MESH_MODEL_OP_SCENE_DELETE_UNACK */ 157 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 */ 158 } esp_ble_mesh_time_scene_client_set_state_t; 159 160 /** 161 * @brief Bluetooth Mesh Time Scene Client Model Get and Set callback parameters structure. 162 */ 163 164 /** Parameters of Time Status */ 165 typedef struct { 166 uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */ 167 uint8_t sub_second; /*!< The sub-second time in units of 1/256 second */ 168 uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */ 169 uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */ 170 uint16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */ 171 uint8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */ 172 } esp_ble_mesh_time_status_cb_t; 173 174 /** Parameters of Time Zone Status */ 175 typedef struct { 176 uint8_t time_zone_offset_curr; /*!< Current local time zone offset */ 177 uint8_t time_zone_offset_new; /*!< Upcoming local time zone offset */ 178 uint8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */ 179 } esp_ble_mesh_time_zone_status_cb_t; 180 181 /** Parameters of TAI-UTC Delta Status */ 182 typedef struct { 183 uint16_t tai_utc_delta_curr : 15; /*!< Current difference between TAI and UTC in seconds */ 184 uint16_t padding_1 : 1; /*!< Always 0b0. Other values are Prohibited. */ 185 uint16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */ 186 uint16_t padding_2 : 1; /*!< Always 0b0. Other values are Prohibited. */ 187 uint8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */ 188 } esp_ble_mesh_tai_utc_delta_status_cb_t; 189 190 /** Parameter of Time Role Status */ 191 typedef struct { 192 uint8_t time_role; /*!< The Time Role for the element */ 193 } esp_ble_mesh_time_role_status_cb_t; 194 195 /** Parameters of Scene Status */ 196 typedef struct { 197 bool op_en; /*!< Indicate if optional parameters are included */ 198 uint8_t status_code; /*!< Status code of the last operation */ 199 uint16_t current_scene; /*!< Scene Number of the current scene */ 200 uint16_t target_scene; /*!< Scene Number of the target scene (optional) */ 201 uint8_t remain_time; /*!< Time to complete state transition (C.1) */ 202 } esp_ble_mesh_scene_status_cb_t; 203 204 /** Parameters of Scene Register Status */ 205 typedef struct { 206 uint8_t status_code; /*!< Status code for the previous operation */ 207 uint16_t current_scene; /*!< Scene Number of the current scene */ 208 struct net_buf_simple *scenes; /*!< A list of scenes stored within an element */ 209 } esp_ble_mesh_scene_register_status_cb_t; 210 211 /** Parameter of Scheduler Status */ 212 typedef struct { 213 uint16_t schedules; /*!< Bit field indicating defined Actions in the Schedule Register */ 214 } esp_ble_mesh_scheduler_status_cb_t; 215 216 /** Parameters of Scheduler Action Status */ 217 typedef struct { 218 uint64_t index : 4; /*!< Enumerates (selects) a Schedule Register entry */ 219 uint64_t year : 7; /*!< Scheduled year for the action */ 220 uint64_t month : 12; /*!< Scheduled month for the action */ 221 uint64_t day : 5; /*!< Scheduled day of the month for the action */ 222 uint64_t hour : 5; /*!< Scheduled hour for the action */ 223 uint64_t minute : 6; /*!< Scheduled minute for the action */ 224 uint64_t second : 6; /*!< Scheduled second for the action */ 225 uint64_t day_of_week : 7; /*!< Schedule days of the week for the action */ 226 uint64_t action : 4; /*!< Action to be performed at the scheduled time */ 227 uint64_t trans_time : 8; /*!< Transition time for this action */ 228 uint16_t scene_number; /*!< Transition time for this action */ 229 } esp_ble_mesh_scheduler_act_status_cb_t; 230 231 /** 232 * @brief Time Scene Client Model received message union 233 */ 234 typedef union { 235 esp_ble_mesh_time_status_cb_t time_status; /*!< For ESP_BLE_MESH_MODEL_OP_TIME_STATUS */ 236 esp_ble_mesh_time_zone_status_cb_t time_zone_status; /*!< For ESP_BLE_MESH_MODEL_OP_TIME_ZONE_STATUS */ 237 esp_ble_mesh_tai_utc_delta_status_cb_t tai_utc_delta_status; /*!< For ESP_BLE_MESH_MODEL_OP_TAI_UTC_DELTA_STATUS */ 238 esp_ble_mesh_time_role_status_cb_t time_role_status; /*!< For ESP_BLE_MESH_MODEL_OP_TIME_ROLE_STATUS */ 239 esp_ble_mesh_scene_status_cb_t scene_status; /*!< For ESP_BLE_MESH_MODEL_OP_SCENE_STATUS */ 240 esp_ble_mesh_scene_register_status_cb_t scene_register_status; /*!< For ESP_BLE_MESH_MODEL_OP_SCENE_REGISTER_STATUS */ 241 esp_ble_mesh_scheduler_status_cb_t scheduler_status; /*!< For ESP_BLE_MESH_MODEL_OP_SCHEDULER_STATUS */ 242 esp_ble_mesh_scheduler_act_status_cb_t scheduler_act_status; /*!< For ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_STATUS */ 243 } esp_ble_mesh_time_scene_client_status_cb_t; 244 245 /** Time Scene Client Model callback parameters */ 246 typedef struct { 247 int error_code; /*!< Appropriate error code */ 248 esp_ble_mesh_client_common_param_t *params; /*!< The client common parameters. */ 249 esp_ble_mesh_time_scene_client_status_cb_t status_cb; /*!< The scene status message callback values */ 250 } esp_ble_mesh_time_scene_client_cb_param_t; 251 252 /** This enum value is the event of Time Scene Client Model */ 253 typedef enum { 254 ESP_BLE_MESH_TIME_SCENE_CLIENT_GET_STATE_EVT, 255 ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT, 256 ESP_BLE_MESH_TIME_SCENE_CLIENT_PUBLISH_EVT, 257 ESP_BLE_MESH_TIME_SCENE_CLIENT_TIMEOUT_EVT, 258 ESP_BLE_MESH_TIME_SCENE_CLIENT_EVT_MAX, 259 } esp_ble_mesh_time_scene_client_cb_event_t; 260 261 /** 262 * @brief Bluetooth Mesh Time Scene Client Model function. 263 */ 264 265 /** 266 * @brief Time Scene Client Model callback function type 267 * @param event: Event type 268 * @param param: Pointer to callback parameter 269 */ 270 typedef void (* esp_ble_mesh_time_scene_client_cb_t)(esp_ble_mesh_time_scene_client_cb_event_t event, 271 esp_ble_mesh_time_scene_client_cb_param_t *param); 272 273 /** 274 * @brief Register BLE Mesh Time Scene Client Model callback. 275 * 276 * @param[in] callback: Pointer to the callback function. 277 * 278 * @return ESP_OK on success or error code otherwise. 279 * 280 */ 281 esp_err_t esp_ble_mesh_register_time_scene_client_callback(esp_ble_mesh_time_scene_client_cb_t callback); 282 283 /** 284 * @brief Get the value of Time Scene Server Model states using the Time Scene Client Model get messages. 285 * 286 * @note If you want to know the opcodes and corresponding meanings accepted by this API, 287 * please refer to esp_ble_mesh_time_scene_message_opcode_t in esp_ble_mesh_defs.h 288 * 289 * @param[in] params: Pointer to BLE Mesh common client parameters. 290 * @param[in] get_state: Pointer to time scene get message value. 291 * Shall not be set to NULL. 292 * 293 * @return ESP_OK on success or error code otherwise. 294 */ 295 esp_err_t esp_ble_mesh_time_scene_client_get_state(esp_ble_mesh_client_common_param_t *params, 296 esp_ble_mesh_time_scene_client_get_state_t *get_state); 297 298 /** 299 * @brief Set the value of Time Scene Server Model states using the Time Scene Client Model set messages. 300 * 301 * @note If you want to know the opcodes and corresponding meanings accepted by this API, 302 * please refer to esp_ble_mesh_time_scene_message_opcode_t in esp_ble_mesh_defs.h 303 * 304 * @param[in] params: Pointer to BLE Mesh common client parameters. 305 * @param[in] set_state: Pointer to time scene set message value. 306 * Shall not be set to NULL. 307 * 308 * @return ESP_OK on success or error code otherwise. 309 */ 310 esp_err_t esp_ble_mesh_time_scene_client_set_state(esp_ble_mesh_client_common_param_t *params, 311 esp_ble_mesh_time_scene_client_set_state_t *set_state); 312 313 /** 314 * @brief Time Scene Server Models related context. 315 */ 316 317 /** @def ESP_BLE_MESH_MODEL_TIME_SRV 318 * 319 * @brief Define a new Time Server Model. 320 * 321 * @note 1. The Time Server model is a root model. When this model is present on an 322 * Element, the corresponding Time Setup Server model shall also be present. 323 * 2. This model shall support model publication and model subscription. 324 * 325 * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. 326 * @param srv_data Pointer to the unique struct esp_ble_mesh_time_srv_t. 327 * 328 * @return New Time Server Model instance. 329 */ 330 #define ESP_BLE_MESH_MODEL_TIME_SRV(srv_pub, srv_data) \ 331 ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_TIME_SRV, \ 332 NULL, srv_pub, srv_data) 333 334 /** @def ESP_BLE_MESH_MODEL_TIME_SETUP_SRV 335 * 336 * @brief Define a new Time Setup Server Model. 337 * 338 * @note 1. The Time Setup Server model extends the Time Server model. Time is 339 * sensitive information that is propagated across a mesh network. 340 * 2. Only an authorized Time Client should be allowed to change the Time 341 * and Time Role states. A dedicated application key Bluetooth SIG 342 * Proprietary should be used on the Time Setup Server to restrict 343 * access to the server to only authorized Time Clients. 344 * 3. This model does not support subscribing nor publishing. 345 * 346 * @param srv_data Pointer to the unique struct esp_ble_mesh_time_setup_srv_t. 347 * 348 * @return New Time Setup Server Model instance. 349 */ 350 #define ESP_BLE_MESH_MODEL_TIME_SETUP_SRV(srv_data) \ 351 ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_TIME_SETUP_SRV, \ 352 NULL, NULL, srv_data) 353 354 /** @def ESP_BLE_MESH_MODEL_SCENE_SRV 355 * 356 * @brief Define a new Scene Server Model. 357 * 358 * @note 1. The Scene Server model is a root model. When this model is present 359 * on an Element, the corresponding Scene Setup Server model shall 360 * also be present. 361 * 2. This model shall support model publication and model subscription. 362 * 3. The model may be present only on the Primary element of a node. 363 * 364 * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. 365 * @param srv_data Pointer to the unique struct esp_ble_mesh_scene_srv_t. 366 * 367 * @return New Scene Server Model instance. 368 */ 369 #define ESP_BLE_MESH_MODEL_SCENE_SRV(srv_pub, srv_data) \ 370 ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCENE_SRV, \ 371 NULL, srv_pub, srv_data) 372 373 /** @def ESP_BLE_MESH_MODEL_SCENE_SETUP_SRV 374 * 375 * @brief Define a new Scene Setup Server Model. 376 * 377 * @note 1. The Scene Setup Server model extends the Scene Server model and 378 * the Generic Default Transition Time Server model. 379 * 2. This model shall support model subscription. 380 * 3. The model may be present only on the Primary element of a node. 381 * 382 * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. 383 * @param srv_data Pointer to the unique struct esp_ble_mesh_scene_setup_srv_t. 384 * 385 * @return New Scene Setup Server Model instance. 386 */ 387 #define ESP_BLE_MESH_MODEL_SCENE_SETUP_SRV(srv_pub, srv_data) \ 388 ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCENE_SETUP_SRV, \ 389 NULL, srv_pub, srv_data) 390 391 /** @def ESP_BLE_MESH_MODEL_SCHEDULER_SRV 392 * 393 * @brief Define a new Scheduler Server Model. 394 * 395 * @note 1. The Scheduler Server model extends the Scene Server model. When 396 * this model is present on an Element, the corresponding Scheduler 397 * Setup Server model shall also be present. 398 * 2. This model shall support model publication and model subscription. 399 * 3. The model may be present only on the Primary element of a node. 400 * 4. The model requires the Time Server model shall be present on the element. 401 * 402 * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. 403 * @param srv_data Pointer to the unique struct esp_ble_mesh_scheduler_srv_t. 404 * 405 * @return New Scheduler Server Model instance. 406 */ 407 #define ESP_BLE_MESH_MODEL_SCHEDULER_SRV(srv_pub, srv_data) \ 408 ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCHEDULER_SRV, \ 409 NULL, srv_pub, srv_data) 410 411 /** @def ESP_BLE_MESH_MODEL_SCHEDULER_SETUP_SRV 412 * 413 * @brief Define a new Scheduler Setup Server Model. 414 * 415 * @note 1. The Scheduler Setup Server model extends the Scheduler Server and 416 * the Scene Setup Server models. 417 * 2. This model shall support model subscription. 418 * 3. The model may be present only on the Primary element of a node. 419 * 420 * @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. 421 * @param srv_data Pointer to the unique struct esp_ble_mesh_scheduler_setup_srv_t. 422 * 423 * @return New Scheduler Setup Server Model instance. 424 */ 425 #define ESP_BLE_MESH_MODEL_SCHEDULER_SETUP_SRV(srv_pub, srv_data) \ 426 ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCHEDULER_SETUP_SRV, \ 427 NULL, srv_pub, srv_data) 428 429 #define ESP_BLE_MESH_UNKNOWN_TAI_SECONDS 0x0000000000 /*!< Unknown TAI Seconds */ 430 #define ESP_BLE_MESH_UNKNOWN_TAI_ZONE_CHANGE 0x0000000000 /*!< Unknown TAI of Zone Change */ 431 #define ESP_BLE_MESH_UNKNOWN_TAI_DELTA_CHANGE 0x0000000000 /*!< Unknown TAI of Delta Change */ 432 433 #define ESP_BLE_MESH_TAI_UTC_DELTA_MAX_VALUE 0x7FFF /*!< Maximum TAI-UTC Delta value */ 434 435 #define ESP_BLE_MESH_TAI_SECONDS_LEN 0x05 /*!< Length of TAI Seconds */ 436 #define ESP_BLE_MESH_TAI_OF_ZONE_CHANGE_LEN 0x05 /*!< Length of TAI of Zone Change */ 437 #define ESP_BLE_MESH_TAI_OF_DELTA_CHANGE_LEN 0x05 /*!< Length of TAI of Delta Change */ 438 439 #define ESP_BLE_MESH_INVALID_SCENE_NUMBER 0x0000 /*!< Invalid Scene Number */ 440 #define ESP_BLE_MESH_SCENE_NUMBER_LEN 0x02 /*!< Length of the Scene Number */ 441 442 #define ESP_BLE_MESH_SCHEDULE_YEAR_ANY_YEAR 0x64 /*!< Any year of the Scheduled year */ 443 444 #define ESP_BLE_MESH_SCHEDULE_DAY_ANY_DAY 0x00 /*!< Any day of the Scheduled day */ 445 446 #define ESP_BLE_MESH_SCHEDULE_HOUR_ANY_HOUR 0x18 /*!< Any hour of the Scheduled hour */ 447 #define ESP_BLE_MESH_SCHEDULE_HOUR_ONCE_A_DAY 0x19 /*!< Any hour of the Scheduled Day */ 448 449 #define ESP_BLE_MESH_SCHEDULE_SEC_ANY_OF_HOUR 0x3C /*!< Any minute of the Scheduled hour */ 450 #define ESP_BLE_MESH_SCHEDULE_SEC_EVERY_15_MIN 0x3D /*!< Every 15 minutes of the Scheduled hour */ 451 #define ESP_BLE_MESH_SCHEDULE_SEC_EVERY_20_MIN 0x3E /*!< Every 20 minutes of the Scheduled hour */ 452 #define ESP_BLE_MESH_SCHEDULE_SEC_ONCE_AN_HOUR 0x3F /*!< Once of the Scheduled hour */ 453 454 #define ESP_BLE_MESH_SCHEDULE_SEC_ANY_OF_MIN 0x3C /*!< Any second of the Scheduled minute */ 455 #define ESP_BLE_MESH_SCHEDULE_SEC_EVERY_15_SEC 0x3D /*!< Every 15 seconds of the Scheduled minute */ 456 #define ESP_BLE_MESH_SCHEDULE_SEC_EVERY_20_SEC 0x3E /*!< Every 20 seconds of the Scheduled minute */ 457 #define ESP_BLE_MESH_SCHEDULE_SEC_ONCE_AN_MIN 0x3F /*!< Once of the Scheduled minute */ 458 459 #define ESP_BLE_MESH_SCHEDULE_ACT_TURN_OFF 0x00 /*!< Scheduled Action - Turn Off */ 460 #define ESP_BLE_MESH_SCHEDULE_ACT_TURN_ON 0x01 /*!< Scheduled Action - Turn On */ 461 #define ESP_BLE_MESH_SCHEDULE_ACT_SCENE_RECALL 0x02 /*!< Scheduled Action - Scene Recall */ 462 #define ESP_BLE_MESH_SCHEDULE_ACT_NO_ACTION 0x0F /*!< Scheduled Action - No Action */ 463 464 #define ESP_BLE_MESH_SCHEDULE_SCENE_NO_SCENE 0x0000 /*!< Scheduled Scene - No Scene */ 465 466 #define ESP_BLE_MESH_SCHEDULE_ENTRY_MAX_INDEX 0x0F /*!< Maximum number of Scheduled entries */ 467 468 #define ESP_BLE_MESH_TIME_NONE 0x00 /*!< Time Role - None */ 469 #define ESP_BLE_MESH_TIME_AUTHORITY 0x01 /*!< Time Role - Mesh Time Authority */ 470 #define ESP_BLE_MESH_TIME_RELAY 0x02 /*!< Time Role - Mesh Time Relay */ 471 #define ESP_BLE_MESH_TIME_CLINET 0x03 /*!< Time Role - Mesh Time Client */ 472 473 #define ESP_BLE_MESH_SCENE_SUCCESS 0x00 /*!< Scene operation - Success */ 474 #define ESP_BLE_MESH_SCENE_REG_FULL 0x01 /*!< Scene operation - Scene Register Full */ 475 #define ESP_BLE_MESH_SCENE_NOT_FOUND 0x02 /*!< Scene operation - Scene Not Found */ 476 477 /** Parameters of Time state */ 478 typedef struct { 479 struct { 480 uint8_t tai_seconds[5]; /*!< The value of the TAI Seconds state */ 481 uint8_t subsecond; /*!< The value of the Subsecond field */ 482 uint8_t uncertainty; /*!< The value of the Uncertainty field */ 483 uint8_t time_zone_offset_curr; /*!< The value of the Time Zone Offset Current field */ 484 uint8_t time_zone_offset_new; /*!< The value of the Time Zone Offset New state */ 485 uint8_t tai_zone_change[5]; /*!< The value of the TAI of Zone Chaneg field */ 486 uint16_t time_authority : 1, /*!< The value of the Time Authority bit */ 487 tai_utc_delta_curr : 15; /*!< The value of the TAI-UTC Delta Current state */ 488 uint16_t tai_utc_delta_new : 15; /*!< The value of the TAI-UTC Delta New state */ 489 uint8_t tai_delta_change[5]; /*!< The value of the TAI of Delta Change field */ 490 } time; /*!< Parameters of the Time state */ 491 uint8_t time_role; /*!< The value of the Time Role state */ 492 } esp_ble_mesh_time_state_t; 493 494 /** User data of Time Server Model */ 495 typedef struct { 496 esp_ble_mesh_model_t *model; /*!< Pointer to the Time Server Model. Initialized internally. */ 497 esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */ 498 esp_ble_mesh_time_state_t *state; /*!< Parameters of the Time state */ 499 } esp_ble_mesh_time_srv_t; 500 501 /** User data of Time Setup Server Model */ 502 typedef struct { 503 esp_ble_mesh_model_t *model; /*!< Pointer to the Time Setup Server Model. Initialized internally. */ 504 esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */ 505 esp_ble_mesh_time_state_t *state; /*!< Parameters of the Time state */ 506 } esp_ble_mesh_time_setup_srv_t; 507 508 /** 509 * 1. Scene Store is an operation of storing values of a present state of an element. 510 * 2. The structure and meaning of the stored state is determined by a model. States 511 * to be stored are specified by each model. 512 * 3. The Scene Store operation shall persistently store all values of all states 513 * marked as Stored with Scene for all models present on all elements of a node. 514 * 4. If a model is extending another model, the extending model shall determine the 515 * Stored with Scene behavior of that model. 516 */ 517 518 /** Parameters of Scene Register state */ 519 typedef struct { 520 uint16_t scene_number; /*!< The value of the Scene Number */ 521 uint8_t scene_type; /*!< The value of the Scene Type */ 522 /** 523 * Scene value may use a union to represent later, the union contains 524 * structures of all the model states which can be stored in a scene. 525 */ 526 struct net_buf_simple *scene_value; /*!< The value of the Scene Value */ 527 } esp_ble_mesh_scene_register_t; 528 529 /** 530 * Parameters of Scenes state. 531 * 532 * Scenes serve as memory banks for storage of states (e.g., a power level 533 * or a light level/color). Values of states of an element can be stored 534 * as a scene and can be recalled later from the scene memory. 535 * 536 * A scene is represented by a Scene Number, which is a 16-bit non-zero, 537 * mesh-wide value. (There can be a maximum of 65535 scenes in a mesh 538 * network.) The meaning of a scene, as well as the state storage container 539 * associated with it, are determined by a model. 540 * 541 * The Scenes state change may start numerous parallel model transitions. 542 * In that case, each individual model handles the transition internally. 543 * 544 * The scene transition is defined as a group of individual model transitions 545 * started by a Scene Recall operation. The scene transition is in progress 546 * when at least one transition from the group of individual model transitions 547 * is in progress. 548 */ 549 typedef struct { 550 const uint16_t scene_count; /*!< The Scenes state's scene count */ 551 esp_ble_mesh_scene_register_t *scenes; /*!< Parameters of the Scenes state */ 552 553 /** 554 * The Current Scene state is a 16-bit value that contains either the Scene 555 * Number of the currently active scene or a value of 0x0000 when no scene 556 * is active. 557 * 558 * When a Scene Store operation or a Scene Recall operation completes with 559 * success, the Current Scene state value shall be to the Scene Number used 560 * during that operation. 561 * 562 * When the Current Scene Number is deleted from a Scene Register state as a 563 * result of Scene Delete operation, the Current Scene state shall be set to 564 * 0x0000. 565 * 566 * When any of the element's state that is marked as “Stored with Scene” has 567 * changed not as a result of a Scene Recall operation, the value of the 568 * Current Scene state shall be set to 0x0000. 569 * 570 * When a scene transition is in progress, the value of the Current Scene 571 * state shall be set to 0x0000. 572 */ 573 uint16_t current_scene; /*!< The value of the Current Scene state */ 574 575 /** 576 * The Target Scene state is a 16-bit value that contains the target Scene 577 * Number when a scene transition is in progress. 578 * 579 * When the scene transition is in progress and the target Scene Number is 580 * deleted from a Scene Register state as a result of Scene Delete operation, 581 * the Target Scene state shall be set to 0x0000. 582 * 583 * When the scene transition is in progress and a new Scene Number is stored 584 * in the Scene Register as a result of Scene Store operation, the Target 585 * Scene state shall be set to the new Scene Number. 586 * 587 * When the scene transition is not in progress, the value of the Target Scene 588 * state shall be set to 0x0000. 589 */ 590 uint16_t target_scene; /*!< The value of the Target Scene state */ 591 592 /* Indicate the status code for the last operation */ 593 uint8_t status_code; /*!< The status code of the last scene operation */ 594 595 /* Indicate if scene transition is in progress */ 596 bool in_progress; /*!< Indicate if the scene transition is in progress */ 597 } esp_ble_mesh_scenes_state_t; 598 599 /** User data of Scene Server Model */ 600 typedef struct { 601 esp_ble_mesh_model_t *model; /*!< Pointer to the Scene Server Model. Initialized internally. */ 602 esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */ 603 esp_ble_mesh_scenes_state_t *state; /*!< Parameters of the Scenes state */ 604 esp_ble_mesh_last_msg_info_t last; /*!< Parameters of the last received set message */ 605 esp_ble_mesh_state_transition_t transition; /*!< Parameters of state transition */ 606 } esp_ble_mesh_scene_srv_t; 607 608 /** User data of Scene Setup Server Model */ 609 typedef struct { 610 esp_ble_mesh_model_t *model; /*!< Pointer to the Scene Setup Server Model. Initialized internally. */ 611 esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */ 612 esp_ble_mesh_scenes_state_t *state; /*!< Parameters of the Scenes state */ 613 } esp_ble_mesh_scene_setup_srv_t; 614 615 /** Parameters of Scheduler Register state */ 616 typedef struct { 617 bool in_use; /*!< Indicate if the registered schedule is in use */ 618 uint64_t year : 7, /*!< The value of Scheduled year for the action */ 619 month : 12, /*!< The value of Scheduled month for the action */ 620 day : 5, /*!< The value of Scheduled day of the month for the action */ 621 hour : 5, /*!< The value of Scheduled hour for the action */ 622 minute : 6, /*!< The value of Scheduled minute for the action */ 623 second : 6, /*!< The value of Scheduled second for the action */ 624 day_of_week : 7, /*!< The value of Schedule days of the week for the action */ 625 action : 4, /*!< The value of Action to be performed at the scheduled time */ 626 trans_time : 8; /*!< The value of Transition time for this action */ 627 uint16_t scene_number; /*!< The value of Scene Number to be used for some actions */ 628 } esp_ble_mesh_schedule_register_t; 629 630 /** Parameters of Scheduler state */ 631 typedef struct { 632 const uint8_t schedule_count; /*!< Scheduler count */ 633 esp_ble_mesh_schedule_register_t *schedules; /*!< Up to 16 scheduled entries */ 634 } esp_ble_mesh_scheduler_state_t; 635 636 /** User data of Scheduler Server Model */ 637 typedef struct { 638 esp_ble_mesh_model_t *model; /*!< Pointer to the Scheduler Server Model. Initialized internally. */ 639 esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */ 640 esp_ble_mesh_scheduler_state_t *state; /*!< Parameters of the Scheduler state */ 641 } esp_ble_mesh_scheduler_srv_t; 642 643 /** User data of Scheduler Setup Server Model */ 644 typedef struct { 645 esp_ble_mesh_model_t *model; /*!< Pointer to the Scheduler Setup Server Model. Initialized internally. */ 646 esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */ 647 esp_ble_mesh_scheduler_state_t *state; /*!< Parameters of the Scheduler state */ 648 } esp_ble_mesh_scheduler_setup_srv_t; 649 650 /** Parameters of Time Set state change event */ 651 typedef struct { 652 uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */ 653 uint8_t subsecond; /*!< The sub-second time in units of 1/256 second */ 654 uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */ 655 uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */ 656 uint16_t tai_utc_delta_curr : 15; /*!< Current difference between TAI and UTC in seconds */ 657 uint8_t time_zone_offset_curr; /*!< The local time zone offset in 15-minute increments */ 658 } esp_ble_mesh_state_change_time_set_t; 659 660 /** Parameters of Time Status state change event */ 661 typedef struct { 662 uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */ 663 uint8_t subsecond; /*!< The sub-second time in units of 1/256 second */ 664 uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */ 665 uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */ 666 uint16_t tai_utc_delta_curr : 15; /*!< Current difference between TAI and UTC in seconds */ 667 uint8_t time_zone_offset_curr; /*!< The local time zone offset in 15-minute increments */ 668 } esp_ble_mesh_state_change_time_status_t; 669 670 /** Parameters of Time Zone Set state change event */ 671 typedef struct { 672 uint8_t time_zone_offset_new; /*!< Upcoming local time zone offset */ 673 uint8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */ 674 } esp_ble_mesh_state_change_time_zone_set_t; 675 676 /** Parameters of TAI UTC Delta Set state change event */ 677 typedef struct { 678 uint16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */ 679 uint8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */ 680 } esp_ble_mesh_state_change_tai_utc_delta_set_t; 681 682 /** Parameter of Time Role Set state change event */ 683 typedef struct { 684 uint8_t time_role; /*!< The Time Role for the element */ 685 } esp_ble_mesh_state_change_time_role_set_t; 686 687 /** Parameter of Scene Store state change event */ 688 typedef struct { 689 uint16_t scene_number; /*!< The number of scenes to be stored */ 690 } esp_ble_mesh_state_change_scene_store_t; 691 692 /** Parameter of Scene Recall state change event */ 693 typedef struct { 694 uint16_t scene_number; /*!< The number of scenes to be recalled */ 695 } esp_ble_mesh_state_change_scene_recall_t; 696 697 /** Parameter of Scene Delete state change event */ 698 typedef struct { 699 uint16_t scene_number; /*!< The number of scenes to be deleted */ 700 } esp_ble_mesh_state_change_scene_delete_t; 701 702 /** Parameter of Scheduler Action Set state change event */ 703 typedef struct { 704 uint64_t index : 4; /*!< Index of the Schedule Register entry to set */ 705 uint64_t year : 7; /*!< Scheduled year for the action */ 706 uint64_t month : 12; /*!< Scheduled month for the action */ 707 uint64_t day : 5; /*!< Scheduled day of the month for the action */ 708 uint64_t hour : 5; /*!< Scheduled hour for the action */ 709 uint64_t minute : 6; /*!< Scheduled minute for the action */ 710 uint64_t second : 6; /*!< Scheduled second for the action */ 711 uint64_t day_of_week : 7; /*!< Schedule days of the week for the action */ 712 uint64_t action : 4; /*!< Action to be performed at the scheduled time */ 713 uint64_t trans_time : 8; /*!< Transition time for this action */ 714 uint16_t scene_number; /*!< Scene number to be used for some actions */ 715 } esp_ble_mesh_state_change_scheduler_act_set_t; 716 717 /** 718 * @brief Time Scene Server Model state change value union 719 */ 720 typedef union { 721 /** 722 * The recv_op in ctx can be used to decide which state is changed. 723 */ 724 esp_ble_mesh_state_change_time_set_t time_set; /*!< Time Set */ 725 esp_ble_mesh_state_change_time_status_t time_status; /*!< Time Status */ 726 esp_ble_mesh_state_change_time_zone_set_t time_zone_set; /*!< Time Zone Set */ 727 esp_ble_mesh_state_change_tai_utc_delta_set_t tai_utc_delta_set; /*!< TAI UTC Delta Set */ 728 esp_ble_mesh_state_change_time_role_set_t time_role_set; /*!< Time Role Set */ 729 esp_ble_mesh_state_change_scene_store_t scene_store; /*!< Scene Store */ 730 esp_ble_mesh_state_change_scene_recall_t scene_recall; /*!< Scene Recall */ 731 esp_ble_mesh_state_change_scene_delete_t scene_delete; /*!< Scene Delete */ 732 esp_ble_mesh_state_change_scheduler_act_set_t scheduler_act_set; /*!< Scheduler Action Set */ 733 } esp_ble_mesh_time_scene_server_state_change_t; 734 735 /** Context of the received Scheduler Action Get message */ 736 typedef struct { 737 uint8_t index; /*!< Index of the Schedule Register entry to get */ 738 } esp_ble_mesh_server_recv_scheduler_act_get_t; 739 740 /** 741 * @brief Time Scene Server Model received get message union 742 */ 743 typedef union { 744 esp_ble_mesh_server_recv_scheduler_act_get_t scheduler_act; /*!< Scheduler Action Get */ 745 } esp_ble_mesh_time_scene_server_recv_get_msg_t; 746 747 /** Context of the received Time Set message */ 748 typedef struct { 749 uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */ 750 uint8_t subsecond; /*!< The sub-second time in units of 1/256 second */ 751 uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */ 752 uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */ 753 uint16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */ 754 uint8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */ 755 } esp_ble_mesh_server_recv_time_set_t; 756 757 /** Context of the received Time Zone Set message */ 758 typedef struct { 759 uint8_t time_zone_offset_new; /*!< Upcoming local time zone offset */ 760 uint8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */ 761 } esp_ble_mesh_server_recv_time_zone_set_t; 762 763 /** Context of the received TAI UTC Delta Set message */ 764 typedef struct { 765 uint16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */ 766 uint16_t padding : 1; /*!< Always 0b0. Other values are Prohibited. */ 767 uint8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */ 768 } esp_ble_mesh_server_recv_tai_utc_delta_set_t; 769 770 /** Context of the received Time Role Set message */ 771 typedef struct { 772 uint8_t time_role; /*!< The Time Role for the element */ 773 } esp_ble_mesh_server_recv_time_role_set_t; 774 775 /** Context of the received Scene Store message */ 776 typedef struct { 777 uint16_t scene_number; /*!< The number of scenes to be stored */ 778 } esp_ble_mesh_server_recv_scene_store_t; 779 780 /** Context of the received Scene Recall message */ 781 typedef struct { 782 bool op_en; /*!< Indicate if optional parameters are included */ 783 uint16_t scene_number; /*!< The number of scenes to be recalled */ 784 uint8_t tid; /*!< Transaction ID */ 785 uint8_t trans_time; /*!< Time to complete state transition (optional) */ 786 uint8_t delay; /*!< Indicate message execution delay (C.1) */ 787 } esp_ble_mesh_server_recv_scene_recall_t; 788 789 /** Context of the received Scene Delete message */ 790 typedef struct { 791 uint16_t scene_number; /*!< The number of scenes to be deleted */ 792 } esp_ble_mesh_server_recv_scene_delete_t; 793 794 /** Context of the received Scheduler Action Set message */ 795 typedef struct { 796 uint64_t index : 4; /*!< Index of the Schedule Register entry to set */ 797 uint64_t year : 7; /*!< Scheduled year for the action */ 798 uint64_t month : 12; /*!< Scheduled month for the action */ 799 uint64_t day : 5; /*!< Scheduled day of the month for the action */ 800 uint64_t hour : 5; /*!< Scheduled hour for the action */ 801 uint64_t minute : 6; /*!< Scheduled minute for the action */ 802 uint64_t second : 6; /*!< Scheduled second for the action */ 803 uint64_t day_of_week : 7; /*!< Schedule days of the week for the action */ 804 uint64_t action : 4; /*!< Action to be performed at the scheduled time */ 805 uint64_t trans_time : 8; /*!< Transition time for this action */ 806 uint16_t scene_number; /*!< Scene number to be used for some actions */ 807 } esp_ble_mesh_server_recv_scheduler_act_set_t; 808 809 /** 810 * @brief Time Scene Server Model received set message union 811 */ 812 typedef union { 813 esp_ble_mesh_server_recv_time_set_t time; /*!< Time Set */ 814 esp_ble_mesh_server_recv_time_zone_set_t time_zone; /*!< Time Zone Set */ 815 esp_ble_mesh_server_recv_tai_utc_delta_set_t tai_utc_delta; /*!< TAI-UTC Delta Set */ 816 esp_ble_mesh_server_recv_time_role_set_t time_role; /*!< Time Role Set */ 817 esp_ble_mesh_server_recv_scene_store_t scene_store; /*!< Scene Store/Scene Store Unack */ 818 esp_ble_mesh_server_recv_scene_recall_t scene_recall; /*!< Scene Recall/Scene Recall Unack */ 819 esp_ble_mesh_server_recv_scene_delete_t scene_delete; /*!< Scene Delete/Scene Delete Unack */ 820 esp_ble_mesh_server_recv_scheduler_act_set_t scheduler_act; /*!< Scheduler Action Set/Scheduler Action Set Unack */ 821 } esp_ble_mesh_time_scene_server_recv_set_msg_t; 822 823 /** Context of the received Time Status message */ 824 typedef struct { 825 uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */ 826 uint8_t subsecond; /*!< The sub-second time in units of 1/256 second */ 827 uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */ 828 uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */ 829 uint16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */ 830 uint8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */ 831 } esp_ble_mesh_server_recv_time_status_t; 832 833 /** 834 * @brief Time Scene Server Model received status message union 835 */ 836 typedef union { 837 esp_ble_mesh_server_recv_time_status_t time_status; /*!< Time Status */ 838 } esp_ble_mesh_time_scene_server_recv_status_msg_t; 839 840 /** 841 * @brief Time Scene Server Model callback value union 842 */ 843 typedef union { 844 esp_ble_mesh_time_scene_server_state_change_t state_change; /*!< ESP_BLE_MESH_TIME_SCENE_SERVER_STATE_CHANGE_EVT */ 845 esp_ble_mesh_time_scene_server_recv_get_msg_t get; /*!< ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_GET_MSG_EVT */ 846 esp_ble_mesh_time_scene_server_recv_set_msg_t set; /*!< ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_SET_MSG_EVT */ 847 esp_ble_mesh_time_scene_server_recv_status_msg_t status; /*!< ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_STATUS_MSG_EVT */ 848 } esp_ble_mesh_time_scene_server_cb_value_t; 849 850 /** Time Scene Server Model callback parameters */ 851 typedef struct { 852 esp_ble_mesh_model_t *model; /*!< Pointer to Time and Scenes Server Models */ 853 esp_ble_mesh_msg_ctx_t ctx; /*!< Context of the received messages */ 854 esp_ble_mesh_time_scene_server_cb_value_t value; /*!< Value of the received Time and Scenes Messages */ 855 } esp_ble_mesh_time_scene_server_cb_param_t; 856 857 /** This enum value is the event of Time Scene Server Model */ 858 typedef enum { 859 /** 860 * 1. When get_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, no event will be 861 * callback to the application layer when Time Scene Get messages are received. 862 * 2. When set_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, this event will 863 * be callback to the application layer when Time Scene Set/Set Unack messages 864 * are received. 865 */ 866 ESP_BLE_MESH_TIME_SCENE_SERVER_STATE_CHANGE_EVT, 867 /** 868 * When get_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be 869 * callback to the application layer when Time Scene Get messages are received. 870 */ 871 ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_GET_MSG_EVT, 872 /** 873 * When set_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be 874 * callback to the application layer when Time Scene Set/Set Unack messages are received. 875 */ 876 ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_SET_MSG_EVT, 877 /** 878 * When status_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will 879 * be callback to the application layer when TIme Status message is received. 880 */ 881 ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_STATUS_MSG_EVT, 882 ESP_BLE_MESH_TIME_SCENE_SERVER_EVT_MAX, 883 } esp_ble_mesh_time_scene_server_cb_event_t; 884 885 /** 886 * @brief Bluetooth Mesh Time and Scenes Server Model function. 887 */ 888 889 /** 890 * @brief Time Scene Server Model callback function type 891 * @param event: Event type 892 * @param param: Pointer to callback parameter 893 */ 894 typedef void (* esp_ble_mesh_time_scene_server_cb_t)(esp_ble_mesh_time_scene_server_cb_event_t event, 895 esp_ble_mesh_time_scene_server_cb_param_t *param); 896 897 /** 898 * @brief Register BLE Mesh Time and Scenes Server Model callback. 899 * 900 * @param[in] callback: Pointer to the callback function. 901 * 902 * @return ESP_OK on success or error code otherwise. 903 * 904 */ 905 esp_err_t esp_ble_mesh_register_time_scene_server_callback(esp_ble_mesh_time_scene_server_cb_t callback); 906 907 #ifdef __cplusplus 908 } 909 #endif 910 911 #endif /* _ESP_BLE_MESH_TIME_SCENE_MODEL_API_H_ */ 912