增加cat1 http升级
authorhcj <1224667075@qq.com>
Mon, 8 Dec 2025 11:29:46 +0000 (19:29 +0800)
committerhcj <1224667075@qq.com>
Mon, 8 Dec 2025 11:29:46 +0000 (19:29 +0800)
cat1modem/src/LeiNiao/cat1Service.py
code/sdk/zhihui/4g/cat1Service/Service/cat1_server.c
code/sdk/zhihui/4g/cat1Service/Service/cat1_tcpServer.c

index 0490b4b..2d00955 100644 (file)
@@ -79,7 +79,7 @@ sms.setCallback(msg_cb)#sms注册回调
 CAT1_SERVICE_HEAD = 'FE' #固定head 
 
 PROJECT_NAME = "Cat1SlipUDPService"
-PROJECT_VERSION = "PY_SRV_V27"
+PROJECT_VERSION = "PY_SRV_V28"
 CONFIG_JSON="/usr/system_config.json"
 CURRENT_APP_TYPE="pysrv"
 
index 07046df..d97f195 100644 (file)
@@ -131,6 +131,9 @@ static uint8_t g_msg_format_type = 0;
 // void watch_replay_cat1_ANSWER(void);
 void cat1_get_DEV_ID(void);
 
+uint8_t g_py_ver_new = 0;
+
+
 static char ble_buffer[20] = {0};
 
 static uint8_t g_flag_disable_cat1_cmd = 0;
@@ -150,6 +153,12 @@ void ble_get_cat1_at_msg(char *buffer,uint8_t len)
     memcpy_s(buffer,len,ble_buffer,strlen(ble_buffer));
 }
 
+
+void send_fota_url(char *buf)//发送VOLTE->CAT1
+{
+    udp_send_msg_toCat1(UDP_MSG_SEND_OTA,buf);
+}
+
 void send_ble_mac_toCat1(void)//发送BLE mac地址 to CAT1
 {
     errcode_t ret = 0;
@@ -1703,6 +1712,11 @@ static int udp_packet_parse(char *rx_buffer, int len)
            
                 restart_time_sync();
                 cat1_getsignal();
+
+                if(g_py_ver_new)
+                {
+                    g_py_ver_new=0;
+                }
                 
                 cat1_print_info("IMEI received, sending AT+ICCID command\n");
                 cat1_at_cmd("AT+ICCID");
index 302cbaa..11c599d 100644 (file)
@@ -1361,6 +1361,91 @@ char* xor_encrypt_decrypt(const char* message, const char* key) {
 }
 
 
+static uint8_t old_model_ver=0;
+
+extern uint8_t g_py_ver;
+
+extern uint8_t g_py_ver_new;
+
+static osTimerId_t modem_ota_timer=NULL;
+
+static uint16 mode_ota_count=0;
+
+
+static void  modem_ota_timer_CallBack(int data_tmp)
+{
+    if(old_model_ver!=g_py_ver)
+    {
+        uint8_t TRANSMIT_DATA=TRANS_FREE;
+        CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1);
+
+        if(modem_ota_timer){
+        osTimerStop(modem_ota_timer);
+        osTimerDelete(modem_ota_timer);
+        modem_ota_timer = NULL;
+    }
+
+    }
+    else
+    {
+        mode_ota_count++;
+        if(mode_ota_count>120 || g_py_ver_new==0)
+        {
+            uint8_t TRANSMIT_DATA=OTA_UPDATA_FAIL;
+            CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1);
+
+            if(modem_ota_timer){
+            osTimerStop(modem_ota_timer);
+            osTimerDelete(modem_ota_timer);
+            modem_ota_timer = NULL;
+            }
+        }
+    }
+}
+
+
+void start_mode_ota_timer()
+{
+    uint32_t tick;
+    osStatus_t retTimer;
+    if(modem_ota_timer == NULL){
+        modem_ota_timer = osTimerNew((osTimerFunc_t)modem_ota_timer_CallBack, osTimerPeriodic, NULL, NULL);
+        tick = 5000;// osMs2Tick(1000);
+        retTimer = osTimerStart(modem_ota_timer, tick);
+        if (retTimer != osOK && modem_ota_timer != NULL) {
+            cat1_print_err("StartCallTimer osTimerStart failed, ret = %lx!!", retTimer);
+            osTimerDelete(modem_ota_timer);
+            modem_ota_timer = NULL;
+        }
+    }
+
+}
+void star_http_ota_updata(char*buf_1,char* buf_2,uint8_t ver)
+{
+    int ret=0;
+    char * send_buf=(char *) malloc(strlen(buf_1)+strlen(buf_2)+40);
+    memset(send_buf,0,strlen(buf_1)+strlen(buf_2)+40);
+    
+    sprintf(send_buf,"%s and %s",buf_1,buf_2);
+    // sprintf(send_buf,"%s and %s","http://snicker.com.cn:8089/FD230/PY_SRV_V19/dfota_1.bin","http://snicker.com.cn:8089/FD230/PY_SRV_V19/dfota_2.bin");
+
+    uint8_t TRANSMIT_DATA=START_CAT1_OTA;
+                    
+    CustomEventPublish(TOPIC_EVENT_BLE_TRANSMIT,&TRANSMIT_DATA,1);
+
+
+    old_model_ver=ver;
+
+
+    send_fota_url(send_buf);
+
+    g_py_ver_new=1;
+
+    start_mode_ota_timer();
+
+    free(send_buf);
+}
+
 
 #ifdef __cplusplus