mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-12 13:08:13 +08:00
add:增加user_config版本,不同时初始化user_config
add:定时开关功能(未测试)
This commit is contained in:
@@ -24,8 +24,26 @@ OSStatus user_sntp_get_time( )
|
||||
err = sntp_get_time( &ipp, ¤t_time );
|
||||
if ( err != kNoErr )
|
||||
{
|
||||
os_log("sntp_get_time1 err = %d.retry", err);
|
||||
ipp.s_addr = 0xd248912c;
|
||||
os_log("sntp_get_time1 err = %d.", err);
|
||||
hostent_content = gethostbyname( "cn.pool.ntp.org" );
|
||||
pptr = hostent_content->h_addr_list;
|
||||
ipp.s_addr = *(uint32_t *) (*pptr);
|
||||
err = sntp_get_time( &ipp, ¤t_time );
|
||||
}
|
||||
if ( err != kNoErr )
|
||||
{
|
||||
os_log("sntp_get_time2 err = %d.", err);
|
||||
hostent_content = gethostbyname( "s1a.time.edu.cn" );
|
||||
pptr = hostent_content->h_addr_list;
|
||||
ipp.s_addr = *(uint32_t *) (*pptr);
|
||||
err = sntp_get_time( &ipp, ¤t_time );
|
||||
}
|
||||
if ( err != kNoErr )
|
||||
{
|
||||
os_log("sntp_get_time3 err = %d.", err);
|
||||
hostent_content = gethostbyname( "ntp.sjtu.edu.cn" );
|
||||
pptr = hostent_content->h_addr_list;
|
||||
ipp.s_addr = *(uint32_t *) (*pptr);
|
||||
err = sntp_get_time( &ipp, ¤t_time );
|
||||
}
|
||||
|
||||
@@ -47,7 +65,7 @@ OSStatus user_sntp_get_time( )
|
||||
}
|
||||
else
|
||||
{
|
||||
os_log("sntp_get_time2 err = %d.", err);
|
||||
os_log("sntp_get_time4 err = %d.", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -88,7 +106,7 @@ OSStatus user_rtc_init( void )
|
||||
|
||||
void rtc_thread( mico_thread_arg_t arg )
|
||||
{
|
||||
iso8601_time_t iso8601_time;
|
||||
int i, j;
|
||||
OSStatus err = kUnknownErr;
|
||||
LinkStatusTypeDef LinkStatus;
|
||||
mico_rtc_time_t rtc_time;
|
||||
@@ -129,6 +147,37 @@ void rtc_thread( mico_thread_arg_t arg )
|
||||
// MicoRtcSetTime( &rtc_time ); //MicoRtc<74><63><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD>ʱ!
|
||||
os_log("time:20%02d/%02d/%02d %d %02d:%02d:%02d",rtc_time.year,rtc_time.month,rtc_time.date,rtc_time.weekday,rtc_time.hr,rtc_time.min,rtc_time.sec);
|
||||
|
||||
char update_user_config_flag = 0;
|
||||
for ( i = 0; i < PLUG_NUM; i++ )
|
||||
{
|
||||
for ( j = 0; j < PLUG_TIME_TASK_NUM; j++ )
|
||||
{
|
||||
if ( user_config->plug[i].task[j].on != 0 )
|
||||
{
|
||||
|
||||
uint8_t repeat = user_config->plug[i].task[j].repeat;
|
||||
if ( //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1>̵<EFBFBD><CCB5><EFBFBD>״̬: <20><>Ϊ0 ʱ<>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>趨ֵ, <20>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>趨ֵ
|
||||
rtc_time.sec == 0 && rtc_time.min == user_config->plug[i].task[j].minute
|
||||
&& rtc_time.hr == user_config->plug[i].task[j].hour
|
||||
&& ((repeat == 0x80) || repeat & (1 << (rtc_time.weekday - 1)))
|
||||
)
|
||||
{
|
||||
user_relay_set( i, user_config->plug[i].task[j].action );
|
||||
if ( repeat == 0x80 )
|
||||
{
|
||||
user_config->plug[i].task[j].on = 0;
|
||||
update_user_config_flag = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( update_user_config_flag == 1 )
|
||||
{
|
||||
mico_system_context_update( sys_config ); //<2F><><EFBFBD>¶<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
update_user_config_flag = 0;
|
||||
}
|
||||
|
||||
if ( rtc_init != 1 || (rtc_time.sec == 0 && rtc_time.min == 0) ) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿСʱУһ<D7BC><D2BB>
|
||||
{
|
||||
micoWlanGetLinkStatus( &LinkStatus );
|
||||
|
||||
Reference in New Issue
Block a user