b.liu | fd87baf | 2024-11-15 15:30:38 +0800 | [diff] [blame^] | 1 | /*
|
| 2 | * main.c
|
| 3 | *
|
| 4 | * mbtk_rild main file.
|
| 5 | *
|
| 6 | * The main functions are as follows:
|
| 7 | * 1. Execute boot script /etc/init.d/mbtk_boot_server_ready after AT is ready(Only execute one time).
|
| 8 | * 2. Execute boot script /etc/init.d/mbtk_boot_net_ready after network is ready(Only execute one time).
|
| 9 | * 3. Set the frequency band based on the relevant information in the "device_info" partition.
|
| 10 | * 4. Create socket server(The client implementation in API).
|
| 11 | * 5. Create 3 connections between atcmdsrv, related devices: /tmp/atcmd_at ,
|
| 12 | * /tmp/atcmd_at_1 , /tmp/atcmd_at_2
|
| 13 | */
|
| 14 | /******************************************************************************
|
| 15 |
|
| 16 | EDIT HISTORY FOR FILE
|
| 17 |
|
| 18 | WHEN WHO WHAT,WHERE,WHY
|
| 19 | -------- -------- -------------------------------------------------------
|
| 20 | 2024/08/13 LiuBin Initial version
|
| 21 |
|
| 22 | ******************************************************************************/
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 23 | #include <stdio.h>
|
| 24 | #include <stdlib.h>
|
| 25 | #include <unistd.h>
|
| 26 | #include <sys/socket.h>
|
| 27 | #include <errno.h>
|
| 28 | #include <fcntl.h>
|
| 29 | #include <string.h>
|
| 30 | #include <netinet/in.h>
|
| 31 | #include <arpa/inet.h>
|
| 32 | #include <linux/un.h>
|
| 33 | #include <linux/netlink.h>
|
| 34 | #include <cutils/properties.h>
|
| 35 | #include <time.h>
|
| 36 | #include <sys/time.h>
|
| 37 | #include <signal.h>
|
| 38 | #include <sys/epoll.h>
|
| 39 | #include <pthread.h>
|
| 40 |
|
| 41 |
|
| 42 | //#include "cploader.h"
|
| 43 | #include "mbtk_log.h"
|
| 44 | #include "mbtk_ifc.h"
|
| 45 | #include "mbtk_type.h"
|
| 46 | #include "atchannel.h"
|
| 47 | #include "at_tok.h"
|
| 48 | #include "mbtk_utils.h"
|
| 49 | #include "mbtk_task.h"
|
| 50 | #include "ril_info.h"
|
| 51 | #include "mbtk_ntp.h"
|
| 52 | #include "mbtk_net_control.h"
|
| 53 | #include "mbtk_ril.h"
|
| 54 | #include "mbtk_str.h"
|
| 55 | #include "mbtk_queue.h"
|
b.liu | fd87baf | 2024-11-15 15:30:38 +0800 | [diff] [blame^] | 56 | #include "mbtk_file.h"
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 57 |
|
b.liu | 62240ee | 2024-11-07 17:52:45 +0800 | [diff] [blame] | 58 | #ifndef TEMP_FAILURE_RETRY
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 59 | #define TEMP_FAILURE_RETRY(exp) ({ \
|
| 60 | typeof (exp) _rc; \
|
| 61 | do { \
|
| 62 | _rc = (exp); \
|
| 63 | } while (_rc == -1 && errno == EINTR); \
|
| 64 | _rc; })
|
b.liu | 62240ee | 2024-11-07 17:52:45 +0800 | [diff] [blame] | 65 | #endif
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 66 |
|
| 67 | #define BUFFER_SIZE 2048
|
| 68 | #define UEVENT_USIM_DEV "/devices/virtual/usim_event/usim0"
|
| 69 | #define MBTK_BOOT_SERVER_READY "/etc/init.d/mbtk_boot_server_ready"
|
| 70 | #define MBTK_BOOT_NET_READY "/etc/init.d/mbtk_boot_net_ready"
|
| 71 | #define MBTK_RILD_PID_FILE "/var/run/mbtk_rild.pid"
|
| 72 | #define MBTK_RILD_FILE_NET_READY "/tmp/mbtk_rild.net_ready"
|
| 73 | #define MBTK_RILD_FILE_SER_READY "/tmp/mbtk_rild.ser_ready"
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 74 | #define RIL_CALL_NUM_MAX 10
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 75 |
|
| 76 | static bool ril_net_ready = FALSE; // Only one time.
|
| 77 | static bool ril_server_ready = FALSE; // Only one time.
|
| 78 | ril_band_info_t band_info;
|
| 79 | ril_info_t ril_info;
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 80 | static mbtk_ril_call_state_info_t call_list[RIL_CALL_NUM_MAX];
|
b.liu | b477207 | 2024-08-15 14:47:03 +0800 | [diff] [blame] | 81 | extern mbtk_cell_pack_info_t cell_info;
|
b.liu | bcf86c9 | 2024-08-19 19:48:28 +0800 | [diff] [blame] | 82 | extern ril_cgact_wait_t cgact_wait;
|
b.liu | fd87baf | 2024-11-15 15:30:38 +0800 | [diff] [blame^] | 83 | extern int ril_cid_start;
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 84 |
|
| 85 | // int urc_msg_distribute(bool async_process, info_urc_msg_id_enum msg, void *data, int data_len);
|
| 86 | // int mbtk_signal_log(char *data);
|
| 87 | int InProduction_Mode(void);
|
| 88 | mbtk_ril_err_enum dev_pack_req_process(sock_cli_info_t* cli_info, ril_msg_pack_info_t* pack);
|
| 89 | mbtk_ril_err_enum call_pack_req_process(sock_cli_info_t* cli_info, ril_msg_pack_info_t* pack);
|
| 90 | mbtk_ril_err_enum sim_pack_req_process(sock_cli_info_t* cli_info, ril_msg_pack_info_t* pack);
|
| 91 | mbtk_ril_err_enum net_pack_req_process(sock_cli_info_t* cli_info, ril_msg_pack_info_t* pack);
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 92 | mbtk_ril_err_enum data_call_pack_req_process(sock_cli_info_t* cli_info, ril_msg_pack_info_t* pack);
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 93 | mbtk_ril_err_enum pb_pack_req_process(sock_cli_info_t* cli_info, ril_msg_pack_info_t* pack);
|
| 94 | mbtk_ril_err_enum sms_pack_req_process(sock_cli_info_t* cli_info, ril_msg_pack_info_t* pack);
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 95 | mbtk_ril_err_enum ecall_pack_req_process(sock_cli_info_t* cli_info, ril_msg_pack_info_t* pack);
|
| 96 |
|
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 97 | void data_call_retry(ATPortType_enum port, mbtk_ril_net_reg_state_info_t *reg_state);
|
b.liu | afdf2c6 | 2024-11-12 11:10:44 +0800 | [diff] [blame] | 98 |
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 99 | void data_call_state_change_cb(int cid, bool action, bool auto_change, int reason);
|
| 100 | static int send_pack_to_queue(sock_cli_info_t* cli_info, void* pack);
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 101 |
|
| 102 | /* Called on command thread */
|
| 103 | static void onATTimeout()
|
| 104 | {
|
| 105 | LOGI("AT channel timeout; closing\n");
|
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 106 | at_close(ATPORTTYPE_0);
|
b.liu | fd87baf | 2024-11-15 15:30:38 +0800 | [diff] [blame^] | 107 | at_close(ATPORTTYPE_1);
|
| 108 | at_close(ATPORTTYPE_2);
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 109 | }
|
| 110 |
|
| 111 | /* Called on command or reader thread */
|
| 112 | static void onATReaderClosed()
|
| 113 | {
|
| 114 | LOGI("AT channel closed\n");
|
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 115 | at_close(ATPORTTYPE_0);
|
b.liu | fd87baf | 2024-11-15 15:30:38 +0800 | [diff] [blame^] | 116 | at_close(ATPORTTYPE_1);
|
| 117 | at_close(ATPORTTYPE_2);
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 118 | }
|
| 119 |
|
| 120 | static void sock_cli_free_func(void *data) |
| 121 | { |
| 122 | if (data) |
| 123 | { |
| 124 | sock_cli_info_t *info = (sock_cli_info_t*) data;
|
| 125 | LOGD("Free Socket client[fd = %d].", info->fd);
|
| 126 | free(info); |
| 127 | } |
| 128 | }
|
| 129 |
|
b.liu | fd87baf | 2024-11-15 15:30:38 +0800 | [diff] [blame^] | 130 | bool asr_auto_data_call_enable()
|
| 131 | {
|
| 132 | /*
|
| 133 | uci show wan_default.default.enable
|
| 134 | wan_default.default.enable='1'
|
| 135 |
|
| 136 | uci get wan_default.default.enable
|
| 137 | 1
|
| 138 | */
|
| 139 | char buff[128] = {0};
|
| 140 | if(mbtk_cmd_line("uci get wan_default.default.enable", buff, sizeof(buff)) && strlen(buff) > 0) {
|
| 141 | return buff[0] == '1' ? TRUE : FALSE;
|
| 142 | } else {
|
| 143 | return FALSE;
|
| 144 | }
|
| 145 | }
|
| 146 |
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 147 | /*
|
| 148 | * Will exec mbtk_boot_server_ready and mbtk_boot_net_ready if is_first_boot is true.
|
| 149 | */
|
| 150 | static int net_ready_set()
|
| 151 | {
|
| 152 | int ret = -1;
|
| 153 | int fd = open(MBTK_RILD_FILE_NET_READY, O_CREAT | O_WRONLY | O_TRUNC, 0644);
|
| 154 | if(fd > 0) {
|
| 155 | if(write(fd, "1", 1) == 1) {
|
| 156 | ret = 0;
|
| 157 | ril_net_ready = TRUE;
|
| 158 | }
|
| 159 | close(fd);
|
| 160 | } else {
|
| 161 | LOGE("Open %s fail:%d", MBTK_RILD_FILE_NET_READY, errno);
|
| 162 | }
|
| 163 |
|
| 164 | return ret;
|
| 165 | }
|
| 166 |
|
| 167 | /*
|
| 168 | * Will exec mbtk_boot_server_ready and mbtk_boot_net_ready if is_first_boot is true.
|
| 169 | */
|
| 170 | static int ser_ready_set()
|
| 171 | {
|
| 172 | int ret = -1;
|
| 173 | int fd = open(MBTK_RILD_FILE_SER_READY, O_CREAT | O_WRONLY | O_TRUNC, 0644);
|
| 174 | if(fd > 0) {
|
| 175 | if(write(fd, "1", 1) == 1) {
|
| 176 | ret = 0;
|
| 177 | ril_server_ready = TRUE;
|
| 178 | }
|
| 179 | close(fd);
|
| 180 | } else {
|
| 181 | LOGE("Open %s fail:%d", MBTK_RILD_FILE_SER_READY, errno);
|
| 182 | }
|
| 183 |
|
| 184 | return ret;
|
| 185 | }
|
| 186 |
|
| 187 | /*
|
| 188 | * Will exec mbtk_boot_server_ready and mbtk_boot_net_ready if is_first_boot is true.
|
| 189 | */
|
| 190 | static void ready_state_update()
|
| 191 | {
|
| 192 | int fd = open(MBTK_RILD_FILE_NET_READY, O_RDONLY, 0644);
|
| 193 | char buff[10];
|
| 194 | if(fd > 0) {
|
| 195 | if(read(fd, buff, sizeof(buff)) > 0) {
|
| 196 | ril_net_ready = TRUE;
|
| 197 | } else {
|
| 198 | ril_net_ready = FALSE;
|
| 199 | }
|
| 200 |
|
| 201 | close(fd);
|
| 202 | } else {
|
| 203 | ril_net_ready = FALSE;
|
| 204 | LOGE("Open %s fail:%d", MBTK_RILD_FILE_NET_READY, errno);
|
| 205 | }
|
| 206 |
|
| 207 | fd = open(MBTK_RILD_FILE_SER_READY, O_RDONLY, 0644);
|
| 208 | if(fd > 0) {
|
| 209 | if(read(fd, buff, sizeof(buff)) > 0) {
|
| 210 | ril_server_ready = TRUE;
|
| 211 | } else {
|
| 212 | ril_server_ready = FALSE;
|
| 213 | }
|
| 214 |
|
| 215 | close(fd);
|
| 216 | } else {
|
| 217 | ril_server_ready = FALSE;
|
| 218 | LOGE("Open %s fail:%d", MBTK_RILD_FILE_SER_READY, errno);
|
| 219 | }
|
| 220 | }
|
| 221 |
|
| 222 | static void mbtk_net_ready()
|
| 223 | {
|
| 224 | // /etc/init.d/mbtk_boot_net_ready
|
| 225 | if(!ril_net_ready) {
|
| 226 | if(access(MBTK_BOOT_NET_READY , X_OK) == 0) {
|
| 227 | LOGD("Exec : %s", MBTK_BOOT_NET_READY);
|
b.liu | 62240ee | 2024-11-07 17:52:45 +0800 | [diff] [blame] | 228 | mbtk_system(MBTK_BOOT_NET_READY);
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 229 | } else {
|
| 230 | LOGE("%s can not exec.", MBTK_BOOT_NET_READY);
|
| 231 | }
|
| 232 | net_ready_set();
|
| 233 | } else {
|
| 234 | LOGD("No exec : %s", MBTK_BOOT_NET_READY);
|
| 235 | }
|
| 236 | }
|
| 237 |
|
| 238 | static void mbtk_ril_ready()
|
| 239 | {
|
| 240 | // /etc/init.d/mbtk_boot_server_ready
|
| 241 | if(!ril_server_ready) {
|
| 242 | if(access(MBTK_BOOT_SERVER_READY , X_OK) == 0) {
|
| 243 | LOGD("Exec : %s", MBTK_BOOT_SERVER_READY);
|
b.liu | 62240ee | 2024-11-07 17:52:45 +0800 | [diff] [blame] | 244 | mbtk_system(MBTK_BOOT_SERVER_READY);
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 245 | } else {
|
| 246 | LOGE("%s can not exec.", MBTK_BOOT_SERVER_READY);
|
| 247 | }
|
| 248 | ser_ready_set();
|
| 249 | } else {
|
| 250 | LOGD("No exec : %s", MBTK_BOOT_SERVER_READY);
|
| 251 | }
|
| 252 | }
|
| 253 |
|
| 254 | static sock_cli_info_t* cli_find(int fd)
|
| 255 | { |
| 256 | sock_cli_info_t *result = NULL;
|
| 257 | list_first(ril_info.sock_client_list);
|
| 258 | while ((result = (sock_cli_info_t*) list_next(ril_info.sock_client_list)))
|
| 259 | { |
| 260 | if (result->fd == fd) |
| 261 | return result; |
| 262 | } |
| 263 | |
| 264 | return NULL; |
| 265 | }
|
| 266 |
|
| 267 | static void cli_close(sock_cli_info_t* client)
|
| 268 | { |
| 269 | struct epoll_event ev; |
| 270 | memset(&ev,0,sizeof(struct epoll_event)); |
| 271 | ev.data.fd = client->fd; |
| 272 | ev.events = EPOLLIN | EPOLLERR | EPOLLET; |
| 273 | epoll_ctl(ril_info.epoll_fd, EPOLL_CTL_DEL, client->fd, &ev);
|
| 274 | |
| 275 | close(client->fd); |
| 276 | |
| 277 | if(list_remove(ril_info.sock_client_list, client))
|
| 278 | { |
| 279 | sock_cli_free_func(client); |
| 280 | } |
| 281 | } |
| 282 | |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 283 | static void ril_error_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, int err)
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 284 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 285 | ril_msg_pack_info_t* pack = ril_msg_pack_creat(port, RIL_MSG_TYPE_RSP, ril_id, msg_index, NULL, 0);
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 286 | if(pack) |
| 287 | {
|
| 288 | pack->err = (uint16)err;
|
| 289 | ril_pack_send(fd, pack);
|
| 290 | ril_msg_pack_free(pack);
|
| 291 | } |
| 292 | else |
| 293 | { |
| 294 | LOGW("ril_msg_pack_creat() fail.");
|
| 295 | } |
| 296 | } |
| 297 | |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 298 | void ril_rsp_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len)
|
b.liu | 10a3410 | 2024-08-20 20:36:24 +0800 | [diff] [blame] | 299 | {
|
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 300 | ril_msg_pack_info_t* pack = ril_msg_pack_creat(port, RIL_MSG_TYPE_RSP, ril_id, msg_index, data, data_len);
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 301 | if(pack) |
| 302 | { |
| 303 | pack->err = (uint16)MBTK_RIL_ERR_SUCCESS;
|
| 304 | #if 0
|
| 305 | if(data != NULL && data_len > 0) |
| 306 | { |
| 307 | pack->data_len = (uint16)data_len; |
| 308 | pack->data = (uint8*)mbtk_memcpy(data, data_len);
|
| 309 | }
|
| 310 | #endif
|
| 311 | ril_pack_send(fd, pack);
|
| 312 | ril_msg_pack_free(pack);
|
| 313 | } |
| 314 | else |
| 315 | { |
| 316 | LOGW("ril_msg_pack_creat() fail.");
|
| 317 | } |
| 318 | }
|
| 319 |
|
| 320 | void ril_ind_pack_send(int fd, int msg_id, const void* data, int data_len)
|
| 321 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 322 | ril_msg_pack_info_t* pack = ril_msg_pack_creat(ATPORTTYPE_NON, RIL_MSG_TYPE_IND, msg_id, RIL_MSG_INDEX_INVALID, data, data_len);
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 323 | if(pack) |
| 324 | { |
| 325 | pack->err = (uint16)0;
|
| 326 | #if 0
|
| 327 | if(data != NULL && data_len > 0) |
| 328 | { |
| 329 | pack->data_len = (uint16)data_len; |
| 330 | pack->data = (uint8*)mbtk_memcpy(data, data_len);
|
| 331 | }
|
| 332 | #endif
|
| 333 | ril_pack_send(fd, pack);
|
| 334 | ril_msg_pack_free(pack);
|
| 335 | } |
| 336 | else |
| 337 | { |
| 338 | LOGW("ril_msg_pack_creat() fail.");
|
| 339 | } |
| 340 | }
|
| 341 |
|
b.liu | fd87baf | 2024-11-15 15:30:38 +0800 | [diff] [blame^] | 342 | void ril_state_change(ril_msg_id_enum msg_id, const void *data, int data_len)
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 343 | { |
| 344 | sock_cli_info_t *cli = NULL;
|
| 345 | list_first(ril_info.sock_client_list);
|
| 346 | while ((cli = (sock_cli_info_t*) list_next(ril_info.sock_client_list)))
|
| 347 | { |
| 348 | if(cli->ind_num > 0) { |
| 349 | int i; |
| 350 | for(i = 0; i < IND_REGISTER_MAX; i++) { |
| 351 | if(cli->ind_register[i] == msg_id) {
|
| 352 | ril_ind_pack_send(cli->fd, msg_id, data, data_len);
|
| 353 | break; |
| 354 | } |
| 355 | } |
| 356 | } |
| 357 | } |
| 358 | }
|
| 359 |
|
b.liu | 9e8584b | 2024-11-06 19:21:28 +0800 | [diff] [blame] | 360 | static int urc_msg_distribute(bool async_process, ril_msg_id_enum msg_id, const void *data, int data_len)
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 361 | {
|
| 362 | // Send urc msg to client.
|
| 363 | if(msg_id > RIL_MSG_ID_IND_BEGIN && msg_id < RIL_MSG_ID_IND_END) {
|
b.liu | fd87baf | 2024-11-15 15:30:38 +0800 | [diff] [blame^] | 364 | if(msg_id == RIL_MSG_ID_IND_PDP_STATE_CHANGE) {
|
| 365 | mbtk_ril_pdp_state_info_t *info = (mbtk_ril_pdp_state_info_t*)data;
|
| 366 | if(info->action && !info->ip_info_valid) {
|
| 367 | LOGD("PDP action but no IP information, not send.");
|
| 368 | } else {
|
| 369 | ril_state_change(msg_id, data, data_len);
|
| 370 | }
|
| 371 | } else {
|
| 372 | ril_state_change(msg_id, data, data_len);
|
| 373 | }
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 374 | }
|
| 375 |
|
| 376 | // Async process urc msg.
|
| 377 | if(async_process) { |
| 378 | ril_urc_msg_info_t *msg = (ril_urc_msg_info_t*)malloc(sizeof(ril_urc_msg_info_t));
|
| 379 | if(msg) {
|
| 380 | msg->msg = msg_id;
|
| 381 | msg->data = mbtk_memcpy(data, data_len);
|
| 382 | msg->data_len = data_len;
|
| 383 | if(msg->data == NULL) {
|
| 384 | LOGE("mbtk_memcpy() fail.");
|
| 385 | return -1;
|
| 386 | }
|
| 387 |
|
| 388 | return send_pack_to_queue(NULL, msg);
|
| 389 | } else {
|
| 390 | LOGE("malloc() fail.");
|
| 391 | return -1;
|
| 392 | }
|
| 393 | }
|
| 394 |
|
| 395 | return 0;
|
| 396 | }
|
| 397 |
|
| 398 | // *SIMDETEC:1,SIM
|
| 399 | // *EUICC:1
|
| 400 | // +CPIN: SIM PIN
|
| 401 | static void urc_sim_state_change_process(const char *s, const char *sms_pdu)
|
| 402 | {
|
| 403 | mbtk_ril_sim_state_info_t state;
|
| 404 | memset(&state, 0, sizeof(mbtk_ril_sim_state_info_t));
|
| 405 | state.sim_type = MBTK_UNKNOWN;
|
| 406 |
|
b.liu | fd87baf | 2024-11-15 15:30:38 +0800 | [diff] [blame^] | 407 | char* tmp_s = memdup(s,strlen(s) + 1);
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 408 | char *line = tmp_s;
|
| 409 | int tmp_int;
|
| 410 | char *tmp_str;
|
| 411 |
|
| 412 | if(strStartsWith(s, "*SIMDETEC:")) {
|
| 413 | if (at_tok_start(&line) < 0)
|
| 414 | {
|
| 415 | goto SIM_STATE_EXIT;
|
| 416 | }
|
| 417 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 418 | {
|
| 419 | goto SIM_STATE_EXIT;
|
| 420 | }
|
| 421 | if (at_tok_nextstr(&line, &tmp_str) < 0)
|
| 422 | {
|
| 423 | goto SIM_STATE_EXIT;
|
| 424 | }
|
| 425 |
|
| 426 | if(tmp_str) {
|
| 427 | if(strcmp(tmp_str, "NOS") == 0) {
|
| 428 | state.sim_type = ril_info.sim_type;
|
| 429 | state.sim_state = MBTK_SIM_STATE_ABSENT;
|
| 430 | ril_info.sim_state = MBTK_SIM_STATE_ABSENT;
|
| 431 | urc_msg_distribute(false, RIL_MSG_ID_IND_SIM_STATE_CHANGE, &state, sizeof(mbtk_ril_sim_state_info_t));
|
| 432 | } else if(strcmp(tmp_str, "SIM") == 0) {
|
| 433 | state.sim_type = ril_info.sim_type;
|
| 434 | state.sim_state = MBTK_SIM_STATE_NOT_READY;
|
| 435 | ril_info.sim_state = MBTK_SIM_STATE_NOT_READY;
|
| 436 | urc_msg_distribute(false, RIL_MSG_ID_IND_SIM_STATE_CHANGE, &state, sizeof(mbtk_ril_sim_state_info_t));
|
| 437 | }
|
| 438 | }
|
| 439 | } else if(strStartsWith(s, "+CPIN:")){
|
| 440 | if(strStartsWith(s, "+CPIN: READY"))
|
| 441 | {
|
| 442 | state.sim_state = MBTK_SIM_STATE_READY;
|
| 443 | }
|
| 444 | else if(strStartsWith(s, "+CPIN: SIM PIN"))
|
| 445 | {
|
| 446 | state.sim_state = MBTK_SIM_STATE_SIM_PIN;
|
| 447 | }
|
| 448 | else if(strStartsWith(s, "+CPIN: SIM PUK"))
|
| 449 | {
|
| 450 | state.sim_state = MBTK_SIM_STATE_SIM_PUK;
|
| 451 | }
|
| 452 | else if(strStartsWith(s, "+CPIN: PH-SIMLOCK PIN"))
|
| 453 | {
|
| 454 | state.sim_state = MBTK_SIM_STATE_PH_SIMLOCK_PIN;
|
| 455 | }
|
| 456 | else if(strStartsWith(s, "+CPIN: PH-SIMLOCK PUK"))
|
| 457 | {
|
| 458 | state.sim_state = MBTK_SIM_STATE_PH_SIMLOCK_PUK;
|
| 459 | }
|
| 460 | else if(strStartsWith(s, "+CPIN: PH-FSIM PIN"))
|
| 461 | {
|
| 462 | state.sim_state = MBTK_SIM_STATE_PH_FSIM_PIN;
|
| 463 | }
|
| 464 | else if(strStartsWith(s, "+CPIN: PH-FSIM PUK"))
|
| 465 | {
|
| 466 | state.sim_state = MBTK_SIM_STATE_PH_FSIM_PUK;
|
| 467 | }
|
| 468 | else if(strStartsWith(s, "+CPIN: SIM PIN2"))
|
| 469 | {
|
| 470 | state.sim_state = MBTK_SIM_STATE_SIM_PIN2;
|
| 471 | }
|
| 472 | else if(strStartsWith(s, "+CPIN: SIM PUK2"))
|
| 473 | {
|
| 474 | state.sim_state = MBTK_SIM_STATE_SIM_PUK2;
|
| 475 | }
|
| 476 | else if(strStartsWith(s, "+CPIN: PH-NET PIN"))
|
| 477 | {
|
| 478 | state.sim_state = MBTK_SIM_STATE_PH_NET_PIN;
|
| 479 | }
|
| 480 | else if(strStartsWith(s, "+CPIN: PH-NET PUK"))
|
| 481 | {
|
| 482 | state.sim_state = MBTK_SIM_STATE_PH_NET_PUK;
|
| 483 | }
|
| 484 | else if(strStartsWith(s, "+CPIN: PH-NETSUB PIN"))
|
| 485 | {
|
| 486 | state.sim_state = MBTK_SIM_STATE_PH_NETSUB_PIN;
|
| 487 | }
|
| 488 | else if(strStartsWith(s, "+CPIN: PH-NETSUB PUK"))
|
| 489 | {
|
| 490 | state.sim_state = MBTK_SIM_STATE_PH_NETSUB_PUK;
|
| 491 | }
|
| 492 | else if(strStartsWith(s, "+CPIN: PH-SP PIN"))
|
| 493 | {
|
| 494 | state.sim_state = MBTK_SIM_STATE_PH_SP_PIN;
|
| 495 | }
|
| 496 | else if(strStartsWith(s, "+CPIN: PH-SP PUK"))
|
| 497 | {
|
| 498 | state.sim_state = MBTK_SIM_STATE_PH_SP_PUK;
|
| 499 | }
|
| 500 | else if(strStartsWith(s, "+CPIN: PH-CORP PIN"))
|
| 501 | {
|
| 502 | state.sim_state = MBTK_SIM_STATE_PH_CORP_PIN;
|
| 503 | }
|
| 504 | else if(strStartsWith(s, "+CPIN: PH-CORP PUK"))
|
| 505 | {
|
| 506 | state.sim_state = MBTK_SIM_STATE_PH_CORP_PUK;
|
| 507 | }
|
| 508 | else if(strStartsWith(s, "+CPIN: SIM REMOVED"))
|
| 509 | {
|
| 510 | state.sim_state = MBTK_SIM_STATE_ABSENT;
|
| 511 | }
|
| 512 |
|
| 513 | state.sim_type = ril_info.sim_type;
|
| 514 | ril_info.sim_state = state.sim_state;
|
| 515 |
|
b.liu | fd87baf | 2024-11-15 15:30:38 +0800 | [diff] [blame^] | 516 | urc_msg_distribute(true, RIL_MSG_ID_IND_SIM_STATE_CHANGE, &state, sizeof(mbtk_ril_sim_state_info_t));
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 517 | } else if(strStartsWith(s, "*EUICC:")){
|
| 518 | if (at_tok_start(&line) < 0)
|
| 519 | {
|
| 520 | goto SIM_STATE_EXIT;
|
| 521 | }
|
| 522 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 523 | {
|
| 524 | goto SIM_STATE_EXIT;
|
| 525 | }
|
| 526 | ril_info.sim_type = (mbtk_sim_card_type_enum)tmp_int;
|
| 527 | } else {
|
| 528 | LOGW("Unknown URC.");
|
| 529 | }
|
| 530 |
|
| 531 | SIM_STATE_EXIT:
|
| 532 | free(tmp_s);
|
| 533 | }
|
| 534 |
|
| 535 | // +CLCC: 1, 1, 6, 0, 0, "18981911691", 129, "",, 0
|
| 536 | // +CALLDISCONNECT: 1
|
| 537 | // +CPAS: 4
|
| 538 | static void urc_call_state_change_process(const char *s, const char *sms_pdu)
|
| 539 | {
|
b.liu | fd87baf | 2024-11-15 15:30:38 +0800 | [diff] [blame^] | 540 | char* tmp_s = memdup(s,strlen(s) + 1);
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 541 | char *line = tmp_s;
|
| 542 | int tmp_int;
|
| 543 | char *tmp_str;
|
| 544 |
|
| 545 | if(strStartsWith(s, "+CLCC:")) {
|
| 546 | if (at_tok_start(&line) < 0)
|
| 547 | {
|
| 548 | goto CALL_STATE_EXIT;
|
| 549 | }
|
| 550 | if (at_tok_nextint(&line, &tmp_int) < 0) // call id
|
| 551 | {
|
| 552 | goto CALL_STATE_EXIT;
|
| 553 | }
|
| 554 |
|
| 555 | int i = 0;
|
| 556 | while(i < RIL_CALL_NUM_MAX) {
|
| 557 | if(call_list[i].call_id == tmp_int)
|
| 558 | break;
|
| 559 | i++;
|
| 560 | }
|
| 561 | if(i == RIL_CALL_NUM_MAX) { // No found this call id.
|
| 562 | i = 0;
|
| 563 | while(i < RIL_CALL_NUM_MAX) { // Find next empty call item.
|
| 564 | if(call_list[i].call_id == 0)
|
| 565 | break;
|
| 566 | i++;
|
| 567 | }
|
| 568 | call_list[i].call_id = tmp_int;
|
| 569 | }
|
| 570 |
|
| 571 | LOGD("Found call id : %d", call_list[i].call_id);
|
| 572 |
|
| 573 | if (at_tok_nextint(&line, &tmp_int) < 0) // dir
|
| 574 | {
|
| 575 | goto CALL_STATE_EXIT;
|
| 576 | }
|
| 577 | call_list[i].dir = (mbtk_ril_call_dir_enum)tmp_int;
|
| 578 |
|
| 579 | if (at_tok_nextint(&line, &tmp_int) < 0) // state
|
| 580 | {
|
| 581 | goto CALL_STATE_EXIT;
|
| 582 | }
|
| 583 | call_list[i].state = (mbtk_ril_call_state_enum)tmp_int;
|
| 584 |
|
| 585 | if (at_tok_nextint(&line, &tmp_int) < 0) // mode
|
| 586 | {
|
| 587 | goto CALL_STATE_EXIT;
|
| 588 | }
|
| 589 |
|
| 590 | if (at_tok_nextint(&line, &tmp_int) < 0) // mpty
|
| 591 | {
|
| 592 | goto CALL_STATE_EXIT;
|
| 593 | }
|
| 594 |
|
| 595 | if (at_tok_nextstr(&line, &tmp_str) < 0) // number
|
| 596 | {
|
| 597 | goto CALL_STATE_EXIT;
|
| 598 | }
|
| 599 | memset(call_list[i].call_number, 0, sizeof(call_list[i].call_number));
|
| 600 | if(tmp_str && strlen(tmp_str) > 0) {
|
| 601 | memcpy(call_list[i].call_number, tmp_str, strlen(tmp_str));
|
| 602 | }
|
| 603 |
|
| 604 | if (at_tok_nextint(&line, &tmp_int) < 0) // type
|
| 605 | {
|
| 606 | goto CALL_STATE_EXIT;
|
| 607 | }
|
| 608 | call_list[i].num_type = (mbtk_ril_call_num_type_enum)tmp_int;
|
| 609 |
|
| 610 | urc_msg_distribute(false, RIL_MSG_ID_IND_CALL_STATE_CHANGE, &(call_list[i]), sizeof(mbtk_ril_call_state_info_t));
|
| 611 | } else if(strStartsWith(s, "+CALLDISCONNECT:")){
|
| 612 | if (at_tok_start(&line) < 0)
|
| 613 | {
|
| 614 | goto CALL_STATE_EXIT;
|
| 615 | }
|
| 616 | if (at_tok_nextint(&line, &tmp_int) < 0) // call id
|
| 617 | {
|
| 618 | goto CALL_STATE_EXIT;
|
| 619 | }
|
| 620 |
|
| 621 | int i = 0;
|
| 622 | while(i < RIL_CALL_NUM_MAX) {
|
| 623 | if(call_list[i].call_id == tmp_int)
|
| 624 | break;
|
| 625 | i++;
|
| 626 | }
|
| 627 |
|
| 628 | if(i == RIL_CALL_NUM_MAX) { // No found this call id.
|
| 629 | LOGE("No found this call id : %d", tmp_int);
|
| 630 | goto CALL_STATE_EXIT;
|
| 631 | }
|
| 632 |
|
| 633 | call_list[i].state = MBTK_RIL_CALL_STATE_DISCONNECT;
|
| 634 |
|
| 635 | urc_msg_distribute(false, RIL_MSG_ID_IND_CALL_STATE_CHANGE, &(call_list[i]), sizeof(mbtk_ril_call_state_info_t));
|
| 636 |
|
| 637 | // Reset after call disconnect.
|
| 638 | memset(&(call_list[i]), 0, sizeof(mbtk_ril_call_state_info_t));
|
| 639 | } else if(strStartsWith(s, "+CPAS:")){
|
| 640 |
|
| 641 | } else {
|
| 642 | LOGW("Unknown URC.");
|
| 643 | }
|
| 644 |
|
| 645 | CALL_STATE_EXIT:
|
| 646 | free(tmp_s);
|
| 647 | }
|
| 648 |
|
| 649 | // *ECALLDATA: <urc_id>[,<urc_data>]
|
| 650 | static void urc_ecall_state_change_process(const char *s, const char *sms_pdu)
|
| 651 | {
|
| 652 | mbtk_ril_ecall_state_info_t ecall_state;
|
| 653 | memset(&ecall_state, 0, sizeof(mbtk_ril_ecall_state_info_t));
|
| 654 |
|
b.liu | fd87baf | 2024-11-15 15:30:38 +0800 | [diff] [blame^] | 655 | char* tmp_s = memdup(s,strlen(s) + 1);
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 656 | char *line = tmp_s;
|
| 657 | int tmp_int;
|
| 658 | char *tmp_str;
|
| 659 | if (at_tok_start(&line) < 0)
|
| 660 | {
|
| 661 | goto ECALLDATA_EXIT;
|
| 662 | }
|
| 663 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 664 | {
|
| 665 | goto ECALLDATA_EXIT;
|
| 666 | }
|
| 667 | ecall_state.urc_id = (uint8)tmp_int; // urc_id
|
| 668 | if (at_tok_nextstr(&line, &tmp_str) < 0)
|
| 669 | {
|
| 670 | goto ECALLDATA_EXIT;
|
| 671 | }
|
| 672 |
|
| 673 | if(tmp_str && strlen(tmp_str) > 0) {
|
| 674 | memcpy(ecall_state.urc_data, tmp_str, strlen(tmp_str));
|
| 675 | }
|
| 676 |
|
| 677 | urc_msg_distribute(false, RIL_MSG_ID_IND_ECALL_STATE_CHANGE, &ecall_state, sizeof(mbtk_ril_ecall_state_info_t));
|
| 678 | ECALLDATA_EXIT:
|
| 679 | free(tmp_s);
|
| 680 | }
|
| 681 |
|
| 682 | // +CMT: ,23
|
| 683 | // 0891683108200855F6240D91688189911196F10000221130717445230331D90C
|
| 684 | static void urc_sms_state_change_process(const char *s, const char *sms_pdu)
|
| 685 | {
|
| 686 |
|
| 687 | }
|
| 688 |
|
| 689 | // +CREG: 1, "8010", "000060a5", 0, 2, 0
|
| 690 | // +CREG: 1, "8330", "06447347", 7, 2, 0
|
| 691 | // +CEREG: 1, "8330", "06447347", 7
|
| 692 | // $CREG: 1, "8330", "06447347", 7,"0d4", 2, 0
|
| 693 | // $CREG: 1, "8010", "000060a7", 0,, 2, 0
|
| 694 | // +CGREG: 1
|
| 695 | static void urc_net_reg_state_change_process(const char *s, const char *sms_pdu)
|
| 696 | {
|
| 697 | mbtk_ril_net_reg_state_info_t state;
|
| 698 | memset(&state, 0, sizeof(mbtk_ril_net_reg_state_info_t));
|
| 699 | state.tech = MBTK_RADIO_TECH_UNKNOWN;
|
| 700 |
|
| 701 | if(strStartsWith(s, "+CREG:"))
|
| 702 | {
|
| 703 | state.type = MBTK_NET_REG_TYPE_CALL;
|
| 704 | } else if(strStartsWith(s, "+CGREG:")) {
|
| 705 | state.type = MBTK_NET_REG_TYPE_DATA_GSM_WCDMA;
|
| 706 | } else {
|
| 707 | state.type = MBTK_NET_REG_TYPE_DATA_LTE;
|
| 708 | }
|
| 709 |
|
b.liu | fd87baf | 2024-11-15 15:30:38 +0800 | [diff] [blame^] | 710 | char* tmp_s = memdup(s,strlen(s) + 1);
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 711 | char *line = tmp_s;
|
| 712 | int tmp_int;
|
| 713 | char *tmp_str;
|
| 714 | if (at_tok_start(&line) < 0)
|
| 715 | {
|
| 716 | goto CGREG_EXIT;
|
| 717 | }
|
| 718 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 719 | {
|
| 720 | goto CGREG_EXIT;
|
| 721 | }
|
| 722 | state.reg_state = (mbtk_net_reg_state_enum)tmp_int; // Reg State.
|
| 723 | if (state.reg_state) // Reg
|
| 724 | {
|
| 725 | if (at_tok_nextstr(&line, &tmp_str) < 0)
|
| 726 | {
|
| 727 | goto CGREG_EXIT;
|
| 728 | }
|
b.liu | fd87baf | 2024-11-15 15:30:38 +0800 | [diff] [blame^] | 729 |
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 730 | if (at_tok_nextstr(&line, &tmp_str) < 0)
|
| 731 | {
|
| 732 | goto CGREG_EXIT;
|
| 733 | }
|
b.liu | fd87baf | 2024-11-15 15:30:38 +0800 | [diff] [blame^] | 734 |
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 735 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 736 | {
|
| 737 | goto CGREG_EXIT;
|
| 738 | }
|
b.liu | fd87baf | 2024-11-15 15:30:38 +0800 | [diff] [blame^] | 739 |
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 740 | state.tech = (mbtk_radio_technology_enum)tmp_int; // AcT
|
| 741 | }
|
| 742 |
|
b.liu | 62240ee | 2024-11-07 17:52:45 +0800 | [diff] [blame] | 743 | if(state.reg_state == MBTK_NET_REG_STATE_HOME
|
| 744 | || state.reg_state == MBTK_NET_REG_STATE_ROAMING) {
|
| 745 | mbtk_net_ready();
|
| 746 | }
|
| 747 |
|
b.liu | afdf2c6 | 2024-11-12 11:10:44 +0800 | [diff] [blame] | 748 | // Should restart data call if necessary.
|
| 749 | urc_msg_distribute(true, RIL_MSG_ID_IND_NET_REG_STATE_CHANGE, &state, sizeof(mbtk_ril_net_reg_state_info_t));
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 750 | CGREG_EXIT:
|
| 751 | free(tmp_s);
|
| 752 | }
|
| 753 |
|
| 754 | static void urc_pdp_state_change_process(const char *s, const char *sms_pdu)
|
b.liu | bcf86c9 | 2024-08-19 19:48:28 +0800 | [diff] [blame] | 755 | {
|
| 756 | // "CONNECT"
|
| 757 | if(strStartsWith(s, "CONNECT"))
|
| 758 | {
|
| 759 | #if 1
|
| 760 | if(cgact_wait.waitting && cgact_wait.act) {
|
| 761 | cgact_wait.waitting = false;
|
| 762 | }
|
| 763 | #endif
|
| 764 | }
|
| 765 | // +CGEV:
|
| 766 | // +CGEV: NW DEACT <cid>,<cid>
|
| 767 | // +CGEV: ME DEACT <cid>,<cid>
|
| 768 | // +CGEV: NW PDN DEACT <cid>
|
| 769 | // +CGEV: ME PDN DEACT <cid>
|
| 770 | // +CGEV: NW DETACH
|
| 771 | // +CGEV: ME DETACH
|
| 772 | //
|
| 773 | // +CGEV: NW ACT <cid>,<cid>
|
| 774 | // +CGEV: ME ACT <cid>,<cid>
|
| 775 | // +CGEV: EPS PDN ACT <cid>
|
| 776 | // +CGEV: ME PDN ACT <cid>,<reason>,<cid>
|
| 777 | // +CGEV: ME PDN ACT <cid>,<reason>
|
| 778 | // +CGEV: NW PDN ACT <cid>
|
| 779 | // +CGEV: EPS ACT <cid>
|
| 780 | // +CGEV: NW MODIFY <cid>,<reason>
|
| 781 | // +CGEV: NW REATTACH
|
| 782 |
|
| 783 | /*
|
| 784 | +CGEV: NW DETACH
|
| 785 | +CGEV: ME DETACH
|
| 786 | +CGEV: NW CLASS <class>
|
| 787 | +CGEV: ME CLASS <class>
|
| 788 | +CGEV: NW PDN ACT <cid>
|
| 789 | +CGEV: ME PDN ACT <cid>[,<reason>[,<cid_other>]]
|
| 790 | +CGEV: NW ACT <p_cid>, <cid>, <event_type>
|
| 791 | +CGEV: ME ACT <p_cid>, <cid>, <event_type>
|
| 792 | +CGEV: NW DEACT <PDP_type>, <PDP_addr>, [<cid>]
|
| 793 | +CGEV: ME DEACT <PDP_type>, <PDP_addr>, [<cid>]
|
| 794 | +CGEV: NW PDN DEACT <cid>
|
| 795 | +CGEV: NW DEACT <PDP_type>, <PDP_addr>, [<cid>]
|
| 796 | +CGEV: ME PDN DEACT <cid>
|
| 797 | +CGEV: ME DEACT <PDP_type>, <PDP_addr>, [<cid>]
|
| 798 | +CGEV: NW DEACT <p_cid>, <cid>, <event_type>
|
| 799 | +CGEV: NW DEACT <PDP_type>, <PDP_addr>, [<cid>]
|
| 800 | +CGEV: ME DEACT <p_cid>, <cid>, <event_type>
|
| 801 | +CGEV: ME DEACT <PDP_type>, <PDP_addr>, [<cid>]
|
| 802 | +CGEV: NW MODIFY <cid>, <change_reason>, <event_type>
|
| 803 | +CGEV: ME MODIFY <cid>, <change_reason>, <event_type>
|
| 804 | +CGEV: REJECT <PDP_type>, <PDP_addr>
|
| 805 | +CGEV: NW REACT <PDP_type>, <PDP_addr>, [<cid>]
|
| 806 | */
|
| 807 | else if(strStartsWith(s, "+CGEV:"))
|
| 808 | {
|
| 809 | #if 1
|
| 810 | // "+CGEV: ME PDN ACT ")) { // +CGEV: ME PDN ACT <cid>[,<reason>[,<cid_other>]]
|
| 811 | // "+CGEV: NW MODIFY ")) { // +CGEV: NW MODIFY <cid>, <change_reason>, <event_type>
|
| 812 | // "+CGEV: ME PDN DEACT ")) { // +CGEV: ME PDN DEACT 1
|
| 813 | // "+CGEV: NW PDN DEACT ")) { // +CGEV: NW PDN DEACT <cid>
|
| 814 | // "+CGEV: EPS PDN ACT ")) { // +CGEV: EPS PDN ACT <cid>
|
| 815 | // "+CGEV: ME PDN DEACT ")) { // +CGEV: EPS PDN DEACT <cid>
|
| 816 | // "+CGEV: ME PDN ACT ")) { // +CGEV: ME PDN ACT <cid>,1
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 817 | mbtk_ril_pdp_state_info_t cgev_info;
|
| 818 | memset(&cgev_info, 0, sizeof(mbtk_ril_pdp_state_info_t));
|
b.liu | 62240ee | 2024-11-07 17:52:45 +0800 | [diff] [blame] | 819 | int cid, reason = 0;
|
| 820 | memset(&cgev_info, 0, sizeof(mbtk_ril_pdp_state_info_t));
|
| 821 | if (sscanf(s, "+CGEV: NW PDN DEACT %d", &cid) == 1) {
|
| 822 | cgev_info.cid = (uint16)cid;
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 823 | cgev_info.action = FALSE;
|
b.liu | 62240ee | 2024-11-07 17:52:45 +0800 | [diff] [blame] | 824 | } else if (sscanf(s, "+CGEV: ME PDN DEACT %d", &cid) == 1) {
|
| 825 | cgev_info.cid = (uint16)cid;
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 826 | cgev_info.action = FALSE;
|
b.liu | 62240ee | 2024-11-07 17:52:45 +0800 | [diff] [blame] | 827 | } else if(sscanf(s, "+CGEV: ME PDN ACT %d,%d", &cid, &reason) == 2
|
| 828 | || sscanf(s, "+CGEV: ME PDN ACT %d", &cid) == 1) {
|
| 829 | cgev_info.cid = (uint16)cid;
|
| 830 | cgev_info.reason = (uint16)reason;
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 831 | cgev_info.action = TRUE;
|
b.liu | bcf86c9 | 2024-08-19 19:48:28 +0800 | [diff] [blame] | 832 | } else if (!strcmp(s, "+CGEV: ME DETACH")) {
|
| 833 | if(cgact_wait.waitting) {
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 834 | cgev_info.cid = cgact_wait.cid;
|
b.liu | bcf86c9 | 2024-08-19 19:48:28 +0800 | [diff] [blame] | 835 | }
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 836 | cgev_info.action = FALSE;
|
b.liu | 62240ee | 2024-11-07 17:52:45 +0800 | [diff] [blame] | 837 | } else if (sscanf(s, "+CGEV: NW MODIFY %d,%d", &cid, &reason) == 2) {
|
| 838 | cgev_info.cid = (uint16)cid;
|
| 839 | cgev_info.reason = (uint16)reason;
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 840 | cgev_info.action = TRUE;
|
b.liu | 62240ee | 2024-11-07 17:52:45 +0800 | [diff] [blame] | 841 | } else if(sscanf(s, "+CGEV: EPS PDN ACT %d", &cid) == 1) {
|
| 842 | cgev_info.cid = (uint16)cid;
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 843 | cgev_info.action = TRUE;
|
b.liu | bcf86c9 | 2024-08-19 19:48:28 +0800 | [diff] [blame] | 844 | } else {
|
| 845 | LOGD(">>>>>>>>>No process +CGEV <<<<<<<<<");
|
| 846 | return;
|
| 847 | }
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 848 | cgev_info.auto_change = !cgact_wait.waitting;
|
b.liu | bcf86c9 | 2024-08-19 19:48:28 +0800 | [diff] [blame] | 849 |
|
| 850 | if(cgact_wait.act) {
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 851 | if(cgact_wait.waitting && cgev_info.action && cgact_wait.cid == cgev_info.cid) {
|
b.liu | bcf86c9 | 2024-08-19 19:48:28 +0800 | [diff] [blame] | 852 | cgact_wait.waitting = false;
|
| 853 | }
|
| 854 | } else {
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 855 | if(cgact_wait.waitting && !cgev_info.action && cgact_wait.cid == cgev_info.cid) {
|
b.liu | bcf86c9 | 2024-08-19 19:48:28 +0800 | [diff] [blame] | 856 | cgact_wait.waitting = false;
|
| 857 | }
|
| 858 | }
|
| 859 |
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 860 | LOGD("+CGEV:cid - %d, act - %d, auto_change - %d, reason - %d", cgev_info.cid, cgev_info.action,
|
| 861 | cgev_info.auto_change, cgev_info.reason);
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 862 | if(cgev_info.cid >= MBTK_APN_CID_MIN && cgev_info.cid <= MBTK_APN_CID_MAX) {
|
b.liu | afdf2c6 | 2024-11-12 11:10:44 +0800 | [diff] [blame] | 863 | data_call_state_change_cb(cgev_info.cid, cgev_info.action, cgev_info.auto_change, cgev_info.reason);
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 864 | urc_msg_distribute(false, RIL_MSG_ID_IND_PDP_STATE_CHANGE, &cgev_info, sizeof(mbtk_ril_pdp_state_info_t));
|
| 865 | }
|
| 866 |
|
b.liu | bcf86c9 | 2024-08-19 19:48:28 +0800 | [diff] [blame] | 867 | #else
|
| 868 | if(at_process) {
|
| 869 | if(cgact_wait.act) {
|
| 870 | if(strStartsWith(s, "+CGEV: ME PDN ACT ")) { // +CGEV: ME PDN ACT 15,4
|
| 871 | if(cgact_wait.cid == atoi(s + 18)) {
|
| 872 | cgact_wait.waitting = false;
|
| 873 | }
|
| 874 |
|
| 875 | uint8 data_pdp;
|
| 876 | char* tmp_s = memdup(s + 18,strlen(s + 18));
|
| 877 | char* free_ptr = tmp_s;
|
| 878 | char *line = tmp_s;
|
| 879 | int tmp_int;
|
| 880 | if (at_tok_start(&line) < 0)
|
| 881 | {
|
| 882 | goto at_PDP_CREG_EXIT;
|
| 883 | }
|
| 884 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 885 | {
|
| 886 | goto at_PDP_CREG_EXIT;
|
| 887 | }
|
| 888 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 889 | {
|
| 890 | goto at_PDP_CREG_EXIT;
|
| 891 | }
|
| 892 | data_pdp = tmp_int;
|
| 893 | at_PDP_CREG_EXIT:
|
| 894 | free(free_ptr);
|
| 895 |
|
| 896 | //data_pdp = (uint8)atoi(s + 20); //reason
|
| 897 | if(cgact_wait.cid >= 1 && cgact_wait.cid < 8)
|
| 898 | {
|
| 899 | if(data_pdp == 0)
|
| 900 | {
|
| 901 | data_pdp = 25;
|
| 902 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 903 | //data_pdp = cgact_wait.cid + 200;
|
| 904 | }
|
| 905 | else if(data_pdp == 1)
|
| 906 | {
|
| 907 | data_pdp = 26;
|
| 908 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 909 | }
|
| 910 | else if(data_pdp == 2)
|
| 911 | {
|
| 912 | data_pdp = 27;
|
| 913 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 914 | }
|
| 915 | else if(data_pdp == 3)
|
| 916 | {
|
| 917 | data_pdp = 27;
|
| 918 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 919 | }
|
| 920 | else
|
| 921 | {
|
| 922 |
|
| 923 | }
|
| 924 | if(cgact_wait.cid != 0)
|
| 925 | {
|
| 926 | data_pdp = cgact_wait.cid + 200;
|
| 927 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 928 | }
|
| 929 | }
|
| 930 | } else if(strStartsWith(s, "+CGEV: NW MODIFY ")) { // +CGEV: NW MODIFY 1,4
|
| 931 | if(cgact_wait.cid == atoi(s + 17)) {
|
| 932 | cgact_wait.waitting = false;
|
| 933 | }
|
| 934 | }
|
| 935 | } else {
|
| 936 | if(strStartsWith(s, "+CGEV: ME PDN DEACT ")) { // +CGEV: ME PDN DEACT 1
|
| 937 | if(cgact_wait.cid == atoi(s + 20)) {
|
| 938 | cgact_wait.waitting = false;
|
| 939 | }
|
| 940 | uint8 data_pdp;
|
| 941 | data_pdp = 0; //
|
| 942 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 943 | if(cgact_wait.cid != 0)
|
| 944 | {
|
| 945 | data_pdp = cgact_wait.cid + 100;
|
| 946 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 947 | }
|
| 948 | }
|
| 949 | }
|
| 950 | } else {
|
| 951 | // apn_state_set
|
| 952 |
|
| 953 | // +CGEV: NW PDN DEACT <cid>
|
| 954 |
|
| 955 | // +CGEV: EPS PDN ACT 1
|
| 956 | // +CGEV: ME PDN ACT 8,1
|
| 957 |
|
| 958 | // +CGEV: ME PDN ACT 2,4
|
| 959 | uint8 data[2] = {0xFF};
|
| 960 | if(strStartsWith(s, "+CGEV: NW PDN DEACT ")) { // +CGEV: NW PDN DEACT <cid>
|
| 961 | //apn_state_set(atoi(s + 20), false);
|
| 962 | data[0] = (uint8)0;
|
| 963 | data[1] = (uint8)atoi(s + 20);
|
| 964 |
|
| 965 | uint8 data_pdp;
|
| 966 | data_pdp = 0; //
|
| 967 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 968 | data_pdp = data[1] + 100;
|
| 969 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 970 | } else if(strStartsWith(s, "+CGEV: EPS PDN ACT ")) { // +CGEV: EPS PDN ACT <cid>
|
| 971 | //apn_state_set(atoi(s + 19), true);
|
| 972 | #if (defined(MBTK_AF_SUPPORT) || defined(MBTK_ALL_CID_SUPPORT))
|
| 973 | //data[0] = (uint8)1;
|
| 974 | //data[1] = (uint8)atoi(s + 19);
|
| 975 | #else
|
| 976 | data[0] = (uint8)1;
|
| 977 | data[1] = (uint8)atoi(s + 19);
|
| 978 | #endif
|
| 979 | } else if(strStartsWith(s, "+CGEV: ME PDN DEACT ")) { // +CGEV: EPS PDN DEACT <cid>
|
| 980 | //apn_state_set(atoi(s + 19), true);
|
| 981 | data[0] = (uint8)0;
|
| 982 | data[1] = (uint8)atoi(s + 20);
|
| 983 |
|
| 984 | uint8 data_pdp;
|
| 985 | data_pdp = 0; //
|
| 986 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 987 | data_pdp = data[1] + 100;
|
| 988 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 989 | } else if(strStartsWith(s, "+CGEV: ME PDN ACT ")) { // +CGEV: ME PDN ACT <cid>,1
|
| 990 | //apn_state_set(atoi(s + 18), true);
|
| 991 | data[0] = (uint8)1;
|
| 992 | data[1] = (uint8)atoi(s + 18);
|
| 993 |
|
| 994 | uint8 data_pdp;
|
| 995 | char* tmp_s = memdup(s + 18,strlen(s + 18));
|
| 996 | char* free_ptr = tmp_s;
|
| 997 | char *line = tmp_s;
|
| 998 | int tmp_int;
|
| 999 | if (at_tok_start(&line) < 0)
|
| 1000 | {
|
| 1001 | goto PDP_CREG_EXIT;
|
| 1002 | }
|
| 1003 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1004 | {
|
| 1005 | goto PDP_CREG_EXIT;
|
| 1006 | }
|
| 1007 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1008 | {
|
| 1009 | goto PDP_CREG_EXIT;
|
| 1010 | }
|
| 1011 | data_pdp = tmp_int;
|
| 1012 | PDP_CREG_EXIT:
|
| 1013 | free(free_ptr);
|
| 1014 | //data_pdp = (uint8)atoi(s + 20); //reason
|
| 1015 | if(data[1] >= 1 && data[1] < 8)
|
| 1016 | {
|
| 1017 | if(data_pdp == 0)
|
| 1018 | {
|
| 1019 | data_pdp = 25;
|
| 1020 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 1021 | }
|
| 1022 | else if(data_pdp == 1)
|
| 1023 | {
|
| 1024 | data_pdp = 26;
|
| 1025 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 1026 | }
|
| 1027 | else if(data_pdp == 2)
|
| 1028 | {
|
| 1029 | data_pdp = 27;
|
| 1030 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 1031 | }
|
| 1032 | else if(data_pdp == 3)
|
| 1033 | {
|
| 1034 | data_pdp = 27;
|
| 1035 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 1036 | }
|
| 1037 | else
|
| 1038 | {
|
| 1039 |
|
| 1040 | }
|
| 1041 |
|
| 1042 | data_pdp = data[1] + 200;
|
| 1043 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 1044 | data[1] = 0;
|
| 1045 | }
|
| 1046 | } else {
|
| 1047 | LOGI("No process : %s", s);
|
| 1048 | }
|
| 1049 |
|
| 1050 | urc_msg_distribute(true, INFO_URC_MSG_CGEV, data, sizeof(uint8) * 2);
|
| 1051 | }
|
| 1052 | #endif
|
| 1053 | } else {
|
| 1054 | LOGW("Unknown PDP URC : %s", s);
|
| 1055 | }
|
| 1056 | }
|
| 1057 |
|
| 1058 |
|
| 1059 | static void urc_cell_info_process(const char *s, const char *sms_pdu)
|
b.liu | b477207 | 2024-08-15 14:47:03 +0800 | [diff] [blame] | 1060 | {
|
| 1061 | /*
|
| 1062 | // <mcc>, <length of mnc>, <mnc>, <tac>, <PCI>, <dlEuarfcn>, < ulEuarfcn >, <band>, <dlBandwidth>,
|
| 1063 | // <rsrp>,<rsrq>, <sinr>,
|
| 1064 | // errcModeState,emmState,serviceState,IsSingleEmmRejectCause,EMMRejectCause,mmeGroupId,mmeCode,mTmsi,
|
| 1065 | // cellId,subFrameAssignType,specialSubframePatterns,transMode
|
| 1066 | // mainRsrp,diversityRsrp,mainRsrq,diversityRsrq,rssi,cqi,pathLoss,tb0DlTpt,tb1DlTpt,tb0DlPeakTpt,tb1DlPeakTpt,tb0UlPeakTpt,
|
| 1067 | // tb1UlPeakTpt,dlThroughPut,dlPeakThroughPut,averDlPRB,averCQITb0,averCQITb1,rankIndex,grantTotal,ulThroughPut,ulPeakThroughPut,currPuschTxPower,averUlPRB,
|
| 1068 | // dlBer, ulBer,
|
| 1069 | // diversitySinr, diversityRssi
|
| 1070 | +EEMLTESVC: 1120, 2, 0, 33584, 430, 40936, 40936, 41, 20,
|
| 1071 | 0, 0, 0,
|
| 1072 | 1, 10, 0, 1, 0, 1059, 78, 3959566565,
|
| 1073 | 105149248, 2, 7, 7,
|
| 1074 | 0, 0, 0, 0, 0, 0, 0, 1190919, 0, 0, 0, 16779777,
|
| 1075 | 0, 5112867, 3959566565, 2, 0, 0, 0, 0, 0, 0, 0, 0,
|
| 1076 | 0, 0,
|
| 1077 | 7, 44
|
| 1078 | */
|
| 1079 | if(strStartsWith(s, "+EEMLTESVC:")) // LTE Server Cell
|
| 1080 | {
|
| 1081 | // tac, PCI, dlEuarfcn, ulEuarfcn, band
|
| 1082 | if(cell_info.running) {
|
| 1083 | int tmp_int;
|
| 1084 | int i = 0;
|
b.liu | fd87baf | 2024-11-15 15:30:38 +0800 | [diff] [blame^] | 1085 | char* tmp_s = memdup(s,strlen(s) + 1);
|
b.liu | b477207 | 2024-08-15 14:47:03 +0800 | [diff] [blame] | 1086 | char* free_ptr = tmp_s;
|
| 1087 | char *line = tmp_s;
|
| 1088 | if (at_tok_start(&line) < 0)
|
| 1089 | {
|
| 1090 | goto EEMLTESVC_EXIT;
|
| 1091 | }
|
| 1092 |
|
| 1093 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1094 | {
|
| 1095 | goto EEMLTESVC_EXIT;
|
| 1096 | }
|
| 1097 | cell_info.cell_list.cell[cell_info.cell_list.num].value6 = (uint32)tmp_int; //mcc
|
| 1098 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1099 | {
|
| 1100 | goto EEMLTESVC_EXIT;
|
| 1101 | }
|
| 1102 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1103 | {
|
| 1104 | goto EEMLTESVC_EXIT;
|
| 1105 | }
|
| 1106 | cell_info.cell_list.cell[cell_info.cell_list.num].value7 = (uint32)tmp_int; //mnc
|
| 1107 | /*
|
| 1108 | // Jump 2 integer.
|
| 1109 | i = 0;
|
| 1110 | while(i < 2) {
|
| 1111 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1112 | {
|
| 1113 | goto EEMLTESVC_EXIT;
|
| 1114 | }
|
| 1115 | i++;
|
| 1116 | }
|
| 1117 | */
|
| 1118 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1119 | {
|
| 1120 | goto EEMLTESVC_EXIT;
|
| 1121 | }
|
| 1122 | cell_info.cell_list.cell[cell_info.cell_list.num].value1 = (uint32)tmp_int; //tac
|
| 1123 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1124 | {
|
| 1125 | goto EEMLTESVC_EXIT;
|
| 1126 | }
|
| 1127 | cell_info.cell_list.cell[cell_info.cell_list.num].value2 = (uint32)tmp_int; //pci
|
| 1128 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1129 | {
|
| 1130 | goto EEMLTESVC_EXIT;
|
| 1131 | }
|
| 1132 | cell_info.cell_list.cell[cell_info.cell_list.num].value3 = (uint32)tmp_int; //dl arfcn
|
| 1133 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1134 | {
|
| 1135 | goto EEMLTESVC_EXIT;
|
| 1136 | }
|
| 1137 | cell_info.cell_list.cell[cell_info.cell_list.num].value4 = (uint32)tmp_int; //ul arfcn
|
| 1138 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1139 | {
|
| 1140 | goto EEMLTESVC_EXIT;
|
| 1141 | }
|
| 1142 | cell_info.cell_list.cell[cell_info.cell_list.num].value5 = (uint32)tmp_int; //band
|
| 1143 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1144 | {
|
| 1145 | goto EEMLTESVC_EXIT;
|
| 1146 | }
|
| 1147 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1148 | {
|
| 1149 | goto EEMLTESVC_EXIT;
|
| 1150 | }
|
| 1151 | cell_info.cell_list.cell[cell_info.cell_list.num].value8 = (uint32)tmp_int; //cid
|
| 1152 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1153 | {
|
| 1154 | goto EEMLTESVC_EXIT;
|
| 1155 | }
|
| 1156 | cell_info.cell_list.cell[cell_info.cell_list.num].value9 = (uint32)tmp_int; //rsrp
|
| 1157 |
|
| 1158 | for(i =0; i < 10; i++)
|
| 1159 | {
|
| 1160 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1161 | {
|
| 1162 | goto EEMLTESVC_EXIT;
|
| 1163 | }
|
| 1164 | }
|
| 1165 | cell_info.cell_list.cell[cell_info.cell_list.num].value10 = (uint32)tmp_int; //cell identiy
|
| 1166 |
|
| 1167 | cell_info.cell_list.num++;
|
| 1168 |
|
| 1169 | EEMLTESVC_EXIT:
|
| 1170 | free(free_ptr);
|
| 1171 | }
|
| 1172 | }
|
| 1173 | /*
|
| 1174 | // index,phyCellId,euArfcn,rsrp,rsrq
|
| 1175 | +EEMLTEINTER: 0, 65535, 38950, 0, 0
|
| 1176 | */
|
| 1177 | else if(strStartsWith(s, "+EEMLTEINTER:") || strStartsWith(s, "+EEMLTEINTRA:")) // LTE ÒìÆµ/Í¬ÆµÐ¡Çø
|
| 1178 | {
|
| 1179 | // phyCellId,euArfcn,rsrp,rsrq
|
| 1180 | if(cell_info.running) {
|
| 1181 | int tmp_int;
|
b.liu | fd87baf | 2024-11-15 15:30:38 +0800 | [diff] [blame^] | 1182 | char* tmp_s = memdup(s,strlen(s) + 1);
|
b.liu | b477207 | 2024-08-15 14:47:03 +0800 | [diff] [blame] | 1183 | char* free_ptr = tmp_s;
|
| 1184 | char *line = tmp_s;
|
| 1185 | if (at_tok_start(&line) < 0)
|
| 1186 | {
|
| 1187 | goto EEMLTEINTER_EXIT;
|
| 1188 | }
|
| 1189 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1190 | {
|
| 1191 | goto EEMLTEINTER_EXIT;
|
| 1192 | }
|
| 1193 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int <= 0 || tmp_int > 503)
|
| 1194 | {
|
| 1195 | goto EEMLTEINTER_EXIT;
|
| 1196 | }
|
| 1197 | cell_info.cell_list.cell[cell_info.cell_list.num].value1 = (uint32)tmp_int;
|
| 1198 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1199 | {
|
| 1200 | goto EEMLTEINTER_EXIT;
|
| 1201 | }
|
| 1202 | cell_info.cell_list.cell[cell_info.cell_list.num].value2 = (uint32)tmp_int;
|
| 1203 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1204 | {
|
| 1205 | goto EEMLTEINTER_EXIT;
|
| 1206 | }
|
| 1207 | cell_info.cell_list.cell[cell_info.cell_list.num].value3 = (uint32)tmp_int;
|
| 1208 | LOG("cell line : %s", line);
|
| 1209 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1210 | {
|
| 1211 | goto EEMLTEINTER_EXIT;
|
| 1212 | }
|
| 1213 | cell_info.cell_list.cell[cell_info.cell_list.num].value4 = (uint32)tmp_int;
|
| 1214 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1215 | {
|
| 1216 | LOG("cell tmp_int : %d", tmp_int);
|
| 1217 | goto EEMLTEINTER_EXIT;
|
| 1218 | }
|
| 1219 | cell_info.cell_list.cell[cell_info.cell_list.num].value5 = (uint32)tmp_int;
|
| 1220 | LOG("cell value5 : %d", cell_info.cell_list.cell[cell_info.cell_list.num].value5);
|
| 1221 | cell_info.cell_list.num++;
|
| 1222 | EEMLTEINTER_EXIT:
|
| 1223 | free(free_ptr);
|
| 1224 | }
|
| 1225 | }
|
| 1226 | // Do nothing
|
| 1227 | else if(strStartsWith(s, "+EEMLTEINTERRAT:")) // LTE RATÐ¡ÇøÐÅÏ¢
|
| 1228 | {
|
| 1229 | if(cell_info.running) {
|
| 1230 |
|
| 1231 | }
|
| 1232 | }
|
| 1233 | // WCDMA
|
| 1234 | /*
|
| 1235 | // Mode, sCMeasPresent, sCParamPresent, ueOpStatusPresent,
|
| 1236 |
|
| 1237 | // if sCMeasPresent == 1
|
| 1238 | // cpichRSCP, utraRssi, cpichEcN0, sQual, sRxLev, txPower,
|
| 1239 | // endif
|
| 1240 |
|
| 1241 | // if sCParamPresent == 1
|
| 1242 | // rac, nom, mcc, mnc_len, mnc, lac, ci,
|
| 1243 | // uraId, psc, arfcn, t3212, t3312, hcsUsed, attDetAllowed,
|
| 1244 | // csDrxCycleLen, psDrxCycleLen, utranDrxCycleLen, HSDPASupport, HSUPASupport,
|
| 1245 | // endif
|
| 1246 |
|
| 1247 | // if ueOpStatusPresent == 1
|
| 1248 | // rrcState, numLinks, srncId, sRnti,
|
| 1249 | // algPresent, cipherAlg, cipherOn, algPresent, cipherAlg, cipherOn,
|
| 1250 | // HSDPAActive, HSUPAActive, MccLastRegisteredNetwork, MncLastRegisteredNetwork, TMSI, PTMSI, IsSingleMmRejectCause, IsSingleGmmRejectCause,
|
| 1251 | // MMRejectCause, GMMRejectCause, mmState, gmmState, gprsReadyState, readyTimerValueInSecs, NumActivePDPContext, ULThroughput, DLThroughput,
|
| 1252 | // serviceStatus, pmmState, LAU_status, LAU_count, RAU_status, RAU_count
|
| 1253 | // endif
|
| 1254 | //
|
| 1255 | +EEMUMTSSVC: 3, 1, 1, 1,
|
| 1256 | -80, 27, -6, -18, -115, -32768,
|
| 1257 | 1, 1, 1120, 2, 1, 61697, 168432821,
|
| 1258 | 15, 24, 10763, 0, 0, 0, 0,
|
| 1259 | 128, 128, 65535, 0, 0,
|
| 1260 | 2, 255, 65535, 4294967295,
|
| 1261 | 0, 0, 0, 0, 0, 0,
|
| 1262 | 0, 0, 0, 0, 0, 0, 1, 1,
|
| 1263 | 28672, 28672, 0, 0, 0, 0, 0, 0, 0,
|
| 1264 | 0, 0, 0, 0, 0, 0
|
| 1265 | */
|
| 1266 | else if(strStartsWith(s, "+EEMUMTSSVC:")) // WCDMA Server Cell
|
| 1267 | {
|
| 1268 | // lac, ci, arfcn
|
| 1269 | if(cell_info.running) {
|
| 1270 | int tmp_int;
|
| 1271 | int i = 0;
|
b.liu | fd87baf | 2024-11-15 15:30:38 +0800 | [diff] [blame^] | 1272 | char* tmp_s = memdup(s,strlen(s) + 1);
|
b.liu | b477207 | 2024-08-15 14:47:03 +0800 | [diff] [blame] | 1273 | char* free_ptr = tmp_s;
|
| 1274 | char *line = tmp_s;
|
| 1275 | if (at_tok_start(&line) < 0)
|
| 1276 | {
|
| 1277 | goto EEMUMTSSVC_EXIT;
|
| 1278 | }
|
| 1279 | // Jump 12 integer.
|
| 1280 | i = 0;
|
| 1281 | while(i < 12) {
|
| 1282 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1283 | {
|
| 1284 | goto EEMUMTSSVC_EXIT;
|
| 1285 | }
|
| 1286 | i++;
|
| 1287 | }
|
| 1288 | // mcc
|
| 1289 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1290 | {
|
| 1291 | goto EEMUMTSSVC_EXIT;
|
| 1292 | }
|
| 1293 | cell_info.cell_list.cell[cell_info.cell_list.num].value4= (uint32)tmp_int;
|
| 1294 | // mnc
|
| 1295 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1296 | {
|
| 1297 | goto EEMUMTSSVC_EXIT;
|
| 1298 | }
|
| 1299 | cell_info.cell_list.cell[cell_info.cell_list.num].value5= (uint32)tmp_int;
|
| 1300 | // lac
|
| 1301 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1302 | {
|
| 1303 | goto EEMUMTSSVC_EXIT;
|
| 1304 | }
|
| 1305 | cell_info.cell_list.cell[cell_info.cell_list.num].value1 = (uint32)tmp_int;
|
| 1306 | // ci
|
| 1307 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1308 | {
|
| 1309 | goto EEMUMTSSVC_EXIT;
|
| 1310 | }
|
| 1311 | cell_info.cell_list.cell[cell_info.cell_list.num].value2 = (uint32)tmp_int;
|
| 1312 |
|
| 1313 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1314 | {
|
| 1315 | goto EEMUMTSSVC_EXIT;
|
| 1316 | }
|
| 1317 | // cpi
|
| 1318 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1319 | {
|
| 1320 | goto EEMUMTSSVC_EXIT;
|
| 1321 | }
|
| 1322 | cell_info.cell_list.cell[cell_info.cell_list.num].value6= (uint32)tmp_int;
|
| 1323 | /*
|
| 1324 | // Jump 2 integer.
|
| 1325 | i = 0;
|
| 1326 | while(i < 2) {
|
| 1327 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1328 | {
|
| 1329 | goto EEMUMTSSVC_EXIT;
|
| 1330 | }
|
| 1331 | i++;
|
| 1332 | }
|
| 1333 | */
|
| 1334 | // arfcn
|
| 1335 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1336 | {
|
| 1337 | goto EEMUMTSSVC_EXIT;
|
| 1338 | }
|
| 1339 | cell_info.cell_list.cell[cell_info.cell_list.num].value3 = (uint32)tmp_int;
|
| 1340 |
|
| 1341 | cell_info.cell_list.num++;
|
| 1342 | EEMUMTSSVC_EXIT:
|
| 1343 | free(free_ptr);
|
| 1344 | }
|
| 1345 | }
|
| 1346 | /*
|
| 1347 | // index, cpichRSCP, utraRssi, cpichEcN0, sQual, sRxLev ,mcc, mnc, lac, ci, arfcn, psc
|
| 1348 | +EEMUMTSINTRA: 0, -32768, -1, -32768, -18, -115, 0, 0, 65534, 1, 10763, 32
|
| 1349 | */
|
| 1350 | else if(strStartsWith(s, "+EEMUMTSINTRA:")) // WCDMAÁÙ½üÐ¡Çø
|
| 1351 | {
|
| 1352 | // lac, ci, arfcn
|
| 1353 | if(cell_info.running) {
|
| 1354 | int tmp_int;
|
| 1355 | int i = 0;
|
b.liu | fd87baf | 2024-11-15 15:30:38 +0800 | [diff] [blame^] | 1356 | char* tmp_s = memdup(s,strlen(s) + 1);
|
b.liu | b477207 | 2024-08-15 14:47:03 +0800 | [diff] [blame] | 1357 | char* free_ptr = tmp_s;
|
| 1358 | char *line = tmp_s;
|
| 1359 | if (at_tok_start(&line) < 0)
|
| 1360 | {
|
| 1361 | goto EEMUMTSINTRA_EXIT;
|
| 1362 | }
|
| 1363 | // Jump 8 integer.
|
| 1364 | i = 0;
|
| 1365 | while(i < 8) {
|
| 1366 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1367 | {
|
| 1368 | goto EEMUMTSINTRA_EXIT;
|
| 1369 | }
|
| 1370 | i++;
|
| 1371 | }
|
| 1372 |
|
| 1373 | // lac
|
| 1374 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int <= 0 || tmp_int >= 65536)
|
| 1375 | {
|
| 1376 | goto EEMUMTSINTRA_EXIT;
|
| 1377 | }
|
| 1378 | cell_info.cell_list.cell[cell_info.cell_list.num].value1 = (uint32)tmp_int;
|
| 1379 |
|
| 1380 | // ci
|
| 1381 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int <= 0 || tmp_int >= 65536)
|
| 1382 | {
|
| 1383 | goto EEMUMTSINTRA_EXIT;
|
| 1384 | }
|
| 1385 | cell_info.cell_list.cell[cell_info.cell_list.num].value2 = (uint32)tmp_int;
|
| 1386 |
|
| 1387 | // arfcn
|
| 1388 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int <= 0 || tmp_int >= 65536)
|
| 1389 | {
|
| 1390 | goto EEMUMTSINTRA_EXIT;
|
| 1391 | }
|
| 1392 | cell_info.cell_list.cell[cell_info.cell_list.num].value3 = (uint32)tmp_int;
|
| 1393 |
|
| 1394 | cell_info.cell_list.num++;
|
| 1395 | EEMUMTSINTRA_EXIT:
|
| 1396 | free(free_ptr);
|
| 1397 | }
|
| 1398 | }
|
| 1399 | /*
|
| 1400 | // index,gsmRssi,rxLev,C1,C2,mcc,mnc,lac,ci,arfcn,bsic
|
| 1401 | +EEMUMTSINTERRAT: 0, -32768, -107, -1, -1, 0, 0, 65534, 0, 117, 36
|
| 1402 | */
|
| 1403 | else if(strStartsWith(s, "+EEMUMTSINTERRAT:")) // WCDMA RATÐ¡ÇøÐÅÏ¢
|
| 1404 | {
|
| 1405 | // lac, ci, arfcn
|
| 1406 | if(cell_info.running) {
|
| 1407 | int tmp_int;
|
| 1408 | int i = 0;
|
b.liu | fd87baf | 2024-11-15 15:30:38 +0800 | [diff] [blame^] | 1409 | char* tmp_s = memdup(s,strlen(s) + 1);
|
b.liu | b477207 | 2024-08-15 14:47:03 +0800 | [diff] [blame] | 1410 | char* free_ptr = tmp_s;
|
| 1411 | char *line = tmp_s;
|
| 1412 | if (at_tok_start(&line) < 0)
|
| 1413 | {
|
| 1414 | goto EEMUMTSINTERRAT_EXIT;
|
| 1415 | }
|
| 1416 | // Jump 7 integer.
|
| 1417 | i = 0;
|
| 1418 | while(i < 7) {
|
| 1419 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1420 | {
|
| 1421 | goto EEMUMTSINTERRAT_EXIT;
|
| 1422 | }
|
| 1423 | i++;
|
| 1424 | }
|
| 1425 |
|
| 1426 | // lac
|
| 1427 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int <= 0 || tmp_int >= 65536)
|
| 1428 | {
|
| 1429 | goto EEMUMTSINTERRAT_EXIT;
|
| 1430 | }
|
| 1431 | cell_info.cell_list.cell[cell_info.cell_list.num].value1 = (uint32)tmp_int;
|
| 1432 |
|
| 1433 | // ci
|
| 1434 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int <= 0 || tmp_int >= 65536)
|
| 1435 | {
|
| 1436 | goto EEMUMTSINTERRAT_EXIT;
|
| 1437 | }
|
| 1438 | cell_info.cell_list.cell[cell_info.cell_list.num].value2 = (uint32)tmp_int;
|
| 1439 |
|
| 1440 | // arfcn
|
| 1441 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int <= 0 || tmp_int >= 65536)
|
| 1442 | {
|
| 1443 | goto EEMUMTSINTERRAT_EXIT;
|
| 1444 | }
|
| 1445 | cell_info.cell_list.cell[cell_info.cell_list.num].value3 = (uint32)tmp_int;
|
| 1446 |
|
| 1447 | cell_info.cell_list.num++;
|
| 1448 | EEMUMTSINTERRAT_EXIT:
|
| 1449 | free(free_ptr);
|
| 1450 | }
|
| 1451 | }
|
| 1452 | // GSM
|
| 1453 | // +EEMGINFOBASIC: 2
|
| 1454 | // Do nothing.
|
| 1455 | else if(strStartsWith(s, "+EEMGINFOBASIC:")) // Basic information in GSM
|
| 1456 | // 0: ME in Idle mode 1: ME in Dedicated mode 2: ME in PS PTM mode
|
| 1457 | {
|
| 1458 | if(cell_info.running) {
|
| 1459 |
|
| 1460 | }
|
| 1461 | }
|
| 1462 | /*
|
| 1463 | // mcc, mnc_len, mnc, lac, ci, nom, nco,
|
| 1464 | // bsic, C1, C2, TA, TxPwr,
|
| 1465 | // RxSig, RxSigFull, RxSigSub, RxQualFull, RxQualSub,
|
| 1466 | // ARFCB_tch, hopping_chnl, chnl_type, TS, PacketIdle, rac, arfcn,
|
| 1467 | // bs_pa_mfrms, C31, C32, t3212, t3312, pbcch_support, EDGE_support,
|
| 1468 | // ncc_permitted, rl_timeout, ho_count, ho_succ, chnl_access_count, chnl_access_succ_count,
|
| 1469 | // gsmBand,channelMode
|
| 1470 | +EEMGINFOSVC: 1120, 2, 0, 32784, 24741, 2, 0,
|
| 1471 | 63, 36, 146, 1, 7,
|
| 1472 | 46, 42, 42, 7, 0,
|
| 1473 | 53, 0, 8, 0, 1, 6, 53,
|
| 1474 | 2, 0, 146, 42, 54, 0, 1,
|
| 1475 | 1, 32, 0, 0, 0, 0,
|
| 1476 | 0, 0
|
| 1477 | */
|
| 1478 | else if(strStartsWith(s, "+EEMGINFOSVC:")) // GSM Server Cell
|
| 1479 | {
|
| 1480 | // lac, ci, arfcn, bsic
|
| 1481 | LOG("+EEMGINFOSVC: 1= %d\n.",cell_info.running);
|
| 1482 | if(cell_info.running) {
|
| 1483 | int tmp_int;
|
| 1484 | int i = 0;
|
b.liu | fd87baf | 2024-11-15 15:30:38 +0800 | [diff] [blame^] | 1485 | char* tmp_s = memdup(s,strlen(s) + 1);
|
b.liu | b477207 | 2024-08-15 14:47:03 +0800 | [diff] [blame] | 1486 | char* free_ptr = tmp_s;
|
| 1487 | char *line = tmp_s;
|
| 1488 | if (at_tok_start(&line) < 0)
|
| 1489 | {
|
| 1490 | goto EEMGINFOSVC_EXIT;
|
| 1491 | }
|
| 1492 |
|
| 1493 | // mcc
|
| 1494 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int <= 0 || tmp_int >= 65536)
|
| 1495 | {
|
| 1496 | goto EEMGINFOSVC_EXIT;
|
| 1497 | }
|
| 1498 | cell_info.cell_list.cell[cell_info.cell_list.num].value5 = (uint32)tmp_int;
|
| 1499 |
|
| 1500 | //mnc_len
|
| 1501 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int <= 0 || tmp_int >= 65536)
|
| 1502 | {
|
| 1503 | goto EEMGINFOSVC_EXIT;
|
| 1504 | }
|
| 1505 | // mnc
|
| 1506 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int <= 0 || tmp_int >= 65536)
|
| 1507 | {
|
| 1508 | goto EEMGINFOSVC_EXIT;
|
| 1509 | }
|
| 1510 | cell_info.cell_list.cell[cell_info.cell_list.num].value6 = (uint32)tmp_int;
|
| 1511 |
|
| 1512 | /*
|
| 1513 | // Jump 3 integer.
|
| 1514 | i = 0;
|
| 1515 | while(i < 3) {
|
| 1516 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1517 | {
|
| 1518 | goto EEMGINFOSVC_EXIT;
|
| 1519 | }
|
| 1520 | i++;
|
| 1521 | }
|
| 1522 | */
|
| 1523 | // lac
|
| 1524 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int < 0 || tmp_int >= 65536)
|
| 1525 | {
|
| 1526 | goto EEMGINFOSVC_EXIT;
|
| 1527 | }
|
| 1528 | cell_info.cell_list.cell[cell_info.cell_list.num].value1 = (uint32)tmp_int;
|
| 1529 |
|
| 1530 | // ci
|
| 1531 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int < 0 || tmp_int >= 65536)
|
| 1532 | {
|
| 1533 | goto EEMGINFOSVC_EXIT;
|
| 1534 | }
|
| 1535 | cell_info.cell_list.cell[cell_info.cell_list.num].value2 = (uint32)tmp_int;
|
| 1536 |
|
| 1537 | // Jump 2 integer.
|
| 1538 | i = 0;
|
| 1539 | while(i < 2) {
|
| 1540 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1541 | {
|
| 1542 | goto EEMGINFOSVC_EXIT;
|
| 1543 | }
|
| 1544 | i++;
|
| 1545 | }
|
| 1546 |
|
| 1547 | // bsic
|
| 1548 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int < 0 || tmp_int >= 65536)
|
| 1549 | {
|
| 1550 | goto EEMGINFOSVC_EXIT;
|
| 1551 | }
|
| 1552 | cell_info.cell_list.cell[cell_info.cell_list.num].value4 = (uint32)tmp_int;
|
| 1553 |
|
| 1554 | // Jump 15 integer.
|
| 1555 | i = 0;
|
| 1556 | while(i < 15) {
|
| 1557 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1558 | {
|
| 1559 | goto EEMGINFOSVC_EXIT;
|
| 1560 | }
|
| 1561 | i++;
|
| 1562 | }
|
| 1563 |
|
| 1564 | // arfcn
|
| 1565 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int < 0 || tmp_int >= 65536)
|
| 1566 | {
|
| 1567 | goto EEMGINFOSVC_EXIT;
|
| 1568 | }
|
| 1569 | cell_info.cell_list.cell[cell_info.cell_list.num].value3 = (uint32)tmp_int;
|
| 1570 |
|
| 1571 | cell_info.cell_list.num++;
|
| 1572 | EEMGINFOSVC_EXIT:
|
| 1573 | free(free_ptr);
|
| 1574 | }
|
| 1575 | }
|
| 1576 | /*
|
| 1577 | // PS_attached, attach_type, service_type, tx_power, c_value,
|
| 1578 | // ul_ts, dl_ts, ul_cs, dl_cs, ul_modulation, dl_modulation,
|
| 1579 | // gmsk_cv_bep, 8psk_cv_bep, gmsk_mean_bep, 8psk_mean_bep, EDGE_bep_period, single_gmm_rej_cause
|
| 1580 | // pdp_active_num, mac_mode, network_control, network_mode, EDGE_slq_measurement_mode, edge_status
|
| 1581 | +EEMGINFOPS: 1, 255, 0, 0, 0,
|
| 1582 | 0, 0, 268435501, 1, 0, 0,
|
| 1583 | 4, 0, 96, 0, 0, 0,
|
| 1584 | 0, 0, 0, 65535, 0, 13350
|
| 1585 | */
|
| 1586 | // Do nothing.
|
| 1587 | else if(strStartsWith(s, "+EEMGINFOPS:")) // PSÐÅÏ¢
|
| 1588 | {
|
| 1589 | if(cell_info.running) {
|
| 1590 |
|
| 1591 | }
|
| 1592 | }
|
| 1593 | else if(strStartsWith(s, "+EEMGINFONC:")) // cell
|
| 1594 | {
|
| 1595 | if(cell_info.running) {
|
| 1596 | int tmp_int;
|
| 1597 | int i = 0;
|
b.liu | fd87baf | 2024-11-15 15:30:38 +0800 | [diff] [blame^] | 1598 | char* tmp_s = memdup(s,strlen(s) + 1);
|
b.liu | b477207 | 2024-08-15 14:47:03 +0800 | [diff] [blame] | 1599 | char* free_ptr = tmp_s;
|
| 1600 | char *line = tmp_s;
|
| 1601 | if (at_tok_start(&line) < 0)
|
| 1602 | {
|
| 1603 | goto EEMGINFOPS_EXIT;
|
| 1604 | }
|
| 1605 |
|
| 1606 | // nc_num
|
| 1607 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int < 0 || tmp_int >= 65536)
|
| 1608 | {
|
| 1609 | LOG("cell_info.running 1= %d\n.",cell_info.running);
|
| 1610 | goto EEMGINFOPS_EXIT;
|
| 1611 | }
|
| 1612 | // mcc
|
| 1613 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int < 0 || tmp_int >= 65536)
|
| 1614 | {
|
| 1615 | LOG("cell_info.running 2= %d\n.",cell_info.running);
|
| 1616 | goto EEMGINFOPS_EXIT;
|
| 1617 | }
|
| 1618 | cell_info.cell_list.cell[cell_info.cell_list.num].value5 = (uint32)tmp_int;
|
| 1619 |
|
| 1620 | // mnc
|
| 1621 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int < 0 || tmp_int >= 65536)
|
| 1622 | {
|
| 1623 | LOG("cell_info.running 3= %d\n.",cell_info.running);
|
| 1624 | goto EEMGINFOPS_EXIT;
|
| 1625 | }
|
| 1626 | cell_info.cell_list.cell[cell_info.cell_list.num].value6 = (uint32)tmp_int;
|
| 1627 |
|
| 1628 | // lac
|
| 1629 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int < 0 || tmp_int >= 65536)
|
| 1630 | {
|
| 1631 | LOG("cell_info.running 4= %d\n.",cell_info.running);
|
| 1632 | goto EEMGINFOPS_EXIT;
|
| 1633 | }
|
| 1634 | cell_info.cell_list.cell[cell_info.cell_list.num].value1 = (uint32)tmp_int;
|
| 1635 |
|
| 1636 | // rac
|
| 1637 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int < 0 || tmp_int >= 65536)
|
| 1638 | {
|
| 1639 | LOG("cell_info.running 5= %d\n.",cell_info.running);
|
| 1640 | goto EEMGINFOPS_EXIT;
|
| 1641 | }
|
| 1642 |
|
| 1643 | // ci
|
| 1644 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int < 0 || tmp_int >= 65536)
|
| 1645 | {
|
| 1646 | LOG("cell_info.running 6= %d\n.",cell_info.running);
|
| 1647 | goto EEMGINFOPS_EXIT;
|
| 1648 | }
|
| 1649 | cell_info.cell_list.cell[cell_info.cell_list.num].value2 = (uint32)tmp_int;
|
| 1650 |
|
| 1651 | // rx_lv
|
| 1652 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1653 | {
|
| 1654 | LOG("cell_info.running 7= %d\n.",cell_info.running);
|
| 1655 | goto EEMGINFOPS_EXIT;
|
| 1656 | }
|
| 1657 |
|
| 1658 | // bsic
|
| 1659 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int < 0 || tmp_int >= 65536)
|
| 1660 | {
|
| 1661 | LOG("cell_info.running 8= %d\n.",cell_info.running);
|
| 1662 | goto EEMGINFOPS_EXIT;
|
| 1663 | }
|
| 1664 | cell_info.cell_list.cell[cell_info.cell_list.num].value4 = (uint32)tmp_int;
|
| 1665 |
|
| 1666 | // Jump 2 integer.
|
| 1667 | i = 0;
|
| 1668 | while(i < 2) {
|
| 1669 | if (at_tok_nextint(&line, &tmp_int) < 0)
|
| 1670 | {
|
| 1671 | LOG("cell_info.running 9= %d\n.",cell_info.running);
|
| 1672 | goto EEMGINFOPS_EXIT;
|
| 1673 | }
|
| 1674 | i++;
|
| 1675 | }
|
| 1676 |
|
| 1677 | // arfcn
|
| 1678 | if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int < 0 || tmp_int >= 65536)
|
| 1679 | {
|
| 1680 | LOG("cell_info.running 10 = %d\n.",cell_info.running);
|
| 1681 | goto EEMGINFOPS_EXIT;
|
| 1682 | }
|
| 1683 | cell_info.cell_list.cell[cell_info.cell_list.num].value3 = (uint32)tmp_int;
|
| 1684 |
|
| 1685 | cell_info.cell_list.num++;
|
| 1686 | EEMGINFOPS_EXIT:
|
| 1687 | free(free_ptr);
|
| 1688 | }
|
| 1689 | } else {
|
| 1690 | LOGW("Unknown CELL URC : %s", s);
|
| 1691 | }
|
| 1692 | }
|
| 1693 |
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1694 |
|
| 1695 | static void onUnsolicited(const char *s, const char *sms_pdu)
|
| 1696 | {
|
b.liu | fd87baf | 2024-11-15 15:30:38 +0800 | [diff] [blame^] | 1697 | LOGV("URC : %s", s);
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1698 | // MBTK_AT_READY
|
| 1699 | if (strStartsWith(s, "MBTK_AT_READY")) // AT ready.
|
| 1700 | {
|
| 1701 |
|
b.liu | bcf86c9 | 2024-08-19 19:48:28 +0800 | [diff] [blame] | 1702 | } else if(strStartsWith(s, "CONNECT") || strStartsWith(s, "+CGEV:")) {
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 1703 | urc_pdp_state_change_process(s, sms_pdu);
|
b.liu | bcf86c9 | 2024-08-19 19:48:28 +0800 | [diff] [blame] | 1704 | } else if(strStartsWith(s, "+EEMLTESVC:") || strStartsWith(s, "+EEMLTEINTER:")
|
| 1705 | || strStartsWith(s, "+EEMLTEINTRA:") || strStartsWith(s, "+EEMLTEINTERRAT:")
|
| 1706 | || strStartsWith(s, "+EEMUMTSSVC:") || strStartsWith(s, "+EEMUMTSINTRA:")
|
| 1707 | || strStartsWith(s, "+EEMUMTSINTERRAT:") || strStartsWith(s, "+EEMGINFOBASIC:")
|
| 1708 | || strStartsWith(s, "+EEMGINFOSVC:") || strStartsWith(s, "+EEMGINFOPS:")
|
| 1709 | || strStartsWith(s, "+EEMGINFONC:")) {
|
| 1710 | urc_cell_info_process(s, sms_pdu);
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1711 | }
|
| 1712 | else if(strStartsWith(s, "*RADIOPOWER:")) // "*RADIOPOWER: 1"
|
| 1713 | {
|
| 1714 | const char* ptr = s + strlen("*RADIOPOWER:");
|
| 1715 | while(*ptr != '\0' && *ptr == ' ' )
|
| 1716 | {
|
| 1717 | ptr++;
|
| 1718 | }
|
| 1719 |
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 1720 | mbtk_ril_radio_state_info_t state;
|
| 1721 | memset(&state, 0, sizeof(mbtk_ril_radio_state_info_t));
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1722 | if(*ptr == '1') {
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 1723 | state.radio_state = MBTK_RADIO_STATE_FULL_FUNC;
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1724 | } else {
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 1725 | state.radio_state = MBTK_RADIO_STATE_MINI_FUNC;
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1726 | }
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 1727 | urc_msg_distribute(true, RIL_MSG_ID_IND_RADIO_STATE_CHANGE, &state, sizeof(mbtk_ril_radio_state_info_t));
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1728 | }
|
| 1729 | // +CREG: 1, "8010", "000060a5", 0, 2, 0
|
| 1730 | // +CREG: 1, "8330", "06447347", 7, 2, 0
|
| 1731 | // +CEREG: 1, "8330", "06447347", 7
|
| 1732 | // $CREG: 1, "8330", "06447347", 7,"0d4", 2, 0
|
| 1733 | // $CREG: 1, "8010", "000060a7", 0,, 2, 0
|
| 1734 | // +CGREG: 1
|
| 1735 | else if(strStartsWith(s, "+CGREG:") // GMS/WCDMA data registed.
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 1736 | || strStartsWith(s, "+CEREG:") // LTE data registed.
|
| 1737 | || strStartsWith(s, "+CREG:")) // GMS/WCDMA/LTE CS registed.
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1738 | {
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 1739 | urc_net_reg_state_change_process(s, sms_pdu);
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1740 | }
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 1741 | // +CLCC: 1, 1, 6, 0, 0, "18981911691", 129, "",, 0
|
| 1742 | else if(strStartsWith(s, "+CLCC:")
|
| 1743 | || strStartsWith(s, "+CPAS:")
|
| 1744 | || strStartsWith(s, "+CALLDISCONNECT:"))
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1745 | {
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 1746 | urc_call_state_change_process(s, sms_pdu);
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1747 | }
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 1748 | else if(strStartsWith(s, "*SIMDETEC:")
|
| 1749 | || strStartsWith(s, "*EUICC:")
|
| 1750 | || strStartsWith(s, "+CPIN:"))
|
| 1751 | {
|
| 1752 | urc_sim_state_change_process(s, sms_pdu);
|
| 1753 | }
|
| 1754 | else if(strStartsWith(s, "+CMT:"))
|
| 1755 | {
|
| 1756 | urc_sms_state_change_process(s, sms_pdu);
|
| 1757 | }
|
| 1758 | else if(strStartsWith(s, "*ECALLDATA:"))
|
| 1759 | {
|
| 1760 | urc_ecall_state_change_process(s, sms_pdu);
|
| 1761 | }
|
| 1762 | #if 0
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1763 | // +CLCC: 1, 1, 6, 0, 0, "18981911691", 129, "",, 0
|
| 1764 | else if(strStartsWith(s, "+CLCC:"))
|
| 1765 | {
|
| 1766 | mbtk_call_info_t reg;
|
| 1767 | reg.call_wait = MBTK_CLCC;
|
| 1768 | char* tmp_s = memdup(s,strlen(s));
|
| 1769 | char* free_ptr = tmp_s;
|
| 1770 | char *line = tmp_s;
|
| 1771 | int tmp_int;
|
| 1772 | char *tmp_str;
|
| 1773 | int err;
|
| 1774 |
|
| 1775 | err = at_tok_start(&line);
|
| 1776 | if (err < 0)
|
| 1777 | {
|
| 1778 | goto CLCC_EXIT;
|
| 1779 | }
|
| 1780 | err = at_tok_nextint(&line, &tmp_int); // dir1
|
| 1781 | if (err < 0)
|
| 1782 | {
|
| 1783 | goto CLCC_EXIT;
|
| 1784 | }
|
| 1785 | reg.dir1 = (uint8)tmp_int;
|
| 1786 | err = at_tok_nextint(&line, &tmp_int);// dir
|
| 1787 | if (err < 0)
|
| 1788 | {
|
| 1789 | goto CLCC_EXIT;
|
| 1790 | }
|
| 1791 | reg.dir = (uint8)tmp_int;
|
| 1792 | err = at_tok_nextint(&line, &tmp_int);// state
|
| 1793 | if (err < 0)
|
| 1794 | {
|
| 1795 | goto CLCC_EXIT;
|
| 1796 | }
|
| 1797 | reg.state = (uint8)tmp_int;
|
| 1798 | err = at_tok_nextint(&line, &tmp_int);// mode
|
| 1799 | if (err < 0)
|
| 1800 | {
|
| 1801 | goto CLCC_EXIT;
|
| 1802 | }
|
| 1803 | reg.mode = (uint8)tmp_int;
|
| 1804 | err = at_tok_nextint(&line, &tmp_int);// mpty
|
| 1805 | if (err < 0)
|
| 1806 | {
|
| 1807 | goto CLCC_EXIT;
|
| 1808 | }
|
| 1809 | reg.mpty = (uint8)tmp_int;
|
| 1810 | err = at_tok_nextstr(&line, &tmp_str); // phone_number
|
| 1811 | if (err < 0)
|
| 1812 | {
|
| 1813 | goto CLCC_EXIT;
|
| 1814 | }
|
| 1815 |
|
| 1816 | memset(reg.phone_number,0,sizeof(reg.phone_number));
|
| 1817 | memcpy(reg.phone_number, tmp_str, strlen(tmp_str));
|
| 1818 | err = at_tok_nextint(&line, &tmp_int);// tpye
|
| 1819 | if (err < 0)
|
| 1820 | {
|
| 1821 | goto CLCC_EXIT;
|
| 1822 | }
|
| 1823 | reg.type = (uint8)tmp_int;
|
| 1824 | urc_msg_distribute(false, INFO_URC_MSG_CALL_STATE, ®, sizeof(mbtk_call_info_t));
|
| 1825 | CLCC_EXIT:
|
| 1826 | free(free_ptr);
|
| 1827 | }
|
| 1828 | // +CPAS: 4
|
| 1829 | else if(strStartsWith(s, "+CPAS:"))
|
| 1830 | {
|
| 1831 | mbtk_call_info_t reg;
|
| 1832 | reg.call_wait = 0;
|
| 1833 | char* tmp_s = memdup(s,strlen(s));
|
| 1834 | char* free_ptr = tmp_s;
|
| 1835 | char *line = tmp_s;
|
| 1836 | int tmp_int;
|
| 1837 | int err;
|
| 1838 |
|
| 1839 | memset(®,0,sizeof(reg));
|
| 1840 |
|
| 1841 | err = at_tok_start(&line);
|
| 1842 | if (err < 0)
|
| 1843 | {
|
| 1844 | goto CPAS_EXIT;
|
| 1845 | }
|
| 1846 | err = at_tok_nextint(&line, &tmp_int);
|
| 1847 | if (err < 0)
|
| 1848 | {
|
| 1849 | goto CPAS_EXIT;
|
| 1850 | }
|
| 1851 | reg.pas = (uint8)tmp_int;
|
| 1852 | reg.call_wait = MBTK_CPAS;
|
| 1853 | urc_msg_distribute(false, INFO_URC_MSG_CALL_STATE, ®, sizeof(mbtk_call_info_t));
|
| 1854 | CPAS_EXIT:
|
| 1855 | free(free_ptr);
|
| 1856 | }
|
| 1857 | // +CALLDISCONNECT: 1
|
| 1858 | else if(strStartsWith(s, "+CALLDISCONNECT:"))
|
| 1859 | {
|
| 1860 | mbtk_call_info_t reg;
|
| 1861 | reg.call_wait = 0;
|
| 1862 | char* tmp_s = memdup(s,strlen(s));
|
| 1863 | char* free_ptr = tmp_s;
|
| 1864 | char *line = tmp_s;
|
| 1865 | int tmp_int;
|
| 1866 | int err;
|
| 1867 |
|
| 1868 | memset(®,0,sizeof(reg));
|
| 1869 |
|
| 1870 | err = at_tok_start(&line);
|
| 1871 | if (err < 0)
|
| 1872 | {
|
| 1873 | goto CALLDISCONNECTED_EXIT;
|
| 1874 | }
|
| 1875 | err = at_tok_nextint(&line, &tmp_int);
|
| 1876 | if (err < 0)
|
| 1877 | {
|
| 1878 | goto CALLDISCONNECTED_EXIT;
|
| 1879 | }
|
| 1880 | reg.disconnected_id = tmp_int;
|
| 1881 | reg.call_wait = MBTK_DISCONNECTED;
|
| 1882 |
|
| 1883 | if(reg.call_wait == MBTK_DISCONNECTED)
|
| 1884 | {
|
| 1885 | //mbtk_net_led_set(MBTK_NET_LED_CALL_DISCONNECT);
|
| 1886 | }
|
| 1887 |
|
| 1888 | urc_msg_distribute(false, INFO_URC_MSG_CALL_STATE, ®, sizeof(mbtk_call_info_t));
|
| 1889 |
|
| 1890 | CALLDISCONNECTED_EXIT:
|
| 1891 | free(free_ptr);
|
| 1892 | }
|
| 1893 | // *SIMDETEC:1,SIM
|
| 1894 | else if(strStartsWith(s, "*SIMDETEC:"))
|
| 1895 | {
|
| 1896 | if(strStartsWith(s, "*SIMDETEC:1,NOS"))
|
| 1897 | {
|
| 1898 | net_info.sim_state = MBTK_SIM_ABSENT;
|
| 1899 | }
|
| 1900 |
|
| 1901 | sim_info_reg.sim = -1;
|
| 1902 | if(strStartsWith(s, "*SIMDETEC:1,NOS"))
|
| 1903 | sim_info_reg.sim = 0;
|
| 1904 | else if(strStartsWith(s, "*SIMDETEC:1,SIM"))
|
| 1905 | sim_info_reg.sim = 1;
|
| 1906 | if(sim_info_reg.sim == 0)
|
| 1907 | {
|
| 1908 | uint8 data_pdp;
|
| 1909 | data_pdp = 11; //
|
| 1910 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 1911 | }
|
| 1912 | urc_msg_distribute(false, INFO_URC_MSG_SIM_STATE, &sim_info_reg, sizeof(mbtk_sim_card_info));
|
| 1913 | }
|
| 1914 | // *EUICC:1
|
| 1915 | /*0: SIM
|
| 1916 | 1: USIM
|
| 1917 | 2: TEST SIM
|
| 1918 | 3: TEST USIM
|
| 1919 | 4: UNKNOWN
|
| 1920 | Note: *EUICC:
|
| 1921 | */
|
| 1922 | else if(strStartsWith(s, "*EUICC:"))
|
| 1923 | {
|
| 1924 | sim_info_reg.sim_card_type = -1;
|
| 1925 | if(strStartsWith(s, "*EUICC: 0"))
|
| 1926 | sim_info_reg.sim_card_type = 1;
|
| 1927 | else if(strStartsWith(s, "*EUICC: 1"))
|
| 1928 | sim_info_reg.sim_card_type = 2;
|
| 1929 | else if(strStartsWith(s, "*EUICC: 2"))
|
| 1930 | sim_info_reg.sim_card_type = 1;
|
| 1931 | else if(strStartsWith(s, "*EUICC: 3"))
|
| 1932 | sim_info_reg.sim_card_type = 2;
|
| 1933 | else if(strStartsWith(s, "*EUICC: 4"))
|
| 1934 | sim_info_reg.sim_card_type = 0;
|
| 1935 | urc_msg_distribute(false, INFO_URC_MSG_SIM_STATE, &sim_info_reg, sizeof(mbtk_sim_card_info));
|
| 1936 | }
|
| 1937 | // +CPIN: SIM PIN
|
| 1938 | else if(strStartsWith(s, "+CPIN:"))
|
| 1939 | {
|
| 1940 | sim_info_reg.sim = -1;
|
| 1941 | if(strStartsWith(s, "+CPIN: READY"))
|
| 1942 | {
|
| 1943 | sim_info_reg.sim = 1;
|
| 1944 | net_info.sim_state = MBTK_SIM_READY;
|
| 1945 | }
|
| 1946 | else if(strStartsWith(s, "+CPIN: SIM PIN"))
|
| 1947 | {
|
| 1948 | sim_info_reg.sim = 2;
|
| 1949 | net_info.sim_state = MBTK_SIM_PIN;
|
| 1950 | }
|
| 1951 | else if(strStartsWith(s, "+CPIN: SIM PUK"))
|
| 1952 | {
|
| 1953 | sim_info_reg.sim = 3;
|
| 1954 | net_info.sim_state = MBTK_SIM_PUK;
|
| 1955 | }
|
| 1956 | else if(strStartsWith(s, "+CPIN: PH-SIMLOCK PIN"))
|
| 1957 | {
|
| 1958 | sim_info_reg.sim = 4;
|
| 1959 | net_info.sim_state = MBTK_SIM_ABSENT;
|
| 1960 | }
|
| 1961 | else if(strStartsWith(s, "+CPIN: PH-SIMLOCK PUK"))
|
| 1962 | {
|
| 1963 | sim_info_reg.sim = 5;
|
| 1964 | net_info.sim_state = MBTK_SIM_ABSENT;
|
| 1965 | }
|
| 1966 | else if(strStartsWith(s, "+CPIN: PH-FSIM PIN"))
|
| 1967 | {
|
| 1968 | sim_info_reg.sim = 6;
|
| 1969 | net_info.sim_state = MBTK_SIM_ABSENT;
|
| 1970 | }
|
| 1971 | else if(strStartsWith(s, "+CPIN: PH-FSIM PUK"))
|
| 1972 | {
|
| 1973 | sim_info_reg.sim = 7;
|
| 1974 | net_info.sim_state = MBTK_SIM_ABSENT;
|
| 1975 | }
|
| 1976 | else if(strStartsWith(s, "+CPIN: SIM PIN2"))
|
| 1977 | {
|
| 1978 | sim_info_reg.sim = 8;
|
| 1979 | net_info.sim_state = MBTK_SIM_ABSENT;
|
| 1980 | }
|
| 1981 | else if(strStartsWith(s, "+CPIN: SIM PUK2"))
|
| 1982 | {
|
| 1983 | sim_info_reg.sim = 9;
|
| 1984 | net_info.sim_state = MBTK_SIM_ABSENT;
|
| 1985 | }
|
| 1986 | else if(strStartsWith(s, "+CPIN: PH-NET PIN"))
|
| 1987 | {
|
| 1988 | sim_info_reg.sim = 10;
|
| 1989 | net_info.sim_state = MBTK_SIM_NETWORK_PERSONALIZATION;
|
| 1990 | }
|
| 1991 | else if(strStartsWith(s, "+CPIN: PH-NET PUK"))
|
| 1992 | {
|
| 1993 | sim_info_reg.sim = 11;
|
| 1994 | net_info.sim_state = MBTK_SIM_ABSENT;
|
| 1995 | }
|
| 1996 | else if(strStartsWith(s, "+CPIN: PH-NETSUB PINMT"))
|
| 1997 | {
|
| 1998 | sim_info_reg.sim = 12;
|
| 1999 | net_info.sim_state = MBTK_SIM_ABSENT;
|
| 2000 | }
|
| 2001 | else if(strStartsWith(s, "+CPIN: PH-NETSUB PUK"))
|
| 2002 | {
|
| 2003 | sim_info_reg.sim = 13;
|
| 2004 | net_info.sim_state = MBTK_SIM_ABSENT;
|
| 2005 | }
|
| 2006 | else if(strStartsWith(s, "+CPIN: PH-SP PIN"))
|
| 2007 | {
|
| 2008 | sim_info_reg.sim = 14;
|
| 2009 | net_info.sim_state = MBTK_SIM_ABSENT;
|
| 2010 | }
|
| 2011 | else if(strStartsWith(s, "+CPIN: PH-SP PUK"))
|
| 2012 | {
|
| 2013 | sim_info_reg.sim = 15;
|
| 2014 | net_info.sim_state = MBTK_SIM_ABSENT;
|
| 2015 | }
|
| 2016 | else if(strStartsWith(s, "+CPIN: PH-CORP PIN"))
|
| 2017 | {
|
| 2018 | sim_info_reg.sim = 16;
|
| 2019 | net_info.sim_state = MBTK_SIM_ABSENT;
|
| 2020 | }
|
| 2021 | else if(strStartsWith(s, "+CPIN: PH-CORP PUK"))
|
| 2022 | {
|
| 2023 | sim_info_reg.sim = 17;
|
| 2024 | net_info.sim_state = MBTK_SIM_ABSENT;
|
| 2025 | }
|
| 2026 | else if(strStartsWith(s, "+CPIN: SIM REMOVED"))
|
| 2027 | {
|
| 2028 | sim_info_reg.sim = 18;
|
| 2029 | net_info.sim_state = MBTK_SIM_ABSENT;
|
| 2030 | }
|
| 2031 | else
|
| 2032 | sim_info_reg.sim = 20;
|
| 2033 |
|
| 2034 | if(sim_info_reg.sim == 18)
|
| 2035 | {
|
| 2036 | uint8 data_pdp;
|
| 2037 | data_pdp = 11; //
|
| 2038 | urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
|
| 2039 | }
|
| 2040 |
|
| 2041 | urc_msg_distribute(false, INFO_URC_MSG_SIM_STATE, &sim_info_reg, sizeof(mbtk_sim_card_info));
|
| 2042 | }
|
| 2043 | // +CMT: ,23
|
| 2044 | // 0891683108200855F6240D91688189911196F10000221130717445230331D90C
|
| 2045 | else if(strStartsWith(s, "+CMT:") || sms_cmt)
|
| 2046 | {
|
| 2047 | if(!sms_cmt){
|
| 2048 | sms_cmt = true;
|
| 2049 | }else{
|
| 2050 | sms_cmt = false;
|
| 2051 | }
|
| 2052 | printf("+CMT() sms_cmt:%d, s:%s, len:%d\n",sms_cmt, s, strlen(s));
|
| 2053 | urc_msg_distribute(false, INFO_URC_MSG_SMS_STATE, s, strlen(s));
|
| 2054 | }
|
b.liu | b477207 | 2024-08-15 14:47:03 +0800 | [diff] [blame] | 2055 | #endif
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2056 | 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"
|
| 2057 | {
|
| 2058 |
|
| 2059 | }
|
| 2060 | else
|
| 2061 | {
|
| 2062 | LOGV("Unknown URC : %s", s);
|
| 2063 | }
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2064 | }
|
| 2065 |
|
| 2066 | static int openSocket(const char* sockname)
|
| 2067 | {
|
| 2068 | int sock = socket(AF_UNIX, SOCK_STREAM, 0);
|
| 2069 | if (sock < 0)
|
| 2070 | {
|
| 2071 | LOGE("Error create socket: %s\n", strerror(errno));
|
| 2072 | return -1;
|
| 2073 | }
|
| 2074 | struct sockaddr_un addr;
|
| 2075 | memset(&addr, 0, sizeof(addr));
|
| 2076 | addr.sun_family = AF_UNIX;
|
| 2077 | strncpy(addr.sun_path, sockname, sizeof(addr.sun_path));
|
| 2078 | while (TEMP_FAILURE_RETRY(connect(sock,(const struct sockaddr*)&addr, sizeof(addr))) != 0)
|
| 2079 | {
|
| 2080 | LOGE("Error connect to socket %s: %s, try again", sockname, strerror(errno));
|
| 2081 | sleep(1);
|
| 2082 | }
|
| 2083 |
|
| 2084 | #if 0
|
| 2085 | int sk_flags = fcntl(sock, F_GETFL, 0);
|
| 2086 | fcntl(sock, F_SETFL, sk_flags | O_NONBLOCK);
|
| 2087 | #endif
|
| 2088 |
|
| 2089 | return sock;
|
| 2090 | }
|
| 2091 |
|
| 2092 | static void ril_at_ready_process() |
| 2093 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 2094 | ril_info.radio_state = ril_radio_state_get(ATPORTTYPE_0);
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2095 | if (ril_info.radio_state != MBTK_RADIO_STATE_FULL_FUNC)
|
| 2096 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 2097 | ril_radio_state_set(ATPORTTYPE_0, MBTK_RADIO_STATE_FULL_FUNC, FALSE);
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2098 | }
|
| 2099 | |
| 2100 | if(ril_info.radio_state == MBTK_RADIO_STATE_FULL_FUNC)
|
| 2101 | {
|
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 2102 | at_send_command(ATPORTTYPE_0, "AT+CEREG=2", NULL);
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2103 | } |
| 2104 | |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 2105 | ril_info.sim_state = ril_sim_state_get(ATPORTTYPE_0);
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2106 | if(ril_info.sim_state == MBTK_SIM_STATE_READY)
|
| 2107 | { |
| 2108 | LOGD("SIM READY!"); |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 2109 | at_send_command(ATPORTTYPE_0, "AT+COPS=3", NULL);
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2110 |
|
| 2111 | // Set APN from prop.
|
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 2112 | apn_auto_conf_from_prop(ATPORTTYPE_0);
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2113 | } |
| 2114 | else |
| 2115 | { |
| 2116 | LOGE("SIM NOT READY!"); |
| 2117 | }
|
| 2118 | }
|
| 2119 |
|
| 2120 | static void ind_regisger(sock_cli_info_t* cli_info, uint16 ind)
|
| 2121 | { |
| 2122 | uint32 i = 0; |
| 2123 | while(i < cli_info->ind_num) |
| 2124 | { |
| 2125 | if(cli_info->ind_register[i] == ind) |
| 2126 | break; |
| 2127 | i++; |
| 2128 | } |
| 2129 | |
| 2130 | if(i == cli_info->ind_num) // No found IND |
| 2131 | { |
| 2132 | cli_info->ind_register[i] = ind; |
| 2133 | cli_info->ind_num++; |
| 2134 | LOGD("Register IND : %s", id2str(ind));
|
| 2135 | } |
| 2136 | else |
| 2137 | { |
| 2138 | LOGW("IND had exist.");
|
| 2139 | } |
| 2140 | }
|
| 2141 |
|
| 2142 | // Process AT URC data |
| 2143 | static int send_pack_to_queue(sock_cli_info_t* cli_info, void* pack)
|
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 2144 | {
|
| 2145 | if(cli_info) {
|
| 2146 | if(ril_info.msg_queue[cli_info->port].count >= PACK_PROCESS_QUEUE_MAX)
|
| 2147 | {
|
| 2148 | LOGE("Packet process queue is full");
|
| 2149 | return -1;
|
| 2150 | }
|
| 2151 | } else {
|
| 2152 | if(ril_info.msg_queue[ATPORTTYPE_0].count >= PACK_PROCESS_QUEUE_MAX)
|
| 2153 | {
|
| 2154 | LOGE("Packet process queue is full");
|
| 2155 | return -1;
|
| 2156 | }
|
| 2157 | }
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2158 | |
| 2159 | ril_msg_queue_info_t *item = (ril_msg_queue_info_t*)malloc(sizeof(ril_msg_queue_info_t));
|
| 2160 | if(!item) |
| 2161 | { |
| 2162 | LOGE("malloc() fail[%d].", errno);
|
| 2163 | return -1; |
| 2164 | } |
| 2165 | item->cli_info = cli_info; |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 2166 | item->pack = pack;
|
| 2167 |
|
| 2168 | if(cli_info) {
|
| 2169 | mbtk_queue_put(&(ril_info.msg_queue[cli_info->port]), item);
|
| 2170 |
|
| 2171 | // If thread is waitting,continue it.
|
| 2172 | pthread_mutex_lock(&(ril_info.msg_mutex[cli_info->port]));
|
| 2173 | pthread_cond_signal(&(ril_info.msg_cond[cli_info->port]));
|
| 2174 | pthread_mutex_unlock(&(ril_info.msg_mutex[cli_info->port]));
|
| 2175 | } else { // URC message, is null.
|
| 2176 | mbtk_queue_put(&(ril_info.msg_queue[ATPORTTYPE_0]), item);
|
| 2177 |
|
| 2178 | // If thread is waitting,continue it.
|
| 2179 | pthread_mutex_lock(&(ril_info.msg_mutex[ATPORTTYPE_0]));
|
| 2180 | pthread_cond_signal(&(ril_info.msg_cond[ATPORTTYPE_0]));
|
| 2181 | pthread_mutex_unlock(&(ril_info.msg_mutex[ATPORTTYPE_0]));
|
| 2182 | }
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2183 | |
| 2184 | return 0; |
| 2185 | }
|
| 2186 |
|
| 2187 |
|
| 2188 | static void pack_distribute(sock_cli_info_t* cli_info, ril_msg_pack_info_t* pack)
|
| 2189 | { |
| 2190 | // Register IND Message. |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 2191 | if(pack->msg_type == RIL_MSG_TYPE_REQ)
|
| 2192 | {
|
| 2193 | if(pack->msg_id > RIL_MSG_ID_IND_BEGIN
|
| 2194 | && pack->msg_id < RIL_MSG_ID_IND_END) {
|
| 2195 | mbtk_ril_err_enum err = MBTK_RIL_ERR_SUCCESS;
|
| 2196 | if(cli_info->ind_num >= IND_REGISTER_MAX)
|
| 2197 | {
|
| 2198 | LOGE("IND if full.");
|
| 2199 | err = MBTK_RIL_ERR_IND_FULL;
|
| 2200 | }
|
| 2201 | else
|
| 2202 | {
|
| 2203 | ind_regisger(cli_info, pack->msg_id);
|
| 2204 | }
|
| 2205 |
|
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 2206 | ril_error_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, err);
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 2207 |
|
| 2208 | ril_msg_pack_free(pack);
|
| 2209 | } else {
|
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 2210 | LOGD("Start process REQ(%s, Port : %d), Length : %d", id2str(pack->msg_id), cli_info->port, pack->data_len);
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 2211 | if(0 && pack->data_len > 0)
|
| 2212 | {
|
| 2213 | log_hex("DATA", pack->data, pack->data_len);
|
| 2214 | }
|
| 2215 |
|
| 2216 | // Send to REQ_process_thread process.
|
| 2217 | send_pack_to_queue(cli_info, pack);
|
| 2218 |
|
| 2219 | // For test.
|
| 2220 | // pack_error_send(cli_info->fd, pack->info_id + 1, MBTK_INFO_ERR_SUCCESS);
|
| 2221 | }
|
| 2222 | } else {
|
| 2223 | LOGE("Pack type error : %d", pack->msg_type);
|
| 2224 | }
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2225 | }
|
| 2226 |
|
| 2227 | // Return MBTK_INFO_ERR_SUCCESS,will call pack_error_send() to send RSP. |
| 2228 | // Otherwise, do not call pack_error_send(). |
| 2229 | static mbtk_ril_err_enum pack_req_process(sock_cli_info_t* cli_info, ril_msg_pack_info_t* pack)
|
| 2230 | { |
| 2231 | if(pack->msg_id > RIL_MSG_ID_DEV_BEGIN && pack->msg_id < RIL_MSG_ID_DEV_END) {
|
| 2232 | return dev_pack_req_process(cli_info, pack);
|
| 2233 | } else if(pack->msg_id > RIL_MSG_ID_SIM_BEGIN && pack->msg_id < RIL_MSG_ID_SIM_END) {
|
| 2234 | return sim_pack_req_process(cli_info, pack);
|
| 2235 | } else if(pack->msg_id > RIL_MSG_ID_NET_BEGIN && pack->msg_id < RIL_MSG_ID_NET_END) {
|
| 2236 | return net_pack_req_process(cli_info, pack);
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 2237 | } else if(pack->msg_id > RIL_MSG_ID_DATA_CALL_BEGIN && pack->msg_id < RIL_MSG_ID_DATA_CALL_END) {
|
| 2238 | return data_call_pack_req_process(cli_info, pack);
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2239 | } else if(pack->msg_id > RIL_MSG_ID_CALL_BEGIN && pack->msg_id < RIL_MSG_ID_CALL_END) {
|
| 2240 | return call_pack_req_process(cli_info, pack);
|
| 2241 | } else if(pack->msg_id > RIL_MSG_ID_SMS_BEGIN && pack->msg_id < RIL_MSG_ID_SMS_END) {
|
| 2242 | return sms_pack_req_process(cli_info, pack);
|
| 2243 | } else if(pack->msg_id > RIL_MSG_ID_PB_BEGIN && pack->msg_id < RIL_MSG_ID_PB_END) {
|
| 2244 | return pb_pack_req_process(cli_info, pack);
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 2245 | } else if(pack->msg_id > RIL_MSG_ID_ECALL_BEGIN && pack->msg_id < RIL_MSG_ID_ECALL_END) {
|
| 2246 | return ecall_pack_req_process(cli_info, pack);
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2247 | } else {
|
| 2248 | LOGW("Unknown msg id : %d", pack->msg_id);
|
| 2249 | return MBTK_RIL_ERR_FORMAT;
|
| 2250 | }
|
| 2251 | }
|
| 2252 |
|
| 2253 | static void urc_msg_process(ril_urc_msg_info_t *msg)
|
| 2254 | { |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 2255 | if(!msg->data || msg->data_len <= 0) {
|
| 2256 | LOGE("URC data is NULL.");
|
| 2257 | return;
|
| 2258 | }
|
| 2259 |
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2260 | switch(msg->msg) { |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 2261 | case RIL_MSG_ID_IND_RADIO_STATE_CHANGE:
|
| 2262 | {
|
| 2263 | mbtk_ril_radio_state_info_t *state = (mbtk_ril_radio_state_info_t*)msg->data;
|
| 2264 | LOGD("Radio state : %d", state->radio_state);
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2265 | break; |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 2266 | }
|
b.liu | fd87baf | 2024-11-15 15:30:38 +0800 | [diff] [blame^] | 2267 | case RIL_MSG_ID_IND_SIM_STATE_CHANGE:
|
| 2268 | {
|
| 2269 | mbtk_ril_sim_state_info_t *state = (mbtk_ril_sim_state_info_t*)msg->data;
|
| 2270 | if(state->sim_state == MBTK_SIM_STATE_READY) {
|
| 2271 | LOGD("SIM READY!");
|
| 2272 | at_send_command(ATPORTTYPE_0, "AT+COPS=3", NULL);
|
| 2273 |
|
| 2274 | // Set APN from prop.
|
| 2275 | apn_auto_conf_from_prop(ATPORTTYPE_0);
|
| 2276 | }
|
| 2277 | }
|
b.liu | afdf2c6 | 2024-11-12 11:10:44 +0800 | [diff] [blame] | 2278 | case RIL_MSG_ID_IND_NET_REG_STATE_CHANGE:
|
| 2279 | {
|
| 2280 | mbtk_ril_net_reg_state_info_t *reg_state = (mbtk_ril_net_reg_state_info_t*)msg->data;
|
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 2281 | data_call_retry(ATPORTTYPE_0, reg_state);
|
b.liu | afdf2c6 | 2024-11-12 11:10:44 +0800 | [diff] [blame] | 2282 | break;
|
| 2283 | }
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2284 | default: |
| 2285 | { |
| 2286 | LOGE("Unknown URC : %d", msg->msg); |
| 2287 | break; |
| 2288 | } |
| 2289 | } |
| 2290 | }
|
| 2291 |
|
| 2292 | // Read client conn/msg and push into ril_info.msg_queue.
|
| 2293 | static void* ril_read_pthread(void* arg)
|
| 2294 | { |
| 2295 | UNUSED(arg); |
| 2296 | ril_info.epoll_fd = epoll_create(SOCK_CLIENT_MAX + 1);
|
| 2297 | if(ril_info.epoll_fd < 0)
|
| 2298 | { |
| 2299 | LOGE("epoll_create() fail[%d].", errno);
|
| 2300 | return NULL; |
| 2301 | } |
| 2302 | |
| 2303 | uint32 event = EPOLLIN | EPOLLET; |
| 2304 | struct epoll_event ev; |
| 2305 | ev.data.fd = ril_info.sock_listen_fd;
|
| 2306 | ev.events = event; //EPOLLIN | EPOLLERR | EPOLLET; |
| 2307 | epoll_ctl(ril_info.epoll_fd, EPOLL_CTL_ADD, ril_info.sock_listen_fd, &ev);
|
| 2308 | |
| 2309 | int nready = -1; |
| 2310 | struct epoll_event epoll_events[EPOLL_LISTEN_MAX]; |
| 2311 | while(1) |
| 2312 | { |
| 2313 | nready = epoll_wait(ril_info.epoll_fd, epoll_events, EPOLL_LISTEN_MAX, -1);
|
| 2314 | if(nready > 0) |
| 2315 | { |
| 2316 | sock_cli_info_t *cli_info = NULL;
|
| 2317 | int i; |
| 2318 | for(i = 0; i < nready; i++) |
| 2319 | { |
| 2320 | LOG("fd[%d] event = %x",epoll_events[i].data.fd, epoll_events[i].events); |
| 2321 | if(epoll_events[i].events & EPOLLHUP) // Client Close. |
| 2322 | { |
| 2323 | if((cli_info = cli_find(epoll_events[i].data.fd)) != NULL) |
| 2324 | { |
| 2325 | cli_close(cli_info); |
| 2326 | } |
| 2327 | else |
| 2328 | { |
| 2329 | LOG("Unknown client[fd = %d].", epoll_events[i].data.fd); |
| 2330 | } |
| 2331 | } |
| 2332 | else if(epoll_events[i].events & EPOLLIN) |
| 2333 | { |
| 2334 | if(epoll_events[i].data.fd == ril_info.sock_listen_fd) // New clients connected.
|
| 2335 | { |
| 2336 | int client_fd = -1; |
| 2337 | while(1) |
| 2338 | { |
| 2339 | struct sockaddr_in cliaddr; |
| 2340 | socklen_t clilen = sizeof(cliaddr); |
| 2341 | client_fd = accept(epoll_events[i].data.fd, (struct sockaddr *) &cliaddr, &clilen); |
| 2342 | if(client_fd < 0) |
| 2343 | { |
| 2344 | if(errno == EAGAIN) |
| 2345 | { |
| 2346 | LOG("All client connect get."); |
| 2347 | } |
| 2348 | else |
| 2349 | { |
| 2350 | LOG("accept() error[%d].", errno); |
| 2351 | } |
| 2352 | break; |
| 2353 | } |
| 2354 | // Set O_NONBLOCK |
| 2355 | int flags = fcntl(client_fd, F_GETFL, 0); |
| 2356 | if (flags > 0) |
| 2357 | { |
| 2358 | flags |= O_NONBLOCK; |
| 2359 | if (fcntl(client_fd, F_SETFL, flags) < 0) |
| 2360 | { |
| 2361 | LOG("Set flags error:%d", errno); |
| 2362 | } |
| 2363 | } |
| 2364 | |
| 2365 | memset(&ev,0,sizeof(struct epoll_event)); |
| 2366 | ev.data.fd = client_fd; |
| 2367 | ev.events = event;//EPOLLIN | EPOLLERR | EPOLLET; |
| 2368 | epoll_ctl(ril_info.epoll_fd, EPOLL_CTL_ADD, client_fd, &ev);
|
| 2369 | |
| 2370 | sock_cli_info_t *info = (sock_cli_info_t*)malloc(sizeof(sock_cli_info_t));
|
| 2371 | if(info) |
| 2372 | { |
| 2373 | memset(info, 0, sizeof(sock_cli_info_t));
|
| 2374 | info->fd = client_fd;
|
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 2375 |
|
| 2376 | // Default AT port.
|
| 2377 | info->port = ATPORTTYPE_0;
|
| 2378 |
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2379 | list_add(ril_info.sock_client_list, info);
|
| 2380 | LOG("Add New Client FD Into List.");
|
| 2381 |
|
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 2382 | // Send msg RIL_MSG_ID_IND_SER_STATE_CHANGE to client.
|
| 2383 | mbtk_ril_ser_state_enum state = MBTK_RIL_SER_STATE_READY;
|
| 2384 | ril_ind_pack_send(client_fd, RIL_MSG_ID_IND_SER_STATE_CHANGE, &state, 1);
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2385 | } |
| 2386 | else |
| 2387 | { |
| 2388 | LOG("malloc() fail."); |
| 2389 | } |
| 2390 | } |
| 2391 | } |
| 2392 | else if((cli_info = cli_find(epoll_events[i].data.fd)) != NULL) // Client data arrive. |
| 2393 | { |
| 2394 | // Read and process every message. |
| 2395 | mbtk_ril_err_enum err = MBTK_RIL_ERR_SUCCESS;
|
| 2396 | ril_msg_pack_info_t** pack = ril_pack_recv(cli_info->fd, true, &err);
|
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 2397 |
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2398 | // Parse packet error,send error response to client. |
| 2399 | if(pack == NULL) |
| 2400 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 2401 | ril_error_pack_send(cli_info->port, cli_info->fd, RIL_MSG_ID_UNKNOWN, RIL_MSG_INDEX_INVALID, err);
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2402 | } |
| 2403 | else |
| 2404 | { |
| 2405 | ril_msg_pack_info_t** pack_ptr = pack;
|
| 2406 | while(*pack_ptr) |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 2407 | {
|
| 2408 | // Update AT port in the first.
|
| 2409 | cli_info->port = (ATPortType_enum)((*pack_ptr)->at_port);
|
| 2410 |
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2411 | pack_distribute(cli_info, *pack_ptr); |
| 2412 | // Not free,will free in pack_process() or packet process thread. |
| 2413 | //mbtk_info_pack_free(pack_ptr); |
| 2414 | pack_ptr++; |
| 2415 | } |
| 2416 | |
| 2417 | free(pack); |
| 2418 | } |
| 2419 | } |
| 2420 | else |
| 2421 | { |
| 2422 | LOG("Unknown socket : %d", epoll_events[i].data.fd); |
| 2423 | } |
| 2424 | } |
| 2425 | else |
| 2426 | { |
| 2427 | LOG("Unknown event : %x", epoll_events[i].events); |
| 2428 | } |
| 2429 | } |
| 2430 | } |
| 2431 | else |
| 2432 | { |
| 2433 | LOG("epoll_wait() fail[%d].", errno); |
| 2434 | } |
| 2435 | } |
| 2436 | |
| 2437 | return NULL; |
| 2438 | }
|
| 2439 |
|
| 2440 | static void* ril_process_thread(void* arg)
|
| 2441 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 2442 | UNUSED(arg);
|
| 2443 | ATPortType_enum *port = (ATPortType_enum*)arg;
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2444 | ril_msg_queue_info_t* item = NULL;
|
| 2445 | |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 2446 | pthread_mutex_lock(&(ril_info.msg_mutex[*port]));
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2447 | while(TRUE) |
| 2448 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 2449 | if(mbtk_queue_empty(&(ril_info.msg_queue[*port])))
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2450 | { |
b.liu | fd87baf | 2024-11-15 15:30:38 +0800 | [diff] [blame^] | 2451 | LOG("[Port-%d]Packet process wait...", *port);
|
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 2452 | pthread_cond_wait(&(ril_info.msg_cond[*port]), &(ril_info.msg_mutex[*port]));
|
b.liu | fd87baf | 2024-11-15 15:30:38 +0800 | [diff] [blame^] | 2453 | LOG("[Port-%d]Packet process continue...", *port);
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2454 | } |
| 2455 | else |
| 2456 | { |
| 2457 | LOG("Packet process queue not empty,continue..."); |
| 2458 | } |
| 2459 | |
| 2460 | // Process all information request. |
| 2461 | mbtk_ril_err_enum err;
|
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 2462 | while((item = (ril_msg_queue_info_t*)mbtk_queue_get(&(ril_info.msg_queue[*port]))) != NULL)
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2463 | { |
| 2464 | if(item->cli_info) { // REQ form client. |
| 2465 | ril_msg_pack_info_t *pack = (ril_msg_pack_info_t*)item->pack;
|
| 2466 | LOGD("Process REQ %s.", id2str(pack->msg_id));
|
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 2467 | ril_info.at_process[*port] = true;
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2468 | err = pack_req_process(item->cli_info, pack); |
| 2469 | if(err != MBTK_RIL_ERR_SUCCESS)
|
| 2470 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 2471 | ril_error_pack_send(item->cli_info->port, item->cli_info->fd, pack->msg_id, pack->msg_index, err);
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2472 | } |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 2473 | ril_info.at_process[*port] = false;
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2474 | ril_msg_pack_free(pack);
|
| 2475 | free(item); |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 2476 | } else { // REQ from myself.
|
| 2477 | if(item->pack) {
|
| 2478 | ril_urc_msg_info_t *urc = (ril_urc_msg_info_t*)item->pack;
|
| 2479 | LOGD("Process URC %d.", urc->msg);
|
| 2480 | urc_msg_process(urc);
|
| 2481 | if(urc->data)
|
| 2482 | free(urc->data);
|
| 2483 | free(urc);
|
| 2484 | }
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2485 | } |
| 2486 | } |
| 2487 | } |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 2488 | pthread_mutex_unlock(&(ril_info.msg_mutex[*port]));
|
| 2489 |
|
| 2490 | free(port);
|
| 2491 |
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2492 | return NULL; |
| 2493 | }
|
| 2494 |
|
| 2495 | /* |
| 2496 | AT*BAND=15,78,147,482,134742231 |
| 2497 | |
| 2498 | OK |
| 2499 | */ |
| 2500 | static void* band_config_thread() |
| 2501 | { |
| 2502 | mbtk_device_info_modem_t info_modem; |
| 2503 | memset(&band_info.band_support, 0, sizeof(mbtk_band_info_t));
|
| 2504 | memset(&info_modem, 0, sizeof(mbtk_device_info_modem_t)); |
| 2505 | band_info.band_set_success = FALSE;
|
| 2506 | if(mbtk_dev_info_read(MBTK_DEVICE_INFO_ITEM_MODEM, &(info_modem), sizeof(mbtk_device_info_modem_t))) { |
| 2507 | LOGD("mbtk_dev_info_read(MODEM) fail, use default band."); |
| 2508 | band_info.band_area = MBTK_MODEM_BAND_AREA_ALL;
|
| 2509 | band_info.band_support.net_pref = MBTK_NET_PREF_UNUSE;
|
| 2510 | band_info.band_support.gsm_band = MBTK_BAND_ALL_GSM_DEFAULT;
|
| 2511 | band_info.band_support.umts_band = MBTK_BAND_ALL_WCDMA_DEFAULT;
|
| 2512 | band_info.band_support.tdlte_band = MBTK_BAND_ALL_TDLTE_DEFAULT;
|
| 2513 | band_info.band_support.fddlte_band = MBTK_BAND_ALL_FDDLTE_DEFAULT;
|
| 2514 | band_info.band_support.lte_ext_band = MBTK_BAND_ALL_EXT_LTE_DEFAULT;
|
| 2515 | } else { |
| 2516 | band_info.band_area = info_modem.band_area;
|
| 2517 | band_info.band_support.net_pref = MBTK_NET_PREF_UNUSE;
|
| 2518 | band_info.band_support.gsm_band = info_modem.band_gsm;
|
| 2519 | band_info.band_support.umts_band = info_modem.band_wcdma;
|
| 2520 | band_info.band_support.tdlte_band = info_modem.band_tdlte;
|
| 2521 | band_info.band_support.fddlte_band = info_modem.band_fddlte;
|
| 2522 | band_info.band_support.lte_ext_band = info_modem.band_lte_ext;
|
| 2523 | } |
| 2524 | |
b.liu | 62240ee | 2024-11-07 17:52:45 +0800 | [diff] [blame] | 2525 | // bool is_first = TRUE;
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2526 | while(!band_info.band_set_success) {
|
| 2527 | // Set band.
|
| 2528 | #if 0
|
| 2529 | info_urc_msg_t *urc = (info_urc_msg_t*)malloc(sizeof(info_urc_msg_t)); |
| 2530 | if(!urc) |
| 2531 | { |
| 2532 | LOG("malloc() fail[%d].", errno); |
| 2533 | break; |
| 2534 | } else { |
| 2535 | urc->msg = INFO_URC_MSG_SET_BAND; |
| 2536 | urc->data = NULL; |
| 2537 | urc->data_len = 0; |
| 2538 | send_pack_to_queue(NULL, urc); |
| 2539 | |
| 2540 | if(is_first) { |
| 2541 | is_first = FALSE; |
| 2542 | } else { |
| 2543 | LOGE("*BAND exec error, will retry in 5s."); |
| 2544 | } |
| 2545 | sleep(5); |
| 2546 | }
|
| 2547 | #else
|
| 2548 | sleep(5);
|
| 2549 | #endif
|
| 2550 | } |
| 2551 | |
| 2552 | LOGD("Set Band thread exit."); |
| 2553 | return NULL; |
| 2554 | } |
| 2555 |
|
| 2556 |
|
| 2557 | int ril_server_start()
|
| 2558 | { |
| 2559 | signal(SIGPIPE, SIG_IGN);
|
| 2560 |
|
| 2561 | memset(&ril_info, 0, sizeof(ril_info_t));
|
| 2562 | memset(&band_info, 0, sizeof(ril_band_info_t));
|
| 2563 | memset(&band_info.band_support, 0xFF, sizeof(mbtk_band_info_t));
|
| 2564 | |
| 2565 | //check cfun and sim card status |
| 2566 | ril_at_ready_process(); |
| 2567 | |
| 2568 | //any AT instruction that is not sent through pack_process_thread needs to precede the thread |
| 2569 | //thread create |
| 2570 | if(ril_info.sock_listen_fd > 0)
|
| 2571 | { |
| 2572 | LOGE("Information Server Has Started.");
|
| 2573 | return -1; |
| 2574 | } |
| 2575 | |
| 2576 | struct sockaddr_un server_addr; |
| 2577 | ril_info.sock_listen_fd = socket(AF_LOCAL, SOCK_STREAM, 0);
|
| 2578 | if(ril_info.sock_listen_fd < 0)
|
| 2579 | { |
| 2580 | LOGE("socket() fail[%d].", errno);
|
| 2581 | return -1; |
| 2582 | } |
| 2583 | |
| 2584 | // Set O_NONBLOCK |
| 2585 | int flags = fcntl(ril_info.sock_listen_fd, F_GETFL, 0);
|
| 2586 | if (flags < 0) |
| 2587 | { |
| 2588 | LOGE("Get flags error:%d", errno);
|
| 2589 | goto error; |
| 2590 | } |
| 2591 | flags |= O_NONBLOCK; |
| 2592 | if (fcntl(ril_info.sock_listen_fd, F_SETFL, flags) < 0)
|
| 2593 | { |
| 2594 | LOGE("Set flags error:%d", errno);
|
| 2595 | goto error; |
| 2596 | } |
| 2597 | |
| 2598 | unlink(RIL_SOCK_NAME);
|
| 2599 | memset(&server_addr, 0, sizeof(struct sockaddr_un)); |
| 2600 | server_addr.sun_family = AF_LOCAL; |
| 2601 | strcpy(server_addr.sun_path, RIL_SOCK_NAME);
|
| 2602 | if(bind(ril_info.sock_listen_fd, (struct sockaddr *)&server_addr, sizeof(server_addr)))
|
| 2603 | { |
| 2604 | LOGE("bind() fail[%d].", errno);
|
| 2605 | goto error; |
| 2606 | } |
| 2607 | |
| 2608 | if(listen(ril_info.sock_listen_fd, SOCK_CLIENT_MAX))
|
| 2609 | { |
| 2610 | LOGE("listen() fail[%d].", errno);
|
| 2611 | goto error; |
| 2612 | } |
| 2613 | |
| 2614 | ril_info.sock_client_list = list_create(sock_cli_free_func);
|
| 2615 | if(ril_info.sock_client_list == NULL)
|
| 2616 | { |
| 2617 | LOGE("list_create() fail.");
|
| 2618 | goto error; |
| 2619 | }
|
| 2620 |
|
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 2621 | mbtk_queue_init(&(ril_info.msg_queue[ATPORTTYPE_0]));
|
| 2622 | pthread_mutex_init(&(ril_info.msg_mutex[ATPORTTYPE_0]), NULL);
|
| 2623 | pthread_cond_init(&(ril_info.msg_cond[ATPORTTYPE_0]), NULL);
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2624 | |
b.liu | 62240ee | 2024-11-07 17:52:45 +0800 | [diff] [blame] | 2625 | pthread_t info_pid, pack_pid/*, monitor_pid, urc_pid, bootconn_pid*/;
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2626 | pthread_attr_t thread_attr; |
| 2627 | pthread_attr_init(&thread_attr); |
| 2628 | if(pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED)) |
| 2629 | { |
| 2630 | LOGE("pthread_attr_setdetachstate() fail.");
|
| 2631 | goto error; |
| 2632 | } |
| 2633 | |
| 2634 | if(pthread_create(&info_pid, &thread_attr, ril_read_pthread, NULL))
|
| 2635 | { |
| 2636 | LOGE("pthread_create() fail.");
|
| 2637 | goto error; |
| 2638 | } |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 2639 |
|
| 2640 | ATPortType_enum *port_0 = (ATPortType_enum*)malloc(sizeof(ATPortType_enum));
|
| 2641 | *port_0 = ATPORTTYPE_0;
|
| 2642 | if(pthread_create(&pack_pid, &thread_attr, ril_process_thread, port_0))
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2643 | { |
| 2644 | LOGE("pthread_create() fail.");
|
| 2645 | goto error; |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 2646 | }
|
| 2647 |
|
| 2648 | ATPortType_enum *port_1 = (ATPortType_enum*)malloc(sizeof(ATPortType_enum));
|
| 2649 | *port_1 = ATPORTTYPE_1;
|
| 2650 | if(pthread_create(&pack_pid, &thread_attr, ril_process_thread, port_1))
|
| 2651 | { |
| 2652 | LOGE("pthread_create() fail.");
|
| 2653 | goto error; |
| 2654 | }
|
b.liu | fd87baf | 2024-11-15 15:30:38 +0800 | [diff] [blame^] | 2655 |
|
b.liu | 61eedc9 | 2024-11-13 16:07:00 +0800 | [diff] [blame] | 2656 | ATPortType_enum *port_2 = (ATPortType_enum*)malloc(sizeof(ATPortType_enum));
|
| 2657 | *port_2 = ATPORTTYPE_2;
|
| 2658 | if(pthread_create(&pack_pid, &thread_attr, ril_process_thread, port_2))
|
b.liu | fd87baf | 2024-11-15 15:30:38 +0800 | [diff] [blame^] | 2659 | { |
b.liu | 61eedc9 | 2024-11-13 16:07:00 +0800 | [diff] [blame] | 2660 | LOGE("pthread_create() fail.");
|
b.liu | fd87baf | 2024-11-15 15:30:38 +0800 | [diff] [blame^] | 2661 | goto error; |
b.liu | 61eedc9 | 2024-11-13 16:07:00 +0800 | [diff] [blame] | 2662 | }
|
b.liu | fd87baf | 2024-11-15 15:30:38 +0800 | [diff] [blame^] | 2663 | |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2664 | // Set Band |
| 2665 | // AT*BAND=15,78,147,482,134742231 |
| 2666 | char buff[10]; |
| 2667 | memset(buff, 0, 10); |
| 2668 | property_get("persist.mbtk.band_config", buff, ""); |
| 2669 | if(strlen(buff) == 0) { |
| 2670 | pthread_t band_pid; |
| 2671 | if(pthread_create(&band_pid, &thread_attr, band_config_thread, NULL)) |
| 2672 | { |
| 2673 | LOGE("pthread_create() fail.");
|
| 2674 | } |
| 2675 | } |
| 2676 | |
b.liu | fd87baf | 2024-11-15 15:30:38 +0800 | [diff] [blame^] | 2677 | pthread_attr_destroy(&thread_attr);
|
| 2678 |
|
| 2679 | if(asr_auto_data_call_enable()) {
|
| 2680 | ril_cid_start = MBTK_RIL_CID_2;
|
| 2681 |
|
| 2682 | char def_cid[10] = {0};
|
| 2683 | char prop_data[100] = {0};
|
| 2684 | int cid = -1;
|
| 2685 | sprintf(def_cid, "%d", MBTK_RIL_CID_DEF); // Default route and DNS is CID 1.
|
| 2686 | memset(prop_data, 0, sizeof(prop_data));
|
| 2687 | if(property_get(MBTK_DEF_DNS_CID, prop_data, def_cid) > 0 && !str_empty(prop_data)) {
|
| 2688 | cid = atoi(prop_data);
|
| 2689 | }
|
| 2690 |
|
| 2691 | if(cid == MBTK_RIL_CID_DEF) {
|
| 2692 | if(file_link("/tmp/resolv.conf", "/etc/resolv.conf")) {
|
| 2693 | LOGE("Create link file fail.");
|
| 2694 | }
|
| 2695 | }
|
| 2696 | } else {
|
| 2697 | ril_cid_start = MBTK_RIL_CID_DEF;
|
| 2698 | }
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2699 | |
b.liu | fd87baf | 2024-11-15 15:30:38 +0800 | [diff] [blame^] | 2700 | LOGD("MBTK Ril Server Start[CID start with : %d]...", ril_cid_start);
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2701 | |
| 2702 | return 0; |
| 2703 | error:
|
| 2704 | if(ril_info.sock_client_list) {
|
| 2705 | list_free(ril_info.sock_client_list);
|
| 2706 | ril_info.sock_client_list = NULL;
|
| 2707 | }
|
| 2708 |
|
| 2709 | if(ril_info.sock_listen_fd > 0) {
|
| 2710 | close(ril_info.sock_listen_fd);
|
| 2711 | ril_info.sock_listen_fd = -1;
|
| 2712 | }
|
| 2713 | return -1; |
| 2714 | }
|
| 2715 |
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2716 | int main(int argc, char *argv[])
|
| 2717 | {
|
| 2718 | mbtk_log_init("radio", "MBTK_RIL");
|
| 2719 |
|
b.liu | bcf86c9 | 2024-08-19 19:48:28 +0800 | [diff] [blame] | 2720 | MBTK_SOURCE_INFO_PRINT("mbtk_rild");
|
| 2721 |
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2722 | #ifdef MBTK_DUMP_SUPPORT
|
| 2723 | mbtk_debug_open(NULL, TRUE);
|
| 2724 | #endif
|
| 2725 |
|
| 2726 | // Using Killall,the file lock may be not release.
|
| 2727 | #if 0
|
| 2728 | if(app_already_running(MBTK_RILD_PID_FILE)) {
|
| 2729 | LOGW("daemon already running.");
|
| 2730 | exit(1);
|
| 2731 | }
|
| 2732 | #endif
|
| 2733 |
|
| 2734 | LOGI("mbtk_rild start.");
|
| 2735 |
|
| 2736 | if(InProduction_Mode()) {
|
| 2737 | LOGI("Is Production Mode, will exit...");
|
| 2738 | exit(0);
|
| 2739 | }
|
| 2740 |
|
| 2741 | ready_state_update();
|
| 2742 |
|
| 2743 | int at_sock = openSocket("/tmp/atcmd_at");
|
| 2744 | if(at_sock < 0)
|
| 2745 | {
|
| 2746 | LOGE("Open AT Socket Fail[%d].", errno);
|
| 2747 | return -1;
|
| 2748 | }
|
| 2749 | int uart_sock = openSocket("/tmp/atcmd_urc");
|
| 2750 | if(uart_sock < 0)
|
| 2751 | {
|
| 2752 | LOGE("Open Uart Socket Fail[%d].", errno);
|
| 2753 | return -1;
|
| 2754 | }
|
| 2755 |
|
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 2756 | int at_sock_1 = openSocket("/tmp/atcmd_at_1");
|
| 2757 | if(at_sock_1 < 0)
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2758 | {
|
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 2759 | LOGE("Open AT Socket Fail[%d].", errno);
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2760 | return -1;
|
| 2761 | }
|
| 2762 |
|
b.liu | 61eedc9 | 2024-11-13 16:07:00 +0800 | [diff] [blame] | 2763 | int at_sock_2 = openSocket("/tmp/atcmd_at_2");
|
| 2764 | if(at_sock_2 < 0)
|
| 2765 | {
|
| 2766 | LOGE("Open AT Socket Fail[%d].", errno);
|
| 2767 | return -1;
|
| 2768 | }
|
| 2769 |
|
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 2770 | at_set_on_reader_closed(onATReaderClosed);
|
| 2771 | at_set_on_timeout(onATTimeout);
|
| 2772 |
|
| 2773 | if(at_open(ATPORTTYPE_0, at_sock, uart_sock, onUnsolicited))
|
| 2774 | {
|
| 2775 | LOGE("Start AT_0 thread fail.");
|
| 2776 | return -1;
|
| 2777 | }
|
| 2778 |
|
| 2779 | if(at_open(ATPORTTYPE_1, at_sock_1, uart_sock, onUnsolicited))
|
| 2780 | {
|
| 2781 | LOGE("Start AT_1 thread fail.");
|
| 2782 | return -1;
|
| 2783 | }
|
| 2784 |
|
b.liu | 61eedc9 | 2024-11-13 16:07:00 +0800 | [diff] [blame] | 2785 | if(at_open(ATPORTTYPE_2, at_sock_2, uart_sock, onUnsolicited))
|
| 2786 | {
|
| 2787 | LOGE("Start AT_1 thread fail.");
|
| 2788 | return -1;
|
| 2789 | }
|
| 2790 |
|
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 2791 | if(at_handshake(ATPORTTYPE_0))
|
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 2792 | {
|
| 2793 | LOGE("AT handshake fail.");
|
| 2794 | return -1;
|
| 2795 | }
|
| 2796 |
|
| 2797 | LOGD("AT OK.");
|
| 2798 |
|
| 2799 | if(ril_server_start())
|
| 2800 | {
|
| 2801 | LOGE("ril_server_start() fail.");
|
| 2802 | return -1;
|
| 2803 | }
|
| 2804 |
|
| 2805 | mbtk_ril_ready();
|
| 2806 |
|
| 2807 | while(1)
|
| 2808 | {
|
| 2809 | sleep(24 * 60 * 60);
|
| 2810 | }
|
| 2811 |
|
| 2812 | LOGD("!!!mbtk_ril exit!!!");
|
| 2813 | return 0;
|
| 2814 | }
|