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