blob: 7276fca0d9d7289e4e31ac4619c95fa424c9fa47 [file] [log] [blame]
b.liu4e243dc2023-11-27 11:20:00 +08001#ifndef LYNQ_QSER_SMS_H
2#define LYNQ_QSER_SMS_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <sys/types.h>
8#include <stdint.h>
9
10#define MIN_MSM_PARAM_NUM 4
11#define MIN_IMS_MSM_PARAM_NUM 6
12#define MIN_WRITMSM_PARAM_NUM 5
13#define MSG_MAX_LEN 1024
14#define TELEPHONNUM_LEN 64
15#define STORAGSMS_MAX_SIZE 128
16#define SMSC_MAX_LEN 22
17#define SMS_NUM_MAX 255
18
19typedef unsigned short uint16_t;
20typedef unsigned int uint32_t;
21typedef uint32_t sms_client_handle_type;
22
23/** Maximum length of an SMS. */
24#define QSER_SMS_MAX_MT_MSG_LENGTH 1440
25
26/** Maximum string length. */
27#define QSER_SMS_MAX_ADDR_LENGTH 252
28
29/** Maximum string length. */
30#define QSER_SMS_MAX_SCA_TYPLENGTH 3
31
32typedef enum
33{
34 QSER_SMS_7BIT = 0,
35 QSER_SMS_8BIT = 1,
36 QSER_SMS_UCS2 = 2,
37 //<2017/12/28-QCM9XOL00004C001-P01-Vicent.Gao, <[SMS] Segment 1==> CharSet to Alpha implementation.>
38 //QSER_SMS_IRA = 3,//just for inside test
39 //>2017/12/28-QCM9XOL00004C001-P01-Vicent.Gao
40
41}QSER_SMS_T;
42
43typedef enum
44{
45 QSER_SMS_MO = 0, ///< SMS mobile terminated message.
46 QSER_SMS_MT = 1, ///< SMS mobile originated message.
47 QSER_SMS_BROADCAST_MT = 2 ///< SMS Cell Broadcast message.
48}QSER_SMS_TYPT;
49
50typedef enum
51{
52 QSER_SMS_STORAGTYPNONE = -1, /**< Message no need to store. */
53 QSER_SMS_STORAGTYPUIM = 0, /**< Message store to UIM. */
54 QSER_SMS_STORAGTYPNV = 1, /**< Message store to NV. */
55 QSER_SMS_STORAGTYPDB = 2, /**< Message store to NV. */
56}QSER_SMS_STORAGTYPT;
57
58typedef enum
59{
60 QSER_SMS_MESSAGMODUNKNOWN = -1, /**< Message type CDMA */
61 QSER_SMS_MESSAGMODCDMA = 0, /**< Message type CDMA */
62 QSER_SMS_MESSAGMODGW = 1, /**< Message type GW. */
63}QSER_SMS_MODTYPT;
64
65typedef struct
66 {
67 uint8_t total_segments; /**< The number of long short message*/
68 uint8_t seg_number; /**< Current number.*/
69 uint8_t referencnumber; /**< referencnumber.*/
70}QSER_sms_user_data_head_t;
71
72typedef struct
73{
74 /* If sms is stored, it won't parse, you need read it by yourself */
75 QSER_SMS_STORAGTYPT storage; ///specify where stored this msg
76
77 QSER_SMS_T format;
78 QSER_SMS_TYPT type;
79 char src_addr[QSER_SMS_MAX_ADDR_LENGTH]; ///Telephone number string.
80 int sms_data_len;
81 char sms_data[QSER_SMS_MAX_MT_MSG_LENGTH]; ///SMS content, data format depends on format
82 char timestamp[21]; ///Message time stamp (in text mode). string format: "yy/MM/dd,hh:mm:ss+/-TimeZone"
83 uint8_t user_data_head_valid; //indicate whether long sms. TRUE-long sms; FALSE-short message;
84 QSER_sms_user_data_head_t user_data_head; //long sms user data head info.
85 QSER_SMS_MODTYPT mode; ///specify where stored this msg cdma or gw area
86 uint32_t storage_index; ///storage index, -1 means not store
87} QSER_sms_info_t;
88
89typedef struct
90{
91 QSER_SMS_STORAGTYPT storage;
92 QSER_SMS_MODTYPT mode;
93 uint32_t storage_idx;
94} QSER_sms_storage_info_t;
95
96typedef enum
97{
98 QSER_SMS_UNKNOWN = -1,
99 QSER_SMS_DISCARD = 0x00, /* Incoming messages for this route are discarded by the WMS service without
100 notifying QMI_WMS clients */
101 QSER_SMS_STORAND_NOTIFY = 0x01, /* Incoming messages for this route are stored to the specified device
102 memory, and new message notifications */
103 QSER_SMS_TRANSFER_ONLY = 0x02, /* Incoming messages for this route are transferred to the client, and the
104 client is expected to send ACK to the network */
105 QSER_SMS_TRANSFER_AND_ACK = 0x03, /* Incoming messages for this route are transferred to the client, and ACK is
106 sent to the network */
107}QSER_SMS_RECEPTION_ACTION_TYPT;
108
109#define QSER_WMS_MESSAGLENGTH_MAX 255
110
111typedef enum
112 {
113 QSER_WMS_MESSAGCDMA = 0x00, //- 0x00 -- MESSAGCDMA -- CDMA \n
114 QSER_WMS_MESSAGGW_PP = 0x06, //- 0x06 -- MESSAGGW_PP -- GW_PP
115}QSER_WMS_MESSAGTYPE;
116
117
118typedef struct
119 {
120 QSER_WMS_MESSAGTYPE format;
121 uint32_t raw_messaglen; /**< Must be set to # of elements in raw_message */
122 uint8_t raw_message[QSER_WMS_MESSAGLENGTH_MAX]; /**< Raw message data*/
123}QSER_wms_send_raw_message_data_t;
124
125typedef enum
126{
127 QSER_WMS_TL_CAUSCODADDR_VACANT = 0x00,
128 QSER_WMS_TL_CAUSCODADDR_TRANSLATION_FAILURE = 0x01,
129 QSER_WMS_TL_CAUSCODNETWORK_RESOURCSHORTAGE = 0x02,
130 QSER_WMS_TL_CAUSCODNETWORK_FAILURE = 0x03,
131 QSER_WMS_TL_CAUSCODINVALID_TELESERVICID = 0x04,
132 QSER_WMS_TL_CAUSCODNETWORK_OTHER = 0x05,
133 QSER_WMS_TL_CAUSCODNO_PAGRESPONSE = 0x20,
134 QSER_WMS_TL_CAUSCODDEST_BUSY = 0x21,
135 QSER_WMS_TL_CAUSCODNO_ACK = 0x22,
136 QSER_WMS_TL_CAUSCODDEST_RESOURCSHORTAGE = 0x23,
137 QSER_WMS_TL_CAUSCODSMS_DELIVERY_POSTPONED = 0x24,
138 QSER_WMS_TL_CAUSCODDEST_OUT_OF_SERV = 0x25,
139 QSER_WMS_TL_CAUSCODDEST_NOT_AT_ADDR = 0x26,
140 QSER_WMS_TL_CAUSCODDEST_OTHER = 0x27,
141 QSER_WMS_TL_CAUSCODRADIO_IF_RESOURCSHORTAGE = 0x40,
142 QSER_WMS_TL_CAUSCODRADIO_IF_INCOMPATABILITY = 0x41,
143 QSER_WMS_TL_CAUSCODRADIO_IF_OTHER = 0x42,
144 QSER_WMS_TL_CAUSCODENCODING = 0x60,
145 QSER_WMS_TL_CAUSCODSMS_ORIG_DENIED = 0x61,
146 QSER_WMS_TL_CAUSCODSMS_TERM_DENIED = 0x62,
147 QSER_WMS_TL_CAUSCODSUPP_SERV_NOT_SUPP = 0x63,
148 QSER_WMS_TL_CAUSCODSMS_NOT_SUPP = 0x64,
149 QSER_WMS_TL_CAUSCODMISSING_EXPECTED_PARAM = 0x65,
150 QSER_WMS_TL_CAUSCODMISSING_MAND_PARAM = 0x66,
151 QSER_WMS_TL_CAUSCODUNRECOGNIZED_PARAM_VAL = 0x67,
152 QSER_WMS_TL_CAUSCODUNEXPECTED_PARAM_VAL = 0x68,
153 QSER_WMS_TL_CAUSCODUSER_DATA_SIZERR = 0x69,
154 QSER_WMS_TL_CAUSCODGENERAL_OTHER = 0x6A,
155}QSER_WMS_TL_CAUSCODTYPE;
156
157
158
159typedef struct
160 {
161 uint16_t messagid; /* Message ID */
162 uint8_t causcodvalid; /**< Must be set to true if causcode is being passed */
163 QSER_WMS_TL_CAUSCODTYPE causcode;
164}QSER_wms_raw_send_resp_t;
165
166typedef struct
167 {
168 char service_center_addr[QSER_SMS_MAX_ADDR_LENGTH + 1]; /**< Address of the service center.*/
169 uint8_t service_center_addr_typvalid;
170 char service_center_addr_type[QSER_SMS_MAX_SCA_TYPLENGTH + 1]; /**< 129 if the SMSC address does not start with a "+" characte;
171 145 if the SMSC address starts with a "+" character*/
172}QSER_sms_service_center_cfg_t;
173
174typedef QSER_sms_info_t QSER_SMS_Msg_t;
175typedef QSER_sms_info_t* QSER_SMS_MsgRef;
176
177/* Callback function registered to qser_sms_addrxmsghandler, msgRef contains the detail msg infor */
178typedef void (*QSER_SMS_RxMsgHandlerFunc_t)(QSER_SMS_MsgRef msgRef, void* contextPtr);
179
180/* Init SMS module and return h_sms, this should be called before any othe ones */
181int qser_sms_client_init(sms_client_handle_type *ph_sms);
182
183/* Add callback function, if any new msg arrived, it will notify app */
184int qser_sms_addrxmsghandler(QSER_SMS_RxMsgHandlerFunc_t handlerPtr, void* contextPtr);
185
186/* Send sms, you just need to fill format/src_addr/sms_data_len/sms_data,
187 if format is UCS2, the data should be Unicode-BE format.
188*/
189int qser_sms_send_sms(sms_client_handle_type h_sms, QSER_sms_info_t *pt_sms_info);
190
191/* DeInit SMS module and release resource, this should be called in the last one. */
192int qser_sms_client_deinit(sms_client_handle_type h_sms);
193
194/* Delete the SMS specified in the pt_sms_storage */
b.liu8583dce2024-04-03 13:30:08 +0800195int qser_sms_deletefromstorage(sms_client_handle_type h_sms, QSER_sms_storage_info_t *pt_sms_storage);
b.liu4e243dc2023-11-27 11:20:00 +0800196
197/* Send sms PDU.
198*/
199int qser_sms_send_smspdu( sms_client_handle_type h_sms,
200 QSER_wms_send_raw_message_data_t *raw_messagdata,
201 QSER_wms_raw_send_resp_t *rawresp);
202
203
204/* Get sms center address.
205*/
206int qser_sms_getsmscenteraddress( sms_client_handle_type h_sms,
207 QSER_sms_service_center_cfg_t *set_sca_cfg);
208
209/* Set sms center address.
210*/
211int qser_sms_setsmscenteraddress( sms_client_handle_type h_sms,
212 QSER_sms_service_center_cfg_t *get_sca_cfg);
213
214/*
215Usage 1 (register callback and wait for new sms arrive):
2161, qser_sms_client_init
2172, qser_sms_addrxmsghandler(pf_cb)
2183, wait for sms arrive, pf_cb will pass the detail sms info to app.
2194, qser_sms_client_deinit
220
221
222Usage 2 (Send sms):
2231, qser_sms_client_init
2242, qser_sms_addrxmsghandler(pf_cb)
2253, qser_sms_send_sms
2264, qser_sms_client_deinit
227
228
229Usage 3 (store sms):
2301, qser_sms_client_init
2312, qser_sms_addrxmsghandler(pf_cb)
2323, qser_sms_setroutelist (Notice: class-0 not allowed to store, class-2 must be stored to UIM)
2334, pf_cb will be called when new sms arrived, and tell you where the sms stored
2345, you can call qser_sms_deletefromstorage to delete specified sms, the location can be got from pf_cb.
2356, qser_sms_client_deinit
236*/
237
238#ifdef __cplusplus
239}
240#endif
241#endif