b.liu | d440f9f | 2025-04-18 10:44:31 +0800 | [diff] [blame^] | 1 | /*-----------------------------------------------------------------------------------------------*/ |
| 2 | /** |
| 3 | @file ql_sim.h |
| 4 | @brief SIM service API |
| 5 | */ |
| 6 | /*-----------------------------------------------------------------------------------------------*/ |
| 7 | |
| 8 | /*------------------------------------------------------------------------------------------------- |
| 9 | Copyright (c) 2024 mobiletek Wireless Solution, Co., Ltd. All Rights Reserved. |
| 10 | mobiletek Wireless Solution Proprietary and Confidential. |
| 11 | -------------------------------------------------------------------------------------------------*/ |
| 12 | |
| 13 | /*------------------------------------------------------------------------------------------------- |
| 14 | EDIT HISTORY |
| 15 | This section contains comments describing changes made to the file. |
| 16 | Notice that changes are listed in reverse chronological order. |
| 17 | $Header: $ |
| 18 | when who what, where, why |
| 19 | -------- --------- ----------------------------------------------------------------- |
| 20 | 20241022 yq.wang Created . |
| 21 | -------------------------------------------------------------------------------------------------*/ |
| 22 | |
| 23 | #include <stdint.h> |
| 24 | #include <stdio.h> |
| 25 | #include <stdlib.h> |
| 26 | #include <sys/epoll.h> |
| 27 | #include <unistd.h> |
| 28 | #include <errno.h> |
| 29 | #include <pthread.h> |
| 30 | #include <string.h> |
| 31 | #include <fcntl.h> |
| 32 | |
| 33 | #include "ql_sim.h" |
| 34 | #include "ql_type.h" |
| 35 | #include "mbtk_type.h" |
| 36 | #include "mbtk_ril_api.h" |
| 37 | #include "mbtk_list.h" |
| 38 | #include "mbtk_log.h" |
| 39 | |
| 40 | /*----------------------------------------------DEFINE-------------------------------------------*/ |
| 41 | #define MBTK_ERR_OK 0 |
| 42 | |
| 43 | #define MBTK_PIN_VALUE_LENGTH 16 |
| 44 | #define MBTK_BUFF_TEMP_SIZE_16 16 |
| 45 | #define MBTK_BUFF_TEMP_SIZE_32 32 |
| 46 | #define MBTK_BUFF_TEMP_SIZE_64 64 |
| 47 | #define MBTK_BUFF_TEMP_SIZE_128 128 |
| 48 | |
| 49 | #define MBTK_READ_EVENT_SIZE 1 |
| 50 | #define MBTK_WRITE_EVENT_SIZE 1 |
| 51 | |
| 52 | #define QL_SIM_LOGE LOGE |
| 53 | #define QL_SIM_LOGD LOGD |
| 54 | |
| 55 | #define MBTK_PIN_ENABLE 1 |
| 56 | /*----------------------------------------------DEFINE-------------------------------------------*/ |
| 57 | |
| 58 | /*----------------------------------------------ENUM-------------------------------------------*/ |
| 59 | typedef enum { |
| 60 | QL_SIM_EVENT_THREAD_QUIT = 0, |
| 61 | QL_SIM_EVENT_STATE_CHANGE, |
| 62 | QL_SIM_EVENT_MAX = 255, |
| 63 | }ql_sim_event_enum; |
| 64 | |
| 65 | /*----------------------------------------------ENUM-------------------------------------------*/ |
| 66 | |
| 67 | /*----------------------------------------------STRUCT-------------------------------------------*/ |
| 68 | typedef struct { |
| 69 | mbtk_ril_handle* handle; |
| 70 | int control[2]; |
| 71 | pthread_t cb_thread_id; |
| 72 | ql_sim_card_status_cb_f status_cb; |
| 73 | ql_sim_service_error_cb_f server_cb; |
| 74 | }ql_sim_info_handle_t; |
| 75 | |
| 76 | /*----------------------------------------------STRUCT-------------------------------------------*/ |
| 77 | |
| 78 | /*----------------------------------------------GLOBAL STATIC VARIABLE---------------------------*/ |
| 79 | static ql_sim_info_handle_t* sim_handle = NULL; |
| 80 | |
| 81 | /*----------------------------------------------GLOBAL STATIC VARIABLE---------------------------*/ |
| 82 | |
| 83 | /*----------------------------------------------SIM FUNCTION-------------------------------------*/ |
| 84 | static void ql_sim_state_change_cb(const void* data, int data_len) |
| 85 | { |
| 86 | if(data_len != sizeof(mbtk_ril_sim_state_info_t)) |
| 87 | { |
| 88 | QL_SIM_LOGE("[%s] data_len[%d] than sim[%d] fail. ", __func__, data_len, sizeof(mbtk_ril_sim_state_info_t)); |
| 89 | } |
| 90 | else |
| 91 | { |
| 92 | mbtk_ril_sim_state_info_t *ptr = (mbtk_ril_sim_state_info_t*)data; |
| 93 | QL_SIM_LOGD("[%s] state[%d] type[%d].", __func__, ptr->sim_state , ptr->sim_type); |
| 94 | ql_sim_event_enum cmd = QL_SIM_EVENT_STATE_CHANGE; |
| 95 | if(sim_handle->control[0] >= 0 && ptr->sim_state != MBTK_SIM_STATE_UNKNOWN) |
| 96 | { |
| 97 | int ret = write(sim_handle->control[0], &cmd, MBTK_WRITE_EVENT_SIZE); |
| 98 | if(ret != MBTK_WRITE_EVENT_SIZE) |
| 99 | { |
| 100 | QL_SIM_LOGE("[%s] write fail.[%d]", __func__, ret); |
| 101 | } |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | static void ql_sim_server_change_cb(const void* data, int data_len) |
| 107 | { |
| 108 | if(data) { |
| 109 | const uint8 *ptr = (const uint8*)data; |
| 110 | mbtk_ril_ser_state_enum state = (mbtk_ril_ser_state_enum)ptr[0]; |
| 111 | LOGD("ril server state : %d.\n", state); |
| 112 | if(sim_handle->server_cb && MBTK_RIL_SER_STATE_EXIT == state) { |
| 113 | sim_handle->server_cb(QL_ERR_ABORTED); |
| 114 | } |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | static int ql_epoll_register(int epoll_fd, int fd) |
| 119 | { |
| 120 | struct epoll_event ev; |
| 121 | int ret, flags; |
| 122 | |
| 123 | /* important: make the fd non-blocking */ |
| 124 | flags = fcntl(fd, F_GETFL); |
| 125 | fcntl(fd, F_SETFL, flags | O_NONBLOCK); |
| 126 | |
| 127 | ev.events = EPOLLIN; |
| 128 | ev.data.fd = fd; |
| 129 | |
| 130 | do |
| 131 | { |
| 132 | ret = epoll_ctl(epoll_fd, EPOLL_CTL_ADD, fd, &ev); |
| 133 | if(ret < 0) |
| 134 | { |
| 135 | QL_SIM_LOGE("[%s] epoll_ctl fail.[%s]", __func__, strerror(errno)); |
| 136 | } |
| 137 | } while (ret < 0 && errno == EINTR); |
| 138 | |
| 139 | return QL_ERR_OK; |
| 140 | } |
| 141 | |
| 142 | static void* ql_cb_thread(void* arg) |
| 143 | { |
| 144 | ql_sim_info_handle_t* info = (ql_sim_info_handle_t*)arg; |
| 145 | |
| 146 | if(info->control[0] < 0 && info->control[0] < 0) |
| 147 | { |
| 148 | if(socketpair(AF_LOCAL, SOCK_STREAM, 0, info->control ) < 0) |
| 149 | { |
| 150 | QL_SIM_LOGE("[%s] control creat fail.", __func__); |
| 151 | return NULL; |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | int ne = 0; |
| 156 | int nevents = 0; |
| 157 | int ret = 0; |
| 158 | struct epoll_event events[3]; |
| 159 | int control_fd = info->control[1]; |
| 160 | ql_sim_event_enum cmd = QL_SIM_EVENT_THREAD_QUIT; |
| 161 | |
| 162 | //A maximum of three events can be processed simultaneously |
| 163 | int epoll_fd = epoll_create(3); |
| 164 | ql_epoll_register(epoll_fd, control_fd); |
| 165 | |
| 166 | QL_SIM_LOGE("[%s] thread start run.", __func__); |
| 167 | while(1) |
| 168 | { |
| 169 | nevents = epoll_wait(epoll_fd, events, 3, -1); |
| 170 | if(nevents < 0) |
| 171 | { |
| 172 | if(errno != EINTR) |
| 173 | { |
| 174 | QL_SIM_LOGE("[%s] epoll_wait fail.[%s]", __func__, strerror(errno)); |
| 175 | } |
| 176 | continue; |
| 177 | } |
| 178 | |
| 179 | for (ne = 0; ne < nevents; ne++) |
| 180 | { |
| 181 | if((events[ne].events & (EPOLLERR|EPOLLHUP)) != 0) |
| 182 | { |
| 183 | QL_SIM_LOGE("[%s] EPOLLERR or EPOLLHUP event error.", __func__); |
| 184 | break; |
| 185 | } |
| 186 | |
| 187 | if ((events[ne].events & EPOLLIN) != 0) |
| 188 | { |
| 189 | if (events[ne].data.fd == control_fd) |
| 190 | { |
| 191 | ret = read(control_fd, &cmd, MBTK_READ_EVENT_SIZE); |
| 192 | if(ret != MBTK_READ_EVENT_SIZE) |
| 193 | { |
| 194 | QL_SIM_LOGE("[%s] read fail.[%d]", __func__, ret); |
| 195 | } |
| 196 | else |
| 197 | { |
| 198 | switch(cmd) |
| 199 | { |
| 200 | case QL_SIM_EVENT_THREAD_QUIT: |
| 201 | { |
| 202 | close(epoll_fd); |
| 203 | epoll_fd = -1; |
| 204 | if(info->control[0] >= 0) |
| 205 | { |
| 206 | close(info->control[0]); |
| 207 | info->control[0] = -1; |
| 208 | } |
| 209 | if(info->control[1] >= 0) |
| 210 | { |
| 211 | close(info->control[1]); |
| 212 | info->control[1] = -1; |
| 213 | } |
| 214 | QL_SIM_LOGD("[%s] thread quit.", __func__); |
| 215 | return NULL; |
| 216 | } |
| 217 | case QL_SIM_EVENT_STATE_CHANGE: |
| 218 | { |
| 219 | if(info->status_cb) |
| 220 | { |
| 221 | ql_sim_card_info_t sim_info = {0}; |
| 222 | ql_sim_get_card_info(QL_SIM_SLOT_1, &sim_info); |
| 223 | info->status_cb(QL_SIM_SLOT_1, &sim_info); |
| 224 | } |
| 225 | break; |
| 226 | } |
| 227 | default: |
| 228 | { |
| 229 | QL_SIM_LOGE("[%s] unknown event.[%d]", __func__, cmd); |
| 230 | break; |
| 231 | } |
| 232 | } |
| 233 | } |
| 234 | } |
| 235 | } |
| 236 | } |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | static int ql_cb_thread_creat(ql_sim_info_handle_t *info) |
| 241 | { |
| 242 | if(info->cb_thread_id == 0) |
| 243 | { |
| 244 | pthread_attr_t thread_attr; |
| 245 | pthread_attr_init(&thread_attr); |
| 246 | if(pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED)) |
| 247 | { |
| 248 | QL_SIM_LOGE("[%s] pthread_attr_setdetachstate fail.", __func__); |
| 249 | return QL_ERR_FAILED; |
| 250 | } |
| 251 | if(pthread_create(&(info->cb_thread_id), &thread_attr, ql_cb_thread, info)) |
| 252 | { |
| 253 | QL_SIM_LOGE("[%s] pthread_create fail.[%ld]", __func__, info->cb_thread_id); |
| 254 | return QL_ERR_FAILED; |
| 255 | } |
| 256 | QL_SIM_LOGD("[%s] pthread_create success.[%ld]", __func__, info->cb_thread_id); |
| 257 | } |
| 258 | |
| 259 | return QL_ERR_OK; |
| 260 | } |
| 261 | |
| 262 | static int ql_cb_thread_free(ql_sim_info_handle_t *info) |
| 263 | { |
| 264 | int ret = 0; |
| 265 | if(info->cb_thread_id != 0) |
| 266 | { |
| 267 | ql_sim_event_enum cmd = QL_SIM_EVENT_THREAD_QUIT; |
| 268 | if(info->control[0] >= 0) |
| 269 | { |
| 270 | ret = write(info->control[0], &cmd, MBTK_WRITE_EVENT_SIZE); |
| 271 | if(ret != MBTK_WRITE_EVENT_SIZE) |
| 272 | { |
| 273 | QL_SIM_LOGE("[%s] write fail.[%d]", __func__, ret); |
| 274 | return QL_ERR_FAILED; |
| 275 | } |
| 276 | } |
| 277 | info->cb_thread_id = 0; |
| 278 | QL_SIM_LOGE("[%s] pthread quit success.", __func__); |
| 279 | } |
| 280 | |
| 281 | return QL_ERR_OK; |
| 282 | } |
| 283 | |
| 284 | /*----------------------------------------------SIM FUNCTION-------------------------------------*/ |
| 285 | |
| 286 | /*----------------------------------------------SIM API------------------------------------------*/ |
| 287 | |
| 288 | /*-----------------------------------------------------------------------------------------------*/ |
| 289 | /** |
| 290 | @brief Initializes SIM service. |
| 291 | @note You must call this function before other functions can be used in this module. |
| 292 | @return Whether the SIM service was intialized successfully. |
| 293 | @retval QL_ERR_OK successful |
| 294 | @retval QL_ERR_SERVICE_NOT_READY service is not ready, need to retry |
| 295 | @retval Other error code defined by ql_type.h |
| 296 | */ |
| 297 | /*-----------------------------------------------------------------------------------------------*/ |
| 298 | int ql_sim_init(void) |
| 299 | { |
| 300 | if(NULL == sim_handle) |
| 301 | { |
| 302 | sim_handle = (ql_sim_info_handle_t*)malloc(sizeof(ql_sim_info_handle_t)); |
| 303 | if(NULL == sim_handle) |
| 304 | { |
| 305 | QL_SIM_LOGE("[%s] sim handle malloc fail.", __func__); |
| 306 | return QL_ERR_FAILED; |
| 307 | } |
| 308 | |
| 309 | sim_handle->handle = mbtk_ril_open(MBTK_AT_PORT_DEF); |
| 310 | if(NULL == sim_handle->handle) |
| 311 | { |
| 312 | QL_SIM_LOGE("[%s] mbtk handle init fail.", __func__); |
| 313 | goto error_1; |
| 314 | } |
| 315 | |
| 316 | int ret = mbtk_sim_state_change_cb_reg(ql_sim_state_change_cb); |
| 317 | if(ret != MBTK_ERR_OK) |
| 318 | { |
| 319 | QL_SIM_LOGE("[%s] set sim state cb fail.[%d]", __func__, ret); |
| 320 | goto error_2; |
| 321 | } |
| 322 | |
| 323 | ret = mbtk_ril_ser_state_change_cb_reg(ql_sim_server_change_cb); |
| 324 | if(ret != MBTK_ERR_OK) |
| 325 | { |
| 326 | QL_SIM_LOGE("[%s] set sim server cb fail.[%d]", __func__, ret); |
| 327 | goto error_2; |
| 328 | } |
| 329 | |
| 330 | sim_handle->status_cb = NULL; |
| 331 | sim_handle->server_cb = NULL; |
| 332 | sim_handle->control[0] = -1; |
| 333 | sim_handle->control[1] = -1; |
| 334 | sim_handle->cb_thread_id = 0; |
| 335 | } |
| 336 | |
| 337 | return QL_ERR_OK; |
| 338 | |
| 339 | error_2: |
| 340 | if(sim_handle->handle) |
| 341 | { |
| 342 | mbtk_ril_close(MBTK_AT_PORT_DEF); |
| 343 | sim_handle->handle = NULL; |
| 344 | } |
| 345 | error_1: |
| 346 | if(sim_handle) |
| 347 | { |
| 348 | free(sim_handle); |
| 349 | sim_handle = NULL; |
| 350 | } |
| 351 | return QL_ERR_FAILED; |
| 352 | } |
| 353 | |
| 354 | /*-----------------------------------------------------------------------------------------------*/ |
| 355 | /** |
| 356 | @brief Deinitializes SIM service. |
| 357 | @return Whether the SIM service was deintialized successfully. |
| 358 | @retval QL_ERR_OK successful |
| 359 | @retval QL_ERR_SERVICE_NOT_READY service is not ready, need to retry |
| 360 | @retval Other error code defined by ql_type.h |
| 361 | */ |
| 362 | /*-----------------------------------------------------------------------------------------------*/ |
| 363 | int ql_sim_deinit(void) |
| 364 | { |
| 365 | if(NULL == sim_handle) |
| 366 | { |
| 367 | QL_SIM_LOGE("[%s] sim handle not init.", __func__); |
| 368 | return QL_ERR_NOT_INIT; |
| 369 | } |
| 370 | |
| 371 | int ret = 0; |
| 372 | sim_handle->server_cb = NULL; |
| 373 | sim_handle->status_cb = NULL; |
| 374 | |
| 375 | if(NULL != sim_handle->handle) |
| 376 | { |
| 377 | ret = mbtk_ril_close(MBTK_AT_PORT_DEF); |
| 378 | if(ret != MBTK_ERR_OK) |
| 379 | { |
| 380 | QL_SIM_LOGE("[%s] mbtk handle deinit fail.[%d]", __func__, ret); |
| 381 | return QL_ERR_FAILED; |
| 382 | } |
| 383 | sim_handle->handle = NULL; |
| 384 | } |
| 385 | |
| 386 | ret = ql_cb_thread_free(sim_handle); |
| 387 | if(ret != QL_ERR_OK) |
| 388 | { |
| 389 | QL_SIM_LOGE("[%s] cb thread free deinit fail.", __func__); |
| 390 | return QL_ERR_FAILED; |
| 391 | } |
| 392 | |
| 393 | free(sim_handle); |
| 394 | sim_handle = NULL; |
| 395 | return QL_ERR_OK; |
| 396 | } |
| 397 | |
| 398 | /*-----------------------------------------------------------------------------------------------*/ |
| 399 | /** |
| 400 | @brief Gets the IMSI (for 3GPP) or IMSI_M (for 3GPP2) from the SIM in ASCII form. |
| 401 | @param [in] slot Slot to be used. |
| 402 | @note This function is only supported by Identify card in slot 1 |
| 403 | @param [in] app_type Application type. |
| 404 | @note This function is only supported by 3GPP applications |
| 405 | @param [out] imsi Buffer to fill IMSI data. |
| 406 | @param [in] imsi_len Buffer length. |
| 407 | @return Whether the IMSI was successfully obtained. |
| 408 | @retval QL_ERR_OK successful |
| 409 | @retval QL_ERR_SERVICE_NOT_READY service is not ready, need to retry |
| 410 | @retval Other error code defined by ql_type.h |
| 411 | */ |
| 412 | /*-----------------------------------------------------------------------------------------------*/ |
| 413 | int ql_sim_get_imsi(QL_SIM_SLOT_E slot, QL_SIM_APP_TYPE_E app_type, char *imsi, int imsi_len) |
| 414 | { |
| 415 | UNUSED(slot); |
| 416 | UNUSED(app_type); |
| 417 | |
| 418 | if(NULL == sim_handle) |
| 419 | { |
| 420 | QL_SIM_LOGE("[%s] sim handle not init.", __func__); |
| 421 | return QL_ERR_NOT_INIT; |
| 422 | } |
| 423 | |
| 424 | if(NULL == imsi) |
| 425 | { |
| 426 | QL_SIM_LOGE("[%s] imsi is NULL.", __func__); |
| 427 | return QL_ERR_INVALID_ARG; |
| 428 | } |
| 429 | |
| 430 | if(imsi_len < QL_SIM_IMSI_LENGTH) |
| 431 | { |
| 432 | QL_SIM_LOGE("[%s] imsi buf is too short.", __func__); |
| 433 | return QL_ERR_BUF_OVERFLOW; |
| 434 | } |
| 435 | |
| 436 | char temp_buff[MBTK_BUFF_TEMP_SIZE_32] = {0}; |
| 437 | memset(imsi, 0x0, imsi_len); |
| 438 | memset(temp_buff, 0x0, MBTK_BUFF_TEMP_SIZE_32); |
| 439 | int ret = mbtk_imsi_get(sim_handle->handle, (void *)temp_buff); |
| 440 | if(ret != MBTK_ERR_OK) |
| 441 | { |
| 442 | QL_SIM_LOGE("[%s] imsi get fail.[%d]", __func__, ret); |
| 443 | return QL_ERR_FAILED; |
| 444 | } |
| 445 | |
| 446 | memcpy(imsi, temp_buff, QL_SIM_IMSI_LENGTH); |
| 447 | return QL_ERR_OK; |
| 448 | } |
| 449 | |
| 450 | /*-----------------------------------------------------------------------------------------------*/ |
| 451 | /** |
| 452 | @brief Retrieves the Integrated Circuit Card ID (ICCID) stored on the card. |
| 453 | @param [in] slot Slot to be used(the parameter currently does not support). |
| 454 | @note This function is only supported by Identify card in slot 1 |
| 455 | @param [out] iccid Buffer to fill ICCID data. |
| 456 | @param [in] iccid_len Buffer length. |
| 457 | @return Whether the ICCID was successfully obtained. |
| 458 | @retval QL_ERR_OK successful |
| 459 | @retval QL_ERR_SERVICE_NOT_READY service is not ready, need to retry |
| 460 | @retval Other error code defined by ql_type.h |
| 461 | */ |
| 462 | /*-----------------------------------------------------------------------------------------------*/ |
| 463 | int ql_sim_get_iccid(QL_SIM_SLOT_E slot, char *iccid, int iccid_len) |
| 464 | { |
| 465 | UNUSED(slot); |
| 466 | |
| 467 | if(NULL == sim_handle) |
| 468 | { |
| 469 | QL_SIM_LOGE("[%s] sim handle not init.", __func__); |
| 470 | return QL_ERR_NOT_INIT; |
| 471 | } |
| 472 | |
| 473 | if(NULL == iccid) |
| 474 | { |
| 475 | QL_SIM_LOGE("[%s] iccid is NULL.", __func__); |
| 476 | return QL_ERR_INVALID_ARG; |
| 477 | } |
| 478 | |
| 479 | if(iccid_len < QL_SIM_ICCID_LENGTH) |
| 480 | { |
| 481 | QL_SIM_LOGE("[%s] imsi buf is too short.", __func__); |
| 482 | return QL_ERR_BUF_OVERFLOW; |
| 483 | } |
| 484 | |
| 485 | char temp_buff[MBTK_BUFF_TEMP_SIZE_32] = {0}; |
| 486 | memset(iccid, 0x0, iccid_len); |
| 487 | memset(temp_buff, 0x0, MBTK_BUFF_TEMP_SIZE_32); |
| 488 | int ret = mbtk_iccid_get(sim_handle->handle, (void *)temp_buff); |
| 489 | if(ret != MBTK_ERR_OK) |
| 490 | { |
| 491 | QL_SIM_LOGE("[%s] iccid get fail.[%d]", __func__, ret); |
| 492 | return QL_ERR_FAILED; |
| 493 | } |
| 494 | |
| 495 | memcpy(iccid, temp_buff, QL_SIM_ICCID_LENGTH); |
| 496 | return QL_ERR_OK; |
| 497 | } |
| 498 | |
| 499 | /*-----------------------------------------------------------------------------------------------*/ |
| 500 | /** |
| 501 | @brief Retrieves the device phone number stored on the card. |
| 502 | @param [in] slot Slot to be used. |
| 503 | @note This function is only supported by Identify card in slot 1 |
| 504 | @param [in] app_type Application type. |
| 505 | @note This function is only supported by 3GPP applications |
| 506 | @param [out] phone_num Buffer to fill phone number. |
| 507 | @param [in] phone_num_len Buffer length. |
| 508 | @return Whether the phone number was successfully retrieved. |
| 509 | @retval QL_ERR_OK successful |
| 510 | @retval QL_ERR_SERVICE_NOT_READY service is not ready, need to retry |
| 511 | @retval Other error code defined by ql_type.h |
| 512 | */ |
| 513 | /*-----------------------------------------------------------------------------------------------*/ |
| 514 | int ql_sim_get_phone_num(QL_SIM_SLOT_E slot, QL_SIM_APP_TYPE_E app_type, |
| 515 | char *phone_num, int phone_num_len) |
| 516 | { |
| 517 | UNUSED(slot); |
| 518 | UNUSED(app_type); |
| 519 | |
| 520 | if(NULL == sim_handle) |
| 521 | { |
| 522 | QL_SIM_LOGE("[%s] sim handle not init.", __func__); |
| 523 | return QL_ERR_NOT_INIT; |
| 524 | } |
| 525 | |
| 526 | if(NULL == phone_num) |
| 527 | { |
| 528 | QL_SIM_LOGE("[%s] phone_num is NULL.", __func__); |
| 529 | return QL_ERR_INVALID_ARG; |
| 530 | } |
| 531 | |
| 532 | if(phone_num_len < QL_SIM_PHONE_NUMBER_MAX) |
| 533 | { |
| 534 | QL_SIM_LOGE("[%s] phone_num buf is too short.", __func__); |
| 535 | return QL_ERR_BUF_OVERFLOW; |
| 536 | } |
| 537 | |
| 538 | char temp_buff[MBTK_BUFF_TEMP_SIZE_128] = {0}; |
| 539 | memset(phone_num, 0x0, phone_num_len); |
| 540 | memset(temp_buff, 0x0, MBTK_BUFF_TEMP_SIZE_128); |
| 541 | int ret = mbtk_phone_number_get(sim_handle->handle, (void *)temp_buff); |
| 542 | if(ret != MBTK_ERR_OK) |
| 543 | { |
| 544 | QL_SIM_LOGE("[%s] phone_num get fail.[%d]", __func__, ret); |
| 545 | return QL_ERR_FAILED; |
| 546 | } |
| 547 | |
| 548 | memcpy(phone_num, temp_buff, QL_SIM_PHONE_NUMBER_MAX); |
| 549 | return QL_ERR_OK; |
| 550 | } |
| 551 | |
| 552 | /*-----------------------------------------------------------------------------------------------*/ |
| 553 | /** |
| 554 | @brief Retrieves the preferred operators stored on the card. |
| 555 | @param [in] slot Slot to be used. |
| 556 | @note This function is only supported by Identify card in slot 1 |
| 557 | @param [out] list Buffer to hold operators. |
| 558 | @note This function is only supported by 3GPP applications |
| 559 | @return Whether the preferred operators were successfully retrieved. |
| 560 | @retval QL_ERR_OK successful |
| 561 | @retval QL_ERR_SERVICE_NOT_READY service is not ready, need to retry |
| 562 | @retval Other error code defined by ql_type.h |
| 563 | */ |
| 564 | /*-----------------------------------------------------------------------------------------------*/ |
| 565 | int ql_sim_get_operators(QL_SIM_SLOT_E slot, ql_sim_operator_list_t *list) |
| 566 | { |
| 567 | UNUSED(slot); |
| 568 | |
| 569 | if(NULL == sim_handle) |
| 570 | { |
| 571 | QL_SIM_LOGE("[%s] sim handle not init.", __func__); |
| 572 | return QL_ERR_NOT_INIT; |
| 573 | } |
| 574 | |
| 575 | if(NULL == list) |
| 576 | { |
| 577 | QL_SIM_LOGE("[%s] list is NULL.", __func__); |
| 578 | return QL_ERR_INVALID_ARG; |
| 579 | } |
| 580 | |
| 581 | #if 0 |
| 582 | list_node_t* operators_list = NULL; |
| 583 | mbtk_net_info_t* operator = NULL; |
| 584 | char temp_buff[MBTK_BUFF_TEMP_SIZE_16] = {0}; |
| 585 | int operators_size = 0; |
| 586 | int ret = mbtk_available_net_get(sim_handle->handle, &operators_list); |
| 587 | if(ret != MBTK_ERR_OK) |
| 588 | { |
| 589 | QL_SIM_LOGE("[%s] available operators get fail.[%d]", __func__, ret); |
| 590 | if(NULL != operators_list) |
| 591 | { |
| 592 | list_free(operators_list); |
| 593 | operators_list = NULL; |
| 594 | } |
| 595 | return QL_ERR_FAILED; |
| 596 | } |
| 597 | |
| 598 | if(NULL == operators_list) |
| 599 | { |
| 600 | QL_SIM_LOGE("[%s] operators list is NULL.", __func__); |
| 601 | return QL_ERR_FAILED; |
| 602 | } |
| 603 | else |
| 604 | { |
| 605 | list_first(operators_list); |
| 606 | memset(list, 0x0, sizeof(ql_sim_operator_list_t)); |
| 607 | while ((operator = (mbtk_net_info_t*) list_next(operators_list))) |
| 608 | { |
| 609 | QL_SIM_LOGD("[%s]operators: %d, %d, %d, %d.", __func__, operator->net_sel_mode, operator->net_type, operator->net_state, operator->plmn); |
| 610 | memset(temp_buff, 0x0, MBTK_BUFF_TEMP_SIZE_16); |
| 611 | ret = sprintf(temp_buff, "%d", operator->plmn); |
| 612 | list->operators[operators_size].mnc_len = ret - QL_SIM_MCC_LENGHT; |
| 613 | if(ret > QL_SIM_MCC_LENGHT && list->operators[operators_size].mnc_len <= QL_SIM_MNC_MAX) |
| 614 | { |
| 615 | memcpy(list->operators[operators_size].mcc, temp_buff, QL_SIM_MCC_LENGHT); |
| 616 | memcpy(list->operators[operators_size].mnc, temp_buff + QL_SIM_MCC_LENGHT, list->operators[operators_size].mnc_len); |
| 617 | } |
| 618 | else |
| 619 | { |
| 620 | QL_SIM_LOGE("[%s] MCC MNC length error.", __func__); |
| 621 | list_free(operators_list); |
| 622 | operators_list = NULL; |
| 623 | return QL_ERR_FAILED; |
| 624 | } |
| 625 | operators_size++; |
| 626 | } |
| 627 | list->len = operators_size; |
| 628 | } |
| 629 | list_free(operators_list); |
| 630 | operators_list = NULL; |
| 631 | #else |
| 632 | mbtk_net_info_array_t net_list; |
| 633 | mbtk_ril_err_enum err = mbtk_available_net_get(sim_handle->handle, &net_list); |
| 634 | if(err != MBTK_RIL_ERR_SUCCESS) { |
| 635 | LOGE("Error : %d", err); |
| 636 | } else { |
| 637 | LOGD("Available net number:%d\n", net_list.num); |
| 638 | int i = 0; |
| 639 | char temp_buff[MBTK_BUFF_TEMP_SIZE_16] = {0}; |
| 640 | int ret; |
| 641 | memset(list, 0x0, sizeof(ql_sim_operator_list_t)); |
| 642 | while(i < net_list.num) { |
| 643 | memset(temp_buff, 0x0, MBTK_BUFF_TEMP_SIZE_16); |
| 644 | LOGD("NET : %d,%d,%d,%d\n", net_list.net_info[i].net_sel_mode, |
| 645 | net_list.net_info[i].net_type, net_list.net_info[i].net_state, |
| 646 | net_list.net_info[i].plmn); |
| 647 | |
| 648 | ret = sprintf(temp_buff, "%d", net_list.net_info[i].plmn); |
| 649 | list->operators[i].mnc_len = ret - QL_SIM_MCC_LENGHT; |
| 650 | if(ret > QL_SIM_MCC_LENGHT && list->operators[i].mnc_len <= QL_SIM_MNC_MAX) |
| 651 | { |
| 652 | memcpy(list->operators[i].mcc, temp_buff, QL_SIM_MCC_LENGHT); |
| 653 | memcpy(list->operators[i].mnc, temp_buff + QL_SIM_MCC_LENGHT, list->operators[i].mnc_len); |
| 654 | } |
| 655 | else |
| 656 | { |
| 657 | QL_SIM_LOGE("[%s] MCC MNC length error.", __func__); |
| 658 | return QL_ERR_FAILED; |
| 659 | } |
| 660 | i++; |
| 661 | } |
| 662 | list->len = net_list.num; |
| 663 | } |
| 664 | |
| 665 | #endif |
| 666 | return QL_ERR_OK; |
| 667 | } |
| 668 | |
| 669 | /*-----------------------------------------------------------------------------------------------*/ |
| 670 | /** |
| 671 | @brief Enables the PIN on an application. |
| 672 | @param [in] slot Slot to be used. |
| 673 | @note This function is only supported by Identify card in slot 1 |
| 674 | @param [in] app_type Application type. |
| 675 | @note This function is only supported by 3GPP applications |
| 676 | @param [in] pin PIN to be used. |
| 677 | @note This function is only supported by Level 1 user verification |
| 678 | @param [in] pin_value PIN value. NULL terminated. |
| 679 | @return Whether the PIN was successfully enabled. |
| 680 | @retval QL_ERR_OK successful. |
| 681 | @retval QL_ERR_SERVICE_NOT_READY service is not ready, need to retry. |
| 682 | @retval Other error code defined by ql_type.h. |
| 683 | */ |
| 684 | /*-----------------------------------------------------------------------------------------------*/ |
| 685 | int ql_sim_enable_pin(QL_SIM_SLOT_E slot, QL_SIM_APP_TYPE_E app_type, |
| 686 | QL_SIM_PIN_E pin, const char *pin_value) |
| 687 | { |
| 688 | UNUSED(slot); |
| 689 | UNUSED(app_type); |
| 690 | UNUSED(pin); |
| 691 | |
| 692 | if(NULL == sim_handle) |
| 693 | { |
| 694 | QL_SIM_LOGE("[%s] sim handle not init.", __func__); |
| 695 | return QL_ERR_NOT_INIT; |
| 696 | } |
| 697 | |
| 698 | if(NULL == pin_value) |
| 699 | { |
| 700 | QL_SIM_LOGE("[%s] pin_value is NULL.", __func__); |
| 701 | return QL_ERR_INVALID_ARG; |
| 702 | } |
| 703 | |
| 704 | int pin_len = strlen(pin_value); |
| 705 | if(pin_len > QL_SIM_PIN_MAX) |
| 706 | { |
| 707 | QL_SIM_LOGE("[%s] pin length is too long.", __func__); |
| 708 | return QL_ERR_ARG_TOO_LONG; |
| 709 | } |
| 710 | else if(pin_len <= 0) |
| 711 | { |
| 712 | QL_SIM_LOGE("[%s] pin length is too short.", __func__); |
| 713 | return QL_ERR_INVALID_ARG; |
| 714 | } |
| 715 | |
| 716 | mbtk_sim_lock_info_t info = {0}; |
| 717 | info.type = MBTK_SIM_LOCK_TYPE_ENABLE; |
| 718 | memcpy(info.pin1, pin_value, pin_len); |
| 719 | |
| 720 | int err = mbtk_sim_lock_set(sim_handle->handle, &info); |
| 721 | if(err) |
| 722 | { |
| 723 | QL_SIM_LOGE("[%s] enable pin fail.[%d]", __func__, err); |
| 724 | return QL_ERR_FAILED; |
| 725 | } |
| 726 | |
| 727 | return QL_ERR_OK; |
| 728 | } |
| 729 | |
| 730 | /*-----------------------------------------------------------------------------------------------*/ |
| 731 | /** |
| 732 | @brief Disables the PIN on an application. |
| 733 | @param [in] slot Slot to be used. |
| 734 | @note This function is only supported by Identify card in slot 1 |
| 735 | @param [in] app_type Application type. |
| 736 | @note This function is only supported by 3GPP applications |
| 737 | @param [in] pin PIN to be used. |
| 738 | @note This function is only supported by Level 1 user verification |
| 739 | @param [in] pin_value PIN value. NULL terminated. |
| 740 | @return Whether the PIN was successfully disabled. |
| 741 | @retval QL_ERR_OK successful. |
| 742 | @retval QL_ERR_SERVICE_NOT_READY service is not ready, need to retry. |
| 743 | @retval Other error code defined by ql_type.h. |
| 744 | */ |
| 745 | /*-----------------------------------------------------------------------------------------------*/ |
| 746 | int ql_sim_disable_pin(QL_SIM_SLOT_E slot, QL_SIM_APP_TYPE_E app_type, |
| 747 | QL_SIM_PIN_E pin, const char *pin_value) |
| 748 | { |
| 749 | UNUSED(slot); |
| 750 | UNUSED(app_type); |
| 751 | UNUSED(pin); |
| 752 | |
| 753 | if(NULL == sim_handle) |
| 754 | { |
| 755 | QL_SIM_LOGE("[%s] sim handle not init.", __func__); |
| 756 | return QL_ERR_NOT_INIT; |
| 757 | } |
| 758 | |
| 759 | if(NULL == pin_value) |
| 760 | { |
| 761 | QL_SIM_LOGE("[%s] pin_value is NULL.", __func__); |
| 762 | return QL_ERR_INVALID_ARG; |
| 763 | } |
| 764 | |
| 765 | int pin_len = strlen(pin_value); |
| 766 | if(pin_len > QL_SIM_PIN_MAX) |
| 767 | { |
| 768 | QL_SIM_LOGE("[%s] pin length is too long.", __func__); |
| 769 | return QL_ERR_ARG_TOO_LONG; |
| 770 | } |
| 771 | else if(pin_len <= 0) |
| 772 | { |
| 773 | QL_SIM_LOGE("[%s] pin length is too short.", __func__); |
| 774 | return QL_ERR_INVALID_ARG; |
| 775 | } |
| 776 | |
| 777 | mbtk_sim_lock_info_t info = {0}; |
| 778 | info.type = MBTK_SIM_LOCK_TYPE_DISABLE; |
| 779 | memcpy(info.pin1, pin_value, pin_len); |
| 780 | |
| 781 | int err = mbtk_sim_lock_set(sim_handle->handle, &info); |
| 782 | if(err) |
| 783 | { |
| 784 | QL_SIM_LOGE("[%s] disenable pin fail.[%d]", __func__, err); |
| 785 | return QL_ERR_FAILED; |
| 786 | } |
| 787 | |
| 788 | return QL_ERR_OK; |
| 789 | } |
| 790 | |
| 791 | /*-----------------------------------------------------------------------------------------------*/ |
| 792 | /** |
| 793 | @brief Verifies the PIN value of an application. |
| 794 | @param [in] slot Slot to be used. |
| 795 | @note This function is only supported by Identify card in slot 1 |
| 796 | @param [in] app_type Application type. |
| 797 | @note This function is only supported by 3GPP applications |
| 798 | @param [in] pin PIN to be used. |
| 799 | @note This function is only supported by Level 1 user verification |
| 800 | @param [in] pin_value PIN value. NULL terminated. |
| 801 | @note PIN must be enabled before calling this function. |
| 802 | @return Whether the PIN was successfully verified. |
| 803 | @retval QL_ERR_OK successful. |
| 804 | @retval QL_ERR_SERVICE_NOT_READY service is not ready, need to retry. |
| 805 | @retval Other error code defined by ql_type.h. |
| 806 | */ |
| 807 | /*-----------------------------------------------------------------------------------------------*/ |
| 808 | int ql_sim_verify_pin(QL_SIM_SLOT_E slot, QL_SIM_APP_TYPE_E app_type, |
| 809 | QL_SIM_PIN_E pin, const char *pin_value) |
| 810 | { |
| 811 | UNUSED(slot); |
| 812 | UNUSED(app_type); |
| 813 | UNUSED(pin); |
| 814 | |
| 815 | if(NULL == sim_handle) |
| 816 | { |
| 817 | QL_SIM_LOGE("[%s] sim handle not init.", __func__); |
| 818 | return QL_ERR_NOT_INIT; |
| 819 | } |
| 820 | |
| 821 | if(NULL == pin_value) |
| 822 | { |
| 823 | QL_SIM_LOGE("[%s] pin_value is NULL.", __func__); |
| 824 | return QL_ERR_INVALID_ARG; |
| 825 | } |
| 826 | |
| 827 | int pin_len = strlen(pin_value); |
| 828 | if(pin_len > QL_SIM_PIN_MAX) |
| 829 | { |
| 830 | QL_SIM_LOGE("[%s] pin length is too long.", __func__); |
| 831 | return QL_ERR_ARG_TOO_LONG; |
| 832 | } |
| 833 | else if(pin_len <= 0) |
| 834 | { |
| 835 | QL_SIM_LOGE("[%s] pin length is too short.", __func__); |
| 836 | return QL_ERR_INVALID_ARG; |
| 837 | } |
| 838 | |
| 839 | mbtk_sim_lock_info_t info = {0}; |
| 840 | info.type = MBTK_SIM_LOCK_TYPE_VERIFY_PIN; |
| 841 | memcpy(info.pin1, pin_value, pin_len); |
| 842 | |
| 843 | int err = mbtk_sim_lock_set(sim_handle->handle, &info); |
| 844 | if(err) |
| 845 | { |
| 846 | QL_SIM_LOGE("[%s] verify pin fail.[%d]", __func__, err); |
| 847 | return QL_ERR_FAILED; |
| 848 | } |
| 849 | |
| 850 | return QL_ERR_OK; |
| 851 | } |
| 852 | |
| 853 | /*-----------------------------------------------------------------------------------------------*/ |
| 854 | /** |
| 855 | @brief Changes the PIN value of an application. |
| 856 | @param [in] slot Slot to be used. |
| 857 | @note This function is only supported by Identify card in slot 1 |
| 858 | @param [in] app_type Application type. |
| 859 | @note This function is only supported by 3GPP applications |
| 860 | @param [in] pin PIN to be used. |
| 861 | @note This function is only supported by Level 1 user verification |
| 862 | @param [in] old_pin_value Old PIN value. NULL terminated. |
| 863 | @param [in] new_pin_value New PIN value. NULL terminated. |
| 864 | @return Whether the PIN was successfully changed. |
| 865 | @retval QL_ERR_OK successful. |
| 866 | @retval QL_ERR_SERVICE_NOT_READY service is not ready, need to retry. |
| 867 | @retval Other error code defined by ql_type.h. |
| 868 | */ |
| 869 | /*-----------------------------------------------------------------------------------------------*/ |
| 870 | int ql_sim_change_pin(QL_SIM_SLOT_E slot, QL_SIM_APP_TYPE_E app_type, |
| 871 | QL_SIM_PIN_E pin, const char *old_pin_value, const char *new_pin_value) |
| 872 | { |
| 873 | UNUSED(slot); |
| 874 | UNUSED(app_type); |
| 875 | UNUSED(pin); |
| 876 | |
| 877 | if(NULL == sim_handle) |
| 878 | { |
| 879 | QL_SIM_LOGE("[%s] sim handle not init.", __func__); |
| 880 | return QL_ERR_NOT_INIT; |
| 881 | } |
| 882 | |
| 883 | if(NULL == old_pin_value || NULL == new_pin_value) |
| 884 | { |
| 885 | QL_SIM_LOGE("[%s] pin_value is NULL.", __func__); |
| 886 | return QL_ERR_INVALID_ARG; |
| 887 | } |
| 888 | |
| 889 | int old_pin_len = strlen(old_pin_value); |
| 890 | int new_pin_len = strlen(new_pin_value); |
| 891 | if(old_pin_len > QL_SIM_PIN_MAX || new_pin_len > QL_SIM_PIN_MAX) |
| 892 | { |
| 893 | QL_SIM_LOGE("[%s] pin length is too long.", __func__); |
| 894 | return QL_ERR_ARG_TOO_LONG; |
| 895 | } |
| 896 | else if(old_pin_len <= 0 || new_pin_len <= 0) |
| 897 | { |
| 898 | QL_SIM_LOGE("[%s] pin length is too short.", __func__); |
| 899 | return QL_ERR_INVALID_ARG; |
| 900 | } |
| 901 | |
| 902 | mbtk_sim_lock_info_t info = {0}; |
| 903 | info.type = MBTK_SIM_LOCK_TYPE_CHANGE; |
| 904 | memcpy(info.pin1, old_pin_value, old_pin_len); |
| 905 | memcpy(info.pin2, new_pin_value, new_pin_len); |
| 906 | |
| 907 | int err = mbtk_sim_lock_set(sim_handle->handle, &info); |
| 908 | if(err) |
| 909 | { |
| 910 | QL_SIM_LOGE("[%s] change pin fail.[%d]", __func__, err); |
| 911 | return QL_ERR_FAILED; |
| 912 | } |
| 913 | |
| 914 | return QL_ERR_OK; |
| 915 | } |
| 916 | |
| 917 | /*-----------------------------------------------------------------------------------------------*/ |
| 918 | /** |
| 919 | @brief Unblocks a blocked PIN using the PUK code. |
| 920 | @param [in] slot Slot to be used. |
| 921 | @note This function is only supported by Identify card in slot 1 |
| 922 | @param [in] app_type Application type. |
| 923 | @note This function is only supported by 3GPP applications |
| 924 | @param [in] pin PIN to be used. |
| 925 | @note This function is only supported by Level 1 user verification |
| 926 | @param [in] puk_value PUK value. NULL terminated. |
| 927 | @param [in] pin_value New PIN value. NULL terminated. |
| 928 | @note The user must pass PUK1 to unblock PIN1 or PUK2 to unblock PIN2. |
| 929 | @return Whether the PIN was successfully unblocked. |
| 930 | @retval QL_ERR_OK successful. |
| 931 | @retval QL_ERR_SERVICE_NOT_READY service is not ready, need to retry. |
| 932 | @retval Other error code defined by ql_type.h. |
| 933 | */ |
| 934 | /*-----------------------------------------------------------------------------------------------*/ |
| 935 | int ql_sim_unblock_pin(QL_SIM_SLOT_E slot, QL_SIM_APP_TYPE_E app_type, |
| 936 | QL_SIM_PIN_E pin, const char *puk_value, const char *pin_value) |
| 937 | { |
| 938 | UNUSED(slot); |
| 939 | UNUSED(app_type); |
| 940 | UNUSED(pin); |
| 941 | |
| 942 | if(NULL == sim_handle) |
| 943 | { |
| 944 | QL_SIM_LOGE("[%s] sim handle not init.", __func__); |
| 945 | return QL_ERR_NOT_INIT; |
| 946 | } |
| 947 | |
| 948 | if(NULL == puk_value || NULL == pin_value) |
| 949 | { |
| 950 | QL_SIM_LOGE("[%s] value is NULL.", __func__); |
| 951 | return QL_ERR_INVALID_ARG; |
| 952 | } |
| 953 | |
| 954 | int puk_len = strlen(puk_value); |
| 955 | int pin_len = strlen(pin_value); |
| 956 | if(puk_len > QL_SIM_PUK_LENGTH || pin_len > QL_SIM_PIN_MAX) |
| 957 | { |
| 958 | QL_SIM_LOGE("[%s] length is too long.", __func__); |
| 959 | return QL_ERR_ARG_TOO_LONG; |
| 960 | } |
| 961 | else if(puk_len <= 0 || pin_len <= 0) |
| 962 | { |
| 963 | QL_SIM_LOGE("[%s] length is too short.", __func__); |
| 964 | return QL_ERR_INVALID_ARG; |
| 965 | } |
| 966 | |
| 967 | mbtk_sim_lock_info_t info = {0}; |
| 968 | info.type = MBTK_SIM_LOCK_TYPE_VERIFY_PUK; |
| 969 | memcpy(info.pin1, pin_value, pin_len); |
| 970 | memcpy(info.puk, puk_value, puk_len); |
| 971 | |
| 972 | int err = mbtk_sim_lock_set(sim_handle->handle, &info); |
| 973 | if(err) |
| 974 | { |
| 975 | QL_SIM_LOGE("[%s] unblock pin fail.[%d]", __func__, err); |
| 976 | return QL_ERR_FAILED; |
| 977 | } |
| 978 | |
| 979 | return QL_ERR_OK; |
| 980 | } |
| 981 | |
| 982 | /*-----------------------------------------------------------------------------------------------*/ |
| 983 | /** |
| 984 | @brief Retrieves the card info stored on a card. |
| 985 | @param [in] slot Slot to be used. |
| 986 | @note This function is only supported by Identify card in slot 1 |
| 987 | @param [out] p_info Pointer of ql_sim_card_info_t. |
| 988 | @return Whether the card info was successfully retrieved. |
| 989 | @retval QL_ERR_OK successful. |
| 990 | @retval QL_ERR_SERVICE_NOT_READY service is not ready, need to retry. |
| 991 | @retval Other error code defined by ql_type.h. |
| 992 | */ |
| 993 | /*-----------------------------------------------------------------------------------------------*/ |
| 994 | int ql_sim_get_card_info(QL_SIM_SLOT_E slot, ql_sim_card_info_t *p_info) |
| 995 | { |
| 996 | UNUSED(slot); |
| 997 | |
| 998 | if(NULL == sim_handle) |
| 999 | { |
| 1000 | QL_SIM_LOGE("[%s] sim handle not init.", __func__); |
| 1001 | return QL_ERR_NOT_INIT; |
| 1002 | } |
| 1003 | |
| 1004 | if(NULL == p_info) |
| 1005 | { |
| 1006 | QL_SIM_LOGE("[%s] p_info is NULL.", __func__); |
| 1007 | return QL_ERR_INVALID_ARG; |
| 1008 | } |
| 1009 | |
| 1010 | mbtk_sim_state_enum sim; |
| 1011 | int ret = mbtk_sim_state_get(sim_handle->handle, &sim); |
| 1012 | if(ret != MBTK_ERR_OK) |
| 1013 | { |
| 1014 | QL_SIM_LOGE("[%s] sim state get fail.[%d]", __func__, ret); |
| 1015 | return QL_ERR_FAILED; |
| 1016 | } |
| 1017 | |
| 1018 | mbtk_sim_card_type_enum sim_card_type; |
| 1019 | ret = mbtk_sim_type_get(sim_handle->handle, &sim_card_type); |
| 1020 | if(ret) |
| 1021 | { |
| 1022 | QL_SIM_LOGE("[%s] sim type get fail.[%d]", __func__, ret); |
| 1023 | return QL_ERR_FAILED; |
| 1024 | } |
| 1025 | |
| 1026 | mbtk_pin_puk_last_times_t sim_last_times = {0}; |
| 1027 | ret = mbtk_sim_lock_retry_times_get(sim_handle->handle, &sim_last_times); |
| 1028 | if(ret) |
| 1029 | { |
| 1030 | QL_SIM_LOGE("[%s] sim pin puk times get fail.[%d]", __func__, ret); |
| 1031 | return QL_ERR_FAILED; |
| 1032 | } |
| 1033 | |
| 1034 | int pin_state; |
| 1035 | ret = mbtk_sim_lock_get(sim_handle->handle, &pin_state); |
| 1036 | if(ret) |
| 1037 | { |
| 1038 | QL_SIM_LOGE("[%s] sim pin state get fail.[%d]", __func__, ret); |
| 1039 | return QL_ERR_FAILED; |
| 1040 | } |
| 1041 | |
| 1042 | memset(p_info, 0x0, sizeof(ql_sim_card_info_t)); |
| 1043 | switch(sim) |
| 1044 | { |
| 1045 | case MBTK_SIM_STATE_ABSENT: //CARD ABSENT |
| 1046 | { |
| 1047 | p_info->state = QL_SIM_CARD_STATE_ABSENT; |
| 1048 | p_info->app_3gpp.app_state = QL_SIM_APP_STATE_UNKNOWN; |
| 1049 | p_info->app_3gpp.pin1_state = QL_SIM_PIN_STATE_UNKNOWN; |
| 1050 | p_info->app_3gpp.pin2_state = QL_SIM_PIN_STATE_UNKNOWN; |
| 1051 | break; |
| 1052 | } |
| 1053 | case MBTK_SIM_STATE_READY: //CARD READY |
| 1054 | { |
| 1055 | p_info->state = QL_SIM_CARD_STATE_PRESENT; |
| 1056 | p_info->app_3gpp.app_state = QL_SIM_APP_STATE_READY; |
| 1057 | if(pin_state == MBTK_PIN_ENABLE) |
| 1058 | { |
| 1059 | p_info->app_3gpp.pin1_state = QL_SIM_PIN_STATE_ENABLED_VERIFIED; |
| 1060 | } |
| 1061 | else |
| 1062 | { |
| 1063 | p_info->app_3gpp.pin1_state = QL_SIM_PIN_STATE_DISABLED; |
| 1064 | } |
| 1065 | p_info->app_3gpp.pin2_state = QL_SIM_PIN_STATE_UNKNOWN; |
| 1066 | break; |
| 1067 | } |
| 1068 | case MBTK_SIM_STATE_SIM_PIN: //SIM PIN |
| 1069 | { |
| 1070 | p_info->state = QL_SIM_CARD_STATE_PRESENT; |
| 1071 | p_info->app_3gpp.app_state = QL_SIM_APP_STATE_PIN1_REQ; |
| 1072 | if(pin_state == MBTK_PIN_ENABLE) |
| 1073 | { |
| 1074 | p_info->app_3gpp.pin1_state = QL_SIM_PIN_STATE_ENABLED_NOT_VERIFIED; |
| 1075 | } |
| 1076 | else |
| 1077 | { |
| 1078 | p_info->app_3gpp.pin1_state = QL_SIM_PIN_STATE_DISABLED; |
| 1079 | } |
| 1080 | p_info->app_3gpp.pin2_state = QL_SIM_PIN_STATE_UNKNOWN; |
| 1081 | break; |
| 1082 | } |
| 1083 | case MBTK_SIM_STATE_SIM_PUK: //SIM PUK |
| 1084 | { |
| 1085 | p_info->state = QL_SIM_CARD_STATE_PRESENT; |
| 1086 | p_info->app_3gpp.app_state = QL_SIM_APP_STATE_PUK1_REQ; |
| 1087 | if(pin_state == MBTK_PIN_ENABLE) |
| 1088 | { |
| 1089 | p_info->app_3gpp.pin1_state = QL_SIM_PIN_STATE_BLOCKED; |
| 1090 | } |
| 1091 | else |
| 1092 | { |
| 1093 | p_info->app_3gpp.pin1_state = QL_SIM_PIN_STATE_DISABLED; |
| 1094 | } |
| 1095 | p_info->app_3gpp.pin2_state = QL_SIM_PIN_STATE_UNKNOWN; |
| 1096 | break; |
| 1097 | } |
| 1098 | case MBTK_SIM_STATE_PH_NET_PIN: //NETWORK PERSON PIN |
| 1099 | { |
| 1100 | p_info->state = QL_SIM_CARD_STATE_PRESENT; |
| 1101 | p_info->app_3gpp.app_state = QL_SIM_APP_STATE_UNKNOWN; |
| 1102 | if(pin_state == MBTK_PIN_ENABLE) |
| 1103 | { |
| 1104 | p_info->app_3gpp.pin1_state = QL_SIM_PIN_STATE_ENABLED_NOT_VERIFIED; |
| 1105 | } |
| 1106 | else |
| 1107 | { |
| 1108 | p_info->app_3gpp.pin1_state = QL_SIM_PIN_STATE_DISABLED; |
| 1109 | } |
| 1110 | p_info->app_3gpp.pin2_state = QL_SIM_PIN_STATE_UNKNOWN; |
| 1111 | break; |
| 1112 | } |
| 1113 | case MBTK_SIM_STATE_NOT_READY: //UNKNOWN STATE |
| 1114 | default: |
| 1115 | { |
| 1116 | p_info->state = QL_SIM_CARD_STATE_UNKNOWN; |
| 1117 | p_info->app_3gpp.app_state = QL_SIM_APP_STATE_UNKNOWN; |
| 1118 | p_info->app_3gpp.pin1_state = QL_SIM_PIN_STATE_UNKNOWN; |
| 1119 | p_info->app_3gpp.pin2_state = QL_SIM_PIN_STATE_UNKNOWN; |
| 1120 | break; |
| 1121 | } |
| 1122 | } |
| 1123 | |
| 1124 | switch(sim_card_type) |
| 1125 | { |
| 1126 | case MBTK_SIM: |
| 1127 | case MBTK_TEST_SIM: |
| 1128 | { |
| 1129 | p_info->type = QL_SIM_CARD_TYPE_ICC; |
| 1130 | break; |
| 1131 | } |
| 1132 | case MBTK_USIM: |
| 1133 | case MBTK_TEST_USIM: |
| 1134 | { |
| 1135 | p_info->type = QL_SIM_CARD_TYPE_UICC; |
| 1136 | break; |
| 1137 | } |
| 1138 | default: |
| 1139 | { |
| 1140 | p_info->type = QL_SIM_CARD_TYPE_UNKNOWN; |
| 1141 | break; |
| 1142 | } |
| 1143 | } |
| 1144 | |
| 1145 | p_info->app_3gpp.pin1_num_retries = sim_last_times.p1_retry; |
| 1146 | p_info->app_3gpp.puk1_num_retries = sim_last_times.puk1_retry; |
| 1147 | p_info->app_3gpp.pin2_num_retries = sim_last_times.p2_retry; |
| 1148 | p_info->app_3gpp.puk2_num_retries = sim_last_times.puk2_retry; |
| 1149 | |
| 1150 | return QL_ERR_OK; |
| 1151 | } |
| 1152 | |
| 1153 | /*-----------------------------------------------------------------------------------------------*/ |
| 1154 | /** |
| 1155 | @brief Reads data from a specific file on a specified application on the card. |
| 1156 | @param [in] slot Slot to be used. |
| 1157 | @param [in] app_type Application type. |
| 1158 | @param [inout] p_file Pointer of ql_sim_file_t. |
| 1159 | @return Whether the file was successfully read. |
| 1160 | @retval QL_ERR_OK successful. |
| 1161 | @retval QL_ERR_SERVICE_NOT_READY service is not ready, need to retry. |
| 1162 | @retval Other error code defined by ql_type.h. |
| 1163 | */ |
| 1164 | /*-----------------------------------------------------------------------------------------------*/ |
| 1165 | int ql_sim_read_file(QL_SIM_SLOT_E slot, QL_SIM_APP_TYPE_E app_type, ql_sim_file_t *p_file) |
| 1166 | { |
| 1167 | UNUSED(slot); |
| 1168 | UNUSED(app_type); |
| 1169 | UNUSED(p_file); |
| 1170 | |
| 1171 | if(NULL == sim_handle) |
| 1172 | { |
| 1173 | QL_SIM_LOGE("[%s] sim handle not init.", __func__); |
| 1174 | return QL_ERR_NOT_INIT; |
| 1175 | } |
| 1176 | |
| 1177 | return QL_ERR_OK; |
| 1178 | } |
| 1179 | |
| 1180 | /*-----------------------------------------------------------------------------------------------*/ |
| 1181 | /** |
| 1182 | @brief Writes data to a specific file on a specified application on the card. |
| 1183 | @param [in] slot Slot to be used. |
| 1184 | @param [in] app_type Application type. |
| 1185 | @param [in] p_file Pointer of ql_sim_file_t |
| 1186 | @note The type of file is determined by the record number field, |
| 1187 | which indicates a transparent file when zero and a record-based file otherwise. |
| 1188 | @return Whether the file was successfully written. |
| 1189 | @retval QL_ERR_OK successful. |
| 1190 | @retval QL_ERR_SERVICE_NOT_READY service is not ready, need to retry. |
| 1191 | @retval Other error code defined by ql_type.h. |
| 1192 | */ |
| 1193 | /*-----------------------------------------------------------------------------------------------*/ |
| 1194 | int ql_sim_write_file(QL_SIM_SLOT_E slot, QL_SIM_APP_TYPE_E app_type, ql_sim_file_t *p_file) |
| 1195 | { |
| 1196 | UNUSED(slot); |
| 1197 | UNUSED(app_type); |
| 1198 | UNUSED(p_file); |
| 1199 | |
| 1200 | if(NULL == sim_handle) |
| 1201 | { |
| 1202 | QL_SIM_LOGE("[%s] sim handle not init.", __func__); |
| 1203 | return QL_ERR_NOT_INIT; |
| 1204 | } |
| 1205 | |
| 1206 | return QL_ERR_OK; |
| 1207 | } |
| 1208 | |
| 1209 | /*-----------------------------------------------------------------------------------------------*/ |
| 1210 | /** |
| 1211 | @brief Retrieves the info of a specific file on a specified application on the card. |
| 1212 | @param [in] slot Slot to be used. |
| 1213 | @param [in] app_type Application type. |
| 1214 | @param [inout] p_info Pointer of ql_sim_file_info_t. |
| 1215 | @return Whether the file info was successfully retrieved. |
| 1216 | @retval QL_ERR_OK successful. |
| 1217 | @retval QL_ERR_SERVICE_NOT_READY service is not ready, need to retry. |
| 1218 | @retval Other error code defined by ql_type.h. |
| 1219 | */ |
| 1220 | /*-----------------------------------------------------------------------------------------------*/ |
| 1221 | int ql_sim_get_file_info(QL_SIM_SLOT_E slot, QL_SIM_APP_TYPE_E app_type, |
| 1222 | ql_sim_file_info_t *p_info) |
| 1223 | { |
| 1224 | UNUSED(slot); |
| 1225 | UNUSED(app_type); |
| 1226 | UNUSED(p_info); |
| 1227 | |
| 1228 | if(NULL == sim_handle) |
| 1229 | { |
| 1230 | QL_SIM_LOGE("[%s] sim handle not init.", __func__); |
| 1231 | return QL_ERR_NOT_INIT; |
| 1232 | } |
| 1233 | |
| 1234 | return QL_ERR_OK; |
| 1235 | } |
| 1236 | |
| 1237 | /*-----------------------------------------------------------------------------------------------*/ |
| 1238 | /** |
| 1239 | @brief Reads phone book on a specified application on the card. |
| 1240 | @param [in] slot Slot to be used. |
| 1241 | @param [in] app_type Spplication type. |
| 1242 | @param [in] pb_path Phone book path. NULL terminated. |
| 1243 | @param [in] record_idx Record index to read. Starts from 1. |
| 1244 | @param [out] p_record Pointer of ql_sim_phone_book_record_t. |
| 1245 | @return Whether the phone book record was successfully retrieved. |
| 1246 | @retval QL_ERR_OK successful. |
| 1247 | @retval QL_ERR_SERVICE_NOT_READY service is not ready, need to retry. |
| 1248 | @retval Other error code defined by ql_type.h. |
| 1249 | */ |
| 1250 | /*-----------------------------------------------------------------------------------------------*/ |
| 1251 | int ql_sim_read_phone_book(QL_SIM_SLOT_E slot, QL_SIM_APP_TYPE_E app_type, |
| 1252 | const char *pb_path, uint8_t record_idx, |
| 1253 | ql_sim_phone_book_record_t *p_record) |
| 1254 | { |
| 1255 | UNUSED(slot); |
| 1256 | UNUSED(app_type); |
| 1257 | UNUSED(pb_path); |
| 1258 | UNUSED(record_idx); |
| 1259 | UNUSED(p_record); |
| 1260 | |
| 1261 | if(NULL == sim_handle) |
| 1262 | { |
| 1263 | QL_SIM_LOGE("[%s] sim handle not init.", __func__); |
| 1264 | return QL_ERR_NOT_INIT; |
| 1265 | } |
| 1266 | |
| 1267 | return QL_ERR_OK; |
| 1268 | } |
| 1269 | |
| 1270 | /*-----------------------------------------------------------------------------------------------*/ |
| 1271 | /** |
| 1272 | @brief Writes phone book on a specified application on the card. |
| 1273 | @param [in] slot Slot to be used. |
| 1274 | @param [in] app_type Application type. |
| 1275 | @param [in] pb_path Phone book path. NULL terminated. |
| 1276 | @param [in] record_idx Record index to write. Starts from 1. |
| 1277 | @param [in] p_record Pointer of ql_sim_phone_book_record_t. |
| 1278 | @note If p_record->name[0] = 0 and p_record->number[0] = 0, record will be deleted. |
| 1279 | @return Whether the phone book record was successfully saved. |
| 1280 | @retval QL_ERR_OK successful. |
| 1281 | @retval QL_ERR_SERVICE_NOT_READY service is not ready, need to retry. |
| 1282 | @retval Other error code defined by ql_type.h. |
| 1283 | */ |
| 1284 | /*-----------------------------------------------------------------------------------------------*/ |
| 1285 | int ql_sim_write_phone_book(QL_SIM_SLOT_E slot, QL_SIM_APP_TYPE_E app_type, |
| 1286 | const char *pb_path, uint8_t record_idx, |
| 1287 | ql_sim_phone_book_record_t *p_record) |
| 1288 | { |
| 1289 | UNUSED(slot); |
| 1290 | UNUSED(app_type); |
| 1291 | UNUSED(pb_path); |
| 1292 | UNUSED(record_idx); |
| 1293 | UNUSED(p_record); |
| 1294 | |
| 1295 | if(NULL == sim_handle) |
| 1296 | { |
| 1297 | QL_SIM_LOGE("[%s] sim handle not init.", __func__); |
| 1298 | return QL_ERR_NOT_INIT; |
| 1299 | } |
| 1300 | |
| 1301 | return QL_ERR_OK; |
| 1302 | } |
| 1303 | |
| 1304 | /*-----------------------------------------------------------------------------------------------*/ |
| 1305 | /** |
| 1306 | @brief Opens a logical channel on a UICC card. |
| 1307 | @param [in] slot Slot to be used. |
| 1308 | @param [out] channel_id Channel opened. |
| 1309 | @return Whether the logical channel was successfully opened. |
| 1310 | @retval QL_ERR_OK successful. |
| 1311 | @retval QL_ERR_SERVICE_NOT_READY service is not ready, need to retry. |
| 1312 | @retval Other error code defined by ql_type.h. |
| 1313 | */ |
| 1314 | /*-----------------------------------------------------------------------------------------------*/ |
| 1315 | int ql_sim_open_logical_channel(QL_SIM_SLOT_E slot, uint8_t *channel_id) |
| 1316 | { |
| 1317 | UNUSED(slot); |
| 1318 | UNUSED(channel_id); |
| 1319 | |
| 1320 | if(NULL == sim_handle) |
| 1321 | { |
| 1322 | QL_SIM_LOGE("[%s] sim handle not init.", __func__); |
| 1323 | return QL_ERR_NOT_INIT; |
| 1324 | } |
| 1325 | |
| 1326 | return QL_ERR_OK; |
| 1327 | } |
| 1328 | |
| 1329 | /*-----------------------------------------------------------------------------------------------*/ |
| 1330 | /** |
| 1331 | @brief Closes a logical channel on a UICC card. |
| 1332 | @param [in] slot Slot to be used. |
| 1333 | @param [in] channel_id Channel to be closed. |
| 1334 | @return Whether the logical channel was successfully closed. |
| 1335 | @retval QL_ERR_OK successful. |
| 1336 | @retval QL_ERR_SERVICE_NOT_READY service is not ready, need to retry. |
| 1337 | @retval Other error code defined by ql_type.h. |
| 1338 | */ |
| 1339 | /*-----------------------------------------------------------------------------------------------*/ |
| 1340 | int ql_sim_close_logical_channel(QL_SIM_SLOT_E slot, uint8_t channel_id) |
| 1341 | { |
| 1342 | UNUSED(slot); |
| 1343 | UNUSED(channel_id); |
| 1344 | |
| 1345 | if(NULL == sim_handle) |
| 1346 | { |
| 1347 | QL_SIM_LOGE("[%s] sim handle not init.", __func__); |
| 1348 | return QL_ERR_NOT_INIT; |
| 1349 | } |
| 1350 | |
| 1351 | return QL_ERR_OK; |
| 1352 | } |
| 1353 | |
| 1354 | /*-----------------------------------------------------------------------------------------------*/ |
| 1355 | /** |
| 1356 | @brief Sends an APDU to the card. |
| 1357 | @param [in] slot Slot to be used. |
| 1358 | @param [in] channel_id Channel to be used. |
| 1359 | @param [inout] p_apdu Pointer of ql_sim_apdu_t. |
| 1360 | @note You must call ql_sim_open_logical_channel before sending an APDU. |
| 1361 | @return Whether the APDU was successfully sent. |
| 1362 | @retval QL_ERR_OK successful. |
| 1363 | @retval QL_ERR_SERVICE_NOT_READY service is not ready, need to retry. |
| 1364 | @retval Other error code defined by ql_type.h. |
| 1365 | */ |
| 1366 | /*-----------------------------------------------------------------------------------------------*/ |
| 1367 | int ql_sim_send_apdu(QL_SIM_SLOT_E slot, uint8_t channel_id, ql_sim_apdu_t *p_apdu) |
| 1368 | { |
| 1369 | UNUSED(slot); |
| 1370 | UNUSED(channel_id); |
| 1371 | UNUSED(p_apdu); |
| 1372 | |
| 1373 | if(NULL == sim_handle) |
| 1374 | { |
| 1375 | QL_SIM_LOGE("[%s] sim handle not init.", __func__); |
| 1376 | return QL_ERR_NOT_INIT; |
| 1377 | } |
| 1378 | |
| 1379 | return QL_ERR_OK; |
| 1380 | } |
| 1381 | |
| 1382 | /*-----------------------------------------------------------------------------------------------*/ |
| 1383 | /** |
| 1384 | @brief Sets SIM card status callback handler |
| 1385 | @param[in] cb call back handler. |
| 1386 | @return Whether the card status callback handler was successfully set. |
| 1387 | @retval QL_ERR_OK successful. |
| 1388 | @retval QL_ERR_SERVICE_NOT_READY service is not ready, need to retry. |
| 1389 | @retval Other error code defined by ql_type.h. |
| 1390 | */ |
| 1391 | /*-----------------------------------------------------------------------------------------------*/ |
| 1392 | int ql_sim_set_card_status_cb(ql_sim_card_status_cb_f cb) |
| 1393 | { |
| 1394 | if(NULL == sim_handle) |
| 1395 | { |
| 1396 | QL_SIM_LOGE("[%s] sim handle not init.", __func__); |
| 1397 | return QL_ERR_NOT_INIT; |
| 1398 | } |
| 1399 | |
| 1400 | int ret = QL_ERR_OK; |
| 1401 | if(NULL != cb) |
| 1402 | { |
| 1403 | ret = ql_cb_thread_creat(sim_handle); |
| 1404 | if(ret != QL_ERR_OK) |
| 1405 | { |
| 1406 | QL_SIM_LOGE("[%s] cb thread creat fail.", __func__); |
| 1407 | } |
| 1408 | } |
| 1409 | else |
| 1410 | { |
| 1411 | ret = ql_cb_thread_free(sim_handle); |
| 1412 | if(ret != QL_ERR_OK) |
| 1413 | { |
| 1414 | QL_SIM_LOGE("[%s] cb thread free deinit fail.", __func__); |
| 1415 | return QL_ERR_FAILED; |
| 1416 | } |
| 1417 | } |
| 1418 | sim_handle->status_cb = cb; |
| 1419 | |
| 1420 | return QL_ERR_OK; |
| 1421 | } |
| 1422 | |
| 1423 | /*-----------------------------------------------------------------------------------------------*/ |
| 1424 | /** |
| 1425 | @brief Switches slot. |
| 1426 | @param [in] log_slot Logical slot to be switched. |
| 1427 | @param [in] phy_slot Physical slot to be switched. |
| 1428 | @return Whether the slot was successfully switched. |
| 1429 | @retval QL_ERR_OK successful. |
| 1430 | @retval QL_ERR_SERVICE_NOT_READY service is not ready, need to retry. |
| 1431 | @retval Other error code defined by ql_type.h. |
| 1432 | */ |
| 1433 | /*-----------------------------------------------------------------------------------------------*/ |
| 1434 | int ql_sim_switch_slot(QL_SIM_SLOT_E log_slot, QL_SIM_PHY_SLOT_E phy_slot) |
| 1435 | { |
| 1436 | UNUSED(log_slot); |
| 1437 | UNUSED(phy_slot); |
| 1438 | |
| 1439 | if(NULL == sim_handle) |
| 1440 | { |
| 1441 | QL_SIM_LOGE("[%s] sim handle not init.", __func__); |
| 1442 | return QL_ERR_NOT_INIT; |
| 1443 | } |
| 1444 | |
| 1445 | return QL_ERR_OK; |
| 1446 | } |
| 1447 | |
| 1448 | /*-----------------------------------------------------------------------------------------------*/ |
| 1449 | /** |
| 1450 | @brief Gets active slots. |
| 1451 | @param [Out] p_active_slots Active slots. |
| 1452 | @return Whether the active slots were successfully obtained. |
| 1453 | @retval QL_ERR_OK successful. |
| 1454 | @retval QL_ERR_SERVICE_NOT_READY service is not ready, need to retry. |
| 1455 | @retval Other error code defined by ql_type.h. |
| 1456 | */ |
| 1457 | /*-----------------------------------------------------------------------------------------------*/ |
| 1458 | int ql_sim_get_active_slots(ql_sim_active_slots_t *p_active_slots) |
| 1459 | { |
| 1460 | UNUSED(p_active_slots); |
| 1461 | |
| 1462 | if(NULL == sim_handle) |
| 1463 | { |
| 1464 | QL_SIM_LOGE("[%s] sim handle not init.", __func__); |
| 1465 | return QL_ERR_NOT_INIT; |
| 1466 | } |
| 1467 | |
| 1468 | return QL_ERR_OK; |
| 1469 | } |
| 1470 | |
| 1471 | /*-----------------------------------------------------------------------------------------------*/ |
| 1472 | /** |
| 1473 | @brief Registration server error callback. Currently, only if the server exits abnormally, |
| 1474 | the callback function will be executed, and the error code is QL_ERR_ABORTED; |
| 1475 | @param[in] cb Callback function |
| 1476 | @return |
| 1477 | QL_ERR_OK - successful |
| 1478 | Other - error code defined by ql_type.h |
| 1479 | */ |
| 1480 | /*-----------------------------------------------------------------------------------------------*/ |
| 1481 | int ql_sim_set_service_error_cb(ql_sim_service_error_cb_f cb) |
| 1482 | { |
| 1483 | if(NULL == sim_handle) |
| 1484 | { |
| 1485 | QL_SIM_LOGE("[%s] sim handle not init.", __func__); |
| 1486 | return QL_ERR_NOT_INIT; |
| 1487 | } |
| 1488 | |
| 1489 | sim_handle->server_cb = cb; |
| 1490 | |
| 1491 | return QL_ERR_OK; |
| 1492 | } |
| 1493 | |
| 1494 | //int ql_sim_switch_slot(QL_SIM_SLOT_E log_slot, QL_SIM_PHY_SLOT_E phy_slot); |
| 1495 | //int ql_sim_get_active_slots(ql_sim_active_slots_t *p_active_slots); |
| 1496 | /*----------------------------------------------SIM API------------------------------------------*/ |
| 1497 | |