ql_api_voice_call.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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. marvin create
  12. =============================================================================*/
  13. #ifndef QL_API_VOICE_CALL_H
  14. #define QL_API_VOICE_CALL_H
  15. #include <stdint.h>
  16. #include <stdbool.h>
  17. #include "sockets.h"
  18. #include "ql_api_common.h"
  19. #include "ql_api_osi.h"
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. /*========================================================================
  24. * Marco Definition
  25. *========================================================================*/
  26. #define QL_VC_LOG(msg, ...) QL_LOG(QL_LOG_LEVEL_INFO, "ql_vc", msg, ##__VA_ARGS__)
  27. #define QL_VC_REASON_NOANSWER 1
  28. #define QL_VC_REASON_NOCARRIER 2
  29. #define QL_VC_REASON_BUSY 3
  30. #define QL_VC_REASON_PWROFF 4
  31. #define QL_VC_REASON_ERROR 5
  32. #define QL_VC_MAX_NUM 7
  33. /*========================================================================
  34. * Type Definition
  35. *========================================================================*/
  36. typedef enum
  37. {
  38. QL_VC_SUCCESS = 0,
  39. QL_VC_ERROR = 1 | (QL_COMPONENT_VOICE_CALL << 16),
  40. QL_VC_NOT_INIT_ERR,
  41. QL_VC_PARA_ERR,
  42. QL_VC_NO_MEMORY_ERR,
  43. QL_VC_NO_CALL_ERR,
  44. QL_VC_SEM_CREATE_ERR,
  45. QL_VC_SEM_TIMEOUT_ERR,
  46. }ql_vc_errcode_e;
  47. typedef enum
  48. {
  49. QL_VC_INIT_OK_IND = 1| (QL_COMPONENT_VOICE_CALL << 16),
  50. QL_VC_RING_IND,
  51. QL_VC_CONNECT_IND,
  52. QL_VC_NOCARRIER_IND,
  53. QL_VC_ERROR_IND,
  54. QL_VC_CCWA_IND,
  55. }ql_vc_event_id_e;
  56. typedef struct
  57. {
  58. uint8_t emcNum_sim[20][2];
  59. uint8_t emcNum_nosim[20][2];
  60. } quec_at_ecc_s;
  61. /*****************************************************************
  62. * Parameters:
  63. * idx: call identification number
  64. * direction: direction of the call
  65. * 0-mobile originated (MO) call
  66. * 1-mobile terminated (MT) call
  67. * status:(status of the call)
  68. * 0 active
  69. * 1 held
  70. * 2 dialing (MO call)
  71. * 3 alerting (MO call)
  72. * 4 incoming (MT call)
  73. * 5 waiting (MT call)
  74. * 7 release (network release this call)
  75. * 8 handshake
  76. * multiparty:
  77. * 0 call is not one of multiparty (conference) call parties
  78. * 1 call is one of multiparty (conference) call parties
  79. * number:
  80. *
  81. *****************************************************************/
  82. typedef struct
  83. {
  84. uint8_t idx;
  85. uint8_t direction;
  86. uint8_t status;
  87. uint8_t multiparty;
  88. char number[23];
  89. }ql_vc_info_s;
  90. /*========================================================================
  91. * Callback Definition
  92. *========================================================================*/
  93. typedef void (*ql_vc_event_handler_t)(uint8_t sim, ql_vc_event_id_e event_id, void *ctx);
  94. extern ql_vc_event_handler_t ql_voice_call_callback;
  95. /*========================================================================
  96. * function Definition
  97. *========================================================================*/
  98. /*****************************************************************
  99. * Function: ql_voice_auto_answer
  100. *
  101. * Description:
  102. * 设置自动接听
  103. *
  104. * Parameters:
  105. * nSim [in] SIM卡索引,取值0-1。
  106. * times [in] 设置响铃多少声后自动接听电话,0表示关闭自动接听功能。
  107. *
  108. * Return:ql_vc_errcode_e
  109. *
  110. *****************************************************************/
  111. ql_vc_errcode_e ql_voice_auto_answer(uint8_t nSim, uint8_t times);
  112. /*****************************************************************
  113. * Function: ql_voice_call_start
  114. *
  115. * Description:
  116. * 拨打电话
  117. *
  118. * Parameters:
  119. * nSim [in] SIM卡索引,取值0-1。
  120. * times [dial_num] 字符串格式手机号码。
  121. *
  122. * Return:ql_vc_errcode_e
  123. *
  124. *****************************************************************/
  125. ql_vc_errcode_e ql_voice_call_start(uint8_t nSim, char* dial_num);
  126. /*****************************************************************
  127. * Function: ql_voice_call_answer
  128. *
  129. * Description:
  130. * 接听电话
  131. *
  132. * Parameters:
  133. * nSim [in] SIM卡索引,取值0-1。
  134. * Return:ql_vc_errcode_e
  135. *
  136. *****************************************************************/
  137. ql_vc_errcode_e ql_voice_call_answer(uint8_t nSim);
  138. /*****************************************************************
  139. * Function: ql_voice_call_end
  140. *
  141. * Description:
  142. * 挂断电话
  143. *
  144. * Parameters:
  145. * nSim [in] SIM卡索引,取值0-1。
  146. *
  147. * Return:ql_vc_errcode_e
  148. *
  149. *****************************************************************/
  150. ql_vc_errcode_e ql_voice_call_end(uint8_t nSim);
  151. /*****************************************************************
  152. * Function: ql_voice_call_start_dtmf
  153. *
  154. * Description:
  155. * 发送DTMF
  156. *
  157. * Parameters:
  158. * nSim [in] SIM卡索引,取值0-1。
  159. * dtmf [in] 包含"0-9,#,*,A-D。"字符的字符串
  160. * duration [in] 持续时间,取值0-10, 0表示使用默认值,1表示100ms
  161. *
  162. * Return:ql_vc_errcode_e
  163. *
  164. *****************************************************************/
  165. ql_vc_errcode_e ql_voice_call_start_dtmf(uint8_t nSim, char *dtmf, uint16_t duration);
  166. /*****************************************************************
  167. * Function: ql_voice_call_wait_set
  168. *
  169. * Description:
  170. * 设置呼叫等待
  171. *
  172. * Parameters:
  173. * nSim [in] SIM卡索引,取值0-1。
  174. * mode [in] 0表示关闭呼叫等待,1表示打开呼叫等待
  175. *
  176. * Return:ql_vc_errcode_e
  177. *
  178. *****************************************************************/
  179. ql_vc_errcode_e ql_voice_call_wait_set(uint8_t nSim, uint8_t mode);
  180. /*****************************************************************
  181. * Function: ql_voice_call_wait_get
  182. *
  183. * Description:
  184. * 获取呼叫等待状态
  185. *
  186. * Parameters:
  187. * nSim [in] SIM卡索引,取值0-1。
  188. * mode [out] 0表示呼叫等待已关闭,1表示呼叫等待已打开
  189. *
  190. * Return:ql_vc_errcode_e
  191. *
  192. *****************************************************************/
  193. ql_vc_errcode_e ql_voice_call_wait_get(uint8_t nSim, uint8_t *mode);
  194. /*****************************************************************
  195. * Function: ql_voice_call_fw_set
  196. *
  197. * Description:
  198. * 设置呼叫转移
  199. *
  200. * Parameters:
  201. * nSim [in] SIM卡索引,取值0-1。
  202. * reason [in] 对应AT+CCFC指令的reason
  203. * fwmode [in] 对应AT+CCFC指令的mode
  204. * phone_num [in] 对应AT+CCFC指令的number
  205. *
  206. * Return:ql_vc_errcode_e
  207. *
  208. *****************************************************************/
  209. ql_vc_errcode_e ql_voice_call_fw(uint8_t nSim, int reason, int fwmode, char* phone_num);
  210. /*****************************************************************
  211. * Function: ql_voice_call_fw_set
  212. *
  213. * Description:
  214. * 呼叫保持
  215. *
  216. * Parameters:
  217. * nSim [in] SIM卡索引,取值0-1。
  218. * n [in] 对应AT+HOLD指令的n
  219. *
  220. * Return:ql_vc_errcode_e
  221. *
  222. *****************************************************************/
  223. ql_vc_errcode_e ql_voice_call_hold(uint8_t nSim, uint8_t n);
  224. /*****************************************************************
  225. * Function: ql_voice_call_fw_set
  226. *
  227. * Description:
  228. * 获取当前电话列表
  229. *
  230. * Parameters:
  231. * nSim [in] SIM卡索引,取值0-1。
  232. * total [out] 当前电话总数
  233. * ql_vc_info_s [out] 结构体数组指针,每个电话的序号、状态、号码等信息.
  234. *
  235. * Return:ql_vc_errcode_e
  236. *
  237. *****************************************************************/
  238. ql_vc_errcode_e ql_voice_call_clcc(uint8_t nSim, uint8_t *total, ql_vc_info_s vc_info[QL_VC_MAX_NUM]);
  239. /*****************************************************************
  240. * Function: ql_voice_call_callback_register
  241. *
  242. * Description:
  243. * 注册回调函数
  244. *
  245. * Parameters:
  246. * ql_vc_event_handler_t [in] 回调函数
  247. *
  248. * Return:ql_vc_errcode_e
  249. *
  250. *****************************************************************/
  251. void ql_voice_call_callback_register(ql_vc_event_handler_t cb);
  252. #ifdef __cplusplus
  253. }/*"C" */
  254. #endif
  255. #endif