blob: e97b24c56c438beb1df56f1c5565e2e6557fd39d [file] [log] [blame]
LUOJian60136c32023-11-24 13:59:45 +08001#include <stdio.h>
2#include <string.h>
3#include <stdlib.h>
4#include <fcntl.h>
5#include "mbtk_audio.h"
6
7
8
9int fota_cb(int status, int percent)
10{
11 printf("status: %d, percent: %d%%\n", status, percent);
12 return 0;
13}
14
15int main(void)
16{
17 int cmdIdx = 0,i=0;
18 int ret = 0;
19 int type_path = 0;
20 char path[256] = {0};
21 char operator[10];
22 int opt = 0;
23
24
25 while(1)
26 {
27 printf("=========fota========2\n"
28 "\t 0 ql_fota_init\n"
29 "\t 1 ql_fota_fw_write_by_url\n"
30 "\t 2 ql_fota_fw_write\n"
31 "\t 3 ql_fota_done\n"
32 "\t 4 Close \n"
33 "=========================\n");
34
35 fflush(stdin);
36 fgets(operator, sizeof(operator), stdin);
37 opt = atoi(operator);
38
39 switch(opt)
40 {
41 case 0://"ql_fota_start"
42 {
43 ret = ql_fota_init(fota_cb);
44 if(ret)
45 {
46 printf("ql_fota_init failed, ret=%d\n", ret);
47 }
48
49 break;
50 }
51 case 1://"ql_fota_start"
52 {
53 printf("<** please input url path(http://118.114.239.159:30119/update.bin)**!>\n");
54 scanf("%s", path);
55
56 if(!strncasecmp(path, "ftp://", 6) || !strncasecmp(path, "http://", 7) || !strncasecmp(path, "https://", 8)) //url
57 {
58 ret = ql_fota_fw_write_by_url(path, 3*1024*1024, 10, 600);
59 if(ret)
60 {
61 printf("ql_fota_fw_write_by_url failed, ret=%d\n", ret);
62 break;
63 }
64 }
65
66 break;
67 }
68 case 2://"ql_fota_start"
69 {
70 printf("<** please input local path( /tmp/updata.bin)>\n");
71 scanf("%s", path);
72 ret = ql_fota_fw_write(path, 3*1024*1024);
73 if(ret)
74 {
75 printf("ql_fota_fw_write failed, ret=%d\n", ret);
76 }
77
78 break;
79 }
80 case 3://"ql_fota_start"
81 {
82 ret = ql_fota_done(1);
83 if(ret)
84 {
85 printf("ql_fota_done failed, ret=%d\n", ret);
86 break;
87 }
88 else
89 {
90 printf("download firmware success!\n");
91 }
92 break;
93 }
94 default://"ql_fota_start"
95 {
96 break;
97 }
98 }
99 }
100 return 0;
101}
102
103
104