b.liu | 9e8584b | 2024-11-06 19:21:28 +0800 | [diff] [blame] | 1 | #include <string.h> |
b.liu | f678f99 | 2024-05-08 15:23:10 +0800 | [diff] [blame] | 2 | #include "mbtk_type.h" |
b.liu | 9f91db3 | 2025-02-13 11:24:18 +0800 | [diff] [blame] | 3 | |
b.liu | f678f99 | 2024-05-08 15:23:10 +0800 | [diff] [blame] | 4 | #include "mbtk_device.h" |
b.liu | 9e8584b | 2024-11-06 19:21:28 +0800 | [diff] [blame] | 5 | #include "mbtk_utils.h" |
| 6 | #if 0 |
b.liu | f678f99 | 2024-05-08 15:23:10 +0800 | [diff] [blame] | 7 | static char* band_2_str(mbtk_modem_band_area_enum band_area) |
| 8 | { |
| 9 | switch(band_area) |
| 10 | { |
| 11 | case MBTK_MODEM_BAND_AREA_CN: |
| 12 | return "CN"; |
| 13 | case MBTK_MODEM_BAND_AREA_EU: |
| 14 | return "EU"; |
| 15 | default: |
| 16 | return "ALL"; |
| 17 | } |
| 18 | } |
b.liu | 9e8584b | 2024-11-06 19:21:28 +0800 | [diff] [blame] | 19 | #endif |
b.liu | f678f99 | 2024-05-08 15:23:10 +0800 | [diff] [blame] | 20 | |
| 21 | static void help() |
| 22 | { |
| 23 | printf("mbtk_reboot [download]\n"); |
| 24 | } |
| 25 | |
| 26 | int main(int argc, char *argv[]) |
| 27 | { |
| 28 | if(argc == 1) { |
b.liu | 9e8584b | 2024-11-06 19:21:28 +0800 | [diff] [blame] | 29 | mbtk_system("reboot -f"); |
b.liu | f678f99 | 2024-05-08 15:23:10 +0800 | [diff] [blame] | 30 | } else if(argc == 2) { |
| 31 | if(strcmp(argv[1], "download")) { |
| 32 | help(); |
| 33 | return 0; |
| 34 | } |
| 35 | } else { |
| 36 | help(); |
| 37 | return 0; |
| 38 | } |
| 39 | |
| 40 | mbtk_device_info_basic_t info_basic; |
| 41 | memset(&info_basic, 0, sizeof(mbtk_device_info_basic_t)); |
| 42 | int result = mbtk_dev_info_read(MBTK_DEVICE_INFO_ITEM_BASIC, &info_basic, sizeof(mbtk_device_info_basic_t)); |
| 43 | if(result) { |
| 44 | printf("mbtk_dev_info_read(BASIC) fail.\n"); |
| 45 | return -1; |
| 46 | } |
| 47 | |
b.liu | b7530d2 | 2025-06-16 19:49:05 +0800 | [diff] [blame] | 48 | if(info_basic.version == DEV_INFO_VERSION_V1) { |
| 49 | info_basic.basic.v1.reboot_flag = MBTK_REBOOT_FLAG_DOWNLOAD; |
| 50 | } else { |
| 51 | info_basic.basic.v2.reboot_flag = MBTK_REBOOT_FLAG_DOWNLOAD; |
| 52 | } |
b.liu | f678f99 | 2024-05-08 15:23:10 +0800 | [diff] [blame] | 53 | result = mbtk_dev_info_write(MBTK_DEVICE_INFO_ITEM_BASIC, &info_basic, sizeof(mbtk_device_info_basic_t)); |
| 54 | if(result) { |
| 55 | printf("mbtk_dev_info_write(BASIC) fail.\n"); |
| 56 | return -1; |
| 57 | } |
| 58 | |
b.liu | 9e8584b | 2024-11-06 19:21:28 +0800 | [diff] [blame] | 59 | mbtk_system("sync"); |
| 60 | mbtk_system("reboot -f"); |
b.liu | f678f99 | 2024-05-08 15:23:10 +0800 | [diff] [blame] | 61 | |
| 62 | return 0; |
| 63 | } |
| 64 | |
| 65 | |