liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 1 | #include <stdio.h>
|
| 2 | #include <stdlib.h>
|
| 3 | #include <unistd.h>
|
| 4 | #include <sys/socket.h>
|
| 5 | #include <errno.h>
|
| 6 | #include <fcntl.h>
|
| 7 | #include <string.h>
|
| 8 | #include <netinet/in.h>
|
| 9 | #include <arpa/inet.h>
|
| 10 | #include <linux/un.h>
|
| 11 | #include <linux/netlink.h>
|
| 12 | #include <cutils/properties.h>
|
| 13 | #include <time.h>
|
| 14 | #include <sys/time.h>
|
| 15 |
|
| 16 | //#include "cploader.h"
|
| 17 | #include "mbtk_log.h"
|
| 18 | #include "mbtk_ifc.h"
|
| 19 | #include "mbtk_type.h"
|
| 20 | #include "atchannel.h"
|
| 21 | #include "at_tok.h"
|
| 22 | #include "mbtk_utils.h"
|
| 23 | #include "mbtk_task.h"
|
| 24 | #include "mbtk_info.h"
|
| 25 | #include "mbtk_ntp.h"
|
| 26 | #include "mbtk_net_control.h"
|
| 27 | #include "info_data.h"
|
wangyouqiang | 38e5336 | 2024-01-23 10:53:48 +0800 | [diff] [blame] | 28 | #include "mbtk_led.h"
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 29 |
|
| 30 | #define TEMP_FAILURE_RETRY(exp) ({ \
|
| 31 | typeof (exp) _rc; \
|
| 32 | do { \
|
| 33 | _rc = (exp); \
|
| 34 | } while (_rc == -1 && errno == EINTR); \
|
| 35 | _rc; })
|
| 36 |
|
| 37 | #define BUFFER_SIZE 2048
|
| 38 | #define UEVENT_USIM_DEV "/devices/virtual/usim_event/usim0"
|
| 39 | #define MBTK_BOOT_SERVER_READY "/etc/init.d/mbtk_boot_server_ready"
|
| 40 |
|
| 41 | struct cooling_device
|
| 42 | {
|
| 43 | const char *name;
|
| 44 | const char *action;
|
| 45 | const char *path;
|
| 46 | const char *event;
|
| 47 | const char *subsystem;
|
| 48 | };
|
| 49 | static pthread_t uevnet_task_id;
|
| 50 | extern net_info_t net_info;
|
| 51 | extern mbtK_cell_pack_info_t cell_info;
|
| 52 | extern info_cgact_wait_t cgact_wait;
|
| 53 | extern bool at_process;
|
| 54 |
|
| 55 | void setRadioPower(int isOn);
|
| 56 | int urc_msg_distribute(bool async_process, info_urc_msg_id_enum msg, void *data, int data_len);
|
| 57 | int mbtk_signal_log(char *data);
|
| 58 |
|
| 59 | /* Called on command thread */
|
| 60 | static void onATTimeout()
|
| 61 | {
|
| 62 | LOGI("AT channel timeout; closing\n");
|
| 63 | at_close();
|
| 64 | }
|
| 65 |
|
| 66 | /* Called on command or reader thread */
|
| 67 | static void onATReaderClosed()
|
| 68 | {
|
| 69 | LOGI("AT channel closed\n");
|
| 70 | at_close();
|
| 71 | }
|
| 72 |
|
| 73 | //int req_time_set(int type, char *time, int *cme_err);
|
| 74 | static int metis_strptime(char *str_time)
|
| 75 | {
|
| 76 | struct tm stm;
|
| 77 | char dateTime[30];
|
| 78 | struct timeval tv;
|
| 79 | if(strptime(str_time, "%Y-%m-%d %H:%M:%S",&stm) != NULL)
|
| 80 | {
|
| 81 | time_t _t = mktime(&stm);
|
| 82 | tv.tv_sec = _t;
|
| 83 | if(settimeofday(&tv, NULL)) {
|
| 84 | LOG("Set time fail:%d", errno);
|
| 85 | return -1;
|
| 86 | } else {
|
| 87 | LOG("Set time to %s.", str_time);
|
| 88 | return 0;
|
| 89 | }
|
| 90 | } else {
|
| 91 | LOG("Set time fail.");
|
| 92 | return -1;
|
| 93 | }
|
| 94 | }
|
| 95 |
|
| 96 | static void* ntp_pthread_run(void* arg)
|
| 97 | {
|
| 98 | // Waitting for network connected.
|
| 99 | while(mbtk_net_state_get() == MBTK_NET_STATE_OFF) {
|
| 100 | sleep(1);
|
| 101 | }
|
| 102 | LOG("Network is connected.");
|
| 103 |
|
| 104 | char time_type[10];
|
| 105 | while(1){
|
| 106 | memset(time_type, 0, 10);
|
| 107 | property_get("persist.mbtk.time_type", time_type, "0");
|
| 108 | if(atoi(time_type) == MBTK_TIME_TYPE_NTP) // NTP time
|
| 109 | {
|
| 110 | char time_str[100] = {0};
|
| 111 | time_t time = 0;
|
| 112 | while((time = (time_t)mbtk_at_systime()) == 0) {
|
| 113 | usleep(100000);
|
| 114 | }
|
| 115 | struct tm *tm_t;
|
| 116 | tm_t = localtime(&time);
|
| 117 | strftime(time_str,128,"%F %T",tm_t);
|
| 118 |
|
| 119 | // NTP time
|
| 120 | metis_strptime(time_str);
|
| 121 | } else {
|
| 122 | break;
|
| 123 | }
|
| 124 |
|
| 125 | sleep(64); // Sleep 64s.
|
| 126 | }
|
| 127 | return NULL;
|
| 128 | }
|
| 129 |
|
| 130 | static void ntp_thread_start()
|
| 131 | {
|
| 132 | pthread_t ntp_pid;
|
| 133 | pthread_attr_t thread_attr;
|
| 134 | pthread_attr_init(&thread_attr);
|
| 135 | if(pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED))
|
| 136 | {
|
| 137 | LOG("pthread_attr_setdetachstate() fail.");
|
| 138 | return;
|
| 139 | }
|
| 140 |
|
| 141 | if(pthread_create(&ntp_pid, &thread_attr, ntp_pthread_run, NULL))
|
| 142 | {
|
| 143 | LOG("pthread_create() fail.");
|
| 144 | }
|
| 145 | }
|
| 146 |
|
| 147 | bool sms_cmt = false;
|
| 148 | mbtk_sim_card_info sim_info_reg={0};
|
| 149 | static void onUnsolicited(const char *s, const char *sms_pdu)
|
| 150 | {
|
| 151 | LOGV("URC : %s", s);
|
| 152 | // MBTK_AT_READY
|
| 153 | if (strStartsWith(s, "MBTK_AT_READY")) // AT ready.
|
| 154 | {
|
| 155 |
|
| 156 | }
|
| 157 | #if 0
|
| 158 | else if(strStartsWith(s, "*SIMDETEC:")) // *SIMDETEC:1,SIM
|
| 159 | {
|
| 160 | const char* ptr = strstr(s, ",");
|
| 161 | if(ptr)
|
| 162 | {
|
| 163 | ptr++; // Jump ','
|
| 164 | if(memcmp(ptr, "SIM", 3) == 0)
|
| 165 | net_info.sim_state = MBTK_SIM_STATE_READY;
|
| 166 | else
|
| 167 | net_info.sim_state = MBTK_SIM_STATE_ABSENT;
|
| 168 | }
|
| 169 | }
|
| 170 | #endif
|
| 171 | else if(strStartsWith(s, "*RADIOPOWER:")) // "*RADIOPOWER: 1"
|
| 172 | {
|
| 173 | const char* ptr = s + strlen("*RADIOPOWER:");
|
| 174 | while(*ptr != '\0' && *ptr == ' ' )
|
| 175 | {
|
| 176 | ptr++;
|
| 177 | }
|
| 178 |
|
| 179 | uint8 state;
|
| 180 | if(*ptr == '1') {
|
| 181 | //net_info.radio_state = MBTK_RADIO_STATE_ON;
|
| 182 | // mbtk_radio_ready_cb();
|
| 183 | state = (uint8)1;
|
| 184 | } else {
|
| 185 | //net_info.radio_state = MBTK_RADIO_STATE_OFF;
|
| 186 | state = (uint8)0;
|
| 187 | }
|
| 188 | urc_msg_distribute(true, INFO_URC_MSG_RADIO_STATE, &state, sizeof(uint8));
|
| 189 | }
|
| 190 | // "CONNECT"
|
| 191 | else if(strStartsWith(s, "CONNECT"))
|
| 192 | {
|
| 193 | if(cgact_wait.waitting && cgact_wait.act) {
|
| 194 | cgact_wait.waitting = false;
|
| 195 | }
|
| 196 |
|
| 197 | uint8 data_pdp;
|
| 198 | data_pdp = 1; //
|
| 199 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 200 | }
|
| 201 | // +CGEV:
|
| 202 | // +CGEV: NW DEACT <cid>,<cid>
|
| 203 | // +CGEV: ME DEACT <cid>,<cid>
|
| 204 | // +CGEV: NW PDN DEACT <cid>
|
| 205 | // +CGEV: ME PDN DEACT <cid>
|
| 206 | // +CGEV: NW DETACH
|
| 207 | // +CGEV: ME DETACH
|
| 208 | //
|
| 209 | // +CGEV: NW ACT <cid>,<cid>
|
| 210 | // +CGEV: ME ACT <cid>,<cid>
|
| 211 | // +CGEV: EPS PDN ACT <cid>
|
| 212 | // +CGEV: ME PDN ACT <cid>,<reason>,<cid>
|
| 213 | // +CGEV: ME PDN ACT <cid>,<reason>
|
| 214 | // +CGEV: NW PDN ACT <cid>
|
| 215 | // +CGEV: EPS ACT <cid>
|
| 216 | // +CGEV: NW MODIFY <cid>,<reason>
|
| 217 | // +CGEV: NW REATTACH
|
| 218 | else if(strStartsWith(s, "+CGEV:"))
|
| 219 | {
|
| 220 | if(at_process) {
|
| 221 | if(cgact_wait.act) {
|
| 222 | if(strStartsWith(s, "+CGEV: ME PDN ACT ")) { // +CGEV: ME PDN ACT 15,4
|
| 223 | if(cgact_wait.cid == atoi(s + 18)) {
|
| 224 | cgact_wait.waitting = false;
|
| 225 | }
|
| 226 |
|
| 227 | uint8 data_pdp;
|
| 228 | char* tmp_s = memdup(s + 18,strlen(s + 18));
|
| 229 | char* free_ptr = tmp_s;
|
| 230 | char *line = tmp_s;
|
| 231 | int tmp_int;
|
| 232 | if (at_tok_start(&line) < 0)
|
| 233 | {
|
| 234 | goto at_PDP_CREG_EXIT;
|
| 235 | }
|
| 236 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 237 | {
|
| 238 | goto at_PDP_CREG_EXIT;
|
| 239 | }
|
| 240 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 241 | {
|
| 242 | goto at_PDP_CREG_EXIT;
|
| 243 | }
|
| 244 | data_pdp = tmp_int;
|
| 245 | at_PDP_CREG_EXIT:
|
| 246 | free(free_ptr);
|
| 247 |
|
| 248 | //data_pdp = (uint8)atoi(s + 20); //reason
|
| 249 | if(cgact_wait.cid >= 1 && cgact_wait.cid < 8)
|
| 250 | {
|
| 251 | if(data_pdp == 0)
|
| 252 | {
|
| 253 | data_pdp = 25;
|
| 254 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 255 | //data_pdp = cgact_wait.cid + 200;
|
| 256 | }
|
| 257 | else if(data_pdp == 1)
|
| 258 | {
|
| 259 | data_pdp = 26;
|
| 260 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 261 | }
|
| 262 | else if(data_pdp == 2)
|
| 263 | {
|
| 264 | data_pdp = 27;
|
| 265 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 266 | }
|
| 267 | else if(data_pdp == 3)
|
| 268 | {
|
| 269 | data_pdp = 27;
|
| 270 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 271 | }
|
| 272 | else
|
| 273 | {
|
| 274 |
|
| 275 | }
|
| 276 | if(cgact_wait.cid != 0)
|
| 277 | {
|
| 278 | data_pdp = cgact_wait.cid + 200;
|
| 279 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 280 | }
|
| 281 | }
|
| 282 | } else if(strStartsWith(s, "+CGEV: NW MODIFY ")) { // +CGEV: NW MODIFY 1,4
|
| 283 | if(cgact_wait.cid == atoi(s + 17)) {
|
| 284 | cgact_wait.waitting = false;
|
| 285 | }
|
| 286 | }
|
| 287 | } else {
|
| 288 | if(strStartsWith(s, "+CGEV: ME PDN DEACT ")) { // +CGEV: ME PDN DEACT 1
|
| 289 | if(cgact_wait.cid == atoi(s + 20)) {
|
| 290 | cgact_wait.waitting = false;
|
| 291 | }
|
| 292 | uint8 data_pdp;
|
| 293 | data_pdp = 0; //
|
| 294 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 295 | if(cgact_wait.cid != 0)
|
| 296 | {
|
| 297 | data_pdp = cgact_wait.cid + 100;
|
| 298 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 299 | }
|
| 300 | }
|
| 301 | }
|
| 302 | } else {
|
| 303 | // apn_state_set
|
| 304 |
|
| 305 | // +CGEV: NW PDN DEACT <cid>
|
| 306 |
|
| 307 | // +CGEV: EPS PDN ACT 1
|
| 308 | // +CGEV: ME PDN ACT 8,1
|
| 309 |
|
| 310 | // +CGEV: ME PDN ACT 2,4
|
| 311 | uint8 data[2] = {0xFF};
|
| 312 | if(strStartsWith(s, "+CGEV: NW PDN DEACT ")) { // +CGEV: NW PDN DEACT <cid>
|
| 313 | //apn_state_set(atoi(s + 20), false);
|
| 314 | data[0] = (uint8)0;
|
| 315 | data[1] = (uint8)atoi(s + 20);
|
| 316 |
|
| 317 | uint8 data_pdp;
|
| 318 | data_pdp = 0; //
|
| 319 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
wangyouqiang | 6588415 | 2023-10-25 19:54:15 +0800 | [diff] [blame] | 320 | data_pdp = data[1] + 100;
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 321 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 322 | } else if(strStartsWith(s, "+CGEV: EPS PDN ACT ")) { // +CGEV: EPS PDN ACT <cid>
|
| 323 | //apn_state_set(atoi(s + 19), true);
|
b.liu | f37bd33 | 2024-03-18 13:51:24 +0800 | [diff] [blame] | 324 | #if (defined(MBTK_AF_SUPPORT) || defined(MBTK_ALL_CID_SUPPORT))
|
wangyouqiang | ed88c72 | 2023-11-22 16:33:43 +0800 | [diff] [blame] | 325 | //data[0] = (uint8)1;
|
| 326 | //data[1] = (uint8)atoi(s + 19);
|
| 327 | #else
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 328 | data[0] = (uint8)1;
|
| 329 | data[1] = (uint8)atoi(s + 19);
|
wangyouqiang | ed88c72 | 2023-11-22 16:33:43 +0800 | [diff] [blame] | 330 | #endif
|
wangyouqiang | 6588415 | 2023-10-25 19:54:15 +0800 | [diff] [blame] | 331 | } else if(strStartsWith(s, "+CGEV: ME PDN DEACT ")) { // +CGEV: EPS PDN DEACT <cid>
|
| 332 | //apn_state_set(atoi(s + 19), true);
|
| 333 | data[0] = (uint8)0;
|
| 334 | data[1] = (uint8)atoi(s + 20);
|
| 335 |
|
| 336 | uint8 data_pdp;
|
| 337 | data_pdp = 0; //
|
| 338 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 339 | data_pdp = data[1] + 100;
|
| 340 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 341 | } else if(strStartsWith(s, "+CGEV: ME PDN ACT ")) { // +CGEV: ME PDN ACT <cid>,1
|
| 342 | //apn_state_set(atoi(s + 18), true);
|
| 343 | data[0] = (uint8)1;
|
| 344 | data[1] = (uint8)atoi(s + 18);
|
| 345 |
|
| 346 | uint8 data_pdp;
|
| 347 | char* tmp_s = memdup(s + 18,strlen(s + 18));
|
| 348 | char* free_ptr = tmp_s;
|
| 349 | char *line = tmp_s;
|
| 350 | int tmp_int;
|
| 351 | if (at_tok_start(&line) < 0)
|
| 352 | {
|
| 353 | goto PDP_CREG_EXIT;
|
| 354 | }
|
| 355 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 356 | {
|
| 357 | goto PDP_CREG_EXIT;
|
| 358 | }
|
| 359 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 360 | {
|
| 361 | goto PDP_CREG_EXIT;
|
| 362 | }
|
| 363 | data_pdp = tmp_int;
|
| 364 | PDP_CREG_EXIT:
|
| 365 | free(free_ptr);
|
| 366 | //data_pdp = (uint8)atoi(s + 20); //reason
|
| 367 | if(data[1] >= 1 && data[1] < 8)
|
| 368 | {
|
| 369 | if(data_pdp == 0)
|
| 370 | {
|
| 371 | data_pdp = 25;
|
| 372 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 373 | }
|
| 374 | else if(data_pdp == 1)
|
| 375 | {
|
| 376 | data_pdp = 26;
|
| 377 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 378 | }
|
| 379 | else if(data_pdp == 2)
|
| 380 | {
|
| 381 | data_pdp = 27;
|
| 382 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 383 | }
|
| 384 | else if(data_pdp == 3)
|
| 385 | {
|
| 386 | data_pdp = 27;
|
| 387 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 388 | }
|
| 389 | else
|
| 390 | {
|
| 391 |
|
| 392 | }
|
b.liu | fe32063 | 2024-01-17 20:38:08 +0800 | [diff] [blame] | 393 |
|
wangyouqiang | 6588415 | 2023-10-25 19:54:15 +0800 | [diff] [blame] | 394 | data_pdp = data[1] + 200;
|
| 395 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 396 | }
|
| 397 | } else {
|
| 398 | LOGI("No process : %s", s);
|
| 399 | }
|
| 400 |
|
| 401 | urc_msg_distribute(true, INFO_URC_MSG_CGEV, data, sizeof(uint8) * 2);
|
| 402 | }
|
| 403 | }
|
| 404 | // +CREG: 1, "8010", "000060a5", 0, 2, 0
|
| 405 | // +CREG: 1, "8330", "06447347", 7, 2, 0
|
| 406 | // +CEREG: 1, "8330", "06447347", 7
|
| 407 | // $CREG: 1, "8330", "06447347", 7,"0d4", 2, 0
|
| 408 | // $CREG: 1, "8010", "000060a7", 0,, 2, 0
|
| 409 | // +CGREG: 1
|
| 410 | else if(strStartsWith(s, "+CGREG:") // GMS/WCDMA data registed.
|
| 411 | || strStartsWith(s, "+CEREG:")) // LTE data registed.
|
| 412 | {
|
| 413 | char* tmp_s = s + 7;
|
| 414 | while(*tmp_s && *tmp_s == ' ')
|
| 415 | tmp_s++;
|
b.liu | fe32063 | 2024-01-17 20:38:08 +0800 | [diff] [blame] | 416 | uint8 data[2];
|
| 417 | data[0] = (uint8)atoi(tmp_s); // Reg State.
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 418 |
|
b.liu | fe32063 | 2024-01-17 20:38:08 +0800 | [diff] [blame] | 419 | if(strStartsWith(s, "+CGREG:")) {
|
| 420 | data[1] = 0; // GMS/WCDMA
|
| 421 | } else {
|
| 422 | data[1] = 1; // LTE
|
wangyouqiang | 38e5336 | 2024-01-23 10:53:48 +0800 | [diff] [blame] | 423 | if(data[0] == 1)
|
| 424 | {
|
| 425 | mbtk_net_led_set(MBTK_NET_LED_NET_CONNECT);
|
| 426 | }
|
| 427 | else
|
| 428 | {
|
| 429 | mbtk_net_led_set(MBTK_NET_LED_SEARCH_NETWORK);
|
| 430 | }
|
b.liu | fe32063 | 2024-01-17 20:38:08 +0800 | [diff] [blame] | 431 | }
|
| 432 |
|
| 433 | urc_msg_distribute(true, INFO_URC_MSG_NET_PS_REG_STATE, data, sizeof(data));
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 434 | }
|
| 435 | // +CREG: 1, "8010", "000060a5", 0, 2, 0
|
| 436 | // +CREG: 1, "8330", "06447347", 7, 2, 0
|
| 437 | // +CREG: 0
|
| 438 | else if(strStartsWith(s, "+CREG:")) // GMS/WCDMA/LTE CS registed.
|
| 439 | {
|
| 440 | uint8 data[3];
|
| 441 | data[0] = (uint8)MBTK_NET_CS_STATE;
|
| 442 | char* tmp_s = memdup(s,strlen(s));
|
| 443 | char* free_ptr = tmp_s;
|
| 444 | char *line = tmp_s;
|
| 445 | int tmp_int;
|
| 446 | char *tmp_str;
|
| 447 | if (at_tok_start(&line) < 0)
|
| 448 | {
|
| 449 | goto CREG_EXIT;
|
| 450 | }
|
| 451 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 452 | {
|
| 453 | goto CREG_EXIT;
|
| 454 | }
|
| 455 | data[1] = (uint8)tmp_int; // Reg State.
|
| 456 | if (data[1])
|
| 457 | {
|
| 458 | if (at_tok_nextstr(&line, &tmp_str) < 0)
|
| 459 | {
|
| 460 | goto CREG_EXIT;
|
| 461 | }
|
| 462 | if (at_tok_nextstr(&line, &tmp_str) < 0)
|
| 463 | {
|
| 464 | goto CREG_EXIT;
|
| 465 | }
|
| 466 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 467 | {
|
| 468 | goto CREG_EXIT;
|
| 469 | }
|
| 470 | data[2] = (uint8)tmp_int; // AcT
|
| 471 | } else {
|
| 472 | data[2] = (uint8)0xFF; // AcT
|
| 473 | }
|
| 474 | if(data[1] == 5)
|
| 475 | {
|
| 476 | uint8 data_pdp;
|
| 477 | data_pdp = 5; //
|
| 478 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 479 | }
|
| 480 | urc_msg_distribute(false, INFO_URC_MSG_NET_CS_REG_STATE, data, sizeof(data));
|
| 481 | CREG_EXIT:
|
| 482 | free(free_ptr);
|
| 483 | }
|
| 484 | // +CLCC: 1, 1, 6, 0, 0, "18981911691", 129, "",, 0
|
| 485 | else if(strStartsWith(s, "+CLCC:"))
|
| 486 | {
|
| 487 | mbtk_call_info_t reg;
|
| 488 | reg.call_wait = MBTK_CLCC;
|
| 489 | char* tmp_s = memdup(s,strlen(s));
|
| 490 | char* free_ptr = tmp_s;
|
| 491 | char *line = tmp_s;
|
| 492 | int tmp_int;
|
| 493 | char *tmp_str;
|
| 494 | int err;
|
| 495 |
|
| 496 | err = at_tok_start(&line);
|
| 497 | if (err < 0)
|
| 498 | {
|
| 499 | goto CLCC_EXIT;
|
| 500 | }
|
| 501 | err = at_tok_nextint(&line, &tmp_int); // dir1
|
| 502 | if (err < 0)
|
| 503 | {
|
| 504 | goto CLCC_EXIT;
|
| 505 | }
|
| 506 | reg.dir1 = (uint8)tmp_int;
|
| 507 | err = at_tok_nextint(&line, &tmp_int);// dir
|
| 508 | if (err < 0)
|
| 509 | {
|
| 510 | goto CLCC_EXIT;
|
| 511 | }
|
| 512 | reg.dir = (uint8)tmp_int;
|
| 513 | err = at_tok_nextint(&line, &tmp_int);// state
|
| 514 | if (err < 0)
|
| 515 | {
|
| 516 | goto CLCC_EXIT;
|
| 517 | }
|
| 518 | reg.state = (uint8)tmp_int;
|
| 519 | err = at_tok_nextint(&line, &tmp_int);// mode
|
| 520 | if (err < 0)
|
| 521 | {
|
| 522 | goto CLCC_EXIT;
|
| 523 | }
|
| 524 | reg.mode = (uint8)tmp_int;
|
| 525 | err = at_tok_nextint(&line, &tmp_int);// mpty
|
| 526 | if (err < 0)
|
| 527 | {
|
| 528 | goto CLCC_EXIT;
|
| 529 | }
|
| 530 | reg.mpty = (uint8)tmp_int;
|
| 531 | err = at_tok_nextstr(&line, &tmp_str); // phone_number
|
| 532 | if (err < 0)
|
| 533 | {
|
| 534 | goto CLCC_EXIT;
|
| 535 | }
|
| 536 |
|
| 537 | memset(reg.phone_number,0,sizeof(reg.phone_number));
|
| 538 | memcpy(reg.phone_number, tmp_str, strlen(tmp_str));
|
| 539 | err = at_tok_nextint(&line, &tmp_int);// tpye
|
| 540 | if (err < 0)
|
| 541 | {
|
| 542 | goto CLCC_EXIT;
|
| 543 | }
|
| 544 | reg.type = (uint8)tmp_int;
|
| 545 |
|
| 546 | urc_msg_distribute(false, INFO_URC_MSG_CALL_STATE, ®, sizeof(mbtk_call_info_t));
|
| 547 | CLCC_EXIT:
|
| 548 | free(free_ptr);
|
| 549 | }
|
| 550 | // +CPAS: 4
|
| 551 | else if(strStartsWith(s, "+CPAS:"))
|
| 552 | {
|
| 553 | mbtk_call_info_t reg;
|
| 554 | reg.call_wait = 0;
|
| 555 | char* tmp_s = memdup(s,strlen(s));
|
| 556 | char* free_ptr = tmp_s;
|
| 557 | char *line = tmp_s;
|
| 558 | int tmp_int;
|
| 559 | int err;
|
| 560 |
|
| 561 | memset(®,0,sizeof(reg));
|
| 562 |
|
| 563 | err = at_tok_start(&line);
|
| 564 | if (err < 0)
|
| 565 | {
|
| 566 | goto CPAS_EXIT;
|
| 567 | }
|
| 568 | err = at_tok_nextint(&line, &tmp_int);
|
| 569 | if (err < 0)
|
| 570 | {
|
| 571 | goto CPAS_EXIT;
|
| 572 | }
|
| 573 | reg.pas = (uint8)tmp_int;
|
| 574 | reg.call_wait = MBTK_CPAS;
|
| 575 | urc_msg_distribute(false, INFO_URC_MSG_CALL_STATE, ®, sizeof(mbtk_call_info_t));
|
| 576 | CPAS_EXIT:
|
| 577 | free(free_ptr);
|
| 578 | }
|
| 579 | // +CALLDISCONNECT: 1
|
| 580 | else if(strStartsWith(s, "+CALLDISCONNECT:"))
|
| 581 | {
|
| 582 | mbtk_call_info_t reg;
|
| 583 | reg.call_wait = 0;
|
| 584 | char* tmp_s = memdup(s,strlen(s));
|
| 585 | char* free_ptr = tmp_s;
|
| 586 | char *line = tmp_s;
|
| 587 | int tmp_int;
|
| 588 | int err;
|
| 589 |
|
| 590 | memset(®,0,sizeof(reg));
|
| 591 |
|
| 592 | err = at_tok_start(&line);
|
| 593 | if (err < 0)
|
| 594 | {
|
| 595 | goto CALLDISCONNECTED_EXIT;
|
| 596 | }
|
| 597 | err = at_tok_nextint(&line, &tmp_int);
|
| 598 | if (err < 0)
|
| 599 | {
|
| 600 | goto CALLDISCONNECTED_EXIT;
|
| 601 | }
|
| 602 | reg.disconnected_id = tmp_int;
|
| 603 | reg.call_wait = MBTK_DISCONNECTED;
|
| 604 | urc_msg_distribute(false, INFO_URC_MSG_CALL_STATE, ®, sizeof(mbtk_call_info_t));
|
| 605 |
|
| 606 | CALLDISCONNECTED_EXIT:
|
| 607 | free(free_ptr);
|
| 608 | }
|
| 609 | // *SIMDETEC:1,SIM
|
| 610 | else if(strStartsWith(s, "*SIMDETEC:"))
|
| 611 | {
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 612 | if(strStartsWith(s, "*SIMDETEC:1,NOS"))
|
| 613 | {
|
| 614 | net_info.sim_state = MBTK_SIM_ABSENT;
|
| 615 | }
|
| 616 |
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 617 | sim_info_reg.sim = -1;
|
| 618 | if(strStartsWith(s, "*SIMDETEC:1,NOS"))
|
| 619 | sim_info_reg.sim = 0;
|
| 620 | else if(strStartsWith(s, "*SIMDETEC:1,SIM"))
|
| 621 | sim_info_reg.sim = 1;
|
| 622 | if(sim_info_reg.sim == 0)
|
| 623 | {
|
| 624 | uint8 data_pdp;
|
| 625 | data_pdp = 11; //
|
| 626 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 627 | }
|
| 628 | urc_msg_distribute(false, INFO_URC_MSG_SIM_STATE, &sim_info_reg, sizeof(mbtk_sim_card_info));
|
| 629 | }
|
| 630 | // *EUICC:1
|
| 631 | /*0: SIM
|
| 632 | 1: USIM
|
| 633 | 2: TEST SIM
|
| 634 | 3: TEST USIM
|
| 635 | 4: UNKNOWN
|
| 636 | Note: *EUICC:
|
| 637 | */
|
| 638 | else if(strStartsWith(s, "*EUICC:"))
|
| 639 | {
|
| 640 | sim_info_reg.sim_card_type = -1;
|
| 641 | if(strStartsWith(s, "*EUICC: 0"))
|
| 642 | sim_info_reg.sim_card_type = 1;
|
| 643 | else if(strStartsWith(s, "*EUICC: 1"))
|
| 644 | sim_info_reg.sim_card_type = 2;
|
| 645 | else if(strStartsWith(s, "*EUICC: 2"))
|
| 646 | sim_info_reg.sim_card_type = 1;
|
| 647 | else if(strStartsWith(s, "*EUICC: 3"))
|
| 648 | sim_info_reg.sim_card_type = 2;
|
| 649 | else if(strStartsWith(s, "*EUICC: 4"))
|
| 650 | sim_info_reg.sim_card_type = 0;
|
| 651 | urc_msg_distribute(false, INFO_URC_MSG_SIM_STATE, &sim_info_reg, sizeof(mbtk_sim_card_info));
|
| 652 | }
|
| 653 | // +CPIN: SIM PIN
|
| 654 | else if(strStartsWith(s, "+CPIN:"))
|
| 655 | {
|
| 656 | sim_info_reg.sim = -1;
|
| 657 | if(strStartsWith(s, "+CPIN: READY"))
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 658 | {
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 659 | sim_info_reg.sim = 1;
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 660 | net_info.sim_state = MBTK_SIM_READY;
|
| 661 | }
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 662 | else if(strStartsWith(s, "+CPIN: SIM PIN"))
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 663 | {
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 664 | sim_info_reg.sim = 2;
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 665 | net_info.sim_state = MBTK_SIM_PIN;
|
| 666 | }
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 667 | else if(strStartsWith(s, "+CPIN: SIM PUK"))
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 668 | {
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 669 | sim_info_reg.sim = 3;
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 670 | net_info.sim_state = MBTK_SIM_PUK;
|
| 671 | }
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 672 | else if(strStartsWith(s, "+CPIN: PH-SIMLOCK PIN"))
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 673 | {
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 674 | sim_info_reg.sim = 4;
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 675 | net_info.sim_state = MBTK_SIM_ABSENT;
|
| 676 | }
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 677 | else if(strStartsWith(s, "+CPIN: PH-SIMLOCK PUK"))
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 678 | {
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 679 | sim_info_reg.sim = 5;
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 680 | net_info.sim_state = MBTK_SIM_ABSENT;
|
| 681 | }
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 682 | else if(strStartsWith(s, "+CPIN: PH-FSIM PIN"))
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 683 | {
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 684 | sim_info_reg.sim = 6;
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 685 | net_info.sim_state = MBTK_SIM_ABSENT;
|
| 686 | }
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 687 | else if(strStartsWith(s, "+CPIN: PH-FSIM PUK"))
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 688 | {
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 689 | sim_info_reg.sim = 7;
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 690 | net_info.sim_state = MBTK_SIM_ABSENT;
|
| 691 | }
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 692 | else if(strStartsWith(s, "+CPIN: SIM PIN2"))
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 693 | {
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 694 | sim_info_reg.sim = 8;
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 695 | net_info.sim_state = MBTK_SIM_ABSENT;
|
| 696 | }
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 697 | else if(strStartsWith(s, "+CPIN: SIM PUK2"))
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 698 | {
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 699 | sim_info_reg.sim = 9;
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 700 | net_info.sim_state = MBTK_SIM_ABSENT;
|
| 701 | }
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 702 | else if(strStartsWith(s, "+CPIN: PH-NET PIN"))
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 703 | {
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 704 | sim_info_reg.sim = 10;
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 705 | net_info.sim_state = MBTK_SIM_NETWORK_PERSONALIZATION;
|
| 706 | }
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 707 | else if(strStartsWith(s, "+CPIN: PH-NET PUK"))
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 708 | {
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 709 | sim_info_reg.sim = 11;
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 710 | net_info.sim_state = MBTK_SIM_ABSENT;
|
| 711 | }
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 712 | else if(strStartsWith(s, "+CPIN: PH-NETSUB PINMT"))
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 713 | {
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 714 | sim_info_reg.sim = 12;
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 715 | net_info.sim_state = MBTK_SIM_ABSENT;
|
| 716 | }
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 717 | else if(strStartsWith(s, "+CPIN: PH-NETSUB PUK"))
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 718 | {
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 719 | sim_info_reg.sim = 13;
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 720 | net_info.sim_state = MBTK_SIM_ABSENT;
|
| 721 | }
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 722 | else if(strStartsWith(s, "+CPIN: PH-SP PIN"))
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 723 | {
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 724 | sim_info_reg.sim = 14;
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 725 | net_info.sim_state = MBTK_SIM_ABSENT;
|
| 726 | }
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 727 | else if(strStartsWith(s, "+CPIN: PH-SP PUK"))
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 728 | {
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 729 | sim_info_reg.sim = 15;
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 730 | net_info.sim_state = MBTK_SIM_ABSENT;
|
| 731 | }
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 732 | else if(strStartsWith(s, "+CPIN: PH-CORP PIN"))
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 733 | {
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 734 | sim_info_reg.sim = 16;
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 735 | net_info.sim_state = MBTK_SIM_ABSENT;
|
| 736 | }
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 737 | else if(strStartsWith(s, "+CPIN: PH-CORP PUK"))
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 738 | {
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 739 | sim_info_reg.sim = 17;
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 740 | net_info.sim_state = MBTK_SIM_ABSENT;
|
| 741 | }
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 742 | else if(strStartsWith(s, "+CPIN: SIM REMOVED"))
|
liuyang | e22a25e | 2024-05-23 19:41:52 +0800 | [diff] [blame^] | 743 | {
|
| 744 | sim_info_reg.sim = 18;
|
| 745 | net_info.sim_state = MBTK_SIM_ABSENT;
|
| 746 | }
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 747 | else
|
| 748 | sim_info_reg.sim = 20;
|
| 749 |
|
| 750 | if(sim_info_reg.sim == 18)
|
| 751 | {
|
| 752 | uint8 data_pdp;
|
| 753 | data_pdp = 11; //
|
| 754 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 755 | }
|
| 756 |
|
| 757 | urc_msg_distribute(false, INFO_URC_MSG_SIM_STATE, &sim_info_reg, sizeof(mbtk_sim_card_info));
|
| 758 | }
|
| 759 | // +CMT: ,23
|
| 760 | // 0891683108200855F6240D91688189911196F10000221130717445230331D90C
|
| 761 | else if(strStartsWith(s, "+CMT:") || sms_cmt)
|
| 762 | {
|
| 763 | if(!sms_cmt){
|
| 764 | sms_cmt = true;
|
| 765 | }else{
|
| 766 | sms_cmt = false;
|
| 767 | }
|
| 768 | printf("+CMT() sms_cmt:%d, s:%s, len:%d\n",sms_cmt, s, strlen(s));
|
| 769 | urc_msg_distribute(false, INFO_URC_MSG_SMS_STATE, s, strlen(s));
|
| 770 | }
|
| 771 | #if 0
|
| 772 | // LTE data registed.
|
| 773 | // +CEREG: 1, "8330", "06447347", 7
|
| 774 | else if(strStartsWith(s, "+CEREG:"))
|
| 775 | {
|
| 776 | char* tmp_s = memdup(s,strlen(s));
|
| 777 | char* free_ptr = tmp_s;
|
| 778 | char *line = tmp_s;
|
| 779 | int tmp_int;
|
| 780 | char *tmp_str;
|
| 781 | if (at_tok_start(&line) < 0)
|
| 782 | {
|
| 783 | goto CREG_EXIT;
|
| 784 | }
|
| 785 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 786 | {
|
| 787 | goto CREG_EXIT;
|
| 788 | }
|
| 789 | uint8 data = (uint8)tmp_int; // Reg State.
|
| 790 |
|
| 791 | urc_msg_distribute(INFO_URC_MSG_NET_REG_STATE, &data, sizeof(uint8));
|
| 792 | CREG_EXIT:
|
| 793 | free(free_ptr);
|
| 794 | }
|
| 795 | #endif
|
| 796 | /*
|
| 797 | // <mcc>, <length of mnc>, <mnc>, <tac>, <PCI>, <dlEuarfcn>, < ulEuarfcn >, <band>, <dlBandwidth>,
|
| 798 | // <rsrp>,<rsrq>, <sinr>,
|
| 799 | // errcModeState,emmState,serviceState,IsSingleEmmRejectCause,EMMRejectCause,mmeGroupId,mmeCode,mTmsi,
|
| 800 | // cellId,subFrameAssignType,specialSubframePatterns,transMode
|
| 801 | // mainRsrp,diversityRsrp,mainRsrq,diversityRsrq,rssi,cqi,pathLoss,tb0DlTpt,tb1DlTpt,tb0DlPeakTpt,tb1DlPeakTpt,tb0UlPeakTpt,
|
| 802 | // tb1UlPeakTpt,dlThroughPut,dlPeakThroughPut,averDlPRB,averCQITb0,averCQITb1,rankIndex,grantTotal,ulThroughPut,ulPeakThroughPut,currPuschTxPower,averUlPRB,
|
| 803 | // dlBer, ulBer,
|
| 804 | // diversitySinr, diversityRssi
|
| 805 | +EEMLTESVC: 1120, 2, 0, 33584, 430, 40936, 40936, 41, 20,
|
| 806 | 0, 0, 0,
|
| 807 | 1, 10, 0, 1, 0, 1059, 78, 3959566565,
|
| 808 | 105149248, 2, 7, 7,
|
| 809 | 0, 0, 0, 0, 0, 0, 0, 1190919, 0, 0, 0, 16779777,
|
| 810 | 0, 5112867, 3959566565, 2, 0, 0, 0, 0, 0, 0, 0, 0,
|
| 811 | 0, 0,
|
| 812 | 7, 44
|
| 813 | */
|
| 814 | else if(strStartsWith(s, "+EEMLTESVC:")) // LTE Server Cell
|
| 815 | {
|
| 816 | // tac, PCI, dlEuarfcn, ulEuarfcn, band
|
| 817 | if(cell_info.running) {
|
| 818 | int tmp_int;
|
| 819 | int i = 0;
|
| 820 | char* tmp_s = memdup(s,strlen(s));
|
| 821 | char* free_ptr = tmp_s;
|
| 822 | char *line = tmp_s;
|
| 823 | if (at_tok_start(&line) < 0)
|
| 824 | {
|
| 825 | goto EEMLTESVC_EXIT;
|
| 826 | }
|
| 827 |
|
| 828 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 829 | {
|
| 830 | goto EEMLTESVC_EXIT;
|
| 831 | }
|
| 832 | cell_info.cell[cell_info.cell_num].value6 = (uint32)tmp_int; //mcc
|
| 833 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 834 | {
|
| 835 | goto EEMLTESVC_EXIT;
|
| 836 | }
|
| 837 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 838 | {
|
| 839 | goto EEMLTESVC_EXIT;
|
| 840 | }
|
| 841 | cell_info.cell[cell_info.cell_num].value7 = (uint32)tmp_int; //mnc
|
| 842 | /*
|
| 843 | // Jump 2 integer.
|
| 844 | i = 0;
|
| 845 | while(i < 2) {
|
| 846 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 847 | {
|
| 848 | goto EEMLTESVC_EXIT;
|
| 849 | }
|
| 850 | i++;
|
| 851 | }
|
| 852 | */
|
| 853 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 854 | {
|
| 855 | goto EEMLTESVC_EXIT;
|
| 856 | }
|
| 857 | cell_info.cell[cell_info.cell_num].value1 = (uint32)tmp_int; //tac
|
| 858 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 859 | {
|
| 860 | goto EEMLTESVC_EXIT;
|
| 861 | }
|
| 862 | cell_info.cell[cell_info.cell_num].value2 = (uint32)tmp_int; //pci
|
| 863 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 864 | {
|
| 865 | goto EEMLTESVC_EXIT;
|
| 866 | }
|
| 867 | cell_info.cell[cell_info.cell_num].value3 = (uint32)tmp_int; //dl arfcn
|
| 868 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 869 | {
|
| 870 | goto EEMLTESVC_EXIT;
|
| 871 | }
|
| 872 | cell_info.cell[cell_info.cell_num].value4 = (uint32)tmp_int; //ul arfcn
|
| 873 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 874 | {
|
| 875 | goto EEMLTESVC_EXIT;
|
| 876 | }
|
| 877 | cell_info.cell[cell_info.cell_num].value5 = (uint32)tmp_int; //band
|
| 878 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 879 | {
|
| 880 | goto EEMLTESVC_EXIT;
|
| 881 | }
|
| 882 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 883 | {
|
| 884 | goto EEMLTESVC_EXIT;
|
| 885 | }
|
| 886 | cell_info.cell[cell_info.cell_num].value8 = (uint32)tmp_int; //cid
|
| 887 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 888 | {
|
| 889 | goto EEMLTESVC_EXIT;
|
| 890 | }
|
| 891 | cell_info.cell[cell_info.cell_num].value9 = (uint32)tmp_int; //rsrp
|
| 892 |
|
| 893 | for(i =0; i < 10; i++)
|
| 894 | {
|
| 895 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 896 | {
|
| 897 | goto EEMLTESVC_EXIT;
|
| 898 | }
|
| 899 | }
|
| 900 | cell_info.cell[cell_info.cell_num].value10 = (uint32)tmp_int; //cell identiy
|
| 901 |
|
| 902 | cell_info.cell_num++;
|
| 903 |
|
| 904 | EEMLTESVC_EXIT:
|
| 905 | free(free_ptr);
|
| 906 | }
|
| 907 | }
|
| 908 | /*
|
| 909 | // index,phyCellId,euArfcn,rsrp,rsrq
|
| 910 | +EEMLTEINTER: 0, 65535, 38950, 0, 0
|
| 911 | */
|
| 912 | else if(strStartsWith(s, "+EEMLTEINTER:") || strStartsWith(s, "+EEMLTEINTRA:")) // LTE ÒìÆµ/Í¬ÆµÐ¡Çø
|
| 913 | {
|
| 914 | // phyCellId,euArfcn,rsrp,rsrq
|
| 915 | if(cell_info.running) {
|
| 916 | int tmp_int;
|
| 917 | char* tmp_s = memdup(s,strlen(s));
|
| 918 | char* free_ptr = tmp_s;
|
| 919 | char *line = tmp_s;
|
| 920 | if (at_tok_start(&line) < 0)
|
| 921 | {
|
| 922 | goto EEMLTEINTER_EXIT;
|
| 923 | }
|
| 924 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 925 | {
|
| 926 | goto EEMLTEINTER_EXIT;
|
| 927 | }
|
| 928 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int <= 0 || tmp_int > 503)
|
| 929 | {
|
| 930 | goto EEMLTEINTER_EXIT;
|
| 931 | }
|
| 932 | cell_info.cell[cell_info.cell_num].value1 = (uint32)tmp_int;
|
| 933 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 934 | {
|
| 935 | goto EEMLTEINTER_EXIT;
|
| 936 | }
|
| 937 | cell_info.cell[cell_info.cell_num].value2 = (uint32)tmp_int;
|
| 938 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 939 | {
|
| 940 | goto EEMLTEINTER_EXIT;
|
| 941 | }
|
| 942 | cell_info.cell[cell_info.cell_num].value3 = (uint32)tmp_int;
|
| 943 | LOG("cell line : %s", line);
|
| 944 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 945 | {
|
| 946 | goto EEMLTEINTER_EXIT;
|
| 947 | }
|
| 948 | cell_info.cell[cell_info.cell_num].value4 = (uint32)tmp_int;
|
| 949 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 950 | {
|
| 951 | LOG("cell tmp_int : %d", tmp_int);
|
| 952 | goto EEMLTEINTER_EXIT;
|
| 953 | }
|
| 954 | cell_info.cell[cell_info.cell_num].value5 = (uint32)tmp_int;
|
| 955 | LOG("cell value5 : %d", cell_info.cell[cell_info.cell_num].value5);
|
| 956 | cell_info.cell_num++;
|
| 957 | EEMLTEINTER_EXIT:
|
| 958 | free(free_ptr);
|
| 959 | }
|
| 960 | }
|
| 961 | // Do nothing
|
| 962 | else if(strStartsWith(s, "+EEMLTEINTERRAT:")) // LTE RATÐ¡ÇøÐÅÏ¢
|
| 963 | {
|
| 964 | if(cell_info.running) {
|
| 965 |
|
| 966 | }
|
| 967 | }
|
| 968 | // WCDMA
|
| 969 | /*
|
| 970 | // Mode, sCMeasPresent, sCParamPresent, ueOpStatusPresent,
|
| 971 |
|
| 972 | // if sCMeasPresent == 1
|
| 973 | // cpichRSCP, utraRssi, cpichEcN0, sQual, sRxLev, txPower,
|
| 974 | // endif
|
| 975 |
|
| 976 | // if sCParamPresent == 1
|
| 977 | // rac, nom, mcc, mnc_len, mnc, lac, ci,
|
| 978 | // uraId, psc, arfcn, t3212, t3312, hcsUsed, attDetAllowed,
|
| 979 | // csDrxCycleLen, psDrxCycleLen, utranDrxCycleLen, HSDPASupport, HSUPASupport,
|
| 980 | // endif
|
| 981 |
|
| 982 | // if ueOpStatusPresent == 1
|
| 983 | // rrcState, numLinks, srncId, sRnti,
|
| 984 | // algPresent, cipherAlg, cipherOn, algPresent, cipherAlg, cipherOn,
|
| 985 | // HSDPAActive, HSUPAActive, MccLastRegisteredNetwork, MncLastRegisteredNetwork, TMSI, PTMSI, IsSingleMmRejectCause, IsSingleGmmRejectCause,
|
| 986 | // MMRejectCause, GMMRejectCause, mmState, gmmState, gprsReadyState, readyTimerValueInSecs, NumActivePDPContext, ULThroughput, DLThroughput,
|
| 987 | // serviceStatus, pmmState, LAU_status, LAU_count, RAU_status, RAU_count
|
| 988 | // endif
|
| 989 | //
|
| 990 | +EEMUMTSSVC: 3, 1, 1, 1,
|
| 991 | -80, 27, -6, -18, -115, -32768,
|
| 992 | 1, 1, 1120, 2, 1, 61697, 168432821,
|
| 993 | 15, 24, 10763, 0, 0, 0, 0,
|
| 994 | 128, 128, 65535, 0, 0,
|
| 995 | 2, 255, 65535, 4294967295,
|
| 996 | 0, 0, 0, 0, 0, 0,
|
| 997 | 0, 0, 0, 0, 0, 0, 1, 1,
|
| 998 | 28672, 28672, 0, 0, 0, 0, 0, 0, 0,
|
| 999 | 0, 0, 0, 0, 0, 0
|
| 1000 | */
|
| 1001 | else if(strStartsWith(s, "+EEMUMTSSVC:")) // WCDMA Server Cell
|
| 1002 | {
|
| 1003 | // lac, ci, arfcn
|
| 1004 | if(cell_info.running) {
|
| 1005 | int tmp_int;
|
| 1006 | int i = 0;
|
| 1007 | char* tmp_s = memdup(s,strlen(s));
|
| 1008 | char* free_ptr = tmp_s;
|
| 1009 | char *line = tmp_s;
|
| 1010 | if (at_tok_start(&line) < 0)
|
| 1011 | {
|
| 1012 | goto EEMUMTSSVC_EXIT;
|
| 1013 | }
|
| 1014 | // Jump 12 integer.
|
| 1015 | i = 0;
|
| 1016 | while(i < 12) {
|
| 1017 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1018 | {
|
| 1019 | goto EEMUMTSSVC_EXIT;
|
| 1020 | }
|
| 1021 | i++;
|
| 1022 | }
|
| 1023 | // mcc
|
| 1024 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1025 | {
|
| 1026 | goto EEMUMTSSVC_EXIT;
|
| 1027 | }
|
| 1028 | cell_info.cell[cell_info.cell_num].value4= (uint32)tmp_int;
|
| 1029 | // mnc
|
| 1030 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1031 | {
|
| 1032 | goto EEMUMTSSVC_EXIT;
|
| 1033 | }
|
| 1034 | cell_info.cell[cell_info.cell_num].value5= (uint32)tmp_int;
|
| 1035 | // lac
|
| 1036 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1037 | {
|
| 1038 | goto EEMUMTSSVC_EXIT;
|
| 1039 | }
|
| 1040 | cell_info.cell[cell_info.cell_num].value1 = (uint32)tmp_int;
|
| 1041 | // ci
|
| 1042 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1043 | {
|
| 1044 | goto EEMUMTSSVC_EXIT;
|
| 1045 | }
|
| 1046 | cell_info.cell[cell_info.cell_num].value2 = (uint32)tmp_int;
|
| 1047 |
|
| 1048 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1049 | {
|
| 1050 | goto EEMUMTSSVC_EXIT;
|
| 1051 | }
|
| 1052 | // cpi
|
| 1053 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1054 | {
|
| 1055 | goto EEMUMTSSVC_EXIT;
|
| 1056 | }
|
| 1057 | cell_info.cell[cell_info.cell_num].value6= (uint32)tmp_int;
|
| 1058 | /*
|
| 1059 | // Jump 2 integer.
|
| 1060 | i = 0;
|
| 1061 | while(i < 2) {
|
| 1062 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1063 | {
|
| 1064 | goto EEMUMTSSVC_EXIT;
|
| 1065 | }
|
| 1066 | i++;
|
| 1067 | }
|
| 1068 | */
|
| 1069 | // arfcn
|
| 1070 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1071 | {
|
| 1072 | goto EEMUMTSSVC_EXIT;
|
| 1073 | }
|
| 1074 | cell_info.cell[cell_info.cell_num].value3 = (uint32)tmp_int;
|
| 1075 |
|
| 1076 | cell_info.cell_num++;
|
| 1077 | EEMUMTSSVC_EXIT:
|
| 1078 | free(free_ptr);
|
| 1079 | }
|
| 1080 | }
|
| 1081 | /*
|
| 1082 | // index, cpichRSCP, utraRssi, cpichEcN0, sQual, sRxLev ,mcc, mnc, lac, ci, arfcn, psc
|
| 1083 | +EEMUMTSINTRA: 0, -32768, -1, -32768, -18, -115, 0, 0, 65534, 1, 10763, 32
|
| 1084 | */
|
| 1085 | else if(strStartsWith(s, "+EEMUMTSINTRA:")) // WCDMAÁÙ½üÐ¡Çø
|
| 1086 | {
|
| 1087 | // lac, ci, arfcn
|
| 1088 | if(cell_info.running) {
|
| 1089 | int tmp_int;
|
| 1090 | int i = 0;
|
| 1091 | char* tmp_s = memdup(s,strlen(s));
|
| 1092 | char* free_ptr = tmp_s;
|
| 1093 | char *line = tmp_s;
|
| 1094 | if (at_tok_start(&line) < 0)
|
| 1095 | {
|
| 1096 | goto EEMUMTSINTRA_EXIT;
|
| 1097 | }
|
| 1098 | // Jump 8 integer.
|
| 1099 | i = 0;
|
| 1100 | while(i < 8) {
|
| 1101 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1102 | {
|
| 1103 | goto EEMUMTSINTRA_EXIT;
|
| 1104 | }
|
| 1105 | i++;
|
| 1106 | }
|
| 1107 |
|
| 1108 | // lac
|
| 1109 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int <= 0 || tmp_int >= 65536)
|
| 1110 | {
|
| 1111 | goto EEMUMTSINTRA_EXIT;
|
| 1112 | }
|
| 1113 | cell_info.cell[cell_info.cell_num].value1 = (uint32)tmp_int;
|
| 1114 |
|
| 1115 | // ci
|
| 1116 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int <= 0 || tmp_int >= 65536)
|
| 1117 | {
|
| 1118 | goto EEMUMTSINTRA_EXIT;
|
| 1119 | }
|
| 1120 | cell_info.cell[cell_info.cell_num].value2 = (uint32)tmp_int;
|
| 1121 |
|
| 1122 | // arfcn
|
| 1123 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int <= 0 || tmp_int >= 65536)
|
| 1124 | {
|
| 1125 | goto EEMUMTSINTRA_EXIT;
|
| 1126 | }
|
| 1127 | cell_info.cell[cell_info.cell_num].value3 = (uint32)tmp_int;
|
| 1128 |
|
| 1129 | cell_info.cell_num++;
|
| 1130 | EEMUMTSINTRA_EXIT:
|
| 1131 | free(free_ptr);
|
| 1132 | }
|
| 1133 | }
|
| 1134 | /*
|
| 1135 | // index,gsmRssi,rxLev,C1,C2,mcc,mnc,lac,ci,arfcn,bsic
|
| 1136 | +EEMUMTSINTERRAT: 0, -32768, -107, -1, -1, 0, 0, 65534, 0, 117, 36
|
| 1137 | */
|
| 1138 | else if(strStartsWith(s, "+EEMUMTSINTERRAT:")) // WCDMA RATÐ¡ÇøÐÅÏ¢
|
| 1139 | {
|
| 1140 | // lac, ci, arfcn
|
| 1141 | if(cell_info.running) {
|
| 1142 | int tmp_int;
|
| 1143 | int i = 0;
|
| 1144 | char* tmp_s = memdup(s,strlen(s));
|
| 1145 | char* free_ptr = tmp_s;
|
| 1146 | char *line = tmp_s;
|
| 1147 | if (at_tok_start(&line) < 0)
|
| 1148 | {
|
| 1149 | goto EEMUMTSINTERRAT_EXIT;
|
| 1150 | }
|
| 1151 | // Jump 7 integer.
|
| 1152 | i = 0;
|
| 1153 | while(i < 7) {
|
| 1154 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1155 | {
|
| 1156 | goto EEMUMTSINTERRAT_EXIT;
|
| 1157 | }
|
| 1158 | i++;
|
| 1159 | }
|
| 1160 |
|
| 1161 | // lac
|
| 1162 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int <= 0 || tmp_int >= 65536)
|
| 1163 | {
|
| 1164 | goto EEMUMTSINTERRAT_EXIT;
|
| 1165 | }
|
| 1166 | cell_info.cell[cell_info.cell_num].value1 = (uint32)tmp_int;
|
| 1167 |
|
| 1168 | // ci
|
| 1169 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int <= 0 || tmp_int >= 65536)
|
| 1170 | {
|
| 1171 | goto EEMUMTSINTERRAT_EXIT;
|
| 1172 | }
|
| 1173 | cell_info.cell[cell_info.cell_num].value2 = (uint32)tmp_int;
|
| 1174 |
|
| 1175 | // arfcn
|
| 1176 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int <= 0 || tmp_int >= 65536)
|
| 1177 | {
|
| 1178 | goto EEMUMTSINTERRAT_EXIT;
|
| 1179 | }
|
| 1180 | cell_info.cell[cell_info.cell_num].value3 = (uint32)tmp_int;
|
| 1181 |
|
| 1182 | cell_info.cell_num++;
|
| 1183 | EEMUMTSINTERRAT_EXIT:
|
| 1184 | free(free_ptr);
|
| 1185 | }
|
| 1186 | }
|
| 1187 | // GSM
|
| 1188 | // +EEMGINFOBASIC: 2
|
| 1189 | // Do nothing.
|
| 1190 | else if(strStartsWith(s, "+EEMGINFOBASIC:")) // Basic information in GSM
|
| 1191 | // 0: ME in Idle mode 1: ME in Dedicated mode 2: ME in PS PTM mode
|
| 1192 | {
|
| 1193 | if(cell_info.running) {
|
| 1194 |
|
| 1195 | }
|
| 1196 | }
|
| 1197 | /*
|
| 1198 | // mcc, mnc_len, mnc, lac, ci, nom, nco,
|
| 1199 | // bsic, C1, C2, TA, TxPwr,
|
| 1200 | // RxSig, RxSigFull, RxSigSub, RxQualFull, RxQualSub,
|
| 1201 | // ARFCB_tch, hopping_chnl, chnl_type, TS, PacketIdle, rac, arfcn,
|
| 1202 | // bs_pa_mfrms, C31, C32, t3212, t3312, pbcch_support, EDGE_support,
|
| 1203 | // ncc_permitted, rl_timeout, ho_count, ho_succ, chnl_access_count, chnl_access_succ_count,
|
| 1204 | // gsmBand,channelMode
|
| 1205 | +EEMGINFOSVC: 1120, 2, 0, 32784, 24741, 2, 0,
|
| 1206 | 63, 36, 146, 1, 7,
|
| 1207 | 46, 42, 42, 7, 0,
|
| 1208 | 53, 0, 8, 0, 1, 6, 53,
|
| 1209 | 2, 0, 146, 42, 54, 0, 1,
|
| 1210 | 1, 32, 0, 0, 0, 0,
|
| 1211 | 0, 0
|
| 1212 | */
|
| 1213 | else if(strStartsWith(s, "+EEMGINFOSVC:")) // GSM Server Cell
|
| 1214 | {
|
| 1215 | // lac, ci, arfcn, bsic
|
| 1216 | LOG("+EEMGINFOSVC: 1= %d\n.",cell_info.running);
|
| 1217 | if(cell_info.running) {
|
| 1218 | int tmp_int;
|
| 1219 | int i = 0;
|
| 1220 | char* tmp_s = memdup(s,strlen(s));
|
| 1221 | char* free_ptr = tmp_s;
|
| 1222 | char *line = tmp_s;
|
| 1223 | if (at_tok_start(&line) < 0)
|
| 1224 | {
|
| 1225 | goto EEMGINFOSVC_EXIT;
|
| 1226 | }
|
| 1227 |
|
| 1228 | // mcc
|
| 1229 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int <= 0 || tmp_int >= 65536)
|
| 1230 | {
|
| 1231 | goto EEMGINFOSVC_EXIT;
|
| 1232 | }
|
| 1233 | cell_info.cell[cell_info.cell_num].value5 = (uint32)tmp_int;
|
| 1234 |
|
| 1235 | //mnc_len
|
| 1236 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int <= 0 || tmp_int >= 65536)
|
| 1237 | {
|
| 1238 | goto EEMGINFOSVC_EXIT;
|
| 1239 | }
|
| 1240 | // mnc
|
| 1241 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int <= 0 || tmp_int >= 65536)
|
| 1242 | {
|
| 1243 | goto EEMGINFOSVC_EXIT;
|
| 1244 | }
|
| 1245 | cell_info.cell[cell_info.cell_num].value6 = (uint32)tmp_int;
|
| 1246 |
|
| 1247 | /*
|
| 1248 | // Jump 3 integer.
|
| 1249 | i = 0;
|
| 1250 | while(i < 3) {
|
| 1251 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1252 | {
|
| 1253 | goto EEMGINFOSVC_EXIT;
|
| 1254 | }
|
| 1255 | i++;
|
| 1256 | }
|
| 1257 | */
|
| 1258 | // lac
|
| 1259 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int < 0 || tmp_int >= 65536)
|
| 1260 | {
|
| 1261 | goto EEMGINFOSVC_EXIT;
|
| 1262 | }
|
| 1263 | cell_info.cell[cell_info.cell_num].value1 = (uint32)tmp_int;
|
| 1264 |
|
| 1265 | // ci
|
| 1266 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int < 0 || tmp_int >= 65536)
|
| 1267 | {
|
| 1268 | goto EEMGINFOSVC_EXIT;
|
| 1269 | }
|
| 1270 | cell_info.cell[cell_info.cell_num].value2 = (uint32)tmp_int;
|
| 1271 |
|
| 1272 | // Jump 2 integer.
|
| 1273 | i = 0;
|
| 1274 | while(i < 2) {
|
| 1275 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1276 | {
|
| 1277 | goto EEMGINFOSVC_EXIT;
|
| 1278 | }
|
| 1279 | i++;
|
| 1280 | }
|
| 1281 |
|
| 1282 | // bsic
|
| 1283 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int < 0 || tmp_int >= 65536)
|
| 1284 | {
|
| 1285 | goto EEMGINFOSVC_EXIT;
|
| 1286 | }
|
| 1287 | cell_info.cell[cell_info.cell_num].value4 = (uint32)tmp_int;
|
| 1288 |
|
| 1289 | // Jump 15 integer.
|
| 1290 | i = 0;
|
| 1291 | while(i < 15) {
|
| 1292 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1293 | {
|
| 1294 | goto EEMGINFOSVC_EXIT;
|
| 1295 | }
|
| 1296 | i++;
|
| 1297 | }
|
| 1298 |
|
| 1299 | // arfcn
|
| 1300 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int < 0 || tmp_int >= 65536)
|
| 1301 | {
|
| 1302 | goto EEMGINFOSVC_EXIT;
|
| 1303 | }
|
| 1304 | cell_info.cell[cell_info.cell_num].value3 = (uint32)tmp_int;
|
| 1305 |
|
| 1306 | cell_info.cell_num++;
|
| 1307 | EEMGINFOSVC_EXIT:
|
| 1308 | free(free_ptr);
|
| 1309 | }
|
| 1310 | }
|
| 1311 | /*
|
| 1312 | // PS_attached, attach_type, service_type, tx_power, c_value,
|
| 1313 | // ul_ts, dl_ts, ul_cs, dl_cs, ul_modulation, dl_modulation,
|
| 1314 | // gmsk_cv_bep, 8psk_cv_bep, gmsk_mean_bep, 8psk_mean_bep, EDGE_bep_period, single_gmm_rej_cause
|
| 1315 | // pdp_active_num, mac_mode, network_control, network_mode, EDGE_slq_measurement_mode, edge_status
|
| 1316 | +EEMGINFOPS: 1, 255, 0, 0, 0,
|
| 1317 | 0, 0, 268435501, 1, 0, 0,
|
| 1318 | 4, 0, 96, 0, 0, 0,
|
| 1319 | 0, 0, 0, 65535, 0, 13350
|
| 1320 | */
|
| 1321 | // Do nothing.
|
| 1322 | else if(strStartsWith(s, "+EEMGINFOPS:")) // PSÐÅÏ¢
|
| 1323 | {
|
| 1324 | if(cell_info.running) {
|
| 1325 |
|
| 1326 | }
|
| 1327 | }
|
| 1328 | else if(strStartsWith(s, "+EEMGINFONC:")) // cell
|
| 1329 | {
|
| 1330 | if(cell_info.running) {
|
| 1331 | int tmp_int;
|
| 1332 | int i = 0;
|
| 1333 | char* tmp_s = memdup(s,strlen(s));
|
| 1334 | char* free_ptr = tmp_s;
|
| 1335 | char *line = tmp_s;
|
| 1336 | if (at_tok_start(&line) < 0)
|
| 1337 | {
|
| 1338 | goto EEMGINFOPS_EXIT;
|
| 1339 | }
|
| 1340 |
|
| 1341 | // nc_num
|
| 1342 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int < 0 || tmp_int >= 65536)
|
| 1343 | {
|
| 1344 | LOG("cell_info.running 1= %d\n.",cell_info.running);
|
| 1345 | goto EEMGINFOPS_EXIT;
|
| 1346 | }
|
| 1347 | // mcc
|
| 1348 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int < 0 || tmp_int >= 65536)
|
| 1349 | {
|
| 1350 | LOG("cell_info.running 2= %d\n.",cell_info.running);
|
| 1351 | goto EEMGINFOPS_EXIT;
|
| 1352 | }
|
| 1353 | cell_info.cell[cell_info.cell_num].value5 = (uint32)tmp_int;
|
| 1354 |
|
| 1355 | // mnc
|
| 1356 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int < 0 || tmp_int >= 65536)
|
| 1357 | {
|
| 1358 | LOG("cell_info.running 3= %d\n.",cell_info.running);
|
| 1359 | goto EEMGINFOPS_EXIT;
|
| 1360 | }
|
| 1361 | cell_info.cell[cell_info.cell_num].value6 = (uint32)tmp_int;
|
| 1362 |
|
| 1363 | // lac
|
| 1364 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int < 0 || tmp_int >= 65536)
|
| 1365 | {
|
| 1366 | LOG("cell_info.running 4= %d\n.",cell_info.running);
|
| 1367 | goto EEMGINFOPS_EXIT;
|
| 1368 | }
|
| 1369 | cell_info.cell[cell_info.cell_num].value1 = (uint32)tmp_int;
|
| 1370 |
|
| 1371 | // rac
|
| 1372 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int < 0 || tmp_int >= 65536)
|
| 1373 | {
|
| 1374 | LOG("cell_info.running 5= %d\n.",cell_info.running);
|
| 1375 | goto EEMGINFOPS_EXIT;
|
| 1376 | }
|
| 1377 |
|
| 1378 | // ci
|
| 1379 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int < 0 || tmp_int >= 65536)
|
| 1380 | {
|
| 1381 | LOG("cell_info.running 6= %d\n.",cell_info.running);
|
| 1382 | goto EEMGINFOPS_EXIT;
|
| 1383 | }
|
| 1384 | cell_info.cell[cell_info.cell_num].value2 = (uint32)tmp_int;
|
| 1385 |
|
| 1386 | // rx_lv
|
| 1387 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1388 | {
|
| 1389 | LOG("cell_info.running 7= %d\n.",cell_info.running);
|
| 1390 | goto EEMGINFOPS_EXIT;
|
| 1391 | }
|
| 1392 |
|
| 1393 | // bsic
|
| 1394 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int < 0 || tmp_int >= 65536)
|
| 1395 | {
|
| 1396 | LOG("cell_info.running 8= %d\n.",cell_info.running);
|
| 1397 | goto EEMGINFOPS_EXIT;
|
| 1398 | }
|
| 1399 | cell_info.cell[cell_info.cell_num].value4 = (uint32)tmp_int;
|
| 1400 |
|
| 1401 | // Jump 2 integer.
|
| 1402 | i = 0;
|
| 1403 | while(i < 2) {
|
| 1404 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1405 | {
|
| 1406 | LOG("cell_info.running 9= %d\n.",cell_info.running);
|
| 1407 | goto EEMGINFOPS_EXIT;
|
| 1408 | }
|
| 1409 | i++;
|
| 1410 | }
|
| 1411 |
|
| 1412 | // arfcn
|
| 1413 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int < 0 || tmp_int >= 65536)
|
| 1414 | {
|
| 1415 | LOG("cell_info.running 10 = %d\n.",cell_info.running);
|
| 1416 | goto EEMGINFOPS_EXIT;
|
| 1417 | }
|
| 1418 | cell_info.cell[cell_info.cell_num].value3 = (uint32)tmp_int;
|
| 1419 |
|
| 1420 | cell_info.cell_num++;
|
| 1421 | EEMGINFOPS_EXIT:
|
| 1422 | free(free_ptr);
|
| 1423 | }
|
| 1424 | }
|
| 1425 | else if(strStartsWith(s, "+ZGIPDNS:")) // +ZGIPDNS: 1,"IPV4V6","10.156.239.245","10.156.239.246","223.87.253.100","223.87.253.253","fe80:0000:0000:0000:0001:0001:9b8c:7c0c","fe80::1:1:9b8c:7c0d","2409:8062:2000:2::1","2409:8062:2000:2::2"
|
| 1426 | {
|
| 1427 |
|
| 1428 | }
|
| 1429 | else
|
| 1430 | {
|
| 1431 | LOGV("Unknown URC : %s", s);
|
| 1432 | }
|
| 1433 | }
|
| 1434 |
|
| 1435 | static int openSocket(const char* sockname)
|
| 1436 | {
|
| 1437 | int sock = socket(AF_UNIX, SOCK_STREAM, 0);
|
| 1438 | if (sock < 0)
|
| 1439 | {
|
| 1440 | LOGE("Error create socket: %s\n", strerror(errno));
|
| 1441 | return -1;
|
| 1442 | }
|
| 1443 | struct sockaddr_un addr;
|
| 1444 | memset(&addr, 0, sizeof(addr));
|
| 1445 | addr.sun_family = AF_UNIX;
|
| 1446 | strncpy(addr.sun_path, sockname, sizeof(addr.sun_path));
|
| 1447 | while (TEMP_FAILURE_RETRY(connect(sock,(const struct sockaddr*)&addr, sizeof(addr))) != 0)
|
| 1448 | {
|
| 1449 | LOGE("Error connect to socket %s: %s, try again", sockname, strerror(errno));
|
| 1450 | sleep(1);
|
| 1451 | }
|
| 1452 |
|
| 1453 | #if 0
|
| 1454 | int sk_flags = fcntl(sock, F_GETFL, 0);
|
| 1455 | fcntl(sock, F_SETFL, sk_flags | O_NONBLOCK);
|
| 1456 | #endif
|
| 1457 |
|
| 1458 | return sock;
|
| 1459 | }
|
| 1460 |
|
| 1461 | static void ril_get_cgpaddr_ip_process()
|
| 1462 | {
|
| 1463 | int err, skip;
|
| 1464 | ATResponse *p_response = NULL;
|
| 1465 | char *line;
|
| 1466 | char *ipv4 = NULL, *ipv6 = NULL;
|
| 1467 | err = at_send_command_singleline("AT+CGPADDR", "+CGPADDR:", &p_response);
|
| 1468 | if ((err < 0) || (p_response == NULL) || (p_response->success == 0))
|
| 1469 | {
|
| 1470 | LOGE("+CGPADDR exec error.");
|
| 1471 | goto error;
|
| 1472 | }
|
| 1473 |
|
| 1474 | // +CGPADDR: 1, "10.51.59.229", "254.128.0.0.0.0.0.0.0.1.0.0.111.176.63.99"
|
| 1475 | // +CGPADDR: 1, "10.124.139.131"
|
| 1476 | line = p_response->p_intermediates->line;
|
| 1477 | err = at_tok_start(&line);
|
| 1478 | if (err < 0)
|
| 1479 | {
|
| 1480 | goto error;
|
| 1481 | }
|
| 1482 |
|
| 1483 | err = at_tok_nextint(&line, &skip);
|
| 1484 | if (err < 0)
|
| 1485 | {
|
| 1486 | goto error;
|
| 1487 | }
|
| 1488 |
|
| 1489 | if (!at_tok_hasmore(&line))
|
| 1490 | {
|
| 1491 | goto error;
|
| 1492 | }
|
| 1493 |
|
| 1494 | err = at_tok_nextstr(&line, &ipv4);
|
| 1495 | if (err < 0)
|
| 1496 | {
|
| 1497 | LOGE("Get IPv4 fail.");
|
| 1498 | goto error;
|
| 1499 | }
|
| 1500 |
|
| 1501 | if (at_tok_hasmore(&line))
|
| 1502 | {
|
| 1503 | err = at_tok_nextstr(&line, &ipv6);
|
| 1504 | if (err < 0)
|
| 1505 | {
|
| 1506 | LOGE("Get IPv6 fail.");
|
| 1507 | goto error;
|
| 1508 | }
|
| 1509 | }
|
| 1510 | else
|
| 1511 | {
|
| 1512 | LOGD("No IPv6 Found.");
|
| 1513 | }
|
| 1514 |
|
| 1515 | if(ipv6)
|
| 1516 | {
|
| 1517 | LOGD("IPv6 : %s", ipv6);
|
| 1518 | }
|
| 1519 |
|
| 1520 | if(ipv4)
|
| 1521 | {
|
| 1522 | LOGD("IPv4 : %s", ipv4);
|
| 1523 |
|
| 1524 | // ril_net_dev_config("ccinet0", ipv4, NULL);
|
| 1525 | }
|
| 1526 | error:
|
| 1527 | at_response_free(p_response);
|
| 1528 | }
|
| 1529 |
|
| 1530 | static void sim_state_change(bool plug_in) {
|
| 1531 | if(plug_in) {
|
| 1532 | // If radio on,must off in the first.
|
| 1533 | if(net_info.radio_state == MBTK_RADIO_STATE_ON) {
|
| 1534 | setRadioPower(0);
|
| 1535 | }
|
| 1536 | setRadioPower(1);
|
| 1537 | } else {
|
| 1538 | setRadioPower(0);
|
| 1539 | }
|
| 1540 | }
|
| 1541 |
|
| 1542 | static int open_uevent_socket()
|
| 1543 | {
|
| 1544 | struct sockaddr_nl addr;
|
| 1545 | int sz = 64*1024;
|
| 1546 | int s = 0;
|
| 1547 |
|
| 1548 | memset(&addr, 0, sizeof(addr));
|
| 1549 | addr.nl_family = AF_NETLINK;
|
| 1550 | addr.nl_pid = getpid();
|
| 1551 | addr.nl_groups = 0xffffffff;
|
| 1552 |
|
| 1553 | s = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT);
|
| 1554 | if (s < 0)
|
| 1555 | {
|
| 1556 | LOGE("socket() fail.[%d]", errno);
|
| 1557 | return -1;
|
| 1558 | }
|
| 1559 |
|
| 1560 | setsockopt(s, SOL_SOCKET, SO_RCVBUFFORCE, &sz, sizeof(sz));
|
| 1561 |
|
| 1562 | if (bind(s, (struct sockaddr *) &addr, sizeof(addr)) < 0)
|
| 1563 | {
|
| 1564 | close(s);
|
| 1565 | return -1;
|
| 1566 | }
|
| 1567 |
|
| 1568 | return s;
|
| 1569 | }
|
| 1570 |
|
| 1571 | static void parse_uevent(const char *msg, int msg_len, struct cooling_device *cdev)
|
| 1572 | {
|
| 1573 | // change@/devices/virtual/usim_event/usim0\0
|
| 1574 | // ACTION=change\0
|
| 1575 | // DEVPATH=/devices/virtual/usim_event/usim0\0
|
| 1576 | // SUBSYSTEM=usim_event\0
|
| 1577 | // USIM_NAME=usim0\0
|
| 1578 | // USIM_EVENT=plugout\0
|
| 1579 | // SEQNUM=704
|
| 1580 | int i = 0;
|
| 1581 | while (i < msg_len)
|
| 1582 | {
|
| 1583 | if(*(msg + i) == '\0')
|
| 1584 | {
|
| 1585 | i++;
|
| 1586 | continue;
|
| 1587 | }
|
| 1588 | if (!strncmp(msg + i, "USIM_NAME=", 10))
|
| 1589 | {
|
| 1590 | i += 10;
|
| 1591 | cdev->name = msg + i;
|
| 1592 | i += strlen(msg + i);
|
| 1593 | }
|
| 1594 | else if (!strncmp(msg + i, "ACTION=", 7))
|
| 1595 | {
|
| 1596 | i += 7;
|
| 1597 | cdev->action = msg + i;
|
| 1598 | i += strlen(msg + i);
|
| 1599 | }
|
| 1600 | else if (!strncmp(msg + i, "DEVPATH=", 8))
|
| 1601 | {
|
| 1602 | i += 8;
|
| 1603 | cdev->path = msg + i;
|
| 1604 | i += strlen(msg + i);
|
| 1605 | }
|
| 1606 | else if (!strncmp(msg + i, "USIM_EVENT=", 11))
|
| 1607 | {
|
| 1608 | i += 11;
|
| 1609 | cdev->event = msg + i;
|
| 1610 | i += strlen(msg + i);
|
| 1611 | }
|
| 1612 | else if (!strncmp(msg + i, "SUBSYSTEM=", 10))
|
| 1613 | {
|
| 1614 | i += 10;
|
| 1615 | cdev->subsystem = msg + i;
|
| 1616 | i += strlen(msg + i);
|
| 1617 | }
|
| 1618 | else
|
| 1619 | {
|
| 1620 | i++;
|
| 1621 | }
|
| 1622 | }
|
| 1623 |
|
| 1624 | if(!strncmp(cdev->path, UEVENT_USIM_DEV, sizeof(UEVENT_USIM_DEV))
|
| 1625 | && !strncmp(cdev->action, "change", 5))
|
| 1626 | {
|
| 1627 | LOGD("event { name=%s, action=%s, path=%s, subsystem=%s, event=%s}",
|
| 1628 | cdev->name, cdev->action, cdev->path, cdev->subsystem, cdev->event);
|
| 1629 | if(!strcmp(cdev->event, "plugout"))
|
| 1630 | {
|
| 1631 | sim_state_change(FALSE);
|
| 1632 | }
|
| 1633 | else if(!strcmp(cdev->event, "plugin"))
|
| 1634 | {
|
| 1635 | sim_state_change(TRUE);
|
| 1636 | }
|
| 1637 | else
|
| 1638 | {
|
| 1639 | LOGE("usim evnet error!");
|
| 1640 | }
|
| 1641 | }
|
| 1642 | }
|
| 1643 |
|
| 1644 | static void* uevnet_run(void *payload)
|
| 1645 | {
|
| 1646 | int socket_fd = -1;
|
| 1647 | char msg[BUFFER_SIZE+2];
|
| 1648 | int n;
|
| 1649 |
|
| 1650 | socket_fd = open_uevent_socket();
|
| 1651 | if(socket_fd > 0)
|
| 1652 | {
|
| 1653 | while(1)
|
| 1654 | {
|
| 1655 | if((n = recv(socket_fd, msg, BUFFER_SIZE, 0)) > 0)
|
| 1656 | {
|
| 1657 | struct cooling_device cdev;
|
| 1658 | memset(&cdev, 0x0, sizeof(cdev));
|
| 1659 |
|
| 1660 | if(n == BUFFER_SIZE)
|
| 1661 | continue;
|
| 1662 | msg[n] = '\0';
|
| 1663 | // change@/devices/virtual/usim_event/usim0\0ACTION=change\0DEVPATH=/devices/virtual/usim_event/usim0\0SUBSYSTEM=usim_event\0USIM_NAME=usim0\0USIM_EVENT=plugout\0SEQNUM=704
|
| 1664 | log_hex("UEVENT", msg, n);
|
| 1665 | parse_uevent(msg, n, &cdev);
|
| 1666 | }
|
| 1667 | else
|
| 1668 | {
|
| 1669 | LOGE("recv msg error.");
|
| 1670 | }
|
| 1671 | }
|
| 1672 | }
|
| 1673 |
|
| 1674 | LOGD("UEVENT Thread exit!!!");
|
| 1675 | return NULL;
|
| 1676 | }
|
| 1677 |
|
| 1678 | int uevent_main()
|
| 1679 | {
|
| 1680 | mbtk_task_info task;
|
| 1681 | task.task_id = &uevnet_task_id;
|
| 1682 | task.thread_run = uevnet_run;
|
| 1683 | task.args = NULL;
|
| 1684 | return mbtk_task_start(&task);
|
| 1685 | }
|
| 1686 |
|
| 1687 | /*
|
| 1688 | int ril_main()
|
| 1689 | {
|
| 1690 | return mbtk_task_queue_start(&ril_task, ril_main_run);
|
| 1691 | }
|
| 1692 | */
|
| 1693 |
|
| 1694 | int mbtk_info_server_start();
|
| 1695 | int InProduction_Mode(void);
|
| 1696 | void server_ready_set(void);
|
| 1697 |
|
| 1698 | |
| 1699 | /* |
| 1700 | *Get mtdblock which name is ASR_FLAG |
| 1701 | *return path if found, else return NULL |
| 1702 | */ |
| 1703 | static int asrFlagPathGet(char *asr_flag_path)
|
| 1704 | { |
| 1705 | char buf[128]; |
| 1706 | unsigned char find = 0; |
| 1707 | FILE *fd = fopen("/proc/mtd", "r");
|
| 1708 | if (fd == NULL) { |
| 1709 | LOGE("Open MTD failed!");
|
| 1710 | return -1;
|
| 1711 | } |
| 1712 | |
| 1713 | memset(buf, '\0', 128); |
| 1714 | while (fgets(buf, 128, fd) != NULL) { |
| 1715 | if(strstr(buf, "asr_flag")) { |
| 1716 | char *p = strstr(buf, "mtd"); |
| 1717 | if(p) |
| 1718 | { |
| 1719 | int bln; |
| 1720 | sscanf(p, "mtd%d", &bln); |
| 1721 | sprintf(asr_flag_path, "/dev/mtdblock%d", bln); |
| 1722 | find = 1; |
| 1723 | break; |
| 1724 | } |
| 1725 | } |
| 1726 | memset(buf, '\0', 128); |
| 1727 | } |
| 1728 | |
| 1729 | fclose(fd); |
| 1730 | return ((find == 1) ? 0 : -1);
|
| 1731 | } |
| 1732 | |
| 1733 | static int readFromMTD(const char *path, unsigned int offset, void *buf, int size)
|
| 1734 | { |
| 1735 | int ret, fd; |
| 1736 | if (!path) |
| 1737 | return -1; |
| 1738 | |
| 1739 | fd = open(path, O_RDONLY); |
| 1740 | if (fd < 0) { |
| 1741 | LOGE("readFromMTD open error,%d", errno);
|
| 1742 | return -1; |
| 1743 | } |
| 1744 | |
| 1745 | ret = lseek(fd, offset, SEEK_SET); |
| 1746 | if (ret < 0) { |
| 1747 | close(fd); |
| 1748 | LOGE("readFromMTD lseek error,%d", errno);
|
| 1749 | return -1; |
| 1750 | } |
| 1751 | ret = read(fd, buf, size); |
| 1752 | if (ret < 0) { |
| 1753 | close(fd); |
| 1754 | LOGE("readFromMTD read error,%d", errno);
|
| 1755 | return -1; |
| 1756 | } |
| 1757 | close(fd); |
| 1758 | return 0; |
| 1759 | } |
| 1760 | |
| 1761 | static int writeToMTD(const char *path, unsigned int offset, void *buf, int size)
|
| 1762 | { |
| 1763 | int ret, fd; |
| 1764 | |
| 1765 | if (!path) |
| 1766 | return -1; |
| 1767 | |
| 1768 | fd = open(path, O_RDWR | O_SYNC); |
| 1769 | if (fd < 0) |
| 1770 | return -1; |
| 1771 | |
| 1772 | ret = lseek(fd, offset, SEEK_SET); |
| 1773 | if (ret < 0) { |
| 1774 | close(fd); |
| 1775 | return -1; |
| 1776 | } |
| 1777 | ret = write(fd, buf, size); |
| 1778 | if (ret < 0) { |
| 1779 | LOGE("writetomtd:write error:%d", errno);
|
| 1780 | close(fd); |
| 1781 | return -1; |
| 1782 | } |
| 1783 | |
| 1784 | close(fd); |
| 1785 | return 0; |
| 1786 | }
|
| 1787 |
|
| 1788 | static void fota_result_check()
|
| 1789 | {
|
| 1790 | #if 0
|
| 1791 | ASR_flag tag;
|
| 1792 | char asr_flag_path[30] = {0};
|
| 1793 | if(asrFlagPathGet(asr_flag_path)) {
|
| 1794 | LOGE("getAsrFlagPath() fail.");
|
| 1795 | return;
|
| 1796 | }
|
| 1797 |
|
| 1798 | if(readFromMTD(asr_flag_path, ASR_FLAG_OFFSET, &tag, sizeof(tag)) < 0)
|
| 1799 | {
|
| 1800 | LOGE("Get FOTA result fail.");
|
| 1801 | }
|
| 1802 | else
|
| 1803 | {
|
| 1804 | LOGD("FOTA result : %d, %d", tag.fota_result[0], tag.fota_result[1]);
|
| 1805 | tag.fota_result[0] = 0;
|
| 1806 | tag.fota_result[1] = 0;
|
| 1807 | if(writeToMTD(asr_flag_path, ASR_FLAG_OFFSET, &tag, sizeof(tag)) < 0)
|
| 1808 | {
|
| 1809 | LOGE("FOTA result update fail.");
|
| 1810 | } else {
|
| 1811 | LOGD("FOTA result update success.");
|
| 1812 | }
|
| 1813 | }
|
| 1814 | #endif
|
| 1815 | }
|
| 1816 |
|
| 1817 | static void mbtk_server_ready()
|
| 1818 | {
|
| 1819 | // /etc/init.d/mbtk_boot_server_ready
|
| 1820 | if(access(MBTK_BOOT_SERVER_READY , X_OK) == 0) {
|
| 1821 | system(MBTK_BOOT_SERVER_READY);
|
| 1822 | } else {
|
| 1823 | LOGE("%s can not exec.", MBTK_BOOT_SERVER_READY);
|
| 1824 | }
|
| 1825 | }
|
| 1826 |
|
| 1827 | #if 1
|
| 1828 | int main(int argc, char *argv[])
|
| 1829 | {
|
| 1830 | mbtk_log_init("radio", "MBTK_RIL");
|
| 1831 | LOGI("mbtk_ril start.");
|
| 1832 |
|
| 1833 | if(InProduction_Mode()) {
|
| 1834 | LOGI("Is Production Mode, will exit...");
|
| 1835 | exit(0);
|
| 1836 | }
|
| 1837 |
|
| 1838 | int at_sock = openSocket("/tmp/atcmd_at");
|
| 1839 | if(at_sock < 0)
|
| 1840 | {
|
| 1841 | LOGE("Open AT Socket Fail[%d].", errno);
|
| 1842 | return -1;
|
| 1843 | }
|
| 1844 | int uart_sock = openSocket("/tmp/atcmd_urc");
|
| 1845 | if(uart_sock < 0)
|
| 1846 | {
|
| 1847 | LOGE("Open Uart Socket Fail[%d].", errno);
|
| 1848 | return -1;
|
| 1849 | }
|
| 1850 |
|
| 1851 | at_set_on_reader_closed(onATReaderClosed);
|
| 1852 | at_set_on_timeout(onATTimeout);
|
| 1853 |
|
| 1854 | if(at_open(at_sock, uart_sock, onUnsolicited))
|
| 1855 | {
|
| 1856 | LOGE("Start AT thread fail.");
|
| 1857 | return -1;
|
| 1858 | }
|
| 1859 |
|
| 1860 | #if 1
|
| 1861 | if(at_handshake())
|
| 1862 | {
|
| 1863 | LOGE("AT handshake fail.");
|
| 1864 | return -1;
|
| 1865 | }
|
| 1866 | #endif
|
| 1867 |
|
| 1868 | LOGD("AT OK.");
|
| 1869 |
|
| 1870 | if(mbtk_info_server_start())
|
| 1871 | {
|
| 1872 | LOGE("mbtk_info_server_start() fail.");
|
| 1873 | return -1;
|
| 1874 | }
|
wangyouqiang | 38e5336 | 2024-01-23 10:53:48 +0800 | [diff] [blame] | 1875 |
|
| 1876 | #ifdef MBTK_PROJECT_T108
|
| 1877 | mbtk_led_init();
|
| 1878 | #endif
|
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 1879 |
|
| 1880 | #if 0
|
| 1881 | if(uevent_main())
|
| 1882 | {
|
| 1883 | LOGE("Start uevent thread fail.");
|
| 1884 | return -1;
|
| 1885 | }
|
| 1886 | #endif
|
| 1887 |
|
| 1888 | char time_type[10];
|
| 1889 | memset(time_type, 0, 10);
|
| 1890 | property_get("persist.mbtk.time_type", time_type, "0");
|
| 1891 | if(atoi(time_type) == MBTK_TIME_TYPE_NTP) { // NTP time
|
| 1892 | LOG("Start NTP thread.");
|
| 1893 | ntp_thread_start();
|
| 1894 | }
|
| 1895 |
|
| 1896 | fota_result_check();
|
| 1897 |
|
| 1898 | mbtk_server_ready();
|
| 1899 |
|
| 1900 | server_ready_set();//Set the server readiness state
|
| 1901 | while(1)
|
| 1902 | {
|
| 1903 | sleep(24 * 60 * 60);
|
| 1904 | }
|
| 1905 |
|
| 1906 | LOGD("!!!mbtk_ril exit!!!");
|
| 1907 | return 0;
|
| 1908 | }
|
| 1909 |
|
| 1910 | #else
|
| 1911 | int main()
|
| 1912 | {
|
| 1913 | char buff[BUFFER_SIZE + 1] = {0};
|
| 1914 | if(!mbtk_at("AT+CFUN=1", buff, BUFFER_SIZE))
|
| 1915 | {
|
| 1916 | LOGD("+CFUN RSP:%s", buff);
|
| 1917 | while(1)
|
| 1918 | {
|
| 1919 | sleep(1);
|
| 1920 | memset(buff, 0x0, BUFFER_SIZE + 1);
|
| 1921 | if(!mbtk_at("AT+CGPADDR", buff, BUFFER_SIZE))
|
| 1922 | {
|
| 1923 | LOGD("+CGPADDR RSP:%s", buff);
|
| 1924 | if(strstr(buff, "+CGPADDR:"))
|
| 1925 | {
|
| 1926 | // +CGPADDR: 1, "10.99.223.168", "254.128.0.0.0.0.0.0.0.1.0.0.117.9.250.59"
|
| 1927 | //
|
| 1928 | // OK
|
| 1929 | char *ip_start = NULL;
|
| 1930 | char *ip_end = NULL;
|
| 1931 | char ipv4[50] = {0};
|
| 1932 | ip_start = strstr(buff,"\"");
|
| 1933 | if(ip_start)
|
| 1934 | ip_end = strstr(ip_start + 1, "\"");
|
| 1935 | if(ip_start && ip_end && ip_end - ip_start - 1 > 0)
|
| 1936 | {
|
| 1937 | memcpy(ipv4, ip_start + 1, ip_end - ip_start - 1);
|
| 1938 | LOGD("IP : %s", ipv4);
|
| 1939 | if(!mbtk_ifc_open())
|
| 1940 | {
|
| 1941 | in_addr_t addr;
|
| 1942 | inet_aton(ipv4,(struct in_addr *)&addr);
|
| 1943 | LOGD("IP : %s -> %x", ipv4, addr);
|
| 1944 | if(!mbtk_ifc_set_addr("ccinet0", addr, 0))
|
| 1945 | {
|
| 1946 | mbtk_ifc_up("ccinet0");
|
| 1947 | }
|
| 1948 |
|
| 1949 | mbtk_ifc_close();
|
| 1950 | }
|
| 1951 |
|
| 1952 | system("route add default dev ccinet0");
|
| 1953 |
|
| 1954 | LOGD("Set IP success.");
|
| 1955 | }
|
| 1956 | else
|
| 1957 | {
|
| 1958 | LOGD("Get IP fail.");
|
| 1959 | }
|
| 1960 |
|
| 1961 | break;
|
| 1962 | }
|
| 1963 | }
|
| 1964 | }
|
| 1965 | }
|
| 1966 |
|
| 1967 | return 0;
|
| 1968 | }
|
| 1969 | #endif
|