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