I am trying to implement a Bluetooth Mesh Time Client Model on a ESP32, tu update the time state of the nodes.
I actually have difficulty sending TIME SET message, i.e. ESP_BLE_MESH_MODEL_OP_TIME_SET (0x5C).
Below is the SendTimeSetMessage function I use to send message.
The message is actually sent, but with an unrecognized value for the field tai_seconds[5].
I wonder how to write this correct input here :
set.time_set.tai_seconds[5].
I read and I have understood that tai_seconds correspond to TAI time in seconds. The input I wanted to use is
738672821 seconds => in hex is 0x2C0740B5.
That is why I prepare an array of these bytes for the field uint8_t tai_seconds[5]. I tried some combinations but not working.
I see so far no example to compare with right syntax.
Thanks a lot for your help once again.
Code: Select all
void SendTimeSetMessage(uint16_t addr)
{
esp_ble_mesh_time_scene_client_set_state_t set = {0};
esp_ble_mesh_client_common_param_t common = {0};
common.opcode = ESP_BLE_MESH_MODEL_OP_TIME_SET;
common.model = time_client.model;
common.ctx.net_idx = 0x0000;
common.ctx.app_idx = 0x0001;
common.ctx.addr = addr;
common.ctx.send_ttl = MSG_SEND_TTL;
common.ctx.send_rel = MSG_SEND_REL;
common.msg_timeout = MSG_TIMEOUT;
common.msg_role = MSG_ROLE;
// uint8_t time_seconds[5] = { 0x00,0x2C,0x07,0x40,0xB5 };
// uint8_t time_seconds[5] = { 0xB5,0x40,0x07,0x2C,0x00 };
// uint8_t time_seconds[5] = { 0x00,0xB5,0x40,0x07,0x2C };
// uint8_t time_seconds[5] = { 0x2C,0x07,0x40,0xB5,0x00 };
uint8_t time_seconds[5] = { 0x01,0x01,0x01,0x01,0x01 };
set.time_set.tai_seconds[5] = time_seconds;
set.time_set.sub_second = 0x00;
set.time_set.uncertainty = 0x0000;
set.time_set.time_authority = 0x0000;
set.time_set.tai_utc_delta = 0x0124;
set.time_set.time_zone_offset = 0x48;
err = esp_ble_mesh_time_scene_client_set_state(&common, &set);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to send time set message 0x%04" PRIx32, ESP_BLE_MESH_MODEL_OP_TIME_SET);
}
}
Code: Select all
/**
* @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;
*****************
union esp_ble_mesh_time_scene_client_set_state_t
Time Scene Client Model set message union.
Public Members
esp_ble_mesh_time_set_t time_set
For ESP_BLE_MESH_MODEL_OP_TIME_SET
****************
struct esp_ble_mesh_time_set_t
Parameters of Time Set
Public Members
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
0 = No Time Authority, 1 = Time Authority
uint16_t tai_utc_delta
Current difference between TAI and UTC in seconds
uint8_t time_zone_offset
The local time zone offset in 15-minute increments