b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | #include <unistd.h> |
| 4 | #include <errno.h> |
| 5 | #include <sys/socket.h> |
| 6 | #include <sys/un.h> |
| 7 | #include <netinet/in.h> |
| 8 | #include <pthread.h> |
| 9 | #include <sys/epoll.h> |
| 10 | #include <fcntl.h> |
| 11 | #include <signal.h> |
| 12 | #include <cutils/properties.h> |
| 13 | #include <arpa/inet.h> |
| 14 | |
| 15 | #include "mbtk_type.h" |
| 16 | #include "mbtk_ril.h" |
| 17 | #include "atchannel.h" |
| 18 | #include "at_tok.h" |
| 19 | #include "mbtk_utils.h" |
| 20 | #include "ril_info.h" |
| 21 | #include "mbtk_str.h" |
| 22 | |
b.liu | b477207 | 2024-08-15 14:47:03 +0800 | [diff] [blame] | 23 | mbtk_cell_pack_info_t cell_info; |
| 24 | |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 25 | extern ril_band_info_t band_info; |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 26 | void ril_rsp_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len); |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 27 | |
| 28 | /* |
| 29 | AT+COPS=? |
| 30 | |
| 31 | +COPS: (2, "CHN-CT", "CT", "46011", 7),(3, "CHN-UNICOM", "UNICOM", "46001", 7),(3, "CHINA MOBILE", "CMCC", "46000", 0),(3, "CHINA MOBILE", "CMCC", "46000", 7),(3, "China Broadnet", "CBN", "46015", 7),,(0,1,2,3,4),(0,1,2) |
| 32 | |
| 33 | OK |
| 34 | */ |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 35 | static int req_available_net_get(ATPortType_enum port, mbtk_net_info_array_t* nets, int *cme_err) |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 36 | { |
| 37 | ATResponse *response = NULL; |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 38 | int err = at_send_command_singleline(port, "AT+COPS=?", "+COPS:", &response); |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 39 | |
| 40 | if (err < 0 || response->success == 0 || !response->p_intermediates){ |
| 41 | if(cme_err) { |
| 42 | *cme_err = at_get_cme_error(response); |
| 43 | } |
| 44 | goto exit; |
| 45 | } |
| 46 | char *line_ptr = response->p_intermediates->line; |
| 47 | if(line_ptr == NULL) { |
| 48 | LOG("line is NULL"); |
| 49 | err = -1; |
| 50 | goto exit; |
| 51 | } |
| 52 | //LOG("Line:%s",line_ptr); |
| 53 | line_ptr = strstr(line_ptr, "("); |
| 54 | while(line_ptr) { |
| 55 | line_ptr++; |
| 56 | // Only for available/current net. |
| 57 | if(*line_ptr == '1' || *line_ptr == '2' || *line_ptr == '3') { |
| 58 | nets->net_info[nets->num].net_state = (uint8)atoi(line_ptr); // net_state |
| 59 | |
| 60 | line_ptr = strstr(line_ptr, ","); |
| 61 | if(line_ptr == NULL) { |
| 62 | err = -1; |
| 63 | goto exit; |
| 64 | } |
| 65 | line_ptr++; |
| 66 | |
| 67 | line_ptr = strstr(line_ptr, ","); |
| 68 | if(line_ptr == NULL) { |
| 69 | err = -1; |
| 70 | goto exit; |
| 71 | } |
| 72 | line_ptr++; |
| 73 | |
| 74 | line_ptr = strstr(line_ptr, ","); |
| 75 | if(line_ptr == NULL) { |
| 76 | err = -1; |
| 77 | goto exit; |
| 78 | } |
| 79 | |
| 80 | while(*line_ptr != '\0' && (*line_ptr == ',' || *line_ptr == ' ' || *line_ptr == '"')) |
| 81 | line_ptr++; |
| 82 | |
| 83 | // set sel_mode to 0 |
| 84 | nets->net_info[nets->num].net_sel_mode = (uint8)0; |
| 85 | // Point to "46000" |
| 86 | //LOG("PLMN:%s",line_ptr); |
| 87 | //sleep(1); |
| 88 | //uint32_2_byte((uint32)atoi(line_ptr), buff_ptr + 3, false); // plmn |
| 89 | nets->net_info[nets->num].plmn = (uint32)atoi(line_ptr); |
| 90 | |
| 91 | line_ptr = strstr(line_ptr, ","); |
| 92 | if(line_ptr == NULL) { |
| 93 | err = -1; |
| 94 | goto exit; |
| 95 | } |
| 96 | |
| 97 | while(*line_ptr != '\0' && (*line_ptr == ',' || *line_ptr == ' ')) |
| 98 | line_ptr++; |
| 99 | |
| 100 | // Point to "7" |
| 101 | if(*line_ptr == '\0') { |
| 102 | err = -1; |
| 103 | goto exit; |
| 104 | } |
| 105 | //LOG("Type:%s",line_ptr); |
| 106 | //sleep(1); |
| 107 | nets->net_info[nets->num].net_type = (uint8)atoi(line_ptr); // net_type |
| 108 | |
| 109 | nets->num++; |
| 110 | } |
| 111 | |
| 112 | line_ptr = strstr(line_ptr, "("); |
| 113 | } |
| 114 | exit: |
| 115 | at_response_free(response); |
| 116 | return err; |
| 117 | } |
| 118 | |
| 119 | /* |
| 120 | AT+COPS? |
| 121 | +COPS: 1 |
| 122 | |
| 123 | OK |
| 124 | |
| 125 | or |
| 126 | |
| 127 | AT+COPS? |
| 128 | +COPS: 0,2,"46001",7 |
| 129 | |
| 130 | OK |
| 131 | |
| 132 | */ |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 133 | static int req_net_sel_mode_get(ATPortType_enum port, mbtk_net_info_t *net, int *cme_err) |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 134 | { |
| 135 | //LOG("req_net_sel_mode_get() 0"); |
| 136 | //sleep(1); |
| 137 | ATResponse *response = NULL; |
| 138 | int tmp_int; |
| 139 | char *tmp_ptr = NULL; |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 140 | int err = at_send_command_singleline(port, "AT+COPS?", "+COPS:", &response); |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 141 | //LOG("req_net_sel_mode_get() 00"); |
| 142 | //sleep(1); |
| 143 | if (err < 0 || response->success == 0 || !response->p_intermediates){ |
| 144 | if(cme_err != NULL) |
| 145 | *cme_err = at_get_cme_error(response); |
| 146 | err = -1; |
| 147 | goto exit; |
| 148 | } |
| 149 | //LOG("req_net_sel_mode_get() 1"); |
| 150 | //sleep(1); |
| 151 | char *line = response->p_intermediates->line; |
| 152 | if(line == NULL) { |
| 153 | LOG("line is NULL"); |
| 154 | goto exit; |
| 155 | } |
| 156 | //LOG("req_net_sel_mode_get() 2"); |
| 157 | //sleep(1); |
| 158 | err = at_tok_start(&line); |
| 159 | if (err < 0) |
| 160 | { |
| 161 | goto exit; |
| 162 | } |
| 163 | //LOG("req_net_sel_mode_get() 3"); |
| 164 | //sleep(1); |
| 165 | err = at_tok_nextint(&line, &tmp_int); |
| 166 | if (err < 0) |
| 167 | { |
| 168 | goto exit; |
| 169 | } |
| 170 | net->net_sel_mode = (uint8)tmp_int; |
| 171 | //LOG("req_net_sel_mode_get() 4"); |
| 172 | //sleep(1); |
| 173 | // +COPS: 1 |
| 174 | if(!at_tok_hasmore(&line)) { |
| 175 | goto exit; |
| 176 | } |
| 177 | //LOG("req_net_sel_mode_get() 5"); |
| 178 | //sleep(1); |
| 179 | err = at_tok_nextint(&line, &tmp_int); |
| 180 | if (err < 0) |
| 181 | { |
| 182 | goto exit; |
| 183 | } |
| 184 | //LOG("req_net_sel_mode_get() 6"); |
| 185 | //sleep(1); |
| 186 | err = at_tok_nextstr(&line, &tmp_ptr); |
| 187 | if (err < 0) |
| 188 | { |
| 189 | goto exit; |
| 190 | } |
| 191 | // memcpy(net->plmn, tmp_ptr, strlen(tmp_ptr)); |
| 192 | net->plmn = (uint32)atoi(tmp_ptr); |
| 193 | //LOG("req_net_sel_mode_get() 7"); |
| 194 | //sleep(1); |
| 195 | err = at_tok_nextint(&line, &tmp_int); |
| 196 | if (err < 0) |
| 197 | { |
| 198 | goto exit; |
| 199 | } |
| 200 | net->net_type = (uint8)tmp_int; |
| 201 | |
| 202 | net->net_state = (uint8)MBTK_NET_AVIL_STATE_CURRENT; |
| 203 | |
| 204 | exit: |
| 205 | //LOG("req_net_sel_mode_get() 8"); |
| 206 | //sleep(1); |
| 207 | at_response_free(response); |
| 208 | return err; |
| 209 | } |
| 210 | |
| 211 | /* |
| 212 | AT+COPS=0 |
| 213 | or |
| 214 | AT+COPS=1,2,"46000",7 |
| 215 | |
| 216 | OK |
| 217 | |
| 218 | */ |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 219 | static int req_net_sel_mode_set(ATPortType_enum port, mbtk_net_info_t* net, int *cme_err) |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 220 | { |
| 221 | ATResponse *response = NULL; |
| 222 | char cmd[50] = {0}; |
| 223 | char* cmp_ptr = cmd; |
| 224 | if(net == NULL) { |
| 225 | cmp_ptr += sprintf(cmp_ptr, "AT+COPS=0"); |
| 226 | } else { |
| 227 | if(net->net_sel_mode == 0) { |
| 228 | cmp_ptr += sprintf(cmp_ptr, "AT+COPS=0"); |
| 229 | } else if(net->net_type == 0xFF) { |
| 230 | cmp_ptr += sprintf(cmp_ptr, "AT+COPS=1,2,\"%d\"",net->plmn); |
| 231 | } else { |
| 232 | cmp_ptr += sprintf(cmp_ptr, "AT+COPS=1,2,\"%d\",%d",net->plmn, net->net_type); |
| 233 | } |
| 234 | } |
| 235 | |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 236 | int err = at_send_command(port, cmd, &response); |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 237 | |
| 238 | if (err < 0 || response->success == 0) { |
| 239 | if(cme_err) { |
| 240 | *cme_err = at_get_cme_error(response); |
| 241 | } |
| 242 | goto exit; |
| 243 | } |
| 244 | |
| 245 | exit: |
| 246 | at_response_free(response); |
| 247 | return err; |
| 248 | } |
| 249 | |
| 250 | /* |
| 251 | AT*BAND=15 |
| 252 | OK |
| 253 | |
| 254 | */ |
b.liu | 472cfaf | 2024-12-19 19:08:19 +0800 | [diff] [blame] | 255 | int req_band_set(ATPortType_enum port, mbtk_band_info_t* band, int *cme_err) |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 256 | { |
| 257 | ATResponse *response = NULL; |
| 258 | char cmd[100] = {0}; |
| 259 | int err = -1; |
| 260 | |
| 261 | if(band->gsm_band == 0 && band->umts_band == 0 |
b.liu | 61ad917 | 2025-01-09 14:33:55 +0800 | [diff] [blame] | 262 | && band->tdlte_band == 0 && band->fddlte_band == 0 && band->lte_ext_band == 0 |
b.liu | 571445f | 2025-02-13 10:22:55 +0800 | [diff] [blame^] | 263 | #ifdef MBTK_DEV_INFO_VERSION_2 |
b.liu | 61ad917 | 2025-01-09 14:33:55 +0800 | [diff] [blame] | 264 | && band->nr_3_band == 0 && band->nr_2_band == 0 |
b.liu | bea31eb | 2025-01-09 15:17:12 +0800 | [diff] [blame] | 265 | && band->nr_1_band == 0 && band->nr_0_band == 0 |
b.liu | 571445f | 2025-02-13 10:22:55 +0800 | [diff] [blame^] | 266 | #endif |
b.liu | bea31eb | 2025-01-09 15:17:12 +0800 | [diff] [blame] | 267 | ) { |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 268 | sprintf(cmd, "AT*BAND=%d", band->net_pref); |
| 269 | } else { |
| 270 | log_hex("BAND_SUPPORT", &band_info.band_support, sizeof(mbtk_band_info_t)); |
| 271 | log_hex("BAND", band, sizeof(mbtk_band_info_t)); |
| 272 | |
b.liu | 571445f | 2025-02-13 10:22:55 +0800 | [diff] [blame^] | 273 | if(band->gsm_band == 0) { |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 274 | band->gsm_band = band_info.band_support.gsm_band; |
| 275 | } |
b.liu | 571445f | 2025-02-13 10:22:55 +0800 | [diff] [blame^] | 276 | if(band->umts_band == 0) { |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 277 | band->umts_band = band_info.band_support.umts_band; |
| 278 | } |
b.liu | 571445f | 2025-02-13 10:22:55 +0800 | [diff] [blame^] | 279 | if(band->tdlte_band == 0) { |
| 280 | band->tdlte_band = band_info.band_support.tdlte_band; |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 281 | } |
b.liu | 571445f | 2025-02-13 10:22:55 +0800 | [diff] [blame^] | 282 | if(band->fddlte_band == 0) { |
| 283 | band->fddlte_band = band_info.band_support.fddlte_band; |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 284 | } |
b.liu | 571445f | 2025-02-13 10:22:55 +0800 | [diff] [blame^] | 285 | if(band->lte_ext_band == 0) { |
| 286 | band->lte_ext_band = band_info.band_support.lte_ext_band; |
| 287 | } |
| 288 | #ifdef MBTK_DEV_INFO_VERSION_2 |
| 289 | if(band->nr_3_band == 0) { |
| 290 | band->nr_3_band = band_info.band_support.nr_3_band; |
| 291 | } |
| 292 | if(band->nr_2_band == 0) { |
| 293 | band->nr_2_band = band_info.band_support.nr_2_band; |
| 294 | } |
| 295 | if(band->nr_1_band == 0) { |
| 296 | band->nr_1_band = band_info.band_support.nr_1_band; |
| 297 | } |
| 298 | if(band->nr_0_band == 0) { |
| 299 | band->nr_0_band = band_info.band_support.nr_0_band; |
| 300 | } |
| 301 | #endif |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 302 | if((band->gsm_band & band_info.band_support.gsm_band) != band->gsm_band) { |
| 303 | LOG("GSM band error."); |
| 304 | goto exit; |
| 305 | } |
| 306 | |
| 307 | if((band->umts_band & band_info.band_support.umts_band) != band->umts_band) { |
| 308 | LOG("UMTS band error."); |
| 309 | goto exit; |
| 310 | } |
| 311 | |
| 312 | if((band->tdlte_band & band_info.band_support.tdlte_band) != band->tdlte_band) { |
| 313 | LOG("TDLTE band error."); |
| 314 | goto exit; |
| 315 | } |
| 316 | |
| 317 | if((band->fddlte_band & band_info.band_support.fddlte_band) != band->fddlte_band) { |
| 318 | LOG("FDDLTE band error."); |
| 319 | goto exit; |
| 320 | } |
| 321 | |
| 322 | if((band->lte_ext_band & band_info.band_support.lte_ext_band) != band->lte_ext_band) { |
| 323 | LOG("EXT_LTE band error."); |
| 324 | goto exit; |
| 325 | } |
b.liu | 571445f | 2025-02-13 10:22:55 +0800 | [diff] [blame^] | 326 | #ifdef MBTK_DEV_INFO_VERSION_2 |
b.liu | 61ad917 | 2025-01-09 14:33:55 +0800 | [diff] [blame] | 327 | if((band->nr_3_band & band_info.band_support.nr_3_band) != band->nr_3_band) { |
| 328 | LOG("nr_3_band band error."); |
| 329 | goto exit; |
| 330 | } |
| 331 | |
| 332 | if((band->nr_2_band & band_info.band_support.nr_2_band) != band->nr_2_band) { |
| 333 | LOG("nr_2_band band error."); |
| 334 | goto exit; |
| 335 | } |
| 336 | |
| 337 | if((band->nr_1_band & band_info.band_support.nr_1_band) != band->nr_1_band) { |
| 338 | LOG("nr_1_band band error."); |
| 339 | goto exit; |
| 340 | } |
| 341 | |
| 342 | if((band->nr_0_band & band_info.band_support.nr_0_band) != band->nr_0_band) { |
| 343 | LOG("nr_0_band band error."); |
| 344 | goto exit; |
| 345 | } |
b.liu | 571445f | 2025-02-13 10:22:55 +0800 | [diff] [blame^] | 346 | #endif |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 347 | if(band->net_pref == 0xFF) { // No change net_pref. |
| 348 | int tmp_int; |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 349 | err = at_send_command_singleline(port, "AT*BAND?", "*BAND:", &response); |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 350 | if (err < 0 || response->success == 0 || !response->p_intermediates){ |
| 351 | if(cme_err) { |
| 352 | *cme_err = at_get_cme_error(response); |
| 353 | } |
| 354 | goto exit; |
| 355 | } |
| 356 | |
| 357 | char *line = response->p_intermediates->line; |
| 358 | err = at_tok_start(&line); |
| 359 | if (err < 0) |
| 360 | { |
| 361 | goto exit; |
| 362 | } |
| 363 | |
| 364 | err = at_tok_nextint(&line, &tmp_int); |
| 365 | if (err < 0) |
| 366 | { |
| 367 | goto exit; |
| 368 | } |
| 369 | band->net_pref = (uint8)tmp_int; // Set to current net_pref. |
| 370 | |
| 371 | at_response_free(response); |
| 372 | } |
b.liu | 571445f | 2025-02-13 10:22:55 +0800 | [diff] [blame^] | 373 | #ifdef MBTK_DEV_INFO_VERSION_2 |
b.liu | 61ad917 | 2025-01-09 14:33:55 +0800 | [diff] [blame] | 374 | // Only support 4G/5G |
| 375 | if(band_info.net_support & MBTK_NET_SUPPORT_5G) { |
| 376 | // AT*band=19,0,0,482,134742231,0,24576,256,134217877,0 |
| 377 | if(band->lte_ext_band > 0) { |
| 378 | sprintf(cmd, "AT*BAND=%d,%d,%d,%d,%d,%d,%d,%d,%d,0,,,,%d", band->net_pref, band->gsm_band, band->umts_band, band->tdlte_band, band->fddlte_band, |
| 379 | band->nr_3_band, band->nr_2_band, band->nr_1_band, band->nr_0_band, band->lte_ext_band); |
| 380 | } else { |
| 381 | sprintf(cmd, "AT*BAND=%d,%d,%d,%d,%d,%d,%d,%d,%d,0", band->net_pref, band->gsm_band, band->umts_band, band->tdlte_band, band->fddlte_band, |
| 382 | band->nr_3_band, band->nr_2_band, band->nr_1_band, band->nr_0_band); |
| 383 | } |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 384 | } else { |
b.liu | 61ad917 | 2025-01-09 14:33:55 +0800 | [diff] [blame] | 385 | if(band->lte_ext_band > 0) { |
| 386 | sprintf(cmd, "AT*BAND=%d,%d,%d,%d,%d,,,,%d", band->net_pref, band->gsm_band, band->umts_band, band->tdlte_band, band->fddlte_band, band->lte_ext_band); |
| 387 | } else { |
| 388 | sprintf(cmd, "AT*BAND=%d,%d,%d,%d,%d", band->net_pref, band->gsm_band, band->umts_band, band->tdlte_band, band->fddlte_band); |
| 389 | } |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 390 | } |
b.liu | 571445f | 2025-02-13 10:22:55 +0800 | [diff] [blame^] | 391 | #else |
| 392 | if(band->lte_ext_band > 0) { |
| 393 | sprintf(cmd, "AT*BAND=%d,%d,%d,%d,%d,,,,%d", band->net_pref, band->gsm_band, band->umts_band, band->tdlte_band, band->fddlte_band, band->lte_ext_band); |
| 394 | } else { |
| 395 | sprintf(cmd, "AT*BAND=%d,%d,%d,%d,%d", band->net_pref, band->gsm_band, band->umts_band, band->tdlte_band, band->fddlte_band); |
| 396 | } |
| 397 | #endif |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 398 | } |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 399 | err = at_send_command(port, cmd, &response); |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 400 | |
| 401 | if (err < 0 || response->success == 0){ |
| 402 | if(cme_err) { |
| 403 | *cme_err = at_get_cme_error(response); |
| 404 | } |
| 405 | goto exit; |
| 406 | } |
| 407 | |
| 408 | err = 0; |
| 409 | exit: |
| 410 | at_response_free(response); |
| 411 | return err; |
| 412 | } |
| 413 | |
| 414 | /* |
| 415 | // ??????? |
| 416 | AT*BAND=? |
| 417 | *BAND:(0-18),79,147,482,524503 |
| 418 | |
| 419 | OK |
| 420 | |
| 421 | // ??????????? |
| 422 | AT*BAND? |
| 423 | *BAND: 15, 78, 147, 482, 524503, 0, 2, 2, 0, 0 |
| 424 | |
| 425 | OK |
| 426 | |
b.liu | 61ad917 | 2025-01-09 14:33:55 +0800 | [diff] [blame] | 427 | 5G : |
| 428 | *BAND: 19, 0, 0, 482, 149,0, 24576, 256, 134217877, 0, 0, 2, 2, 0 |
| 429 | |
| 430 | |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 431 | // ????????? |
| 432 | AT*BAND=5,79,147,128,1 |
| 433 | OK |
| 434 | |
| 435 | net_prefferred?? |
| 436 | 0 : GSM only |
| 437 | 1 : UMTS only |
| 438 | 2 : GSM/UMTS(auto) |
| 439 | 3 : GSM/UMTS(GSM preferred) |
| 440 | 4 : GSM/UMTS(UMTS preferred) |
| 441 | 5 : LTE only |
| 442 | 6 : GSM/LTE(auto) |
| 443 | 7 : GSM/LTE(GSM preferred) |
| 444 | 8 : GSM/LTE(LTE preferred) |
| 445 | 9 : UMTS/LTE(auto) |
| 446 | 10 : UMTS/LTE(UMTS preferred) |
| 447 | 11 : UMTS/LTE(LTE preferred) |
| 448 | 12 : GSM/UMTS/LTE(auto) |
| 449 | 13 : GSM/UMTS/LTE(GSM preferred) |
| 450 | 14 : GSM/UMTS/LTE(UMTS preferred) |
| 451 | 15 : GSM/UMTS/LTE(LTE preferred) |
| 452 | GSM band?? |
| 453 | 1 ?C PGSM 900 (standard or primary) |
| 454 | 2 ?C DCS GSM 1800 |
| 455 | 4 ?C PCS GSM 1900 |
| 456 | 8 ?C EGSM 900 (extended) |
| 457 | 16 ?C GSM 450 |
| 458 | 32 ?C GSM 480 |
| 459 | 64 ?C GSM 850 |
| 460 | 512 - BAND_LOCK_BIT // used for GSM band setting |
| 461 | UMTS band?? |
| 462 | 1 ?C UMTS_BAND_1 |
| 463 | 2 ?C UMTS_BAND_2 |
| 464 | 4 ?C UMTS_BAND_3 |
| 465 | 8 ?C UMTS_BAND_4 |
| 466 | 16 ?C UMTS_BAND_5 |
| 467 | 32 ?C UMTS_BAND_6 |
| 468 | 64 ?C UMTS_BAND_7 |
| 469 | 128 ?C UMTS_BAND_8 |
| 470 | 256 ?C UMTS_BAND_9 |
| 471 | LTEbandH(TDD-LTE band) |
| 472 | 32 ?C TDLTE_BAND_38 |
| 473 | 64 ?C TDLTE_BAND_39 |
| 474 | 128 ?C TDLTE_BAND_40 |
| 475 | 256 ?C TDLTE_BAND_41 |
| 476 | LTEbandL(FDD-LTE band) |
| 477 | 1 ?C FDDLTE_BAND_1 |
| 478 | 4 ?C FDDLTE _BAND_3 |
| 479 | 8 ?C FDDLTE _BAND_4 |
| 480 | 64 ?C FDDLTE _BAND_7 |
| 481 | 65536 ?C FDDLTE _BAND_17 |
| 482 | 524288 ?C FDDLTE _BAND_20 |
| 483 | */ |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 484 | static int req_band_get(ATPortType_enum port, mbtk_band_info_t *band, int *cme_err) |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 485 | { |
| 486 | ATResponse *response = NULL; |
| 487 | int tmp_int; |
| 488 | |
| 489 | log_hex("BAND_SUPPORT", &band_info.band_support, sizeof(mbtk_band_info_t)); |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 490 | int err = at_send_command_singleline(port, "AT*BAND?", "*BAND:", &response); |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 491 | if (err < 0 || response->success == 0 || !response->p_intermediates){ |
| 492 | if(cme_err) { |
| 493 | *cme_err = at_get_cme_error(response); |
| 494 | } |
| 495 | goto exit; |
| 496 | } |
| 497 | |
| 498 | char *line = response->p_intermediates->line; |
| 499 | err = at_tok_start(&line); |
| 500 | if (err < 0) |
| 501 | { |
| 502 | goto exit; |
| 503 | } |
| 504 | |
| 505 | err = at_tok_nextint(&line, &tmp_int); |
| 506 | if (err < 0) |
| 507 | { |
| 508 | goto exit; |
| 509 | } |
| 510 | band->net_pref = (uint8)tmp_int; |
| 511 | |
| 512 | err = at_tok_nextint(&line, &tmp_int); |
| 513 | if (err < 0) |
| 514 | { |
| 515 | goto exit; |
| 516 | } |
| 517 | band->gsm_band = (uint16)tmp_int; |
| 518 | |
| 519 | err = at_tok_nextint(&line, &tmp_int); |
| 520 | if (err < 0) |
| 521 | { |
| 522 | goto exit; |
| 523 | } |
| 524 | band->umts_band = (uint16)tmp_int; |
| 525 | |
| 526 | err = at_tok_nextint(&line, &tmp_int); |
| 527 | if (err < 0) |
| 528 | { |
| 529 | goto exit; |
| 530 | } |
| 531 | band->tdlte_band = (uint32)tmp_int; |
| 532 | |
| 533 | err = at_tok_nextint(&line, &tmp_int); |
| 534 | if (err < 0) |
| 535 | { |
| 536 | goto exit; |
| 537 | } |
| 538 | band->fddlte_band = (uint32)tmp_int; |
| 539 | |
b.liu | 571445f | 2025-02-13 10:22:55 +0800 | [diff] [blame^] | 540 | #ifdef MBTK_DEV_INFO_VERSION_2 |
b.liu | f2ea8bf | 2025-01-09 15:07:34 +0800 | [diff] [blame] | 541 | if(band_info.net_support & MBTK_NET_SUPPORT_5G) |
| 542 | { |
b.liu | 61ad917 | 2025-01-09 14:33:55 +0800 | [diff] [blame] | 543 | err = at_tok_nextint(&line, &tmp_int); |
| 544 | if (err < 0) |
| 545 | { |
| 546 | goto exit; |
| 547 | } |
| 548 | band->nr_3_band = (uint32)tmp_int; |
| 549 | |
| 550 | err = at_tok_nextint(&line, &tmp_int); |
| 551 | if (err < 0) |
| 552 | { |
| 553 | goto exit; |
| 554 | } |
| 555 | band->nr_2_band = (uint32)tmp_int; |
| 556 | |
| 557 | err = at_tok_nextint(&line, &tmp_int); |
| 558 | if (err < 0) |
| 559 | { |
| 560 | goto exit; |
| 561 | } |
| 562 | band->nr_1_band = (uint32)tmp_int; |
| 563 | |
| 564 | err = at_tok_nextint(&line, &tmp_int); |
| 565 | if (err < 0) |
| 566 | { |
| 567 | goto exit; |
| 568 | } |
| 569 | band->nr_0_band = (uint32)tmp_int; |
| 570 | } |
b.liu | 571445f | 2025-02-13 10:22:55 +0800 | [diff] [blame^] | 571 | #endif |
b.liu | 61ad917 | 2025-01-09 14:33:55 +0800 | [diff] [blame] | 572 | |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 573 | // roamingConfig |
| 574 | err = at_tok_nextint(&line, &tmp_int); |
| 575 | if (err < 0) |
| 576 | { |
| 577 | goto exit; |
| 578 | } |
| 579 | |
| 580 | // srvDomain |
| 581 | err = at_tok_nextint(&line, &tmp_int); |
| 582 | if (err < 0) |
| 583 | { |
| 584 | goto exit; |
| 585 | } |
| 586 | |
| 587 | // bandPriorityFlag |
| 588 | err = at_tok_nextint(&line, &tmp_int); |
| 589 | if (err < 0) |
| 590 | { |
| 591 | goto exit; |
| 592 | } |
| 593 | |
| 594 | // |
| 595 | err = at_tok_nextint(&line, &tmp_int); |
| 596 | if (err < 0) |
| 597 | { |
| 598 | goto exit; |
| 599 | } |
| 600 | |
| 601 | // ltebandExt |
| 602 | err = at_tok_nextint(&line, &tmp_int); |
| 603 | if (err < 0) |
| 604 | { |
| 605 | goto exit; |
| 606 | } |
| 607 | band->lte_ext_band = (uint32)tmp_int; |
| 608 | |
| 609 | log_hex("BAND", band, sizeof(mbtk_band_info_t)); |
| 610 | |
| 611 | exit: |
| 612 | at_response_free(response); |
| 613 | return err; |
| 614 | } |
| 615 | |
| 616 | /* |
| 617 | AT+CSQ |
| 618 | +CSQ: 31,99 |
| 619 | |
| 620 | OK |
| 621 | |
| 622 | AT+CESQ |
| 623 | +CESQ: 60,99,255,255,20,61 |
| 624 | |
| 625 | OK |
| 626 | |
| 627 | AT+COPS? |
| 628 | +COPS: 0,2,"46001",7 |
| 629 | |
| 630 | OK |
| 631 | |
| 632 | */ |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 633 | static int req_net_signal_get(ATPortType_enum port, mbtk_signal_info_t *signal, int *cme_err) |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 634 | { |
| 635 | ATResponse *response = NULL; |
| 636 | int tmp_int; |
| 637 | char *tmp_ptr = NULL; |
| 638 | // AT+EEMOPT=1 in the first. |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 639 | int err = at_send_command_singleline(port, "AT+CSQ", "+CSQ:", &response); |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 640 | if (err < 0 || response->success == 0 || !response->p_intermediates){ |
| 641 | if(cme_err != NULL) |
| 642 | *cme_err = at_get_cme_error(response); |
| 643 | err = -1; |
| 644 | goto exit; |
| 645 | } |
| 646 | |
| 647 | char *line = response->p_intermediates->line; |
| 648 | err = at_tok_start(&line); |
| 649 | if (err < 0) |
| 650 | { |
| 651 | goto exit; |
| 652 | } |
| 653 | err = at_tok_nextint(&line, &tmp_int); |
| 654 | if (err < 0) |
| 655 | { |
| 656 | goto exit; |
| 657 | } |
| 658 | signal->rssi = (uint8)tmp_int; |
| 659 | at_response_free(response); |
| 660 | |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 661 | err = at_send_command_singleline(port, "AT+CESQ", "+CESQ:", &response); |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 662 | if (err < 0 || response->success == 0 || !response->p_intermediates){ |
| 663 | if(cme_err != NULL) |
| 664 | *cme_err = at_get_cme_error(response); |
| 665 | err = -1; |
| 666 | goto exit; |
| 667 | } |
| 668 | |
| 669 | line = response->p_intermediates->line; |
| 670 | err = at_tok_start(&line); |
| 671 | if (err < 0) |
| 672 | { |
| 673 | goto exit; |
| 674 | } |
| 675 | err = at_tok_nextint(&line, &tmp_int); |
| 676 | if (err < 0) |
| 677 | { |
| 678 | goto exit; |
| 679 | } |
| 680 | signal->rxlev = (uint8)tmp_int; |
| 681 | |
| 682 | err = at_tok_nextint(&line, &tmp_int); |
| 683 | if (err < 0) |
| 684 | { |
| 685 | goto exit; |
| 686 | } |
| 687 | signal->ber = (uint8)tmp_int; |
| 688 | |
| 689 | err = at_tok_nextint(&line, &tmp_int); |
| 690 | if (err < 0) |
| 691 | { |
| 692 | goto exit; |
| 693 | } |
| 694 | signal->rscp = (uint8)tmp_int; |
| 695 | |
| 696 | err = at_tok_nextint(&line, &tmp_int); |
| 697 | if (err < 0) |
| 698 | { |
| 699 | goto exit; |
| 700 | } |
| 701 | signal->ecno = (uint8)tmp_int; |
| 702 | |
| 703 | err = at_tok_nextint(&line, &tmp_int); |
| 704 | if (err < 0) |
| 705 | { |
| 706 | goto exit; |
| 707 | } |
| 708 | signal->rsrq = (uint8)tmp_int; |
| 709 | |
| 710 | err = at_tok_nextint(&line, &tmp_int); |
| 711 | if (err < 0) |
| 712 | { |
| 713 | goto exit; |
| 714 | } |
| 715 | signal->rsrp = (uint8)tmp_int; |
| 716 | |
| 717 | at_response_free(response); |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 718 | err = at_send_command_singleline(port, "AT+COPS?", "+COPS:", &response); |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 719 | if (err < 0 || response->success == 0 || !response->p_intermediates){ |
| 720 | if(cme_err != NULL) |
| 721 | *cme_err = at_get_cme_error(response); |
| 722 | err = -1; |
| 723 | goto exit; |
| 724 | } |
| 725 | line = response->p_intermediates->line; |
| 726 | err = at_tok_start(&line); |
| 727 | if (err < 0) |
| 728 | { |
| 729 | goto exit; |
| 730 | } |
| 731 | err = at_tok_nextint(&line, &tmp_int); |
| 732 | if (err < 0) |
| 733 | { |
| 734 | goto exit; |
| 735 | } |
| 736 | if(!at_tok_hasmore(&line)) { |
| 737 | goto exit; |
| 738 | } |
| 739 | err = at_tok_nextint(&line, &tmp_int); |
| 740 | if (err < 0) |
| 741 | { |
| 742 | goto exit; |
| 743 | } |
| 744 | err = at_tok_nextstr(&line, &tmp_ptr); |
| 745 | if (err < 0) |
| 746 | { |
| 747 | goto exit; |
| 748 | } |
| 749 | err = at_tok_nextint(&line, &tmp_int); |
| 750 | if (err < 0) |
| 751 | { |
| 752 | goto exit; |
| 753 | } |
| 754 | signal->type = (uint8)tmp_int; |
| 755 | |
| 756 | exit: |
| 757 | at_response_free(response); |
| 758 | return err; |
| 759 | } |
| 760 | |
| 761 | /* |
| 762 | AT+CREG=3 |
| 763 | OK |
| 764 | |
| 765 | AT+CREG? |
| 766 | +CREG: 3,1,"8330","06447340",7 |
| 767 | |
| 768 | OK |
| 769 | |
| 770 | AT+CREG? |
| 771 | +CREG: 3,0 |
| 772 | |
| 773 | OK |
| 774 | |
| 775 | AT+CEREG? |
| 776 | +CEREG: 3,1,"8330","06447340",7 |
| 777 | |
| 778 | OK |
| 779 | |
| 780 | |
| 781 | AT+CIREG? |
| 782 | +CIREG: 2,1,15 |
| 783 | |
| 784 | OK |
| 785 | |
| 786 | AT+CIREG? |
| 787 | +CIREG: 0 |
| 788 | |
| 789 | OK |
| 790 | |
| 791 | |
| 792 | */ |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 793 | static int req_net_reg_get(ATPortType_enum port, mbtk_net_reg_info_t *reg, int *cme_err) |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 794 | { |
| 795 | ATResponse *response = NULL; |
| 796 | int tmp_int; |
| 797 | char *tmp_str = NULL; |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 798 | int err = at_send_command(port, "AT+CREG=3", &response); |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 799 | if (err < 0 || response->success == 0){ |
| 800 | if(cme_err) { |
| 801 | *cme_err = at_get_cme_error(response); |
| 802 | } |
| 803 | goto exit; |
| 804 | } |
| 805 | at_response_free(response); |
| 806 | |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 807 | err = at_send_command_multiline(port, "AT+CREG?", "+CREG:", &response); |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 808 | if (err < 0 || response->success == 0 || !response->p_intermediates){ |
| 809 | if(cme_err) { |
| 810 | *cme_err = at_get_cme_error(response); |
| 811 | } |
| 812 | goto exit; |
| 813 | } |
| 814 | |
| 815 | char *line = response->p_intermediates->line; |
| 816 | err = at_tok_start(&line); |
| 817 | if (err < 0) |
| 818 | { |
| 819 | goto exit; |
| 820 | } |
| 821 | err = at_tok_nextint(&line, &tmp_int); // n |
| 822 | if (err < 0) |
| 823 | { |
| 824 | goto exit; |
| 825 | } |
| 826 | err = at_tok_nextint(&line, &tmp_int);// stat |
| 827 | if (err < 0) |
| 828 | { |
| 829 | goto exit; |
| 830 | } |
| 831 | reg->call_state = (uint8)tmp_int; |
| 832 | |
| 833 | if(at_tok_hasmore(&line)) { |
| 834 | err = at_tok_nextstr(&line, &tmp_str); // lac |
| 835 | if (err < 0) |
| 836 | { |
| 837 | goto exit; |
| 838 | } |
| 839 | reg->lac = strtol(tmp_str, NULL, 16); |
| 840 | |
| 841 | err = at_tok_nextstr(&line, &tmp_str); // ci |
| 842 | if (err < 0) |
| 843 | { |
| 844 | goto exit; |
| 845 | } |
| 846 | reg->ci = strtol(tmp_str, NULL, 16); |
| 847 | |
| 848 | err = at_tok_nextint(&line, &tmp_int);// AcT |
| 849 | if (err < 0) |
| 850 | { |
| 851 | goto exit; |
| 852 | } |
| 853 | reg->type = (uint8)tmp_int; |
| 854 | } |
| 855 | at_response_free(response); |
| 856 | |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 857 | err = at_send_command_multiline(port, "AT+CEREG?", "+CEREG:", &response); |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 858 | if (err < 0 || response->success == 0 || !response->p_intermediates){ |
| 859 | if(cme_err) { |
| 860 | *cme_err = at_get_cme_error(response); |
| 861 | } |
| 862 | goto exit; |
| 863 | } |
| 864 | |
| 865 | line = response->p_intermediates->line; |
| 866 | err = at_tok_start(&line); |
| 867 | if (err < 0) |
| 868 | { |
| 869 | goto exit; |
| 870 | } |
| 871 | err = at_tok_nextint(&line, &tmp_int); // n |
| 872 | if (err < 0) |
| 873 | { |
| 874 | goto exit; |
| 875 | } |
| 876 | err = at_tok_nextint(&line, &tmp_int);// stat |
| 877 | if (err < 0) |
| 878 | { |
| 879 | goto exit; |
| 880 | } |
| 881 | reg->data_state = (uint8)tmp_int; |
| 882 | |
| 883 | if(reg->lac == 0 && at_tok_hasmore(&line)) { |
| 884 | err = at_tok_nextstr(&line, &tmp_str); // lac |
| 885 | if (err < 0) |
| 886 | { |
| 887 | goto exit; |
| 888 | } |
| 889 | reg->lac = strtol(tmp_str, NULL, 16); |
| 890 | |
| 891 | err = at_tok_nextstr(&line, &tmp_str); // ci |
| 892 | if (err < 0) |
| 893 | { |
| 894 | goto exit; |
| 895 | } |
| 896 | reg->ci = strtol(tmp_str, NULL, 16); |
| 897 | |
| 898 | err = at_tok_nextint(&line, &tmp_int);// AcT |
| 899 | if (err < 0) |
| 900 | { |
| 901 | goto exit; |
| 902 | } |
| 903 | reg->type = (uint8)tmp_int; |
| 904 | } |
| 905 | at_response_free(response); |
| 906 | |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 907 | err = at_send_command_multiline(port, "AT+CIREG?", "+CIREG:", &response); |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 908 | if (err < 0 || response->success == 0 || !response->p_intermediates){ |
| 909 | reg->ims_state = (uint8)0; |
| 910 | err = 0; |
| 911 | goto exit; |
| 912 | } |
| 913 | line = response->p_intermediates->line; |
| 914 | err = at_tok_start(&line); |
| 915 | if (err < 0) |
| 916 | { |
| 917 | goto exit; |
| 918 | } |
| 919 | err = at_tok_nextint(&line, &tmp_int); // n/stat |
| 920 | if (err < 0) |
| 921 | { |
| 922 | goto exit; |
| 923 | } |
| 924 | if(at_tok_hasmore(&line)) { |
| 925 | err = at_tok_nextint(&line, &tmp_int);// stat |
| 926 | if (err < 0) |
| 927 | { |
| 928 | goto exit; |
| 929 | } |
| 930 | reg->ims_state = (uint8)tmp_int; |
| 931 | } else { |
| 932 | reg->ims_state = (uint8)tmp_int; |
| 933 | } |
| 934 | |
| 935 | exit: |
| 936 | at_response_free(response); |
| 937 | return err; |
| 938 | } |
| 939 | |
| 940 | /* |
b.liu | b477207 | 2024-08-15 14:47:03 +0800 | [diff] [blame] | 941 | AT+EEMOPT=1 |
| 942 | OK |
| 943 | |
| 944 | // LTE |
| 945 | AT+EEMGINFO? |
| 946 | // <mcc>, <length of mnc>, <mnc>, <tac>, <PCI>, <dlEuarfcn>, < ulEuarfcn >, <band>, <dlBandwidth>, |
| 947 | // <rsrp>,<rsrq>, <sinr>, |
| 948 | // errcModeState,emmState,serviceState,IsSingleEmmRejectCause,EMMRejectCause,mmeGroupId,mmeCode,mTmsi, |
| 949 | // cellId,subFrameAssignType,specialSubframePatterns,transMode |
| 950 | // mainRsrp,diversityRsrp,mainRsrq,diversityRsrq,rssi,cqi,pathLoss,tb0DlTpt,tb1DlTpt,tb0DlPeakTpt,tb1DlPeakTpt,tb0UlPeakTpt, |
| 951 | // tb1UlPeakTpt,dlThroughPut,dlPeakThroughPut,averDlPRB,averCQITb0,averCQITb1,rankIndex,grantTotal,ulThroughPut,ulPeakThroughPut,currPuschTxPower,averUlPRB, |
| 952 | // dlBer, ulBer, |
| 953 | // diversitySinr, diversityRssi |
| 954 | +EEMLTESVC: 1120, 2, 0, 33584, 430, 40936, 40936, 41, 20, |
| 955 | 0, 0, 0, |
| 956 | 1, 10, 0, 1, 0, 1059, 78, 3959566565, |
| 957 | 105149248, 2, 7, 7, |
| 958 | 0, 0, 0, 0, 0, 0, 0, 1190919, 0, 0, 0, 16779777, |
| 959 | 0, 5112867, 3959566565, 2, 0, 0, 0, 0, 0, 0, 0, 0, |
| 960 | 0, 0, |
| 961 | 7, 44 |
| 962 | |
| 963 | // index,phyCellId,euArfcn,rsrp,rsrq |
| 964 | +EEMLTEINTER: 0, 65535, 38950, 0, 0 |
| 965 | |
| 966 | +EEMLTEINTER: 1, 0, 0, 0, 0 |
| 967 | |
| 968 | +EEMLTEINTER: 2, 0, 4294967295, 255, 255 |
| 969 | |
| 970 | +EEMLTEINTER: 3, 65535, 1300, 0, 0 |
| 971 | |
| 972 | +EEMLTEINTER: 4, 0, 0, 0, 0 |
| 973 | |
| 974 | +EEMLTEINTER: 5, 0, 4294967295, 247, 0 |
| 975 | |
| 976 | +EEMLTEINTER: 6, 197, 41332, 24, 9 |
| 977 | |
| 978 | +EEMLTEINTER: 7, 0, 0, 0, 0 |
| 979 | |
| 980 | +EEMLTEINTER: 8, 0, 0, 0, 0 |
| 981 | |
| 982 | +EEMLTEINTRA: 0, 429, 40936, 56, 12 |
| 983 | |
| 984 | +EEMLTEINTERRAT: 0,0 |
| 985 | |
| 986 | +EEMLTEINTERRAT: 1,0 |
| 987 | |
| 988 | +EEMGINFO: 3, 2 // <state>: |
| 989 | // 0: ME in Idle mode |
| 990 | // 1: ME in Dedicated mode |
| 991 | // 2: ME in PS PTM mode |
| 992 | // 3: invalid state |
| 993 | // <nw_type>: |
| 994 | // 0: GSM 1: UMTS 2: LTE |
| 995 | |
| 996 | OK |
| 997 | |
| 998 | // WCDMA |
| 999 | AT+EEMGINFO? |
| 1000 | // Mode, sCMeasPresent, sCParamPresent, ueOpStatusPresent, |
| 1001 | |
| 1002 | // if sCMeasPresent == 1 |
| 1003 | // cpichRSCP, utraRssi, cpichEcN0, sQual, sRxLev, txPower, |
| 1004 | // endif |
| 1005 | |
| 1006 | // if sCParamPresent == 1 |
| 1007 | // rac, nom, mcc, mnc_len, mnc, lac, ci, |
| 1008 | // uraId, psc, arfcn, t3212, t3312, hcsUsed, attDetAllowed, |
| 1009 | // csDrxCycleLen, psDrxCycleLen, utranDrxCycleLen, HSDPASupport, HSUPASupport, |
| 1010 | // endif |
| 1011 | |
| 1012 | // if ueOpStatusPresent == 1 |
| 1013 | // rrcState, numLinks, srncId, sRnti, |
| 1014 | // algPresent, cipherAlg, cipherOn, algPresent, cipherAlg, cipherOn, |
| 1015 | // HSDPAActive, HSUPAActive, MccLastRegisteredNetwork, MncLastRegisteredNetwork, TMSI, PTMSI, IsSingleMmRejectCause, IsSingleGmmRejectCause, |
| 1016 | // MMRejectCause, GMMRejectCause, mmState, gmmState, gprsReadyState, readyTimerValueInSecs, NumActivePDPContext, ULThroughput, DLThroughput, |
| 1017 | // serviceStatus, pmmState, LAU_status, LAU_count, RAU_status, RAU_count |
| 1018 | // endif |
| 1019 | // |
| 1020 | +EEMUMTSSVC: 3, 1, 1, 1, |
| 1021 | -80, 27, -6, -18, -115, -32768, |
| 1022 | 1, 1, 1120, 2, 1, 61697, 168432821, |
| 1023 | 15, 24, 10763, 0, 0, 0, 0, |
| 1024 | 128, 128, 65535, 0, 0, |
| 1025 | 2, 255, 65535, 4294967295, |
| 1026 | 0, 0, 0, 0, 0, 0, |
| 1027 | 0, 0, 0, 0, 0, 0, 1, 1, |
| 1028 | 28672, 28672, 0, 0, 0, 0, 0, 0, 0, |
| 1029 | 0, 0, 0, 0, 0, 0 |
| 1030 | |
| 1031 | // index, cpichRSCP, utraRssi, cpichEcN0, sQual, sRxLev ,mcc, mnc, lac, ci, arfcn, psc |
| 1032 | +EEMUMTSINTRA: 0, -32768, -1, -32768, -18, -115, 0, 0, 65534, 1, 10763, 32 |
| 1033 | |
| 1034 | +EEMUMTSINTRA: 1, -1, -32768, -18, -115, 0, 0, 65534, 2, 10763, 40, 32768 |
| 1035 | |
| 1036 | +EEMUMTSINTRA: 2, -32768, -18, -115, 0, 0, 65534, 3, 10763, 278, 32768, 65535 |
| 1037 | |
| 1038 | +EEMUMTSINTRA: 3, -18, -115, 0, 0, -2, 4, 10763, 28, 32768, 65535, 32768 |
| 1039 | |
| 1040 | +EEMUMTSINTRA: 4, -115, 0, 0, -2, 5, 10763, 270, 32768, 65535, 32768, 65518 |
| 1041 | |
| 1042 | +EEMUMTSINTRA: 5, 0, 0, -2, 6, 10763, 286, 32768, 65535, 32768, 65518, 65421 |
| 1043 | |
| 1044 | +EEMUMTSINTRA: 6, 0, -2, 7, 10763, 80, 32768, 65535, 32768, 65518, 65421, 0 |
| 1045 | |
| 1046 | +EEMUMTSINTRA: 7, -2, 8, 10763, 206, -32768, 65535, 32768, 65518, 65421, 0, 0 |
| 1047 | |
| 1048 | +EEMUMTSINTRA: 8, 9, 10763, 11, -32768, -1, 32768, 65518, 65421, 0, 0, 65534 |
| 1049 | |
| 1050 | +EEMUMTSINTRA: 9, 10763, 19, -32768, -1, -32768, 65518, 65421, 0, 0, 65534, 11 |
| 1051 | |
| 1052 | +EEMUMTSINTRA: 10, 232, -32768, -1, -32768, -18, 65421, 0, 0, 65534, 12, 10763 |
| 1053 | |
| 1054 | +EEMUMTSINTRA: 11, -32768, -1, -32768, -18, -115, 0, 0, 65534, 13, 10763, 66 |
| 1055 | |
| 1056 | +EEMUMTSINTRA: 12, -1, -32768, -18, -115, 0, 0, 65534, 14, 10763, 216, 32768 |
| 1057 | |
| 1058 | +EEMUMTSINTRA: 13, -32768, -18, -115, 0, 0, 65534, 15, 10763, 183, 32768, 65535 |
| 1059 | |
| 1060 | +EEMUMTSINTRA: 14, -18, -115, 0, 0, -2, 16, 10763, 165, 32768, 65535, 32768 |
| 1061 | |
| 1062 | +EEMUMTSINTRA: 15, -115, 0, 0, -2, 17, 10763, 151, 32768, 65535, 32768, 65518 |
| 1063 | |
| 1064 | +EEMUMTSINTRA: 16, 0, 0, -2, 18, 10763, 43, 32768, 65535, 32768, 65518, 65421 |
| 1065 | |
| 1066 | +EEMUMTSINTRA: 17, 0, -2, 19, 10763, 72, 32768, 65535, 32768, 65518, 65421, 0 |
| 1067 | |
| 1068 | +EEMUMTSINTRA: 18, -2, 20, 10763, 157, -32768, 65535, 32768, 65518, 65421, 0, 0 |
| 1069 | |
| 1070 | +EEMUMTSINTRA: 19, 21, 10763, 165, -32768, -1, 32768, 65518, 65421, 0, 0, 65534 |
| 1071 | |
| 1072 | +EEMUMTSINTRA: 20, 10763, 301, -32768, -1, -32768, 65518, 65421, 0, 0, 65534, 23 |
| 1073 | |
| 1074 | +EEMUMTSINTRA: 21, 23, -32768, -1, -32768, -18, 65421, 0, 0, 65534, 24, 10763 |
| 1075 | |
| 1076 | +EEMUMTSINTRA: 22, -32768, -1, -32768, -18, -115, 0, 0, 65534, 25, 10763, 0 |
| 1077 | |
| 1078 | +EEMUMTSINTRA: 23, -1, -32768, -18, -115, 0, 0, 65534, 26, 10763, 167, 32768 |
| 1079 | |
| 1080 | +EEMUMTSINTRA: 24, -32768, -18, -115, 0, 0, 65534, 27, 10763, 34, 32768, 65535 |
| 1081 | |
| 1082 | +EEMUMTSINTRA: 25, -18, -115, 0, 0, -2, 28, 10763, 313, 32768, 65535, 32768 |
| 1083 | |
| 1084 | +EEMUMTSINTRA: 26, -115, 0, 0, -2, 29, 10763, 152, 32768, 65535, 32768, 65518 |
| 1085 | |
| 1086 | +EEMUMTSINTRA: 27, 0, 0, -2, 30, 10763, 239, 0, 0, 0, 0, 0 |
| 1087 | |
| 1088 | +EEMUMTSINTRA: 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 |
| 1089 | |
| 1090 | +EEMUMTSINTRA: 29, 0, 0, 0, 0, -115, 0, 0, 65534, 30, 10763, 239 |
| 1091 | |
| 1092 | // index,gsmRssi,rxLev,C1,C2,mcc,mnc,lac,ci,arfcn,bsic |
| 1093 | +EEMUMTSINTERRAT: 0, -32768, -107, -1, -1, 0, 0, 65534, 0, 117, 36 |
| 1094 | |
| 1095 | +EEMUMTSINTERRAT: 1, -107, -1, -1, 0, 0, 65534, 1, 72, 49, 0 |
| 1096 | |
| 1097 | +EEMUMTSINTERRAT: 2, -1, -1, 0, 0, 65534, 2, 119, 15, 32768, 149 |
| 1098 | |
| 1099 | +EEMUMTSINTERRAT: 3, -1, 0, 0, -2, 3, 121, 23, 0, 0, 0 |
| 1100 | |
| 1101 | +EEMGINFO: 3, 1 |
| 1102 | |
| 1103 | OK |
| 1104 | |
| 1105 | |
| 1106 | // GSM |
| 1107 | AT+EEMGINFO? |
| 1108 | +EEMGINFOBASIC: 2 |
| 1109 | |
| 1110 | // mcc, mnc_len, mnc, lac, ci, nom, nco, |
| 1111 | // bsic, C1, C2, TA, TxPwr, |
| 1112 | // RxSig, RxSigFull, RxSigSub, RxQualFull, RxQualSub, |
| 1113 | // ARFCB_tch, hopping_chnl, chnl_type, TS, PacketIdle, rac, arfcn, |
| 1114 | // bs_pa_mfrms, C31, C32, t3212, t3312, pbcch_support, EDGE_support, |
| 1115 | // ncc_permitted, rl_timeout, ho_count, ho_succ, chnl_access_count, chnl_access_succ_count, |
| 1116 | // gsmBand,channelMode |
| 1117 | +EEMGINFOSVC: 1120, 2, 0, 32784, 24741, 2, 0, |
| 1118 | 63, 36, 146, 1, 7, |
| 1119 | 46, 42, 42, 7, 0, |
| 1120 | 53, 0, 8, 0, 1, 6, 53, |
| 1121 | 2, 0, 146, 42, 54, 0, 1, |
| 1122 | 1, 32, 0, 0, 0, 0, |
| 1123 | 0, 0 |
| 1124 | |
| 1125 | // PS_attached, attach_type, service_type, tx_power, c_value, |
| 1126 | // ul_ts, dl_ts, ul_cs, dl_cs, ul_modulation, dl_modulation, |
| 1127 | // gmsk_cv_bep, 8psk_cv_bep, gmsk_mean_bep, 8psk_mean_bep, EDGE_bep_period, single_gmm_rej_cause |
| 1128 | // pdp_active_num, mac_mode, network_control, network_mode, EDGE_slq_measurement_mode, edge_status |
| 1129 | +EEMGINFOPS: 1, 255, 0, 0, 0, |
| 1130 | 0, 0, 268435501, 1, 0, 0, |
| 1131 | 4, 0, 96, 0, 0, 0, |
| 1132 | 0, 0, 0, 65535, 0, 13350 |
| 1133 | |
| 1134 | +EEMGINFO: 0, 0 |
| 1135 | |
| 1136 | OK |
| 1137 | |
| 1138 | */ |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1139 | static int req_cell_info_get(ATPortType_enum port, int *cme_err) |
b.liu | b477207 | 2024-08-15 14:47:03 +0800 | [diff] [blame] | 1140 | { |
| 1141 | ATResponse *response = NULL; |
| 1142 | int tmp_int; |
| 1143 | int buff_size = 0; |
| 1144 | // AT+EEMOPT=1 in the first. |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1145 | int err = at_send_command(port, "AT+EEMOPT=1", &response); |
b.liu | b477207 | 2024-08-15 14:47:03 +0800 | [diff] [blame] | 1146 | if (err < 0 || response->success == 0){ |
| 1147 | *cme_err = at_get_cme_error(response); |
| 1148 | goto exit; |
| 1149 | } |
| 1150 | |
| 1151 | // Reset buffer in the first. |
| 1152 | memset(&cell_info, 0xFF, sizeof(mbtK_cell_pack_info_t)); |
| 1153 | cell_info.running = true; |
| 1154 | cell_info.cell_list.num = 0; |
| 1155 | |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1156 | err = at_send_command_singleline(port, "AT+EEMGINFO?", "+EEMGINFO:", &response); |
b.liu | b477207 | 2024-08-15 14:47:03 +0800 | [diff] [blame] | 1157 | if (err < 0 || response->success == 0 || !response->p_intermediates){ |
| 1158 | *cme_err = at_get_cme_error(response); |
| 1159 | goto exit; |
| 1160 | } |
| 1161 | |
| 1162 | // Now, cell infomation has get from URC message. |
| 1163 | |
| 1164 | char *line = response->p_intermediates->line; |
| 1165 | err = at_tok_start(&line); |
| 1166 | if (err < 0) |
| 1167 | { |
| 1168 | goto exit; |
| 1169 | } |
| 1170 | err = at_tok_nextint(&line, &tmp_int); |
| 1171 | if (err < 0) |
| 1172 | { |
| 1173 | goto exit; |
| 1174 | } |
| 1175 | err = at_tok_nextint(&line, &tmp_int); |
| 1176 | if (err < 0) |
| 1177 | { |
| 1178 | goto exit; |
| 1179 | } |
| 1180 | |
| 1181 | cell_info.cell_list.type = (uint8)tmp_int; |
| 1182 | cell_info.running = false; |
| 1183 | |
| 1184 | #if 0 |
| 1185 | while(lines_ptr) |
| 1186 | { |
| 1187 | // LTE |
| 1188 | if(strStartsWith(line, "+EEMLTESVC:")) // LTE Server Cell |
| 1189 | { |
| 1190 | |
| 1191 | } |
| 1192 | else if(strStartsWith(line, "+EEMLTEINTER:")) // LTE |
| 1193 | { |
| 1194 | |
| 1195 | } |
| 1196 | else if(strStartsWith(line, "+EEMLTEINTRA:")) // LTE |
| 1197 | { |
| 1198 | |
| 1199 | } |
| 1200 | else if(strStartsWith(line, "+EEMLTEINTERRAT:")) // LTE |
| 1201 | { |
| 1202 | |
| 1203 | } |
| 1204 | else if(strStartsWith(line, "+EEMGINFO:")) // <state>: 0: ME in Idle mode 1: ME in Dedicated mode 2: ME in PS PTM mode 3: invalid state |
| 1205 | // <nw_type>: 0: GSM 1: UMTS 2: LTE |
| 1206 | { |
| 1207 | |
| 1208 | } |
| 1209 | // WCDMA |
| 1210 | else if(strStartsWith(line, "+EEMUMTSSVC:")) // WCDMA Server Cell |
| 1211 | { |
| 1212 | |
| 1213 | } |
| 1214 | else if(strStartsWith(line, "+EEMUMTSINTRA:")) // WCDMA |
| 1215 | { |
| 1216 | |
| 1217 | } |
| 1218 | else if(strStartsWith(line, "+EEMUMTSINTERRAT:")) // WCDMA |
| 1219 | { |
| 1220 | |
| 1221 | } |
| 1222 | // GSM |
| 1223 | else if(strStartsWith(line, "+EEMGINFOBASIC:")) // Basic information in GSM |
| 1224 | // 0: ME in Idle mode 1: ME in Dedicated mode 2: ME in PS PTM mode |
| 1225 | { |
| 1226 | |
| 1227 | } |
| 1228 | else if(strStartsWith(line, "+EEMGINFOSVC:")) // GSM Server Cell |
| 1229 | { |
| 1230 | |
| 1231 | } |
| 1232 | else if(strStartsWith(line, "+EEMGINFOPS:")) // PS |
| 1233 | { |
| 1234 | |
| 1235 | } |
| 1236 | |
| 1237 | |
| 1238 | lines_ptr = lines_ptr->p_next; |
| 1239 | } |
| 1240 | #endif |
| 1241 | |
| 1242 | exit: |
| 1243 | at_response_free(response); |
| 1244 | return buff_size; |
| 1245 | } |
| 1246 | |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1247 | static int req_cell_info_set(ATPortType_enum port, const char *cmgl, char *reg, int len, int *cme_err) |
b.liu | b477207 | 2024-08-15 14:47:03 +0800 | [diff] [blame] | 1248 | { |
| 1249 | ATResponse *response = NULL; |
b.liu | 62240ee | 2024-11-07 17:52:45 +0800 | [diff] [blame] | 1250 | char cmd[500] = {0}; |
b.liu | b477207 | 2024-08-15 14:47:03 +0800 | [diff] [blame] | 1251 | char data[218] = {0}; |
| 1252 | int err = 0; |
| 1253 | |
| 1254 | memcpy(data, cmgl, len); |
| 1255 | |
| 1256 | sprintf(cmd, "AT*CELL=%s", data); |
| 1257 | |
| 1258 | if(strlen(cmd) > 0) |
| 1259 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1260 | err = at_send_command_multiline(port, cmd, "", &response); |
b.liu | b477207 | 2024-08-15 14:47:03 +0800 | [diff] [blame] | 1261 | if (err < 0 || response->success == 0 || !response->p_intermediates){ |
| 1262 | *cme_err = at_get_cme_error(response); |
| 1263 | goto exit; |
| 1264 | } |
| 1265 | |
| 1266 | ATLine* lines_ptr = response->p_intermediates; |
| 1267 | char *line = NULL; |
b.liu | 62240ee | 2024-11-07 17:52:45 +0800 | [diff] [blame] | 1268 | // int reg_len = 0; |
| 1269 | // bool flag = false; |
b.liu | b477207 | 2024-08-15 14:47:03 +0800 | [diff] [blame] | 1270 | while(lines_ptr) |
| 1271 | { |
| 1272 | line = lines_ptr->line; |
| 1273 | if(line ==NULL) |
| 1274 | { |
| 1275 | LOGD("line is null----------------------"); |
| 1276 | } |
| 1277 | lines_ptr = lines_ptr->p_next; |
| 1278 | } |
| 1279 | } |
| 1280 | err = 0; |
| 1281 | memcpy(reg, "req_cell_info_set succss", strlen("req_cell_info_set succss")); |
| 1282 | exit: |
| 1283 | at_response_free(response); |
| 1284 | return err; |
| 1285 | } |
| 1286 | |
b.liu | 557c81d | 2024-11-19 16:52:45 +0800 | [diff] [blame] | 1287 | /* |
| 1288 | AT+OOSPP=1 |
| 1289 | or |
| 1290 | AT+OOSPP=0 |
| 1291 | or |
| 1292 | AT+OOSPP=1,20,30,40 //AtOospp() |
| 1293 | param1£ºmode |
| 1294 | param2£ºoosPhasePeriod[0] //5 times, 5s by default; |
| 1295 | param3£ºoosPhasePeriod[1] //5 times, 10s by default; |
| 1296 | param4£ºoosPhasePeriod[2] //unlimited, 20s by default; |
| 1297 | |
| 1298 | |
| 1299 | BTW |
| 1300 | 1, Èç¹ûÖ»ÊäÈëmode=1£¬ÆäÓà²ÎÊý²»ÉèÖã¬Ï൱ÓÚÕâ¸ö¹¦ÄÜ´ò¿ª£¬Ê±¼ä¼ä¸ôÊÇÕâ¸ö¹¦ÄܵÄĬÈÏÖµ¡£ |
| 1301 | 2, Èç¹ûµ±mode=1¼ÓÉÏÆäÓàÉèÖòÎÊýºó£¬¹¦ÄÜ´ò¿ª£¬Ê±¼ä¼ä¸ôÊDZ¾´ÎÉèÖõÄÖµ£» |
| 1302 | 3£¬Èç¹ûÔÙÉèÖÃmode=0£¬Ï൱ÓÚÕâ¸ö¹¦Äܹرգ¬ÊÇ×߯½Ì¨×Ô¼ºÁíÒ»Ì×µÄËÑÍøÉèÖᣠ|
| 1303 | ƽ̨±¾ÉíÊÇÓÐÒ»Ì×¼ä¸ôËÑÍø£¬Ò²ÓÐÀúʷƵµãÓÅÏÈ´¦ÀíµÄÂß¼£¨²»ÐèÒªÎÒÃǽøÐд¦Àí£©£¬ |
| 1304 | Ìṩ¸øÎÒÃǵÄAT+OOSPPÖ¸ÁîÊÇÈÃÎÒÃÇ¿ÉÒÔ×Ô¶¨ÒåËÑÍø¼ä¸ô |
| 1305 | */ |
| 1306 | static int req_oos_set(ATPortType_enum port, const mbtk_ril_oos_info_t* oos_info, int *cme_err) |
| 1307 | { |
| 1308 | ATResponse *response = NULL; |
| 1309 | char cmd[100] = {0}; |
| 1310 | int err = 0; |
| 1311 | |
| 1312 | if ((oos_info->state == 1 && oos_info->oosPhase[0] == 0 && oos_info->oosPhase[1] == 0 && oos_info->oosPhase[2] == 0) \ |
| 1313 | || oos_info->state == 0) |
| 1314 | { |
| 1315 | sprintf(cmd, "AT+OOSPP=%d", oos_info->state);//Ö»ÓÐÒ»¸öÖµ0/1 |
| 1316 | } |
| 1317 | else |
| 1318 | { |
| 1319 | if ((oos_info->oosPhase[0] != 0) && (oos_info->oosPhase[1] != 0) && (oos_info->oosPhase[2] != 0)) |
| 1320 | { |
| 1321 | sprintf(cmd, "AT+OOSPP=%d,%d,%d,%d", oos_info->state, oos_info->oosPhase[0], oos_info->oosPhase[1], oos_info->oosPhase[2]); |
| 1322 | } |
| 1323 | else if ((oos_info->oosPhase[0] != 0) && (oos_info->oosPhase[1] != 0) && (oos_info->oosPhase[2] == 0)) |
| 1324 | { |
| 1325 | sprintf(cmd, "AT+OOSPP=%d,%d,%d", oos_info->state, oos_info->oosPhase[0], oos_info->oosPhase[1]); |
| 1326 | } |
| 1327 | else if ((oos_info->oosPhase[0] != 0) && (oos_info->oosPhase[1] == 0) && (oos_info->oosPhase[2] == 0)) |
| 1328 | { |
| 1329 | sprintf(cmd, "AT+OOSPP=%d,%d", oos_info->state, oos_info->oosPhase[0]); |
| 1330 | } |
| 1331 | else |
| 1332 | { |
| 1333 | LOGE("AT+OOSPP SET ERR"); |
| 1334 | goto exit; |
| 1335 | } |
| 1336 | } |
| 1337 | |
| 1338 | LOGI("Set the oos command is = [%s]\n", cmd); |
| 1339 | err = at_send_command(port, cmd, &response); |
| 1340 | if (err < 0 || response->success == 0){ |
| 1341 | *cme_err = at_get_cme_error(response); |
| 1342 | goto exit; |
| 1343 | } |
| 1344 | |
| 1345 | exit: |
| 1346 | at_response_free(response); |
| 1347 | return err; |
| 1348 | } |
| 1349 | |
| 1350 | /* |
| 1351 | AT+OOSPP? |
| 1352 | ¿ª(ĬÈÏÖµ)£º |
| 1353 | +OOSPP:5,10,20 |
| 1354 | ¹Ø£º |
| 1355 | +OOSPP:0 |
| 1356 | */ |
| 1357 | static int req_oos_get(ATPortType_enum port, mbtk_ril_oos_info_t *oos_info, int *cme_err) |
| 1358 | { |
| 1359 | ATResponse *response = NULL; |
| 1360 | |
| 1361 | int err = at_send_command_singleline(port, "AT+OOSPP?", "+OOSPP:", &response); |
| 1362 | |
| 1363 | if (err < 0 || response->success == 0 || !response->p_intermediates){ |
| 1364 | *cme_err = at_get_cme_error(response); |
| 1365 | goto exit; |
| 1366 | } |
| 1367 | |
| 1368 | char *line = response->p_intermediates->line; |
| 1369 | |
| 1370 | char *tmp_str = NULL; |
| 1371 | err = at_tok_start(&line);//+OOSPP:10,15,20,¹ýÂË+OOSPP: |
| 1372 | if (err < 0) |
| 1373 | { |
| 1374 | goto exit; |
| 1375 | } |
| 1376 | |
| 1377 | //LOG("req_oos_get =[%s]",line); |
| 1378 | |
| 1379 | err = at_tok_nextstr(&line, &tmp_str); |
| 1380 | if (err < 0) |
| 1381 | { |
| 1382 | goto exit; |
| 1383 | } |
| 1384 | |
| 1385 | int mode = atoi(tmp_str); |
| 1386 | if (mode == 0)//¹Ø±Õ״̬ |
| 1387 | { |
| 1388 | oos_info->state = mode; |
| 1389 | } |
| 1390 | else//¿ª×´Ì¬ |
| 1391 | { |
| 1392 | oos_info->state = 1; |
| 1393 | //LOG("tmp_str =[%s]",tmp_str); |
| 1394 | oos_info->oosPhase[0] = atoi(tmp_str); |
| 1395 | |
| 1396 | err = at_tok_nextstr(&line, &tmp_str); |
| 1397 | if (err < 0) |
| 1398 | { |
| 1399 | goto exit; |
| 1400 | } |
| 1401 | //LOG("tmp_str =[%s]",tmp_str); |
| 1402 | oos_info->oosPhase[1] = atoi(tmp_str); |
| 1403 | |
| 1404 | err = at_tok_nextstr(&line, &tmp_str); |
| 1405 | if (err < 0) |
| 1406 | { |
| 1407 | goto exit; |
| 1408 | } |
| 1409 | //LOG("tmp_str =[%s]",tmp_str); |
| 1410 | oos_info->oosPhase[2] = atoi(tmp_str); |
| 1411 | } |
| 1412 | |
| 1413 | exit: |
| 1414 | at_response_free(response); |
| 1415 | return err; |
| 1416 | } |
| 1417 | |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1418 | //void net_list_free(void *data); |
| 1419 | // Return MBTK_INFO_ERR_SUCCESS,will call pack_error_send() to send RSP. |
| 1420 | // Otherwise, do not call pack_error_send(). |
| 1421 | mbtk_ril_err_enum net_pack_req_process(sock_cli_info_t* cli_info, ril_msg_pack_info_t* pack) |
| 1422 | { |
| 1423 | mbtk_ril_err_enum err = MBTK_RIL_ERR_SUCCESS; |
| 1424 | int cme_err = MBTK_RIL_ERR_CME_NON; |
| 1425 | switch(pack->msg_id) |
| 1426 | { |
| 1427 | case RIL_MSG_ID_NET_AVAILABLE: |
| 1428 | { |
| 1429 | if(pack->data_len == 0 || pack->data == NULL) |
| 1430 | { |
| 1431 | mbtk_net_info_array_t net_array; |
| 1432 | memset(&net_array, 0, sizeof(mbtk_net_info_array_t)); |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1433 | if(req_available_net_get(cli_info->port, &net_array, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1434 | { |
| 1435 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1436 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1437 | } else { |
| 1438 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1439 | } |
| 1440 | LOGD("Get Available Net fail."); |
| 1441 | } |
| 1442 | else |
| 1443 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1444 | ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &net_array, sizeof(mbtk_net_info_array_t)); |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1445 | } |
| 1446 | } |
| 1447 | else // Set |
| 1448 | { |
| 1449 | err = MBTK_RIL_ERR_UNSUPPORTED; |
| 1450 | LOGW("Unsupport set available net."); |
| 1451 | } |
| 1452 | break; |
| 1453 | } |
| 1454 | case RIL_MSG_ID_NET_SEL_MODE: |
| 1455 | { |
| 1456 | if(pack->data_len == 0 || pack->data == NULL) |
| 1457 | { |
| 1458 | mbtk_net_info_t info; |
| 1459 | memset(&info, 0, sizeof(mbtk_net_info_t)); |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1460 | if(req_net_sel_mode_get(cli_info->port, &info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1461 | { |
| 1462 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1463 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1464 | } else { |
| 1465 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1466 | } |
| 1467 | LOGD("Get Net sel mode fail."); |
| 1468 | } |
| 1469 | else |
| 1470 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1471 | ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &info, sizeof(mbtk_net_info_t)); |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1472 | } |
| 1473 | } |
| 1474 | else // Set |
| 1475 | { |
| 1476 | mbtk_net_info_t *info = (mbtk_net_info_t*)pack->data; |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1477 | if(req_net_sel_mode_set(cli_info->port, info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1478 | { |
| 1479 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1480 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1481 | } else { |
| 1482 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1483 | } |
| 1484 | LOGD("Set Net sel mode fail."); |
| 1485 | } |
| 1486 | else |
| 1487 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1488 | ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0); |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1489 | } |
| 1490 | } |
| 1491 | break; |
| 1492 | } |
| 1493 | case RIL_MSG_ID_NET_BAND: |
| 1494 | { |
| 1495 | if(pack->data_len == 0 || pack->data == NULL) |
| 1496 | { |
| 1497 | err = MBTK_RIL_ERR_REQ_PARAMETER; |
| 1498 | LOG("No data found."); |
| 1499 | } |
| 1500 | else // Set |
| 1501 | { |
| 1502 | if(pack->data_len == sizeof(uint8)) { |
| 1503 | if(*(pack->data)) { // Get current bands. |
| 1504 | mbtk_band_info_t band; |
| 1505 | memset(&band, 0x0, sizeof(mbtk_band_info_t)); |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1506 | if(req_band_get(cli_info->port, &band, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1507 | { |
| 1508 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1509 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1510 | } else { |
| 1511 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1512 | } |
| 1513 | LOG("Get net band fail."); |
| 1514 | } |
| 1515 | else |
| 1516 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1517 | ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &band, sizeof(mbtk_band_info_t)); |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1518 | } |
| 1519 | } else { // Get support bands. |
b.liu | 571445f | 2025-02-13 10:22:55 +0800 | [diff] [blame^] | 1520 | ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &band_info.band_support , sizeof(mbtk_band_info_t)); |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1521 | } |
| 1522 | } else { // Set current bands. |
| 1523 | mbtk_band_info_t* band = (mbtk_band_info_t*)pack->data; |
| 1524 | if(pack->data_len != sizeof(mbtk_band_info_t)) |
| 1525 | { |
| 1526 | err = MBTK_RIL_ERR_REQ_PARAMETER; |
| 1527 | LOG("Set net band error."); |
| 1528 | break; |
| 1529 | } |
| 1530 | |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1531 | if(req_band_set(cli_info->port, band, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1532 | { |
| 1533 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1534 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1535 | } else { |
| 1536 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1537 | } |
| 1538 | LOG("Set net band fail."); |
| 1539 | } |
| 1540 | else |
| 1541 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1542 | ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0); |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1543 | } |
| 1544 | } |
| 1545 | } |
| 1546 | break; |
| 1547 | } |
| 1548 | case RIL_MSG_ID_NET_SIGNAL: |
| 1549 | { |
| 1550 | if(pack->data_len == 0 || pack->data == NULL) |
| 1551 | { |
| 1552 | mbtk_signal_info_t signal; |
| 1553 | memset(&signal, 0, sizeof(mbtk_signal_info_t)); |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1554 | if(req_net_signal_get(cli_info->port, &signal, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1555 | { |
| 1556 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1557 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1558 | } else { |
| 1559 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1560 | } |
| 1561 | LOGD("Get net signal fail."); |
| 1562 | } |
| 1563 | else |
| 1564 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1565 | ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &signal, sizeof(mbtk_signal_info_t)); |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1566 | } |
| 1567 | } |
| 1568 | else // Set |
| 1569 | { |
| 1570 | err = MBTK_RIL_ERR_UNSUPPORTED; |
| 1571 | LOGW("Unsupport set net signal."); |
| 1572 | } |
| 1573 | break; |
| 1574 | } |
| 1575 | case RIL_MSG_ID_NET_REG: |
| 1576 | { |
| 1577 | if(pack->data_len == 0 || pack->data == NULL) |
| 1578 | { |
| 1579 | mbtk_net_reg_info_t net_reg; |
| 1580 | memset(&net_reg, 0, sizeof(mbtk_net_reg_info_t)); |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1581 | if(req_net_reg_get(cli_info->port, &net_reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1582 | { |
| 1583 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1584 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1585 | } else { |
| 1586 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1587 | } |
| 1588 | LOGD("Get Net reg info fail."); |
| 1589 | } |
| 1590 | else |
| 1591 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1592 | ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &net_reg, sizeof(mbtk_net_reg_info_t)); |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1593 | } |
| 1594 | } |
| 1595 | else // Set |
| 1596 | { |
| 1597 | err = MBTK_RIL_ERR_UNSUPPORTED; |
| 1598 | LOGW("Unsupport set net reg info."); |
| 1599 | } |
| 1600 | break; |
| 1601 | } |
| 1602 | case RIL_MSG_ID_NET_CELL: |
| 1603 | { |
b.liu | b477207 | 2024-08-15 14:47:03 +0800 | [diff] [blame] | 1604 | if(pack->data_len == 0 || pack->data == NULL) // Get net cell. |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1605 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1606 | if(req_cell_info_get(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1607 | { |
| 1608 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1609 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1610 | } else { |
| 1611 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1612 | } |
b.liu | b477207 | 2024-08-15 14:47:03 +0800 | [diff] [blame] | 1613 | LOG("Get net cell fail."); |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1614 | } |
| 1615 | else |
| 1616 | { |
b.liu | b477207 | 2024-08-15 14:47:03 +0800 | [diff] [blame] | 1617 | LOG("req_cell_info_get() success,cell number: %d", cell_info.cell_list.num); |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1618 | ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &cell_info.cell_list, sizeof(mbtk_cell_info_array_t)); |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1619 | } |
| 1620 | } |
b.liu | b477207 | 2024-08-15 14:47:03 +0800 | [diff] [blame] | 1621 | else // Lock cell |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1622 | { |
b.liu | b477207 | 2024-08-15 14:47:03 +0800 | [diff] [blame] | 1623 | char *mem = (char*)(pack->data); |
| 1624 | int len = pack->data_len; |
| 1625 | char reg[100] = {0}; |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1626 | if(req_cell_info_set(cli_info->port, mem, reg, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
b.liu | b477207 | 2024-08-15 14:47:03 +0800 | [diff] [blame] | 1627 | { |
| 1628 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1629 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1630 | } else { |
| 1631 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1632 | } |
| 1633 | } |
| 1634 | else |
| 1635 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1636 | ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg)); |
b.liu | b477207 | 2024-08-15 14:47:03 +0800 | [diff] [blame] | 1637 | } |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1638 | } |
| 1639 | break; |
| 1640 | } |
b.liu | 557c81d | 2024-11-19 16:52:45 +0800 | [diff] [blame] | 1641 | case RIL_MSG_ID_NET_OOS: |
| 1642 | { |
| 1643 | if(pack->data_len == 0 || pack->data == NULL) // Get net oos. |
| 1644 | { |
| 1645 | mbtk_ril_oos_info_t oos_info; |
| 1646 | memset(&oos_info, 0, sizeof(mbtk_ril_oos_info_t)); |
| 1647 | if(req_oos_get(cli_info->port, &oos_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
| 1648 | { |
| 1649 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1650 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1651 | } else { |
| 1652 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1653 | } |
| 1654 | LOG("Get net oos fail."); |
| 1655 | } |
| 1656 | else |
| 1657 | { |
| 1658 | LOG("req_oos_get() success,cell number: %d", oos_info.state); |
| 1659 | ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &oos_info, sizeof(mbtk_ril_oos_info_t)); |
| 1660 | } |
| 1661 | } |
| 1662 | else // Set net oos. |
| 1663 | { |
| 1664 | mbtk_ril_oos_info_t *oos_info = (mbtk_ril_oos_info_t*)(pack->data); |
| 1665 | if(req_oos_set(cli_info->port, oos_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
| 1666 | { |
| 1667 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1668 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1669 | } else { |
| 1670 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1671 | } |
| 1672 | } |
| 1673 | else |
| 1674 | { |
| 1675 | ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0); |
| 1676 | } |
| 1677 | } |
| 1678 | break; |
| 1679 | } |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1680 | default: |
| 1681 | { |
| 1682 | err = MBTK_RIL_ERR_REQ_UNKNOWN; |
| 1683 | LOG("Unknown request : %s", id2str(pack->msg_id)); |
| 1684 | break; |
| 1685 | } |
| 1686 | } |
| 1687 | |
| 1688 | return err; |
| 1689 | } |
| 1690 | |