diff --git a/TC1/main.c b/TC1/main.c index 6c3b797..26028dc 100644 --- a/TC1/main.c +++ b/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[7] = 0; -// sprintf( userConfigDefault->plug[i].name, "插座%d", i );//编码异常 +// sprintf( userConfigDefault->plug[i].name, "插座%d", i );//编码异常 for ( j = 0; j < PLUG_TIME_TASK_NUM; j++ ) { 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; } } -// 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; OSStatus err = kNoErr; -// for ( i = 0; i < Relay_NUM; i++ ) -// { -// MicoGpioOutputLow( Relay[(i)] ); -// MicoGpioInitialize( Relay[i], OUTPUT_PUSH_PULL ); -// MicoGpioOutputLow( Relay[(i)] ); -// //MicoGpioOutputHigh(Relay[i]); -// } +// for ( i = 0; i < Relay_NUM; i++ ) +// { +// MicoGpioOutputLow( Relay[(i)] ); +// MicoGpioInitialize( Relay[i], OUTPUT_PUSH_PULL ); +// MicoGpioOutputLow( Relay[(i)] ); +// MicoGpioOutputHigh(Relay[i]); +// } /* Create mico system context and read application's config data from flash */ sys_config = mico_system_context_init( sizeof(user_config_t) ); 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( "version:%d",user_config->version ); -// for ( i = 0; i < PLUG_NUM; i++ ) -// { -// os_log("plug_%d:",i); -// os_log("\tname:%s:",user_config->plug[i].name); -// 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, -// user_config->plug[i].task[j].hour,user_config->plug[i].task[j].minute, -// user_config->plug[i].task[j].repeat); -// } -// } +// for ( i = 0; i < PLUG_NUM; i++ ) +// { +// os_log("plug_%d:",i); +// os_log("\tname:%s:",user_config->plug[i].name); +// 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, +// user_config->plug[i].task[j].hour,user_config->plug[i].task[j].minute, +// user_config->plug[i].task[j].repeat); +// } +// } ap_init(); wifi_init( ); diff --git a/TC1/main.h b/TC1/main.h index 5886079..c755ee0 100644 --- a/TC1/main.h +++ b/TC1/main.h @@ -57,7 +57,7 @@ typedef struct int mqtt_port; //mqtt service port char mqtt_user[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; user_plug_config_t plug[PLUG_NUM]; diff --git a/TC1/ota_server/ota_server.c b/TC1/ota_server/ota_server.c index 0b1c3d0..0b34c3b 100644 --- a/TC1/ota_server/ota_server.c +++ b/TC1/ota_server/ota_server.c @@ -175,7 +175,7 @@ static int ota_server_send_header( void ) 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 ); return ret; } diff --git a/TC1/user_function.c b/TC1/user_function.c index b969fa0..242afbb 100644 --- a/TC1/user_function.c +++ b/TC1/user_function.c @@ -56,7 +56,7 @@ void user_function_cmd_received( int udp_flag, uint8_t *pusrdata ) cJSON_AddStringToObject( pRoot, "ip", para.ip ); char *s = cJSON_Print( pRoot ); -// os_log( "pRoot: %s\r\n", s ); +// os_log( "pRoot: %s\r\n", s ); user_send( udp_flag, s ); //发送数据 free( (void *) s ); 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 *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) { os_log("cmd:restart"); @@ -192,7 +192,7 @@ void user_function_cmd_received( int udp_flag, uint8_t *pusrdata ) if ( return_flag == true ) { 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 ); //发送数据 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 *p_nvalue = cJSON_GetObjectItem( pJsonRoot, "nvalue" ); -// if ( p_plug || p_nvalue ) +// cJSON *p_nvalue = cJSON_GetObjectItem( pJsonRoot, "nvalue" ); +// if ( p_plug || p_nvalue ) cJSON_AddNumberToObject( json_plug_send, "on", user_config->plug[x].on ); cJSON_AddItemToObject( pJsonSend, plug_str, json_plug_send ); diff --git a/TC1/user_gpio.c b/TC1/user_gpio.c index 8cd1748..e5b65ae 100644 --- a/TC1/user_gpio.c +++ b/TC1/user_gpio.c @@ -99,9 +99,9 @@ void user_relay_set_all( char y ) static void key_long_press( void ) { -// os_log("key_long_press"); -// user_led_set( 1 ); -// user_mqtt_send( "mqtt test" ); +// os_log("key_long_press"); +// user_led_set( 1 ); +// user_mqtt_send( "mqtt test" ); } static void key_long_10s_press( void ) @@ -109,12 +109,12 @@ static void key_long_10s_press( void ) OSStatus err; char i = 0; os_log( "WARNGIN: user params restored!" ); -// for ( i = 0; i < 3; i++ ) -// { -// user_led_set( 1 ); -// mico_rtos_thread_msleep( 100 ); -// user_led_set( 0 ); -// } +// for ( i = 0; i < 3; i++ ) +// { +// user_led_set( 1 ); +// mico_rtos_thread_msleep( 100 ); +// user_led_set( 0 ); +// } // appRestoreDefault_callback( user_config, sizeof(user_config_t) ); sys_config->micoSystemConfig.ssid[0] = 0; @@ -155,7 +155,7 @@ static void key_timeout_handler( void* arg ) uint8_t tmp = ~(0xfe | MicoGpioInputGet( Button )); key_trigger = tmp & (tmp ^ key_continue); 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; //新按键按下时,重新开始按键计时 if ( key_continue != 0 ) { diff --git a/TC1/user_mqtt_client.c b/TC1/user_mqtt_client.c index 96f98bf..ebb14d2 100644 --- a/TC1/user_mqtt_client.c +++ b/TC1/user_mqtt_client.c @@ -173,7 +173,7 @@ void user_mqtt_timer_func( void *arg ) break; default: mico_stop_timer( &timer_handle ); -// mico_deinit_timer( &timer_handle ); +// mico_deinit_timer( &timer_handle ); break; } } @@ -474,7 +474,7 @@ OSStatus user_mqtt_send_topic( char *topic, char *arg, char retained ) OSStatus err = kUnknownErr; 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 */ if ( mico_rtos_is_queue_full( &mqtt_msg_send_queue ) == true ) diff --git a/TC1/user_power.c b/TC1/user_power.c index 8a4c50c..eab6bb3 100644 --- a/TC1/user_power.c +++ b/TC1/user_power.c @@ -17,14 +17,14 @@ static uint32_t timer_irq_count = 0; static void power_timer_handler( void* arg ) { -// uint8_t pin_input = MicoGpioInputGet( POWER ); +// uint8_t pin_input = MicoGpioInputGet( POWER ); uint32_t timer = 0; if ( timer_irq_count > 1 ) { 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 ) { timer /= 1000; @@ -42,20 +42,20 @@ static void power_timer_handler( void* arg ) 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); -// timer = (timer_count - clock_count_last); -// if ( timer_count < clock_count_last ) timer += 0xffffffff; +// timer = (timer_count - clock_count_last); +// if ( timer_count < clock_count_last ) timer += 0xffffffff; // -// timer = timer / 1000; -// power = 15200000 / timer; -// os_log("power_irq_handler:%u,%07u",power,timer); -// clock_count_last = timer_count; -// } -// if(timer_count==0) os_log("power_timer_handler Hight:%d",clock_count_last); -// timer_count++; -// clock_count_last=timer_count; +// timer = timer / 1000; +// power = 15200000 / timer; +// os_log("power_irq_handler:%u,%07u",power,timer); +// clock_count_last = timer_count; +// } +// if(timer_count==0) os_log("power_timer_handler Hight:%d",clock_count_last); +// timer_count++; +// clock_count_last=timer_count; } static void power_irq_handler( void* arg ) diff --git a/TC1/user_rtc.c b/TC1/user_rtc.c index 2e6febb..328bbaa 100644 --- a/TC1/user_rtc.c +++ b/TC1/user_rtc.c @@ -19,7 +19,7 @@ OSStatus user_sntp_get_time( ) char ** pptr = NULL; struct in_addr ipp; -// mico_rtc_time_t rtc_time; +// mico_rtc_time_t rtc_time; hostent_content = gethostbyname( "pool.ntp.org" ); 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 + (current_time.microseconds / 1000); mico_time_set_utc_time_ms( &utc_time_ms ); -// mico_utc_time_t utc_time = utc_time_ms / 1000 + 28800; //+8:00 -// struct tm * currentTime = localtime( (const time_t *) &utc_time ); -// rtc_time.sec = currentTime->tm_sec; -// rtc_time.min = currentTime->tm_min; -// rtc_time.hr = currentTime->tm_hour; -// rtc_time.date = currentTime->tm_mday; -// rtc_time.weekday = currentTime->tm_wday; -// rtc_time.month = currentTime->tm_mon + 1; -// rtc_time.year = (currentTime->tm_year + 1900) % 100; -// MicoRtcSetTime( &rtc_time ); +// mico_utc_time_t utc_time = utc_time_ms / 1000 + 28800; //+8:00 +// struct tm * currentTime = localtime( (const time_t *) &utc_time ); +// rtc_time.sec = currentTime->tm_sec; +// rtc_time.min = currentTime->tm_min; +// rtc_time.hr = currentTime->tm_hour; +// rtc_time.date = currentTime->tm_mday; +// rtc_time.weekday = currentTime->tm_wday; +// rtc_time.month = currentTime->tm_mon + 1; +// rtc_time.year = (currentTime->tm_year + 1900) % 100; +// MicoRtcSetTime( &rtc_time ); } else { @@ -92,22 +92,22 @@ OSStatus user_rtc_init( void ) { OSStatus err = kNoErr; -// mico_rtc_time_t rtc_time; -// rtc_time.sec = 0; -// rtc_time.min = 0; -// rtc_time.hr = 0; +// mico_rtc_time_t rtc_time; +// rtc_time.sec = 0; +// rtc_time.min = 0; +// rtc_time.hr = 0; // -// rtc_time.date = 1; -// rtc_time.weekday = 1; -// rtc_time.month = 1; -// rtc_time.year = 1; +// rtc_time.date = 1; +// rtc_time.weekday = 1; +// rtc_time.month = 1; +// rtc_time.year = 1; // -// MicoRtcSetTime( &rtc_time ); +// MicoRtcSetTime( &rtc_time ); -// /* create mqtt msg send queue */ -// err = mico_rtos_init_queue( &mqtt_msg_send_queue, "mqtt_msg_send_queue", sizeof(p_mqtt_send_msg_t), -// MAX_MQTT_SEND_QUEUE_SIZE ); -// require_noerr_action( err, exit, app_log("ERROR: create mqtt msg send queue err=%d.", err) ); +// /* create mqtt msg send queue */ +// err = mico_rtos_init_queue( &mqtt_msg_send_queue, "mqtt_msg_send_queue", sizeof(p_mqtt_send_msg_t), +// MAX_MQTT_SEND_QUEUE_SIZE ); +// require_noerr_action( err, exit, app_log("ERROR: create mqtt msg send queue err=%d.", err) ); /* start rtc client */ 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.year = (currentTime->tm_year + 1900) % 100; -// MicoRtcSetTime( &rtc_time ); //MicoRtc不自动走时! +// MicoRtcSetTime( &rtc_time ); //MicoRtc不自动走时! 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); @@ -251,7 +251,7 @@ void rtc_thread( mico_thread_arg_t arg ) free( json_str ); cJSON_Delete( json_send ); -// os_log("cJSON_Delete"); +// os_log("cJSON_Delete"); } //SNTP服务 开机及每小时校准一次 @@ -273,7 +273,7 @@ void rtc_thread( mico_thread_arg_t arg ) mico_rtos_thread_msleep( 900 ); } -// exit: +// exit: os_log("EXIT: rtc exit with err = %d.", err); mico_rtos_delete_thread( NULL ); } diff --git a/TC1/user_sntp.c b/TC1/user_sntp.c index 49de66a..f6f4ec6 100644 --- a/TC1/user_sntp.c +++ b/TC1/user_sntp.c @@ -9,12 +9,12 @@ static void sntp_time_call_back( void ) { struct tm * currentTime; -// iso8601_time_t iso8601_time; +// iso8601_time_t iso8601_time; mico_utc_time_t utc_time; mico_rtc_time_t rtc_time; -// mico_time_get_iso8601_time( &iso8601_time ); -// os_log("sntp_time_synced: %.26s", (char*)&iso8601_time); +// mico_time_get_iso8601_time( &iso8601_time ); +// os_log("sntp_time_synced: %.26s", (char*)&iso8601_time); mico_time_get_utc_time( &utc_time ); utc_time+=28800; //+8:00 diff --git a/TC1/user_udp.c b/TC1/user_udp.c index 8158433..46e2510 100644 --- a/TC1/user_udp.c +++ b/TC1/user_udp.c @@ -91,7 +91,7 @@ void udp_thread( void *arg ) if(len<1024) buf[len]=0; os_log( "udp recv from %s:%d, len:%d ", ip_address,addr.sin_port, len ); 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 */ @@ -105,7 +105,7 @@ void udp_thread( void *arg ) // send message to server 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); free( p_send_msg ); @@ -149,7 +149,7 @@ OSStatus user_udp_send( char *arg ) OSStatus err = kUnknownErr; 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 */ if ( mico_rtos_is_queue_full( &udp_msg_send_queue ) == true )