#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <fcntl.h> | |
#include "mbtk_audio.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 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"); | |
scanf("%s", path); | |
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( /tmp/updata.bin)>\n"); | |
scanf("%s", path); | |
ret = ql_fota_fw_write(path, 3*1024*1024); | |
if(ret) | |
{ | |
printf("ql_fota_fw_write failed, ret=%d\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" | |
{ | |
break; | |
} | |
} | |
} | |
return 0; | |
} | |