From: kyz Date: Wed, 26 Jun 2024 05:53:31 +0000 (+0800) Subject: 按平台协议更新,修改远程加解锁和ota指令的处理和回应 X-Git-Url: http://kyz.pub/gitweb/?a=commitdiff_plain;h=deb9940cddfa7680c52d0f0b9f333579a4903e62;p=yn%2Fweldingcontroller.git 按平台协议更新,修改远程加解锁和ota指令的处理和回应 --- diff --git a/user/user_4g.c b/user/user_4g.c index fe790eb..f10a965 100644 --- a/user/user_4g.c +++ b/user/user_4g.c @@ -621,6 +621,7 @@ void user_cat1_task( void* unused ) vTaskDelayUntil(&last_ticks, 1000 ); if( iot_act_resp == 1 ){ + //废弃代码 2024/6/26 char * lock_resp_str( void ); char * s = lock_resp_str(); cat1_tcp_tx( CONN_ID_IOT, (uint8_t*)s, strlen(s) ); @@ -631,6 +632,7 @@ void user_cat1_task( void* unused ) if( resp_data_get( &tx_buf,&tx_sz) > 0 ){ cat1_tcp_tx( CONN_ID_IOT, tx_buf, tx_sz ); resp_data_clean(); + continue; } iot_act_resp = 0; } diff --git a/user/user_eth.c b/user/user_eth.c index d33fdaa..74f3cab 100644 --- a/user/user_eth.c +++ b/user/user_eth.c @@ -354,6 +354,7 @@ void user_eth_task( void* unused ) } if( iot_act_resp == 1 ){ + //废弃代码 2024/6/26 char * lock_resp_str( void ); char * s = lock_resp_str(); if( tcp_write( g_iot_client.pcb, s, strlen(s), 1 ) == ERR_OK ){ @@ -368,6 +369,7 @@ void user_eth_task( void* unused ) tcp_output( g_iot_client.pcb ); } resp_data_clean(); + continue; } iot_act_resp = 0; } diff --git a/user/user_ota.c b/user/user_ota.c index f9ce375..202848e 100644 --- a/user/user_ota.c +++ b/user/user_ota.c @@ -248,6 +248,7 @@ int32_t http_get_blk( void ) tick = xTaskGetTickCount(); while( xTaskGetTickCount() - tick < 10*1000 && !g_ota.resp ){ + osDelay(10); } if( g_ota.resp ){ @@ -325,7 +326,7 @@ static void ota_task( void * unused ) g_ota.start_time = xTaskGetTickCount(); while( xTaskGetTickCount()-g_ota.start_time < 5*60*1000 ){ //总共5分钟超时 - + osDelay(5); if( http_get_blk() == 0 ){ if( g_ota.resp<0){ if( err_cnt++ < 3 ){ diff --git a/user/user_report.c b/user/user_report.c index ddaa31d..3c93700 100644 --- a/user/user_report.c +++ b/user/user_report.c @@ -277,6 +277,35 @@ char * lock_resp_str( void ) "gasFlow":1.1 // 气体流量 范围0-50, 0:焊接时气体流量按电流调节, 大于0: 焊接时气体流量固定到这个值 } } + +//锁机/解锁 +{ + "action": "lockDevice", + "timeStamp":1716445485381, // 6.25新增 + "data":{ + "mac":"00:06:00:3B:30:33", // 6.25新增 + "deviceNo":"C0201240508000025" // 6.25新增 + } +} +{ + "action": "unlockDevice", + "timeStamp":1716445485381, // 6.25新增 + "data":{ + "mac":"00:06:00:3B:30:33", // 6.25新增 + "deviceNo":"C0201240508000025" // 6.25新增 + } +} +//OTA 升级 +{ + "action": "update", + "timeStamp":1716445485381, // 6.25新增 + "data": { + "version": "V1.2", + "downloadUrl": "http://xxxxxxx", + "mac":"00:06:00:3B:30:33", // 6.25新增 + "deviceNo":"C0201240508000025" // 6.25新增 + } +} //设备回应,原包返回 #endif @@ -299,11 +328,17 @@ int32_t iot_cmd_parse( uint32_t link, char *cmd ) if(action && cJSON_IsString( action ) ){ //lock/unlock 设备响应数据暂定如下: op代表操作数据 lock代表当前机器锁机状态 0锁机 1正常 //{cmd:"op", mac:"", lock:"0" - if( strcmp( action->valuestring, "lockDevice" )== 0 ){ - debug_printf( "lockdevice %d->1\n", g_dev.cfg.remote_locked ); - g_dev.cfg.remote_locked = 1; - dev_cfg_store( &g_dev.cfg ); - act = 1; + if( strcmp( action->valuestring, "lockDevice" )== 0 || strcmp( action->valuestring, "unlockDevice" )== 0){ + data = cJSON_GetObjectItem( root, "data" ); + if(data){ + mac = cJSON_GetObjectItem( data, "mac" ); + if( mac && strcasecmp( mac->valuestring, g_mac_str ) == 0 ){ + g_dev.cfg.remote_locked = (strcmp( action->valuestring, "lockDevice" )== 0)?1:0; + debug_printf( "unlockdevice %d->0\n", g_dev.cfg.remote_locked ); + dev_cfg_store( &g_dev.cfg ); + act = 4; //原包回发。 + } + } }else if( strcmp( action->valuestring, "updateSolarTermFactor" )== 0 ){ data = cJSON_GetObjectItem( root, "data" ); if(data){ @@ -359,30 +394,30 @@ int32_t iot_cmd_parse( uint32_t link, char *cmd ) } } } - }else if( strcmp( action->valuestring, "unlockDevice" )== 0 ){ - debug_printf( "unlockdevice %d->0\n", g_dev.cfg.remote_locked ); - g_dev.cfg.remote_locked = 0; - dev_cfg_store( &g_dev.cfg ); - act = 2; }else if( strcmp( action->valuestring, "update" )== 0 ){ //ota; data = cJSON_GetObjectItem( root, "data" ); debug_printf( "-----ota----- " ); if(data){ - ver = cJSON_GetObjectItem( data, "version" ); - url = cJSON_GetObjectItem( data, "downloadUrl" ); - if( ver ) debug_printf( "--version:[%s]", ver->valuestring ); - if( url ) debug_printf( "--url:[%s]", url->valuestring ); - if( ver &&url ){ - if(link==0){ - wifi_ota_start( url->valuestring, ver->valuestring ); - }else if(link==1){ - eth_ota_start( url->valuestring, ver->valuestring ); - }else if(link== 2){ - cat1_ota_start( url->valuestring, ver->valuestring ); - } - act = 3; + mac = cJSON_GetObjectItem( data, "mac" ); + if( mac && strcasecmp( mac->valuestring, g_mac_str ) == 0 ){ + ver = cJSON_GetObjectItem( data, "version" ); + url = cJSON_GetObjectItem( data, "downloadUrl" ); + if( ver ) debug_printf( "--version:[%s]", ver->valuestring ); + if( url ) debug_printf( "--url:[%s]", url->valuestring ); + if( ver &&url ){ + if(link==0){ + wifi_ota_start( url->valuestring, ver->valuestring ); + }else if(link==1){ + eth_ota_start( url->valuestring, ver->valuestring ); + }else if(link== 2){ + cat1_ota_start( url->valuestring, ver->valuestring ); + } + act = 3; + act = 4; //原包回发。 + } + } } debug_printf( "\n" ); diff --git a/user/user_wifi.c b/user/user_wifi.c index 4394cff..a220d80 100644 --- a/user/user_wifi.c +++ b/user/user_wifi.c @@ -472,6 +472,7 @@ void user_wifi_task( void* unused ) vTaskDelayUntil(&last_ticks, 1000 ); if( iot_act_resp == 1 ){ + //废弃代码 2024/6/26 char * lock_resp_str( void ); char * s = lock_resp_str(); wifi_tcp_tx( CONN_ID_IOT, (uint8_t*)s, strlen(s) ); @@ -482,6 +483,7 @@ void user_wifi_task( void* unused ) if( resp_data_get( &tx_buf,&tx_sz) > 0 ){ wifi_tcp_tx( CONN_ID_IOT, tx_buf, tx_sz ); resp_data_clean(); + continue; } iot_act_resp = 0; }