ql_api_vsim_adapt.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*============================================================================
  2. Copyright (c) 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved.
  3. Quectel Wireless Solution Proprietary and Confidential.
  4. =============================================================================*/
  5. /*===========================================================================
  6. EDIT HISTORY FOR MODULE
  7. This section contains comments describing changes made to the module.
  8. Notice that changes are listed in reverse chronological order.
  9. WHEN WHO WHAT, WHERE, WHY
  10. ---------- ------------ ----------------------------------------------------
  11. 2022.07.21 Joe.tu create
  12. =============================================================================*/
  13. #ifndef QL_API_VSIM_ADAPT_H
  14. #define QL_API_VSIM_ADAPT_H
  15. #include <stdint.h>
  16. #include "ql_api_common.h"
  17. #ifdef CONFIG_QUEC_PROJECT_FEATURE_VSIM_ADAPT_STD
  18. #include "quec_atc_common.h"
  19. #include "at_engine.h"
  20. #include "quec_sio_adapter.h"
  21. #endif
  22. #ifdef CONFIG_QUEC_PROJECT_FEATURE_VSIM_ADAPT_STD
  23. #define QL_VSIM_RSP_BUFFER_SIZE (1500)
  24. #endif
  25. typedef enum
  26. {
  27. QL_VSIM_ADAPT_SUCCESS = 0,
  28. QL_VSIM_ADAPT_ERROR = 1 | (QL_COMPONENT_VSIM_ADAPT << 16),
  29. QL_VSIM_ADAPT_PARA_ERR,
  30. }ql_vsim_adapt_errcode_e;
  31. typedef enum
  32. {
  33. QL_VSIM_ADAPT_SIM_TYPE_TSIM, /* physical sim card */
  34. QL_VSIM_ADAPT_SIM_TYPE_SSIM, /* local soft sim card */
  35. QL_VSIM_ADAPT_SIM_TYPE_CSIM, /* cloud sim card */
  36. QL_VSIM_ADAPT_SIM_TYPE_MAX,
  37. } ql_vsim_adapt_sim_type_e;
  38. typedef int (*ql_vsim_adapt_process_apdu)(uint8_t *apdu_req, uint16_t apdu_req_len, uint8_t *apdu_rsp,
  39. uint16_t *apdu_rsp_len, uint8_t slot);
  40. typedef uint16_t (*ql_vsim_adapt_reset)(uint8_t *atr_data, uint8_t *atr_size, uint8_t nSim);
  41. typedef struct
  42. {
  43. ql_vsim_adapt_process_apdu process_apdu;
  44. ql_vsim_adapt_reset reset;
  45. }ql_vsim_adapt_handler_s;
  46. #ifdef CONFIG_QUEC_PROJECT_FEATURE_VSIM_ADAPT_STD
  47. typedef struct
  48. {
  49. atCmdEngine_t *engine;
  50. _AtciResultCode resultCode;
  51. uint32_t report_code;
  52. char* rsp_buffer; /* buffer size: QL_VSIM_RSP_BUFFER_SIZE */
  53. uint16_t rsp_len; /* 0:no return string other:return string length */
  54. uint8_t padding;
  55. } ql_vsim_adapt_at_resp_s;
  56. typedef struct
  57. {
  58. atCommand_t *command;
  59. ql_vsim_adapt_at_resp_s* response;
  60. } ql_vsim_adapt_at_message_s;
  61. #endif
  62. /*****************************************************************
  63. * Function: ql_vsim_adapt_callback
  64. *
  65. * Description:
  66. * QUEC_VSIM_ADAPT_POWERON_IND: to change sim type at start-up. Otherwise, physical sim card will be selected, ctx is null.
  67. * QUEC_VSIM_ADAPT_RDY_IND: only for STD AT solution, indicate that quectel core is ready, allowed to use related API, ctx is null.
  68. *
  69. * Parameters:
  70. * ind_type [in] indicate type, QUEC_VSIM_ADAPT_POWERON_IND or QUEC_VSIM_ADAPT_RDY_IND
  71. * ctx [in] the context of specific indicate.
  72. *
  73. * Return:ql_vsim_adapt_errcode_e
  74. *****************************************************************/
  75. typedef int (*ql_vsim_adapt_callback)(uint32_t ind_type, void *ctx);
  76. ql_vsim_adapt_errcode_e ql_vsim_adapt_register_callback(ql_vsim_adapt_callback vsim_adapt_cb);
  77. /*****************************************************************
  78. * Function: ql_vsim_adapt_set_sim_type
  79. *
  80. * Description:
  81. * change sim card type, this is a synchronous api, the thread which will be blocked when called
  82. *
  83. * Parameters:
  84. * sim_type [in] sim type, should be physical sim card, local soft sim card or cloud sim card
  85. * handler [in] APDU and ATR function
  86. * nSim [in] Index of Sim, range:0-1.
  87. *
  88. * Return:ql_vsim_adapt_errcode_e
  89. *****************************************************************/
  90. ql_vsim_adapt_errcode_e ql_vsim_adapt_set_sim_type(ql_vsim_adapt_sim_type_e sim_type,
  91. const ql_vsim_adapt_handler_s *handler, uint8_t nSim);
  92. /*****************************************************************
  93. * Function: ql_vsim_adapt_get_sim_type
  94. *
  95. * Description:
  96. * get sim card type
  97. *
  98. * Parameters:
  99. * nSim [in] Index of Sim, range:0-1.
  100. *
  101. * Return:ql_vsim_adapt_sim_type_e
  102. *****************************************************************/
  103. ql_vsim_adapt_sim_type_e ql_vsim_adapt_get_sim_type(uint8_t nSim);
  104. #endif