b.liu | 4e243dc | 2023-11-27 11:20:00 +0800 | [diff] [blame] | 1 | #ifndef LYNQ_QSER_SMS_H |
| 2 | #define LYNQ_QSER_SMS_H |
| 3 | #ifdef __cplusplus |
| 4 | extern "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 | |
| 19 | typedef unsigned short uint16_t; |
| 20 | typedef unsigned int uint32_t; |
| 21 | typedef 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 | |
| 32 | typedef 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 | |
| 43 | typedef 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 | |
| 50 | typedef 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 | |
| 58 | typedef 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 | |
| 65 | typedef 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 | |
| 72 | typedef 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 | |
| 89 | typedef struct |
| 90 | { |
| 91 | QSER_SMS_STORAGTYPT storage; |
| 92 | QSER_SMS_MODTYPT mode; |
| 93 | uint32_t storage_idx; |
| 94 | } QSER_sms_storage_info_t; |
| 95 | |
| 96 | typedef 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 | |
| 111 | typedef 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 | |
| 118 | typedef 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 | |
| 125 | typedef 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 | |
| 159 | typedef 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 | |
| 166 | typedef 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 | |
| 174 | typedef QSER_sms_info_t QSER_SMS_Msg_t; |
| 175 | typedef QSER_sms_info_t* QSER_SMS_MsgRef; |
| 176 | |
| 177 | /* Callback function registered to qser_sms_addrxmsghandler, msgRef contains the detail msg infor */ |
| 178 | typedef 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 */ |
| 181 | int qser_sms_client_init(sms_client_handle_type *ph_sms); |
| 182 | |
| 183 | /* Add callback function, if any new msg arrived, it will notify app */ |
| 184 | int 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 | */ |
| 189 | int 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. */ |
| 192 | int qser_sms_client_deinit(sms_client_handle_type h_sms); |
| 193 | |
| 194 | /* Delete the SMS specified in the pt_sms_storage */ |
b.liu | 8583dce | 2024-04-03 13:30:08 +0800 | [diff] [blame] | 195 | int qser_sms_deletefromstorage(sms_client_handle_type h_sms, QSER_sms_storage_info_t *pt_sms_storage); |
b.liu | 4e243dc | 2023-11-27 11:20:00 +0800 | [diff] [blame] | 196 | |
| 197 | /* Send sms PDU. |
| 198 | */ |
| 199 | int 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 | */ |
| 206 | int 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 | */ |
| 211 | int qser_sms_setsmscenteraddress( sms_client_handle_type h_sms, |
| 212 | QSER_sms_service_center_cfg_t *get_sca_cfg); |
| 213 | |
| 214 | /* |
| 215 | Usage 1 (register callback and wait for new sms arrive): |
| 216 | 1, qser_sms_client_init |
| 217 | 2, qser_sms_addrxmsghandler(pf_cb) |
| 218 | 3, wait for sms arrive, pf_cb will pass the detail sms info to app. |
| 219 | 4, qser_sms_client_deinit |
| 220 | |
| 221 | |
| 222 | Usage 2 (Send sms): |
| 223 | 1, qser_sms_client_init |
| 224 | 2, qser_sms_addrxmsghandler(pf_cb) |
| 225 | 3, qser_sms_send_sms |
| 226 | 4, qser_sms_client_deinit |
| 227 | |
| 228 | |
| 229 | Usage 3 (store sms): |
| 230 | 1, qser_sms_client_init |
| 231 | 2, qser_sms_addrxmsghandler(pf_cb) |
| 232 | 3, qser_sms_setroutelist (Notice: class-0 not allowed to store, class-2 must be stored to UIM) |
| 233 | 4, pf_cb will be called when new sms arrived, and tell you where the sms stored |
| 234 | 5, you can call qser_sms_deletefromstorage to delete specified sms, the location can be got from pf_cb. |
| 235 | 6, qser_sms_client_deinit |
| 236 | */ |
| 237 | |
| 238 | #ifdef __cplusplus |
| 239 | } |
| 240 | #endif |
| 241 | #endif |