From: hcj <1224667075@qq.com> Date: Wed, 24 Apr 2024 02:57:17 +0000 (+0800) Subject: 添加开机升级自动上报升级结果 X-Git-Tag: release_V1.2.70_20241020_135402~1137^2~1 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=4334d6ac4dab9ba420afe585e41b23dbc07c93a9;p=mirrors%2FFD230.git 添加开机升级自动上报升级结果 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemModel.h b/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemModel.h index 4a7db4693..0ef20beb4 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemModel.h @@ -4,6 +4,7 @@ namespace OHOS { + int start_report_timer(void); class SystemModel { public: diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/include/Systemupgrade.h b/code/sdk/application/wearable/fd230app/nativeui/system/include/Systemupgrade.h index 6901e3433..6c2ab86de 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/include/Systemupgrade.h +++ b/code/sdk/application/wearable/fd230app/nativeui/system/include/Systemupgrade.h @@ -12,6 +12,20 @@ #include "components/ui_label_button_ext.h" #include "cat1_ctl.h" +#define HTTP_JSON_SERVER_NAME "test.iot.api.thisiot.com"//"test.app.api.thisiot.com"//获取升级服务器 +#define HTTP_FWPGK_SERVER_NAME "r-oss.thisiot.com"//"//升级包服务器 +#define PORT (80)//(443)//http端口号 +#define UPDATAJSONPATH "/update/ota_start_.json"//获取升级的得到的json + +#define UPDATAREPORT "/update/ota_start_reported_.json"//点升级后保存下来的json + +#define UPDATAFWPKGPATH "/update/update.fwpkg" //升级包 + +#define UPDATAREPORT_ "/update/ota_report_.json"//上报升级得到的json + +#define POST_URL "http://test.iot.api.thisiot.com/ota/update-result"//上报url +#define JSON_URL "http://test.iot.api.thisiot.com/ota/task?deviceId=%s&sourceVersion=%s"//获取升级url + namespace OHOS { typedef enum { diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemModel.cpp index b7c2261ea..127f06ca1 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemModel.cpp @@ -1,8 +1,89 @@ #include "system/include/SystemModel.h" +#include "system/include/Systemupgrade.h" +#include "wearable_log.h" +#include "UiConfig.h" +#include "custom_utils.h" +#include "stdio.h" +#include +#include +#include "cJSON.h" +#include "config/include/ConfigModel.h" +#include "lwip/err.h" +#include "power_display_service.h" +#include "cmsis_os2.h" +#include "los_memory.h" +#include "thread_init.h" + #include "lwip/apps/http_client.h" + #include "tcxo.h" + #include "cat1_server.h" + #include "linux/delay.h" + +#define UPDATAREPORT_M UPDATAREPORT namespace OHOS { + static void upgrade_report_task(void *arg) + { + FILE * fp = fopen(UPDATAREPORT_M,"rb+"); + bool falg=false; + if(fp!=NULL) + { + falg=true; + PRINT("UPDATAREPORT_M IS TRUE!\r\n"); + fclose(fp); + } + + while (falg) + { + + for(int i=0;i<60;i++) + { + msleep(1000); + } + if(ConfigModel::GetInstance()->GetCat1_4Gability()) + { + upgrade_reported_data(); + } + for(int i=0;i<60;i++) + { + msleep(1000); + } + fp = fopen(UPDATAREPORT_M,"rb+"); + if(fp!=NULL) + { + falg=true; + fclose(fp); + } + else + { + falg=false; + } + } + PRINT("UPDATAREPORT IS OK!\r\n"); + } + + int start_report_timer(void) + { + PRINT("uapi_upgrade_service_init !\r\n"); + app_task_definition_t taskcfg={0}; + taskcfg.create_queue_handle = NULL; + taskcfg.attr.name="report_upgrade_service"; + taskcfg.attr.priority = TASK_PRIORITY_APP; + taskcfg.attr.stack_size = 1024*4; + taskcfg.func = upgrade_report_task; + taskcfg.use_mem = USE_EXTEND_MEM; + + errcode_t ret=uapi_create_osThread_custom(&taskcfg); + if(ret != ERRCODE_SUCC) + { + PRINT("create uapi_upgrade_service_init failed %d!\r\n",ret); + return ERRCODE_FAIL; + } + + return ERRCODE_SUCC; + + } SystemModel *SystemModel::GetInstance(void) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/src/Systemupgrade.cpp b/code/sdk/application/wearable/fd230app/nativeui/system/src/Systemupgrade.cpp index a33224958..28accae7a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/src/Systemupgrade.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/system/src/Systemupgrade.cpp @@ -18,17 +18,7 @@ #include "cat1_server.h" #include "linux/delay.h" -#define HTTP_JSON_SERVER_NAME "test.iot.api.thisiot.com"//"test.app.api.thisiot.com" -#define HTTP_FWPGK_SERVER_NAME "r-oss.thisiot.com"//" -#define PORT (80)//(443) -#define UPDATAJSONPATH "/update/ota_start_.json" -#define UPDATAREPORT "/update/ota_start_reported_.json" - -#define UPDATAFWPKGPATH "/update/update.fwpkg" - -#define POST_URL "http://test.iot.api.thisiot.com/ota/update-result" -#define JSON_URL "http://test.iot.api.thisiot.com/ota/task?deviceId=%s&sourceVersion=%s" //https://test.app.api.thisiot.com/ota/task?deviceId=deviceId&sourceVersion=sourceVersion @@ -64,10 +54,15 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "httpc_download_result_ui"); PRINT("httpc_download_result , httpc_result_t %d, rx_content_len %d , srv_res %d, err %d\n", httpc_result,rx_content_len,srv_res,err); + if(srv_res==200 && err==0) + remove(UPDATAREPORT); + return ; } + + - + // // httpc_get_file( // const ip_addr_t* server_addr, // u16_t port, @@ -83,7 +78,7 @@ namespace OHOS settings.use_post=1; settings.args=(u8_t*)data; settings.arglen=data_len; - uint8_t *otadatapath =(uint8_t *)"/update/ota_report_.json"; + uint8_t *otadatapath =(uint8_t *)UPDATAREPORT_; settings.result_fn=httpc_download_result_report_data; @@ -169,8 +164,7 @@ namespace OHOS u16_t buf_len=strlen(buf); report_data_by_get_file(buf,buf_len); - remove(UPDATAREPORT); - + // } } cJSON_Delete(data); @@ -594,7 +588,7 @@ namespace OHOS if(is_new_version) { //下载差分包 - // //********** + // // //********** container_updating->SetVisible(true); scrollView->SetTouchable(false); scrollView->SetDraggable(false); @@ -606,6 +600,7 @@ namespace OHOS if(data_len!=0) { FILE *FP_= fopen(UPDATAREPORT,"w+"); + printf("升级文件保存\r\n"); fwrite(report_jsonString,1,data_len,FP_); fclose(FP_); printf("data%d %s\r\n",data_len,report_jsonString); diff --git a/code/sdk/drivers/peripheral/slip/cat1Service/CMakeLists.txt b/code/sdk/drivers/peripheral/slip/cat1Service/CMakeLists.txt index 76f2702fc..be64061ae 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/CMakeLists.txt +++ b/code/sdk/drivers/peripheral/slip/cat1Service/CMakeLists.txt @@ -13,6 +13,7 @@ set(PRIVATE_HEADER ${ROOT_DIR}/middleware/services/gui/uikit/utils/interfaces/kits ${ROOT_DIR}/application/wearable/nativeapp/nativeui/heartrate/include ${ROOT_DIR}/application/wearable/fd230app/nativeui/phone/include + ${ROOT_DIR}/application/wearable/fd230app/nativeui/system/include ) set(SOURCES diff --git a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server_hal.cpp b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server_hal.cpp index 7a441780f..090a022bc 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server_hal.cpp +++ b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server_hal.cpp @@ -17,7 +17,7 @@ #include "samgr_lite.h" #include "thread_adapter.h" #include "graphic_service.h" - +#include "SystemModel.h" #ifdef __cplusplus extern "C" { @@ -150,6 +150,11 @@ int cat1_msg_event_sendmsg_toUI(char* callno) return ERRCODE_SUCC; } +void up_report_timer(void) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "up_report_timer_"); + OHOS::start_report_timer(); +} diff --git a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server_hal.h b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server_hal.h index 6cdc82a18..4c5290b6b 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server_hal.h +++ b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server_hal.h @@ -19,6 +19,7 @@ int callend_event_sendmsg_toUI(char* callno); int incomingcall_event_sendmsg_toUI(char* callno); int calldial_event_sendmsg_toUI(char* callno); int cat1_msg_event_sendmsg_toUI(char* callno); +void up_report_timer(void); #ifdef __cplusplus #if __cplusplus } diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.c b/code/sdk/drivers/peripheral/utils/custom_utils.c index d430101a2..e30ed72db 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -229,6 +229,7 @@ void startup_post_init_task(void) LOS_Msleep(5000); addressbookToRead(NULL); + up_report_timer(); if ( poweron_cat1_on_bootup_flag() ) { PRINT("PowerOn Cat1 !\r\n"); diff --git a/code/sdk/open_source/openharmony/third_party/lwip/src/include/lwip/apps/http_client.h b/code/sdk/open_source/openharmony/third_party/lwip/src/include/lwip/apps/http_client.h index d7dc9f233..29667e047 100644 --- a/code/sdk/open_source/openharmony/third_party/lwip/src/include/lwip/apps/http_client.h +++ b/code/sdk/open_source/openharmony/third_party/lwip/src/include/lwip/apps/http_client.h @@ -140,7 +140,7 @@ typedef struct _httpc_connection { //添加post u8_t use_post; - u8_t arglen; + u16_t arglen; u8_t* args;