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 | 61ad917 | 2025-01-09 14:33:55 +0800 | [diff] [blame] | 3 | #include "mbtk_utils.h" |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 4 | |
b.liu | bb5e768 | 2024-02-28 20:13:04 +0800 | [diff] [blame] | 5 | #include "mbtk_device.h" |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 6 | |
b.liu | bb5e768 | 2024-02-28 20:13:04 +0800 | [diff] [blame] | 7 | |
| 8 | static char* band_2_str(mbtk_modem_band_area_enum band_area) |
| 9 | { |
| 10 | switch(band_area) |
| 11 | { |
| 12 | case MBTK_MODEM_BAND_AREA_CN: |
| 13 | return "CN"; |
| 14 | case MBTK_MODEM_BAND_AREA_EU: |
| 15 | return "EU"; |
b.liu | 288093c | 2024-05-09 17:02:57 +0800 | [diff] [blame] | 16 | case MBTK_MODEM_BAND_AREA_SA: |
| 17 | return "SA"; |
b.liu | bb5e768 | 2024-02-28 20:13:04 +0800 | [diff] [blame] | 18 | default: |
| 19 | return "ALL"; |
| 20 | } |
| 21 | } |
| 22 | |
b.liu | 61ad917 | 2025-01-09 14:33:55 +0800 | [diff] [blame] | 23 | static char* net_support_str_get(uint32 net_support) |
| 24 | { |
| 25 | static char net_str[100] = {0}; |
| 26 | |
| 27 | if(net_support & MBTK_NET_SUPPORT_2G) { // GSM |
| 28 | if(strlen(net_str) > 0) { |
| 29 | strcat(net_str, "/2G"); |
| 30 | } else { |
| 31 | strcat(net_str, "2G"); |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | if(net_support & MBTK_NET_SUPPORT_3G) { // WCDMA |
| 36 | if(strlen(net_str) > 0) { |
| 37 | strcat(net_str, "/3G"); |
| 38 | } else { |
| 39 | strcat(net_str, "3G"); |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | if(net_support & MBTK_NET_SUPPORT_4G) { // LTE |
| 44 | if(strlen(net_str) > 0) { |
| 45 | strcat(net_str, "/4G"); |
| 46 | } else { |
| 47 | strcat(net_str, "4G"); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | if(net_support & MBTK_NET_SUPPORT_5G) { // NR |
| 52 | if(strlen(net_str) > 0) { |
| 53 | strcat(net_str, "/5G"); |
| 54 | } else { |
| 55 | strcat(net_str, "5G"); |
| 56 | } |
| 57 | } |
| 58 | return net_str; |
| 59 | } |
| 60 | |
| 61 | static char* band_str_get(uint32 band, int index) |
| 62 | { |
| 63 | int band_list[33] = {0}; |
| 64 | int ret = mbtk_band_2_list(band, index, band_list); |
| 65 | if(ret > 0) { |
| 66 | static char buff[150] = {0}; |
| 67 | memset(buff, 0, sizeof(buff)); |
| 68 | int i = 0; |
| 69 | while(i < ret) { |
| 70 | if(strlen(buff) > 0) { |
| 71 | sprintf(buff + strlen(buff), "/b%d", band_list[i]); |
| 72 | } else { |
| 73 | sprintf(buff + strlen(buff), "b%d", band_list[i]); |
| 74 | } |
| 75 | i++; |
| 76 | } |
| 77 | return buff; |
| 78 | } else { |
| 79 | return "NON"; |
| 80 | } |
| 81 | } |
| 82 | |
b.liu | bb5e768 | 2024-02-28 20:13:04 +0800 | [diff] [blame] | 83 | int main(int argc, char *argv[]) |
| 84 | { |
| 85 | mbtk_device_info_basic_t info_basic; |
| 86 | memset(&info_basic, 0, sizeof(mbtk_device_info_basic_t)); |
| 87 | int result = mbtk_dev_info_read(MBTK_DEVICE_INFO_ITEM_BASIC, &info_basic, sizeof(mbtk_device_info_basic_t)); |
| 88 | if(result) { |
| 89 | printf("mbtk_dev_info_read(BASIC) fail.\n"); |
| 90 | return -1; |
| 91 | } |
| 92 | |
| 93 | /* |
| 94 | uint8 project[16]; // T108 / L508_X6 |
| 95 | uint8 project_cust[16]; // T108_C1 / L508_X6_C1 (Refer to: Custom_Model in blf file.) |
| 96 | uint32 ab_support; // 1 for ab |
| 97 | uint8 revision_out[48]; // L508_X6v01.01b04.00 |
| 98 | uint8 revision_in[64]; |
| 99 | */ |
| 100 | printf("Project:%s\n", info_basic.project); |
| 101 | printf("Custom_Model:%s\n", info_basic.project_cust); |
| 102 | printf("Revision_Out:%s\n", info_basic.revision_out); |
| 103 | printf("Revision_In:%s\n", info_basic.revision_in); |
b.liu | 96f2ced | 2024-08-29 18:40:34 +0800 | [diff] [blame] | 104 | printf("Build_Time:%s\n", info_basic.build_time); |
b.liu | bb5e768 | 2024-02-28 20:13:04 +0800 | [diff] [blame] | 105 | printf("AB System:%s\n", info_basic.ab_support ? "Yes" : "No"); |
b.liu | f678f99 | 2024-05-08 15:23:10 +0800 | [diff] [blame] | 106 | printf("Reboot flag:%d\n", info_basic.reboot_flag); |
b.liu | 166be48 | 2025-02-27 15:23:29 +0800 | [diff] [blame] | 107 | printf("ASR Baseline:%s\n", info_basic.asr_baseline); |
b.liu | bb5e768 | 2024-02-28 20:13:04 +0800 | [diff] [blame] | 108 | |
| 109 | mbtk_device_info_modem_t info_modem; |
| 110 | memset(&info_modem, 0, sizeof(mbtk_device_info_modem_t)); |
| 111 | result = mbtk_dev_info_read(MBTK_DEVICE_INFO_ITEM_MODEM, &info_modem, sizeof(mbtk_device_info_modem_t)); |
| 112 | if(result) { |
| 113 | printf("mbtk_dev_info_read(MODEM) fail.\n"); |
| 114 | return -1; |
| 115 | } |
| 116 | |
b.liu | 61ad917 | 2025-01-09 14:33:55 +0800 | [diff] [blame] | 117 | printf("net_pref:%d\n", info_modem.net_pref); |
| 118 | printf("net_support:%s\n", net_support_str_get(info_modem.net_support)); |
b.liu | bb5e768 | 2024-02-28 20:13:04 +0800 | [diff] [blame] | 119 | printf("Band:%s\n", band_2_str(info_modem.band_area)); |
b.liu | 61ad917 | 2025-01-09 14:33:55 +0800 | [diff] [blame] | 120 | printf("Band GSM:0x%08x(%s)\n", info_modem.band_gsm, band_str_get(info_modem.band_gsm, 0)); |
| 121 | printf("Band WCDMA:0x%08x(%s)\n", info_modem.band_wcdma, band_str_get(info_modem.band_wcdma, 0)); |
| 122 | printf("Band TDLTE:0x%08x(%s)\n", info_modem.band_tdlte, band_str_get(info_modem.band_tdlte, 1)); |
| 123 | printf("Band FDDLTE:0x%08x(%s)\n", info_modem.band_fddlte, band_str_get(info_modem.band_fddlte, 0)); |
| 124 | printf("Band EXT_LTE:0x%08x(%s)\n", info_modem.band_lte_ext, band_str_get(info_modem.band_lte_ext, 0)); |
| 125 | printf("Band NR_3:0x%08x(%s)\n", info_modem.band_nr_3, band_str_get(info_modem.band_nr_3, 3)); |
| 126 | printf("Band NR_2:0x%08x(%s)\n", info_modem.band_nr_2, band_str_get(info_modem.band_nr_2, 2)); |
| 127 | printf("Band NR_1:0x%08x(%s)\n", info_modem.band_nr_1, band_str_get(info_modem.band_nr_1, 1)); |
| 128 | printf("Band NR_0:0x%08x(%s)\n", info_modem.band_nr_0, band_str_get(info_modem.band_nr_0, 0)); |
b.liu | f2ea8bf | 2025-01-09 15:07:34 +0800 | [diff] [blame] | 129 | |
b.liu | bb5e768 | 2024-02-28 20:13:04 +0800 | [diff] [blame] | 130 | return 0; |
| 131 | } |
| 132 | |
| 133 | |