This commit is contained in:
wujiahao17 2024-08-20 19:50:05 +08:00
parent 50bb7a3f9f
commit ec2be17951
3 changed files with 11 additions and 79 deletions

View File

@ -15,37 +15,6 @@ static u8 OTA_DEVICE_TYPE_NAME[][30] = {
"sensor"//传感设备
};
//==============================================================================
// 功能JSON转义方法供AT指令使用的格式
// 参数:要转义的字符串
// 返回:转义后的字符(需要手动释放)
// =============================================================================
static u8 *escapeString(const char *input)
{
u32 len = strlen(input);
u8 *escaped = (char *)malloc(2 * len + 1); // 分配足够的空间来存储转义后的字符串
if (escaped == NULL)
{
printf("内存分配失败\n");
return NULL;
}
u32 j = 0;
for (u32 i = 0; i < len; i++)
{
if (input[i] == '\"' || input[i] == '\\')
{
escaped[j++] = '\\'; // 添加反斜杠
}
escaped[j++] = input[i];
}
escaped[j] = '\0'; // 添加字符串结束符
return escaped;
}
static void timerisr(struct Timer *timer)
{
printf("10秒到了");

View File

@ -293,7 +293,7 @@ bool_t OTA_HTTP_GetOTAFile(u8 *hashCode){
request.UrlLen = strlen(request.Url);
u32 requestTime;
for(requestTime = 0;requestTime < 3;requestTime ++){
wjh_TipChange("进行文件获取");
// wjh_TipChange("进行文件获取");
WifiHttpRequest(&request, CN_TIMEOUT_FOREVER);
if(request.RetDataLen == request.HttpRetDataLen && request.RetDataLen > 0){
wjh_TipChange("文件下载成功");
@ -307,13 +307,14 @@ bool_t OTA_HTTP_GetOTAFile(u8 *hashCode){
if(data != NULL){
if(dq_packNum == 0){
cJSON *total = cJSON_GetObjectItemCaseSensitive(data, "total");
packNum = 0;//统计有多少包
packNum = 0;
u8 *p = total->valuestring;
while(*p != '\0'){
while(*p != 0){
packNum *= 10;
packNum += (*p) - '0';
p ++;
}
// packNum = total->valueint;//统计有多少包
u8 zfc[80];
sprintf(zfc,"总共有%d个包",packNum);
wjh_TipChange(zfc);
@ -389,14 +390,19 @@ bool_t OTA_HTTP_GetOTAFile(u8 *hashCode){
//如果获取的包与总包数相同则进入OTA升级部分
if(packNum == dq_packNum){
wjh_TipChange("OTA升级中");
printf("准备进行OTA升级\r\n");
char ProductionTime[4] = {0, 1, 2, 3};
char ProductionNumber[5] = {4, 5, 6, 7, 8};
Iboot_SetOtaFilename(OTA_FILE_PATH, strlen(OTA_FILE_PATH) + 1);
WriteAppFromFile(ProductionTime, ProductionNumber);
wjh_TipChange("OTA升级成功");
runiboot("1");
}else{
wjh_TipChange("OTA升级失败");
printf("不进行OTA升级\r\n");
DJY_EventDelay(2000 * 1000);
wjh_TipDelete();
flag = false;
}
}else{

View File

@ -45,29 +45,8 @@
#include "wjh_OTAConfig.h"
#include "page.h"
bool_t Module_Paint(struct WindowMsg *pMsg){
HWND hwnd = pMsg->hwnd;
HDC hdc = GDD_BeginPaint(hwnd);
GDD_SetBackGroundColor(hdc,RGB(255,255,255));
GDD_CleanClient(hdc);
GDD_EndPaint(hwnd,hdc);
}
struct MsgProcTable s_gModule[] =
{
{.MsgCode = MSG_PAINT + MSG_ADOPT_NONE, .MsgProc = Module_Paint}, // 不继承父类的paint消息
{.MsgCode = MSG_TOUCH_DOWN + MSG_ADOPT_NONE, .MsgProc = NULL},
{.MsgCode = MSG_TOUCH_UP + MSG_ADOPT_NONE, .MsgProc = NULL},
{.MsgCode = MSG_TOUCH_MOVE + MSG_ADOPT_NONE, .MsgProc = NULL},
};
// 用户定义的消息链表
struct MsgTableLink Module =
{
.MsgNum = sizeof(s_gModule) / sizeof(struct MsgProcTable),
.myTable = (struct MsgProcTable *)&s_gModule,
};
ptu32_t djy_main(void)
{
@ -77,29 +56,7 @@ ptu32_t djy_main(void)
ModuleInstall_CharsetUtf8(NULL);
OTA_Initialize();
WinMainInitialize(GDD_GetDesktopWindow(NULL));
// struct stat fp_info;
// // 检查文件系统下是否存在升级文件存在删除
// if (stat(OTA_FILE_PATH, &fp_info) == 0)
// {
// remove(OTA_FILE_PATH);
// }
// FILE *pFile;
// pFile = fopen(OTA_FILE_PATH, "ab"); // 以ab标志末尾追加方式写入
// u32 Write_Size = fwrite(file_demo, 1,1133672, pFile);
// fclose(pFile);
//
// char ProductionTime[4] = {0, 1, 2, 3};
// char ProductionNumber[5] = {4, 5, 6, 7, 8};
// Iboot_SetOtaFilename(OTA_FILE_PATH, strlen(OTA_FILE_PATH) + 1);
// WriteAppFromFile(ProductionTime, ProductionNumber);
// runiboot("1");
// GDD_CreateWindow("窗口1",&Module,0,0,1024,600, CN_WINBUF_PARENT, 0, CN_SYS_PF_DISPLAY, RGB(255, 255, 255), 0, 0, GDD_GetDesktopWindow(NULL));
enter_to_page1();
while (1)
{