fix:多个ztc1加入hass 实体id重复的问题

add:增加当前启动时间(仅app获取,hass无法获取)
This commit is contained in:
Zip
2019-04-15 15:01:32 +08:00
parent 879516c3f3
commit d8b424f653
7 changed files with 180 additions and 89 deletions

View File

@@ -117,7 +117,7 @@ void rtc_thread( mico_thread_arg_t arg )
uint32_t power_last = 0xffffffff;
mico_utc_time_t utc_time;
mico_utc_time_t utc_time_last;
while ( 1 )
{ //<2F>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>wifi<66>ſ<EFBFBD>ʼ<EFBFBD><CABC>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD>
micoWlanGetLinkStatus( &LinkStatus );
@@ -138,6 +138,14 @@ void rtc_thread( mico_thread_arg_t arg )
{
mico_time_get_utc_time( &utc_time );
utc_time += 28800;
if(utc_time_last!=utc_time)
{
utc_time_last==utc_time;
total_time++;
}
struct tm * currentTime = localtime( (const time_t *) &utc_time );
rtc_time.sec = currentTime->tm_sec;
rtc_time.min = currentTime->tm_min;
@@ -255,7 +263,7 @@ void rtc_thread( mico_thread_arg_t arg )
power_buf = malloc( 128 ); //
if ( power_buf != NULL )
{
sprintf( power_buf, "{\"mac\":\"%s\",\"power\":\"%d.%d\"}", strMac, power/10,power%10 );
sprintf( power_buf, "{\"mac\":\"%s\",\"power\":\"%d.%d\",\"total_time\":%d}", strMac, power/10,power%10,total_time );
user_send( 0, power_buf );
free( power_buf );
}