#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <fcntl.h> | |
#include "lynq-qser-fota.h" | |
int fota_cb(int status, int percent) | |
{ | |
printf("status: %d, percent: %d%%\n", status, percent); | |
return 0; | |
} | |
int main(void) | |
{ | |
int cmdIdx = 0,i=0; | |
int ret = 0; | |
int type_path = 0; | |
char path[256] = {0}; | |
char operator[10]; | |
int opt = 0; | |
while(1) | |
{ | |
printf("=========fota========2\n" | |
"\t 0 lynq_fota_set_addr_value\n" | |
"\t 1 lynq_rock_main\n" | |
"\t 2 lynq_fota_nrestart\n" | |
"\t 3 lynq_get_upgrade_status\n" | |
"\t 4 Close \n" | |
"=========================\n"); | |
fflush(stdin); | |
fgets(operator, sizeof(operator), stdin); | |
opt = atoi(operator); | |
switch(opt) | |
{ | |
case 0://"ql_fota_start" | |
{ | |
ret = lynq_fota_set_addr_value("/tmp/updata.bin", 26976256); | |
if(ret) | |
{ | |
printf("lynq_fota_set_addr_value failed, ret=%d\n", ret); | |
} | |
break; | |
} | |
case 1://"ql_fota_start" | |
{ | |
ret = lynq_rock_main(1); | |
printf("lynq_rock_main() ret:%d!\n", ret); | |
break; | |
} | |
case 2://"ql_fota_start" | |
{ | |
ret = lynq_fota_nrestart(); | |
printf("lynq_fota_nrestart() ret:%d!\n", ret); | |
break; | |
} | |
case 3://"ql_fota_start" | |
{ | |
ret = lynq_get_upgrade_status(); | |
printf("lynq_get_upgrade_status() ret:%d!\n", ret); | |
break; | |
} | |
default://"ql_fota_start" | |
{ | |
printf("break\n"); | |
return 0; | |
} | |
} | |
} | |
return 0; | |
} | |
int main_1(void) | |
{ | |
int cmdIdx = 0,i=0; | |
int ret = 0; | |
int type_path = 0; | |
char path[256] = {0}; | |
char operator[10]; | |
int opt = 0; | |
while(1) | |
{ | |
printf("=========fota========2\n" | |
"\t 0 ql_fota_init\n" | |
"\t 1 ql_fota_fw_write_by_url\n" | |
"\t 2 ql_fota_fw_write\n" | |
"\t 3 ql_fota_done\n" | |
"\t 4 Close \n" | |
"=========================\n"); | |
fflush(stdin); | |
fgets(operator, sizeof(operator), stdin); | |
opt = atoi(operator); | |
switch(opt) | |
{ | |
case 0://"ql_fota_start" | |
{ | |
ret = ql_fota_init(fota_cb); | |
if(ret) | |
{ | |
printf("ql_fota_init failed, ret=%d\n", ret); | |
} | |
break; | |
} | |
case 1://"ql_fota_start" | |
{ | |
printf("<** please input url path(http://118.114.239.159:30119/update.bin)**!>\n"); | |
memcpy(path, "http://118.114.239.159:30119/update.bin", strlen("http://118.114.239.159:30119/update.bin")); | |
if(!strncasecmp(path, "ftp://", 6) || !strncasecmp(path, "http://", 7) || !strncasecmp(path, "https://", 8)) //url | |
{ | |
ret = ql_fota_fw_write_by_url(path, 3*1024*1024, 10, 600); | |
if(ret) | |
{ | |
printf("ql_fota_fw_write_by_url failed, ret=%d\n", ret); | |
break; | |
} | |
} | |
break; | |
} | |
case 2://"ql_fota_start" | |
{ | |
printf("<** please input local path( /NVM/updata.bin)>\n"); | |
ret = ql_fota_fw_write("/NVM/updata.bin", 3*1024*1024); | |
if(ret) | |
{ | |
printf("ql_fota_fw_write failed, ret=%d\n", ret); | |
}else{ | |
printf("ql_fota_fw_write success ret £º%\n", ret); | |
} | |
break; | |
} | |
case 3://"ql_fota_start" | |
{ | |
ret = ql_fota_done(1); | |
if(ret) | |
{ | |
printf("ql_fota_done failed, ret=%d\n", ret); | |
break; | |
} | |
else | |
{ | |
printf("download firmware success!\n"); | |
} | |
break; | |
} | |
default://"ql_fota_start" | |
{ | |
printf("break\n"); | |
return 0; | |
} | |
} | |
} | |
return 0; | |
} | |