mirror of
https://gitee.com/Vancouver2017/luban-lite-t3e-pro.git
synced 2025-12-16 19:38:56 +00:00
first commit
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include "zigbee.h"
|
||||
#include "zigbee_fun.h"
|
||||
#include "custom.h"
|
||||
#include <sys/time.h>
|
||||
|
||||
// static const char *TAG = "protocol";
|
||||
|
||||
@@ -3365,8 +3366,8 @@ void mcu_write_rtctime(unsigned char time[])
|
||||
time[0]~time[3]:standard time
|
||||
time[4]~time[7]: Local time
|
||||
*/
|
||||
unsigned int standardtime;
|
||||
unsigned int Localtime;
|
||||
long standardtime;
|
||||
long Localtime;
|
||||
standardtime=time[0];
|
||||
standardtime=standardtime<<8;
|
||||
standardtime|=time[1];
|
||||
@@ -3381,18 +3382,34 @@ void mcu_write_rtctime(unsigned char time[])
|
||||
Localtime|=time[6];
|
||||
Localtime=Localtime<<8;
|
||||
Localtime|=time[7];
|
||||
printf("standardtime:%d\r\n",standardtime);
|
||||
printf("Localtime:%d\r\n",Localtime);
|
||||
printf("standardtime:%ld\r\n",standardtime);
|
||||
printf("Localtime:%ld\r\n",Localtime);
|
||||
//确定时区
|
||||
//Localtime-standardtime/3600
|
||||
//=0是utc+0
|
||||
//<0是utc-
|
||||
//>0是utc+
|
||||
char zone=(char)((Localtime-standardtime)/3600);
|
||||
printf("zone:%d\r\n", zone);
|
||||
|
||||
struct timeval tv;
|
||||
//tv.tv_sec=(time_t)Localtime;//用本地时间 时区要设置0 相对0时区的时间
|
||||
|
||||
tz_set(zone);
|
||||
tv.tv_sec=(time_t)standardtime;//utc时间
|
||||
tv.tv_usec=0;
|
||||
// int settimeofday(const struct timeval *tv , const struct timezone *tz);
|
||||
//tz参数为时区 通常将参数tz设置为NULL,表示使用当前系统的时区
|
||||
//输入时间戳,通过settimeofday()函数来设置系统时间,这个函数设置的精度可以精确到微秒
|
||||
// tz_set(0);//本地时间就是相对0时区的时间
|
||||
settimeofday(&tv, NULL);//不用重新设置时区
|
||||
my_memcpy((void *)timestamp,(const char *)time,4); //get timestamp
|
||||
zigbee_timestamp_to_time();
|
||||
|
||||
SET_nvs_Sys_Info_tzzone(zone);
|
||||
nvs_eepom_sysInfo_update();
|
||||
//更新时区信息
|
||||
|
||||
struct timeval tv;
|
||||
tv.tv_sec=(time_t)standardtime;//用本地时间 不用处理时区了
|
||||
tv.tv_usec=0;
|
||||
// int settimeofday(const struct timeval *tv , const struct timezone *tz);
|
||||
//tz参数为时区 通常将参数tz设置为NULL,表示使用当前系统的时区
|
||||
//输入时间戳,通过settimeofday()函数来设置系统时间,这个函数设置的精度可以精确到微秒
|
||||
settimeofday(&tv, NULL);//不用重新设置时区
|
||||
my_memcpy((void *)timestamp,(const char *)time,4); //get timestamp
|
||||
zigbee_timestamp_to_time();
|
||||
/*
|
||||
year = _time.w_year; //year
|
||||
month = _time.w_month; //month
|
||||
@@ -3781,10 +3798,10 @@ void zigbee_net_work_state_event(unsigned char zigbee_work_state)
|
||||
break;
|
||||
|
||||
case ZIGBEE_JOIN_GATEWAY://已入网
|
||||
// if(GET_nvs_Sys_Info_autoupdatetime())//是否自动获取时间
|
||||
// {
|
||||
if(GET_nvs_Sys_Info_autoupdatetime())//是否自动获取时间
|
||||
{
|
||||
mcu_get_system_time();//入网后自动获取时间
|
||||
// }
|
||||
}
|
||||
|
||||
printf("protocol:net_work_state JOIN_GATEWAY\r\n");
|
||||
//ZIGEvent evt;
|
||||
@@ -3833,10 +3850,10 @@ void zigbee_work_state_event(unsigned char zigbee_work_state)
|
||||
break;
|
||||
|
||||
case ZIGBEE_JOIN_GATEWAY://已入网
|
||||
//if(GET_nvs_Sys_Info_autoupdatetime())//是否自动获取玩疯了时间
|
||||
//{
|
||||
if(GET_nvs_Sys_Info_autoupdatetime())//是否自动获取玩疯了时间
|
||||
{
|
||||
mcu_get_system_time();//入网后自动获取时间
|
||||
//}
|
||||
}
|
||||
|
||||
printf("protocol:work_state JOIN_GATEWAY\r\n");
|
||||
//ZIGEvent evt;
|
||||
|
||||
@@ -33,7 +33,7 @@ extern "C"
|
||||
|
||||
|
||||
///< mcu version
|
||||
#define MCU_VER "1.0.1" // MAX 3.3.15 BIT 7~0 XX.XX.XXXX 00~14
|
||||
#define MCU_VER "1.0.5" // MAX 3.3.15 BIT 7~0 XX.XX.XXXX 00~14
|
||||
|
||||
#define ZIGBEE_UART_QUEUE_LMT 768 // using to save data received from uart
|
||||
#define ZIGBEE_UART_RECV_BUF_LMT 256 //
|
||||
|
||||
Reference in New Issue
Block a user