mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-12 13:08:13 +08:00
优化注释
This commit is contained in:
40
TC1/main.c
40
TC1/main.c
@@ -57,7 +57,7 @@ void appRestoreDefault_callback( void * const user_config_data, uint32_t size )
|
|||||||
userConfigDefault->plug[i].name[6] = i + '1';
|
userConfigDefault->plug[i].name[6] = i + '1';
|
||||||
userConfigDefault->plug[i].name[7] = 0;
|
userConfigDefault->plug[i].name[7] = 0;
|
||||||
|
|
||||||
// sprintf( userConfigDefault->plug[i].name, "<22><><EFBFBD><EFBFBD>%d", i );//<2F><><EFBFBD><EFBFBD><EFBFBD>쳣
|
// sprintf( userConfigDefault->plug[i].name, "<22><><EFBFBD><EFBFBD>%d", i );//<2F><><EFBFBD><EFBFBD><EFBFBD>쳣
|
||||||
for ( j = 0; j < PLUG_TIME_TASK_NUM; j++ )
|
for ( j = 0; j < PLUG_TIME_TASK_NUM; j++ )
|
||||||
{
|
{
|
||||||
userConfigDefault->plug[i].task[j].hour = 0;
|
userConfigDefault->plug[i].task[j].hour = 0;
|
||||||
@@ -67,7 +67,7 @@ void appRestoreDefault_callback( void * const user_config_data, uint32_t size )
|
|||||||
userConfigDefault->plug[i].task[j].action = 1;
|
userConfigDefault->plug[i].task[j].action = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// mico_system_context_update( sys_config );
|
// mico_system_context_update( sys_config );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,13 +80,13 @@ int application_start( void )
|
|||||||
uint32_t power_last = 0xffffffff;
|
uint32_t power_last = 0xffffffff;
|
||||||
OSStatus err = kNoErr;
|
OSStatus err = kNoErr;
|
||||||
|
|
||||||
// for ( i = 0; i < Relay_NUM; i++ )
|
// for ( i = 0; i < Relay_NUM; i++ )
|
||||||
// {
|
// {
|
||||||
// MicoGpioOutputLow( Relay[(i)] );
|
// MicoGpioOutputLow( Relay[(i)] );
|
||||||
// MicoGpioInitialize( Relay[i], OUTPUT_PUSH_PULL );
|
// MicoGpioInitialize( Relay[i], OUTPUT_PUSH_PULL );
|
||||||
// MicoGpioOutputLow( Relay[(i)] );
|
// MicoGpioOutputLow( Relay[(i)] );
|
||||||
// //MicoGpioOutputHigh(Relay[i]);
|
// MicoGpioOutputHigh(Relay[i]);
|
||||||
// }
|
// }
|
||||||
/* Create mico system context and read application's config data from flash */
|
/* Create mico system context and read application's config data from flash */
|
||||||
sys_config = mico_system_context_init( sizeof(user_config_t) );
|
sys_config = mico_system_context_init( sizeof(user_config_t) );
|
||||||
user_config = ((system_context_t *) sys_config)->user_config_data;
|
user_config = ((system_context_t *) sys_config)->user_config_data;
|
||||||
@@ -141,17 +141,17 @@ int application_start( void )
|
|||||||
os_log( "mqtt_password:%s",user_config->mqtt_password );
|
os_log( "mqtt_password:%s",user_config->mqtt_password );
|
||||||
|
|
||||||
os_log( "version:%d",user_config->version );
|
os_log( "version:%d",user_config->version );
|
||||||
// for ( i = 0; i < PLUG_NUM; i++ )
|
// for ( i = 0; i < PLUG_NUM; i++ )
|
||||||
// {
|
// {
|
||||||
// os_log("plug_%d:",i);
|
// os_log("plug_%d:",i);
|
||||||
// os_log("\tname:%s:",user_config->plug[i].name);
|
// os_log("\tname:%s:",user_config->plug[i].name);
|
||||||
// for ( j = 0; j < PLUG_TIME_TASK_NUM; j++ )
|
// for ( j = 0; j < PLUG_TIME_TASK_NUM; j++ )
|
||||||
// {
|
// {
|
||||||
// os_log("\t\ton:%d\t %02d:%02d repeat:0x%X",user_config->plug[i].task[j].on,
|
// os_log("\t\ton:%d\t %02d:%02d repeat:0x%X",user_config->plug[i].task[j].on,
|
||||||
// user_config->plug[i].task[j].hour,user_config->plug[i].task[j].minute,
|
// user_config->plug[i].task[j].hour,user_config->plug[i].task[j].minute,
|
||||||
// user_config->plug[i].task[j].repeat);
|
// user_config->plug[i].task[j].repeat);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
ap_init();
|
ap_init();
|
||||||
wifi_init( );
|
wifi_init( );
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ typedef struct
|
|||||||
int mqtt_port; //mqtt service port
|
int mqtt_port; //mqtt service port
|
||||||
char mqtt_user[SETTING_MQTT_STRING_LENGTH_MAX]; //mqtt service user
|
char mqtt_user[SETTING_MQTT_STRING_LENGTH_MAX]; //mqtt service user
|
||||||
char mqtt_password[SETTING_MQTT_STRING_LENGTH_MAX]; //mqtt service user
|
char mqtt_password[SETTING_MQTT_STRING_LENGTH_MAX]; //mqtt service user
|
||||||
// char mqtt_device_id[SETTING_MQTT_STRING_LENGTH_MAX]; //mqtt service user device name
|
// char mqtt_device_id[SETTING_MQTT_STRING_LENGTH_MAX]; //mqtt service user device name
|
||||||
|
|
||||||
char version;
|
char version;
|
||||||
user_plug_config_t plug[PLUG_NUM];
|
user_plug_config_t plug[PLUG_NUM];
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ static int ota_server_send_header( void )
|
|||||||
|
|
||||||
ret = ota_server_send( (uint8_t *) header, strlen( header ) );
|
ret = ota_server_send( (uint8_t *) header, strlen( header ) );
|
||||||
|
|
||||||
// ota_server_log("send: %d\r\n%s", strlen(header), header);
|
// ota_server_log("send: %d\r\n%s", strlen(header), header);
|
||||||
if ( header != NULL ) free( header );
|
if ( header != NULL ) free( header );
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ void user_function_cmd_received( int udp_flag, uint8_t *pusrdata )
|
|||||||
cJSON_AddStringToObject( pRoot, "ip", para.ip );
|
cJSON_AddStringToObject( pRoot, "ip", para.ip );
|
||||||
|
|
||||||
char *s = cJSON_Print( pRoot );
|
char *s = cJSON_Print( pRoot );
|
||||||
// os_log( "pRoot: %s\r\n", s );
|
// os_log( "pRoot: %s\r\n", s );
|
||||||
user_send( udp_flag, s ); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
user_send( udp_flag, s ); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
free( (void *) s );
|
free( (void *) s );
|
||||||
cJSON_Delete( pRoot );
|
cJSON_Delete( pRoot );
|
||||||
@@ -76,7 +76,7 @@ void user_function_cmd_received( int udp_flag, uint8_t *pusrdata )
|
|||||||
cJSON_AddStringToObject( json_send, "mac", strMac );
|
cJSON_AddStringToObject( json_send, "mac", strMac );
|
||||||
|
|
||||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
// cJSON *p_cmd = cJSON_GetObjectItem( pJsonRoot, "name" );
|
// cJSON *p_cmd = cJSON_GetObjectItem( pJsonRoot, "name" );
|
||||||
if(p_cmd && cJSON_IsString( p_cmd ) && strcmp( p_cmd->valuestring, "restart" ) == 0)
|
if(p_cmd && cJSON_IsString( p_cmd ) && strcmp( p_cmd->valuestring, "restart" ) == 0)
|
||||||
{
|
{
|
||||||
os_log("cmd:restart");
|
os_log("cmd:restart");
|
||||||
@@ -192,7 +192,7 @@ void user_function_cmd_received( int udp_flag, uint8_t *pusrdata )
|
|||||||
if ( return_flag == true )
|
if ( return_flag == true )
|
||||||
{
|
{
|
||||||
char *json_str = cJSON_Print( json_send );
|
char *json_str = cJSON_Print( json_send );
|
||||||
// os_log( "pRoot: %s\r\n", json_str );
|
// os_log( "pRoot: %s\r\n", json_str );
|
||||||
user_send( udp_flag, json_str ); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
user_send( udp_flag, json_str ); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
free( (void *) json_str );
|
free( (void *) json_str );
|
||||||
}
|
}
|
||||||
@@ -270,8 +270,8 @@ bool json_plug_analysis( int udp_flag, unsigned char x, cJSON * pJsonRoot, cJSON
|
|||||||
cJSON_AddItemToObject( json_plug_send, "setting", json_plug_setting_send );
|
cJSON_AddItemToObject( json_plug_send, "setting", json_plug_setting_send );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// cJSON *p_nvalue = cJSON_GetObjectItem( pJsonRoot, "nvalue" );
|
// cJSON *p_nvalue = cJSON_GetObjectItem( pJsonRoot, "nvalue" );
|
||||||
// if ( p_plug || p_nvalue )
|
// if ( p_plug || p_nvalue )
|
||||||
cJSON_AddNumberToObject( json_plug_send, "on", user_config->plug[x].on );
|
cJSON_AddNumberToObject( json_plug_send, "on", user_config->plug[x].on );
|
||||||
|
|
||||||
cJSON_AddItemToObject( pJsonSend, plug_str, json_plug_send );
|
cJSON_AddItemToObject( pJsonSend, plug_str, json_plug_send );
|
||||||
|
|||||||
@@ -99,9 +99,9 @@ void user_relay_set_all( char y )
|
|||||||
|
|
||||||
static void key_long_press( void )
|
static void key_long_press( void )
|
||||||
{
|
{
|
||||||
// os_log("key_long_press");
|
// os_log("key_long_press");
|
||||||
// user_led_set( 1 );
|
// user_led_set( 1 );
|
||||||
// user_mqtt_send( "mqtt test" );
|
// user_mqtt_send( "mqtt test" );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void key_long_10s_press( void )
|
static void key_long_10s_press( void )
|
||||||
@@ -109,12 +109,12 @@ static void key_long_10s_press( void )
|
|||||||
OSStatus err;
|
OSStatus err;
|
||||||
char i = 0;
|
char i = 0;
|
||||||
os_log( "WARNGIN: user params restored!" );
|
os_log( "WARNGIN: user params restored!" );
|
||||||
// for ( i = 0; i < 3; i++ )
|
// for ( i = 0; i < 3; i++ )
|
||||||
// {
|
// {
|
||||||
// user_led_set( 1 );
|
// user_led_set( 1 );
|
||||||
// mico_rtos_thread_msleep( 100 );
|
// mico_rtos_thread_msleep( 100 );
|
||||||
// user_led_set( 0 );
|
// user_led_set( 0 );
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
appRestoreDefault_callback( user_config, sizeof(user_config_t) );
|
appRestoreDefault_callback( user_config, sizeof(user_config_t) );
|
||||||
sys_config->micoSystemConfig.ssid[0] = 0;
|
sys_config->micoSystemConfig.ssid[0] = 0;
|
||||||
@@ -155,7 +155,7 @@ static void key_timeout_handler( void* arg )
|
|||||||
uint8_t tmp = ~(0xfe | MicoGpioInputGet( Button ));
|
uint8_t tmp = ~(0xfe | MicoGpioInputGet( Button ));
|
||||||
key_trigger = tmp & (tmp ^ key_continue);
|
key_trigger = tmp & (tmp ^ key_continue);
|
||||||
key_continue = tmp;
|
key_continue = tmp;
|
||||||
// os_log("button scan:%02x %02x",key_trigger,key_continue);
|
// os_log("button scan:%02x %02x",key_trigger,key_continue);
|
||||||
if ( key_trigger != 0 ) key_time = 0; //<2F>°<EFBFBD><C2B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ,<2C><><EFBFBD>¿<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ
|
if ( key_trigger != 0 ) key_time = 0; //<2F>°<EFBFBD><C2B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ,<2C><><EFBFBD>¿<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ
|
||||||
if ( key_continue != 0 )
|
if ( key_continue != 0 )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ void user_mqtt_timer_func( void *arg )
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
mico_stop_timer( &timer_handle );
|
mico_stop_timer( &timer_handle );
|
||||||
// mico_deinit_timer( &timer_handle );
|
// mico_deinit_timer( &timer_handle );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -474,7 +474,7 @@ OSStatus user_mqtt_send_topic( char *topic, char *arg, char retained )
|
|||||||
OSStatus err = kUnknownErr;
|
OSStatus err = kUnknownErr;
|
||||||
p_mqtt_send_msg_t p_send_msg = NULL;
|
p_mqtt_send_msg_t p_send_msg = NULL;
|
||||||
|
|
||||||
// app_log("======App prepare to send ![%d]======", MicoGetMemoryInfo()->free_memory);
|
// app_log("======App prepare to send ![%d]======", MicoGetMemoryInfo()->free_memory);
|
||||||
|
|
||||||
/* Send queue is full, pop the oldest */
|
/* Send queue is full, pop the oldest */
|
||||||
if ( mico_rtos_is_queue_full( &mqtt_msg_send_queue ) == true )
|
if ( mico_rtos_is_queue_full( &mqtt_msg_send_queue ) == true )
|
||||||
|
|||||||
@@ -17,14 +17,14 @@ static uint32_t timer_irq_count = 0;
|
|||||||
static void power_timer_handler( void* arg )
|
static void power_timer_handler( void* arg )
|
||||||
{
|
{
|
||||||
|
|
||||||
// uint8_t pin_input = MicoGpioInputGet( POWER );
|
// uint8_t pin_input = MicoGpioInputGet( POWER );
|
||||||
uint32_t timer = 0;
|
uint32_t timer = 0;
|
||||||
|
|
||||||
if ( timer_irq_count > 1 )
|
if ( timer_irq_count > 1 )
|
||||||
{
|
{
|
||||||
timer = (clock_count - clock_count_last);
|
timer = (clock_count - clock_count_last);
|
||||||
|
|
||||||
// os_log("power_irq_handler:%09u %u %u",timer,timer_irq_count,timer_count);
|
// os_log("power_irq_handler:%09u %u %u",timer,timer_irq_count,timer_count);
|
||||||
if ( timer_count > 3 )
|
if ( timer_count > 3 )
|
||||||
{
|
{
|
||||||
timer /= 1000;
|
timer /= 1000;
|
||||||
@@ -42,20 +42,20 @@ static void power_timer_handler( void* arg )
|
|||||||
timer_count++;
|
timer_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if ( clock_count_last != timer_count )
|
// if ( clock_count_last != timer_count )
|
||||||
// {
|
// {
|
||||||
//// os_log("power_irq_handler:%u-%u=%u",timer_count,clock_count_last,timer);
|
//// os_log("power_irq_handler:%u-%u=%u",timer_count,clock_count_last,timer);
|
||||||
// timer = (timer_count - clock_count_last);
|
// timer = (timer_count - clock_count_last);
|
||||||
// if ( timer_count < clock_count_last ) timer += 0xffffffff;
|
// if ( timer_count < clock_count_last ) timer += 0xffffffff;
|
||||||
//
|
//
|
||||||
// timer = timer / 1000;
|
// timer = timer / 1000;
|
||||||
// power = 15200000 / timer;
|
// power = 15200000 / timer;
|
||||||
// os_log("power_irq_handler:%u,%07u",power,timer);
|
// os_log("power_irq_handler:%u,%07u",power,timer);
|
||||||
// clock_count_last = timer_count;
|
// clock_count_last = timer_count;
|
||||||
// }
|
// }
|
||||||
// if(timer_count==0) os_log("power_timer_handler Hight:%d",clock_count_last);
|
// if(timer_count==0) os_log("power_timer_handler Hight:%d",clock_count_last);
|
||||||
// timer_count++;
|
// timer_count++;
|
||||||
// clock_count_last=timer_count;
|
// clock_count_last=timer_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void power_irq_handler( void* arg )
|
static void power_irq_handler( void* arg )
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ OSStatus user_sntp_get_time( )
|
|||||||
char ** pptr = NULL;
|
char ** pptr = NULL;
|
||||||
struct in_addr ipp;
|
struct in_addr ipp;
|
||||||
|
|
||||||
// mico_rtc_time_t rtc_time;
|
// mico_rtc_time_t rtc_time;
|
||||||
|
|
||||||
hostent_content = gethostbyname( "pool.ntp.org" );
|
hostent_content = gethostbyname( "pool.ntp.org" );
|
||||||
pptr = hostent_content->h_addr_list;
|
pptr = hostent_content->h_addr_list;
|
||||||
@@ -69,16 +69,16 @@ OSStatus user_sntp_get_time( )
|
|||||||
mico_utc_time_ms_t utc_time_ms = (uint64_t) current_time.seconds * (uint64_t) 1000
|
mico_utc_time_ms_t utc_time_ms = (uint64_t) current_time.seconds * (uint64_t) 1000
|
||||||
+ (current_time.microseconds / 1000);
|
+ (current_time.microseconds / 1000);
|
||||||
mico_time_set_utc_time_ms( &utc_time_ms );
|
mico_time_set_utc_time_ms( &utc_time_ms );
|
||||||
// mico_utc_time_t utc_time = utc_time_ms / 1000 + 28800; //+8:00
|
// mico_utc_time_t utc_time = utc_time_ms / 1000 + 28800; //+8:00
|
||||||
// struct tm * currentTime = localtime( (const time_t *) &utc_time );
|
// struct tm * currentTime = localtime( (const time_t *) &utc_time );
|
||||||
// rtc_time.sec = currentTime->tm_sec;
|
// rtc_time.sec = currentTime->tm_sec;
|
||||||
// rtc_time.min = currentTime->tm_min;
|
// rtc_time.min = currentTime->tm_min;
|
||||||
// rtc_time.hr = currentTime->tm_hour;
|
// rtc_time.hr = currentTime->tm_hour;
|
||||||
// rtc_time.date = currentTime->tm_mday;
|
// rtc_time.date = currentTime->tm_mday;
|
||||||
// rtc_time.weekday = currentTime->tm_wday;
|
// rtc_time.weekday = currentTime->tm_wday;
|
||||||
// rtc_time.month = currentTime->tm_mon + 1;
|
// rtc_time.month = currentTime->tm_mon + 1;
|
||||||
// rtc_time.year = (currentTime->tm_year + 1900) % 100;
|
// rtc_time.year = (currentTime->tm_year + 1900) % 100;
|
||||||
// MicoRtcSetTime( &rtc_time );
|
// MicoRtcSetTime( &rtc_time );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -92,22 +92,22 @@ OSStatus user_rtc_init( void )
|
|||||||
{
|
{
|
||||||
OSStatus err = kNoErr;
|
OSStatus err = kNoErr;
|
||||||
|
|
||||||
// mico_rtc_time_t rtc_time;
|
// mico_rtc_time_t rtc_time;
|
||||||
// rtc_time.sec = 0;
|
// rtc_time.sec = 0;
|
||||||
// rtc_time.min = 0;
|
// rtc_time.min = 0;
|
||||||
// rtc_time.hr = 0;
|
// rtc_time.hr = 0;
|
||||||
//
|
//
|
||||||
// rtc_time.date = 1;
|
// rtc_time.date = 1;
|
||||||
// rtc_time.weekday = 1;
|
// rtc_time.weekday = 1;
|
||||||
// rtc_time.month = 1;
|
// rtc_time.month = 1;
|
||||||
// rtc_time.year = 1;
|
// rtc_time.year = 1;
|
||||||
//
|
//
|
||||||
// MicoRtcSetTime( &rtc_time );
|
// MicoRtcSetTime( &rtc_time );
|
||||||
|
|
||||||
// /* create mqtt msg send queue */
|
// /* create mqtt msg send queue */
|
||||||
// err = mico_rtos_init_queue( &mqtt_msg_send_queue, "mqtt_msg_send_queue", sizeof(p_mqtt_send_msg_t),
|
// err = mico_rtos_init_queue( &mqtt_msg_send_queue, "mqtt_msg_send_queue", sizeof(p_mqtt_send_msg_t),
|
||||||
// MAX_MQTT_SEND_QUEUE_SIZE );
|
// MAX_MQTT_SEND_QUEUE_SIZE );
|
||||||
// require_noerr_action( err, exit, app_log("ERROR: create mqtt msg send queue err=%d.", err) );
|
// require_noerr_action( err, exit, app_log("ERROR: create mqtt msg send queue err=%d.", err) );
|
||||||
|
|
||||||
/* start rtc client */
|
/* start rtc client */
|
||||||
err = mico_rtos_create_thread( NULL, MICO_APPLICATION_PRIORITY, "rtc",
|
err = mico_rtos_create_thread( NULL, MICO_APPLICATION_PRIORITY, "rtc",
|
||||||
@@ -170,7 +170,7 @@ void rtc_thread( mico_thread_arg_t arg )
|
|||||||
rtc_time.month = currentTime->tm_mon + 1;
|
rtc_time.month = currentTime->tm_mon + 1;
|
||||||
rtc_time.year = (currentTime->tm_year + 1900) % 100;
|
rtc_time.year = (currentTime->tm_year + 1900) % 100;
|
||||||
|
|
||||||
// MicoRtcSetTime( &rtc_time ); //MicoRtc<74><63><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD>ʱ!
|
// MicoRtcSetTime( &rtc_time ); //MicoRtc<74><63><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD>ʱ!
|
||||||
|
|
||||||
if ( rtc_time.sec == 0 )
|
if ( rtc_time.sec == 0 )
|
||||||
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);
|
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);
|
||||||
@@ -251,7 +251,7 @@ void rtc_thread( mico_thread_arg_t arg )
|
|||||||
|
|
||||||
free( json_str );
|
free( json_str );
|
||||||
cJSON_Delete( json_send );
|
cJSON_Delete( json_send );
|
||||||
// os_log("cJSON_Delete");
|
// os_log("cJSON_Delete");
|
||||||
}
|
}
|
||||||
|
|
||||||
//SNTP<54><50><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿСʱУһ<D7BC><D2BB>
|
//SNTP<54><50><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿСʱУһ<D7BC><D2BB>
|
||||||
@@ -273,7 +273,7 @@ void rtc_thread( mico_thread_arg_t arg )
|
|||||||
mico_rtos_thread_msleep( 900 );
|
mico_rtos_thread_msleep( 900 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// exit:
|
// exit:
|
||||||
os_log("EXIT: rtc exit with err = %d.", err);
|
os_log("EXIT: rtc exit with err = %d.", err);
|
||||||
mico_rtos_delete_thread( NULL );
|
mico_rtos_delete_thread( NULL );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,12 +9,12 @@
|
|||||||
static void sntp_time_call_back( void )
|
static void sntp_time_call_back( void )
|
||||||
{
|
{
|
||||||
struct tm * currentTime;
|
struct tm * currentTime;
|
||||||
// iso8601_time_t iso8601_time;
|
// iso8601_time_t iso8601_time;
|
||||||
mico_utc_time_t utc_time;
|
mico_utc_time_t utc_time;
|
||||||
mico_rtc_time_t rtc_time;
|
mico_rtc_time_t rtc_time;
|
||||||
|
|
||||||
// mico_time_get_iso8601_time( &iso8601_time );
|
// mico_time_get_iso8601_time( &iso8601_time );
|
||||||
// os_log("sntp_time_synced: %.26s", (char*)&iso8601_time);
|
// os_log("sntp_time_synced: %.26s", (char*)&iso8601_time);
|
||||||
|
|
||||||
mico_time_get_utc_time( &utc_time );
|
mico_time_get_utc_time( &utc_time );
|
||||||
utc_time+=28800; //+8:00
|
utc_time+=28800; //+8:00
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ void udp_thread( void *arg )
|
|||||||
if(len<1024) buf[len]=0;
|
if(len<1024) buf[len]=0;
|
||||||
os_log( "udp recv from %s:%d, len:%d ", ip_address,addr.sin_port, len );
|
os_log( "udp recv from %s:%d, len:%d ", ip_address,addr.sin_port, len );
|
||||||
user_function_cmd_received(1,buf);
|
user_function_cmd_received(1,buf);
|
||||||
// sendto( udp_fd, buf, len, 0, (struct sockaddr *) &addr, sizeof(struct sockaddr_in) );
|
// sendto( udp_fd, buf, len, 0, (struct sockaddr *) &addr, sizeof(struct sockaddr_in) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* recv msg from user worker thread to be sent to server */
|
/* recv msg from user worker thread to be sent to server */
|
||||||
@@ -105,7 +105,7 @@ void udp_thread( void *arg )
|
|||||||
|
|
||||||
// send message to server
|
// send message to server
|
||||||
err = udp_msg_send( udp_fd, p_send_msg->data, p_send_msg->datalen );
|
err = udp_msg_send( udp_fd, p_send_msg->data, p_send_msg->datalen );
|
||||||
// require_noerr_string( err, MQTT_reconnect, "ERROR: udp publish data err" );
|
// require_noerr_string( err, MQTT_reconnect, "ERROR: udp publish data err" );
|
||||||
|
|
||||||
os_log( "udp send data success! msg=[%ld].\r\n", p_send_msg->datalen);
|
os_log( "udp send data success! msg=[%ld].\r\n", p_send_msg->datalen);
|
||||||
free( p_send_msg );
|
free( p_send_msg );
|
||||||
@@ -149,7 +149,7 @@ OSStatus user_udp_send( char *arg )
|
|||||||
OSStatus err = kUnknownErr;
|
OSStatus err = kUnknownErr;
|
||||||
p_udp_send_msg_t p_send_msg = NULL;
|
p_udp_send_msg_t p_send_msg = NULL;
|
||||||
|
|
||||||
// app_log("======App prepare to send ![%d]======", MicoGetMemoryInfo()->free_memory);
|
// app_log("======App prepare to send ![%d]======", MicoGetMemoryInfo()->free_memory);
|
||||||
|
|
||||||
/* Send queue is full, pop the oldest */
|
/* Send queue is full, pop the oldest */
|
||||||
if ( mico_rtos_is_queue_full( &udp_msg_send_queue ) == true )
|
if ( mico_rtos_is_queue_full( &udp_msg_send_queue ) == true )
|
||||||
|
|||||||
Reference in New Issue
Block a user