ql_mms_client.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /*================================================================
  2. Copyright (c) 2021, Quectel Wireless Solutions Co., Ltd. All rights reserved.
  3. Quectel Wireless Solutions Proprietary and Confidential.
  4. =================================================================*/
  5. #ifndef QL_MMS_CLIENT_H
  6. #define QL_MMS_CLIENT_H
  7. #define mms_print(msg, ...) custom_log_tag("MMS_CLI", QUEC_LOG_TAG_MMS, msg, ##__VA_ARGS__)
  8. #define QL_MMS_BCC_ADDR_MAX_CNT 6
  9. #define QL_MMS_CC_ADDR_MAX_CNT 6
  10. #define QL_MMS_TO_ADDR_MAX_CNT 6
  11. #define QL_MMS_ATTACHMENT_MAX_CNT 12
  12. typedef void* ql_mms_client;
  13. typedef enum{
  14. QL_MMS_OK = 0,
  15. QL_MMS_INVLIAD_PARAM = -1,
  16. QL_MMS_WOULDBLOCK = -2,
  17. QL_MMS_OUT_OF_MEM = -3,
  18. QL_MMS_HTTP_REQ_FAIL = -4,
  19. QL_MMS_OPT_BUSY = -5,
  20. QL_MMS_HTTP_RESP_FAIL = -6,
  21. QL_MMS_SEND_FAIL = -7,
  22. QL_MMS_HTTP_TIMEOUT = -8,
  23. QL_MMS_DNS_FAIL = -9,
  24. QL_MMS_FS_FAIL = -10,
  25. }mms_result_code_e;
  26. typedef enum{
  27. MMS_CHARSET_ASCII_VALUE = 0x03,
  28. MMS_CHARSET_UTF8_VALUE = 0x6A,
  29. MMS_CHARSET_UCS2_VALUE = 0x03E8,
  30. MMS_CHARSET_BIG5_VALUE = 0x07EA,
  31. MMS_CHARSET_GBK_VALUE = 0x71,
  32. }mms_charset_type;
  33. typedef enum
  34. {
  35. MMS_PARAM_VALID_1HOUR=0,
  36. MMS_PARAM_VALID_12HOURS,
  37. MMS_PARAM_VALID_24HOURS,
  38. MMS_PARAM_VALID_2DAYS,
  39. MMS_PARAM_VALID_1WEEK,
  40. MMS_PARAM_VALID_MAXIMUM,
  41. MMS_PARAM_VALID_DEFAULT
  42. }mms_valid_type;
  43. typedef enum
  44. {
  45. MMS_PARAM_PRIORITY_LOWEST=0,
  46. MMS_PARAM_PRIORITY_NORMAL,
  47. MMS_PARAM_PRIORITY_HIGHEST,
  48. MMS_PARAM_PRIORITY_DEFAULT
  49. }mms_priority_type;
  50. typedef enum
  51. {
  52. MMS_PARAM_SENDERADDR_HIDE=0,
  53. MMS_PARAM_SENDERADDR_SHOW,
  54. MMS_PARAM_SENDERADDR_DEFAULT
  55. }mms_visible_type;
  56. typedef enum
  57. {
  58. MMS_PARAM_CLASS_PERSONAL=0,
  59. MMS_PARAM_CLASS_ADVERTISEMENT,
  60. MMS_PARAM_CLASS_INFORMATIONAL,
  61. MMS_PARAM_CLASS_AUTO,
  62. MMS_PARAM_CLASS_DEFAULT
  63. }mms_class_type;
  64. struct mms_send_param_t{
  65. int validity_period;
  66. int priority;
  67. int delivery_report;
  68. int read_report;
  69. int visible;
  70. int class;
  71. };
  72. struct mms_addr_t{
  73. struct mms_addr_t *next;
  74. int addr_len;
  75. char *address;
  76. };
  77. struct mms_attachment_t{
  78. struct mms_attachment_t *next;
  79. char *file_path;
  80. };
  81. struct mms_subject_t{
  82. char *subject;
  83. int length;
  84. };
  85. struct mms_option_t{
  86. int context_id;
  87. int sim_id;
  88. char *mmsc_url;
  89. char *proxy_addr;
  90. uint16_t proxy_port;
  91. int charset;
  92. uint8_t supportfield;
  93. int wait_timeout;
  94. struct mms_send_param_t send_param;
  95. };
  96. struct mms_info_t{
  97. struct mms_subject_t *subject;
  98. struct mms_addr_t *to_addr;
  99. struct mms_addr_t *cc_addr;
  100. struct mms_addr_t *bcc_addr;
  101. struct mms_attachment_t *attachments;
  102. };
  103. typedef void(*mms_send_result_cb)(ql_mms_client client_hndl, int mms_result, int http_code, char *mms_err_msg, void *arg);
  104. /*****************************************************************
  105. * Function: ql_mms_client_new
  106. *
  107. * Description: 创建并初始化mms client端的句柄
  108. *
  109. * Parameters:
  110. * client_hndl [out] mms client 端句柄,用于记录mms消息头和消息体,以及mms的状态信息.
  111. * result_cb [in] 结果的回调处理函数,mms消息响应后,调用此函数,获取mms响应的状态信息.
  112. * arg [in] arg用户自定义配置参数,可用于回调函数result_cb中.
  113. *
  114. * Return:
  115. * 0 成功.
  116. * other 错误码.
  117. *
  118. *****************************************************************/
  119. int ql_mms_client_new(ql_mms_client *client_hndl, mms_send_result_cb result_cb, void *arg);
  120. /*****************************************************************
  121. * Function: ql_mms_client_send_msg
  122. *
  123. * Description: 发送mms消息
  124. *
  125. * Parameters:
  126. * client_hndl [in] mms client 端句柄,将已记录mms消息作为发送内容的一部分.
  127. * send_option [in] 用户配置mms的参数信息,决定mms消息的具体属性.
  128. * mms_info_t [in] 用户通过命令行设置的mms信息,做为mms将要发送的内容的一部分.
  129. *
  130. * Return:
  131. * 0 成功.
  132. * other 错误码.
  133. *
  134. *****************************************************************/
  135. int ql_mms_client_send_msg(ql_mms_client *client_hndl, struct mms_option_t *send_option, struct mms_info_t *mms_info);
  136. /*****************************************************************
  137. * Function: ql_mms_client_release
  138. *
  139. * Description: 释放mms client端句柄所持有的全部资源
  140. *
  141. * Parameters:
  142. * client_hndl [in] mms client 端句柄.
  143. *
  144. * Return:
  145. * 0 成功.
  146. * other 错误码.
  147. *
  148. *****************************************************************/
  149. int ql_mms_client_release(ql_mms_client *client_hndl);
  150. #endif