#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
//http://test.iot.api.thisiot.com/ota/task?deviceId=deviceId&sourceVersion=sourceVersion
static char *Path_ota_package= UPDATAFWPKGPATH;
static uint8_t uri_ota_package[256] ={0};
+ static const char *imei_str=NULL;
+ static char *report_jsonString=NULL;
+
+ static err_t httpc_download_headers_done_ui(httpc_state_t *connection, void *arg, struct pbuf *hdr, u16_t hdr_len, u32_t content_len)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "httpc_download_headers_done_ui");
+ return 0;
+ }
+
+ static void httpc_download_result_report_data(void *arg, httpc_result_t httpc_result, u32_t rx_content_len, u32_t srv_res, err_t err)
+ {
+ 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);
+ return ;
+ }
+
+ // // httpc_get_file(
+ // const ip_addr_t* server_addr,
+ // u16_t port,
+ // const char* uri,
+ // const httpc_connection_t *settings,
+ // // // altcp_recv_fn recv_fn,
+ // void* callback_arg, httpc_state_t **connection)
+
+ static void report_data_by_get_file(char *data,u16_t data_len)
+ {
+ settings.use_proxy=0;
+
+ settings.use_post=1;
+ settings.args=(u8_t*)data;
+ settings.arglen=data_len;
+ uint8_t *otadatapath =(uint8_t *)"/update/ota_report_.json";
+
+ settings.result_fn=httpc_download_result_report_data;
+
+ settings.headers_done_fn=httpc_download_headers_done_ui;
+
+ httpc_state_t* connection=NULL;
+ err_t rett= httpc_get_file_dns_to_disk(
+ HTTP_JSON_SERVER_NAME,
+ PORT,
+ POST_URL,
+ &settings,
+ NULL,
+ (const char*) otadatapath,
+ &connection);
+ PRINT("custom_start_ota_download %d \r\n",rett);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "use_post_");
+
+ }
void upgrade_reported_data(void)
{
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "");
FILE * fp = fopen(UPDATAREPORT,"rb+");
if(fp==NULL)
{
if(data!=NULL)
{
char *targetVersion=cJSON_GetObjectItem(data, "targetVersion")->valuestring;
+ char *taskId=cJSON_GetObjectItem(data, "updateId")->valuestring;
char version_buf[128]={0};
uint32_t version_len=128;
uapi_get_buildversion((uint8_t*)version_buf,version_len);
- if(strcmp(targetVersion,version_buf)==0)
- {
+ // if(strcmp(targetVersion,version_buf)==0)
+ // {
//HTTP_send_data
- }
+ cJSON* dataJSON=cJSON_CreateObject();
+ imei_str= const_cast<char*>(ConfigModel::GetInstance()->Getimei().c_str());
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",imei_str);
+
+ cJSON_AddStringToObject(dataJSON,"deviceId",imei_str);
+
+ cJSON_AddStringToObject(dataJSON,"companyId","");
+
+ cJSON_AddStringToObject(dataJSON,"createTime","");
+
+ cJSON_AddStringToObject(dataJSON,"id","");
+ if(strcmp(targetVersion,version_buf)==0)
+ {
+ cJSON_AddStringToObject(dataJSON,"result","1");
+ }
+ else
+ {
+ cJSON_AddStringToObject(dataJSON,"result","0");
+ }
+ cJSON_AddStringToObject(dataJSON,"taskId",taskId);
+ cJSON_AddStringToObject(dataJSON,"updateTime","");
+ buf = cJSON_PrintUnformatted(dataJSON);
+ cJSON_Delete(dataJSON);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",buf);
+ u16_t buf_len=strlen(buf);
+ report_data_by_get_file(buf,buf_len);
+
+ remove(UPDATAREPORT);
+
+ // }
}
cJSON_Delete(data);
}
cJSON *data=cJSON_GetObjectItem(root, "data");
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "");
- char *jsonString = cJSON_PrintUnformatted(data);
- uint32_t data_len=strlen(jsonString);
- FILE *FP_= fopen(UPDATAREPORT,"w+");
- fwrite(jsonString,1,data_len,FP_);
- fclose(FP_);
- printf("data%d %s\r\n",data_len,jsonString);
+ report_jsonString = cJSON_PrintUnformatted(data);
+
if(data!=NULL)
{
}
//static osTimerId_t upgrade_timer=NULL;
- static err_t httpc_download_headers_done_ui(httpc_state_t *connection, void *arg, struct pbuf *hdr, u16_t hdr_len, u32_t content_len)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "httpc_download_headers_done_ui");
- return 0;
- }
-
+
static uint32_t custom_start_ota_download_ui_1( uint8_t *uri_str,uint8_t *Path,bool falg,const char *server_name)
{
if(is_new_version)
{
//下载差分包
- //**********
+ // //**********
container_updating->SetVisible(true);
scrollView->SetTouchable(false);
scrollView->SetDraggable(false);
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "custom_start_ota_download_ui_1");
custom_start_ota_download_ui_1(uri_ota_package,(uint8_t*)Path_ota_package,false,HTTP_FWPGK_SERVER_NAME);
+ if(report_jsonString!=NULL)
+ {
+ uint32_t data_len=strlen(report_jsonString);
+ if(data_len!=0)
+ {
+ FILE *FP_= fopen(UPDATAREPORT,"w+");
+ fwrite(report_jsonString,1,data_len,FP_);
+ fclose(FP_);
+ printf("data%d %s\r\n",data_len,report_jsonString);
+ }
+
+ }
+
+
+ // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "");
+ // upgrade_reported_data();
}
}
}
- // char *imei_str= const_cast<char*>(ConfigModel::GetInstance()->Getimei().c_str());
+ // imei_str= const_cast<char*>(ConfigModel::GetInstance()->Getimei().c_str());
// char * version_buf=const_cast<char*>(ConfigModel::GetInstance()->GetmoderVer().c_str());
// sprintf((char *)uri,"https://test.app.api.thisiot.com/ota/task?deviceId=%s&sourceVersion=%s",imei_str,version_buf);
// custom_start_ota_download_ui_1(uri,(uint8_t*)Path,true);
}
display_api->set_screen_set_keepon_timeout(-1);
memset(uri,0,256);
- char *imei_str= const_cast<char*>(ConfigModel::GetInstance()->Getimei().c_str());
+ imei_str= const_cast<char*>(ConfigModel::GetInstance()->Getimei().c_str());
//https://test.app.api.thisiot.com/ota/task?deviceId=deviceId&sourceVersion=sourceVersion
// 860132060347507
// v1.1_20240419_152549
- sprintf((char *)uri,"http://test.iot.api.thisiot.com/ota/task?deviceId=%s&sourceVersion=%s",imei_str,"V1.1_20240422_161728");//version_buf);
+ sprintf((char *)uri,JSON_URL,imei_str,version_buf);//"V1.1_20240422_161728");//version_buf);
custom_start_ota_download_ui_1(uri,(uint8_t*)Path,true,HTTP_JSON_SERVER_NAME);
-
+ //report_data_by_get_file();
falg_dwon_json=0;
//uograde_service_service_init();