LUOJian | 60136c3 | 2023-11-24 13:59:45 +0800 | [diff] [blame] | 1 | #include <stdio.h>
|
| 2 | #include <string.h>
|
| 3 | #include <stdlib.h>
|
| 4 | #include <fcntl.h>
|
| 5 | #include "mbtk_audio.h"
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 | int fota_cb(int status, int percent)
|
| 10 | {
|
| 11 | printf("status: %d, percent: %d%%\n", status, percent);
|
| 12 | return 0;
|
| 13 | }
|
| 14 |
|
| 15 | int 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");
|
LUOJian | 0959870 | 2023-12-14 13:58:42 +0800 | [diff] [blame^] | 54 |
|
| 55 | memcpy(path, "http://118.114.239.159:30119/update.bin", strlen("http://118.114.239.159:30119/update.bin"));
|
LUOJian | 60136c3 | 2023-11-24 13:59:45 +0800 | [diff] [blame] | 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 | {
|
LUOJian | 0959870 | 2023-12-14 13:58:42 +0800 | [diff] [blame^] | 70 | printf("<** please input local path( /NVM/updata.bin)>\n");
|
| 71 | ret = ql_fota_fw_write("/NVM/updata.bin", 3*1024*1024);
|
LUOJian | 60136c3 | 2023-11-24 13:59:45 +0800 | [diff] [blame] | 72 | if(ret)
|
| 73 | {
|
| 74 | printf("ql_fota_fw_write failed, ret=%d\n", ret);
|
LUOJian | 0959870 | 2023-12-14 13:58:42 +0800 | [diff] [blame^] | 75 | }else{
|
| 76 | printf("ql_fota_fw_write success ret £º%\n", ret);
|
LUOJian | 60136c3 | 2023-11-24 13:59:45 +0800 | [diff] [blame] | 77 | }
|
| 78 |
|
| 79 | break;
|
| 80 | }
|
| 81 | case 3://"ql_fota_start"
|
| 82 | {
|
| 83 | ret = ql_fota_done(1);
|
| 84 | if(ret)
|
| 85 | {
|
| 86 | printf("ql_fota_done failed, ret=%d\n", ret);
|
| 87 | break;
|
| 88 | }
|
| 89 | else
|
| 90 | {
|
| 91 | printf("download firmware success!\n");
|
| 92 | }
|
| 93 | break;
|
| 94 | }
|
| 95 | default://"ql_fota_start"
|
| 96 | {
|
LUOJian | 0959870 | 2023-12-14 13:58:42 +0800 | [diff] [blame^] | 97 | printf("break\n");
|
| 98 | return 0;
|
LUOJian | 60136c3 | 2023-11-24 13:59:45 +0800 | [diff] [blame] | 99 | }
|
| 100 | }
|
| 101 | }
|
| 102 | return 0;
|
| 103 | }
|
| 104 |
|
| 105 |
|
| 106 |
|