按平台协议更新,修改远程加解锁和ota指令的处理和回应
authorkyz <kongyuzhong@google.com>
Wed, 26 Jun 2024 05:53:31 +0000 (13:53 +0800)
committerkyz <kongyuzhong@google.com>
Wed, 26 Jun 2024 05:53:31 +0000 (13:53 +0800)
user/user_4g.c
user/user_eth.c
user/user_ota.c
user/user_report.c
user/user_wifi.c

index fe790ebf534e404bec65fd22b9fa3cdd939d7e48..f10a9652b6b428875409e80262b874de78c62e80 100644 (file)
@@ -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;
                                                        }
index d33fdaa364fa6a4888f45c99a6e761197dc43f79..74f3cab0ee50e1bc4509c92485af99fd0b091eb1 100644 (file)
@@ -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;
             }
index f9ce375a42f3b8bad1bec3b0f4a869bb549aa0ce..202848ee14a845f4074adc70c08a37a1433e616a 100644 (file)
@@ -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 ){
index ddaa31d6668721232c837e0df2ce7b795a9d9adb..3c937008f095223fcc69815f28263cfc194fcbde 100644 (file)
@@ -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" );
index 4394cffb6c3afb6434f44fd24ecb2699a7781d2e..a220d807275c011e6f35a2f211cc31b1862cb017 100644 (file)
@@ -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;
                                                }