TuyaOS蓝牙mesh获取Unix时间应该怎么获取呢?
【已解决】TuyaOS 蓝牙mesh关于获取Unix时间获取
- joey_nobug
- Posts: 140
Re: 【求组】TuyaOS 蓝牙mesh关于获取Unix时间获取
可参考 VOID_T test_mesh_time_request(VOID_T); 来向 APP 或者网关请求时间,时间回复数据的处理,参考 app_common.c 中 OPERATE_RET app_mesh_data_recv(TAL_MESH_ACCESS_MSG_T *msg_raw, TAL_MESH_NET_PARAM_T *net_param) 函数中的处理:
Code: Select all
if(0x02 == msg_raw->data[0]){
tal_utc_date_t date = {0};
UINT32_T unix_time = 0;
INT16_T time_zone = 0;
if(msg_raw->data[2] & 0x04){
unix_time += (msg_raw->data[3] << 24);
unix_time += (msg_raw->data[4] << 16);
unix_time += (msg_raw->data[5] << 8);
unix_time += msg_raw->data[6] & 0xFF;
}
if(msg_raw->data[2] & 0x02){
time_zone += (msg_raw->data[7] << 8);
time_zone += msg_raw->data[8] & 0xFF;
}
tal_rtc_time_set(unix_time);
tal_utc_timestamp2date(unix_time, &date, false);
tal_utc_set_time_zone(time_zone);
date.year -= 2000;
#if TUYA_SDK_TEST
tal_sdk_test_get_time_rsp(&date);
#endif
}
Talk is cheap, show me the code.