diff --git a/TC1/main.c b/TC1/main.c index d476c52..1b53f46 100644 --- a/TC1/main.c +++ b/TC1/main.c @@ -145,12 +145,12 @@ int application_start( void ) // } wifi_init( ); + user_udp_init( ); key_init( ); err = user_mqtt_init( ); require_noerr( err, exit ); err = user_rtc_init( ); require_noerr( err, exit ); - user_udp_init( ); // user_power_init(); while ( 1 ) { diff --git a/TC1/user_function.c b/TC1/user_function.c index 1ffd75d..08153b2 100644 --- a/TC1/user_function.c +++ b/TC1/user_function.c @@ -52,6 +52,11 @@ void user_function_cmd_received( int udp_flag, uint8_t *pusrdata ) cJSON_AddStringToObject( pRoot, "mac", strMac ); cJSON_AddNumberToObject( pRoot, "type", TYPE ); cJSON_AddStringToObject( pRoot, "type_name", TYPE_NAME ); + + IPStatusTypedef para; + micoWlanGetIPStatus( ¶, Station ); + cJSON_AddStringToObject( pRoot, "ip", para.ip ); + char *s = cJSON_Print( pRoot ); // os_log( "pRoot: %s\r\n", s ); user_send( udp_flag, s ); //发送数据 @@ -227,6 +232,7 @@ bool json_plug_analysis( int udp_flag, unsigned char x, cJSON * pJsonRoot, cJSON { return_flag = true; sprintf( user_config->plug[x].name, p_plug_setting_name->valuestring ); + user_mqtt_hass_auto(x); } cJSON_AddStringToObject( json_plug_setting_send, "name", user_config->plug[x].name ); } diff --git a/TC1/user_ota.c b/TC1/user_ota.c index 4ccb982..6f33de3 100644 --- a/TC1/user_ota.c +++ b/TC1/user_ota.c @@ -9,11 +9,13 @@ static void ota_server_status_handler( OTA_STATE_E state, float progress ) { - char str[64]={0}; + char str[64] = { 0 }; switch ( state ) { case OTA_LOADING: os_log("ota server is loading, progress %.2f%%", progress); +// if ( (int) progress == progress ) +// sprintf( str, "{\"mac\":\"%s\",\"ota_progress\":%d}", strMac,(int) progress ); break; case OTA_SUCCE: os_log("ota server daemons success"); @@ -26,9 +28,9 @@ static void ota_server_status_handler( OTA_STATE_E state, float progress ) default: break; } - if(str[0]>0) + if ( str[0] > 0 ) { - user_send(true,str); + user_send( true, str ); } } diff --git a/TC1/user_wifi.c b/TC1/user_wifi.c index 4e77b04..07c839f 100644 --- a/TC1/user_wifi.c +++ b/TC1/user_wifi.c @@ -64,6 +64,7 @@ static void wifi_get_ip_callback( IPStatusTypedef *pnet, void * arg ) { os_log("got IP:%s", pnet->ip); wifi_status = WIFI_STATE_CONNECTED; + user_function_cmd_received(1,"{\"cmd\":\"device report\"}"); } //wifi连接状态改变回调 static void wifi_status_callback( WiFiEvent status, void *arg ) diff --git a/build/TC1@MK3031@moc/binary/TC1@MK3031@moc.all.bin b/build/TC1@MK3031@moc/binary/TC1@MK3031@moc.all.bin index 74b9a6d..db50a15 100644 Binary files a/build/TC1@MK3031@moc/binary/TC1@MK3031@moc.all.bin and b/build/TC1@MK3031@moc/binary/TC1@MK3031@moc.all.bin differ diff --git a/build/TC1@MK3031@moc/binary/TC1@MK3031@moc.ota.bin b/build/TC1@MK3031@moc/binary/TC1@MK3031@moc.ota.bin index 1b74721..a93454f 100644 Binary files a/build/TC1@MK3031@moc/binary/TC1@MK3031@moc.ota.bin and b/build/TC1@MK3031@moc/binary/TC1@MK3031@moc.ota.bin differ