liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 1 | /** |
| 2 | *@file ql_sms.h |
| 3 | *@date 2017-05-02 |
| 4 | *@author |
| 5 | *@brief |
| 6 | */ |
| 7 | |
| 8 | #ifndef __QL_SMS_H__ |
| 9 | #define __QL_SMS_H__ |
| 10 | |
| 11 | #include "mbtk_type.h" |
| 12 | |
| 13 | typedef uint32 sms_client_handle_type; |
| 14 | |
| 15 | /** Maximum length of an SMS. */ |
| 16 | #define QL_SMS_MAX_MT_MSG_LENGTH 1440 |
| 17 | |
| 18 | /** Maximum string length. */ |
| 19 | #define QL_SMS_MAX_ADDR_LENGTH 252 |
| 20 | |
| 21 | /** Maximum string length. */ |
| 22 | #define QL_SMS_MAX_SCA_TYPE_LENGTH 3 |
| 23 | |
| 24 | |
| 25 | typedef enum |
| 26 | { |
| 27 | E_QL_SMS_FORMAT_GSM_7BIT = 0, |
| 28 | E_QL_SMS_FORMAT_BINARY_DATA = 1, |
| 29 | E_QL_SMS_FORMAT_UCS2 = 2, |
| 30 | //<2017/12/28-QCM9XOL00004C001-P01-Vicent.Gao, <[SMS] Segment 1==> CharSet to Alpha implementation.> |
| 31 | E_QL_SMS_FORMAT_IRA = 3, |
| 32 | //>2017/12/28-QCM9XOL00004C001-P01-Vicent.Gao |
| 33 | |
| 34 | }E_QL_SMS_FORMAT_T; |
| 35 | |
| 36 | typedef enum |
| 37 | { |
| 38 | E_QL_SMS_TYPE_RX = 0, ///< SMS mobile terminated message. |
| 39 | E_QL_SMS_TYPE_TX = 1, ///< SMS mobile originated message. |
| 40 | E_QL_SMS_TYPE_BROADCAST_RX = 2 ///< SMS Cell Broadcast message. |
| 41 | }E_QL_SMS_TYPE_T; |
| 42 | |
| 43 | typedef enum |
| 44 | { |
| 45 | E_QL_SMS_STORAGE_TYPE_NONE = -1, /**< Message no need to store. */ |
| 46 | E_QL_SMS_STORAGE_TYPE_UIM = 0, /**< Message store to UIM. */ |
| 47 | E_QL_SMS_STORAGE_TYPE_NV = 1, /**< Message store to NV. */ |
| 48 | }E_QL_SMS_STORAGE_TYPE_T; |
| 49 | |
| 50 | typedef enum |
| 51 | { |
| 52 | E_QL_SMS_MESSAGE_MODE_UNKNOWN = -1, /**< Message type CDMA */ |
| 53 | E_QL_SMS_MESSAGE_MODE_CDMA = 0, /**< Message type CDMA */ |
| 54 | E_QL_SMS_MESSAGE_MODE_GW = 1, /**< Message type GW. */ |
| 55 | }E_QL_SMS_MODE_TYPE_T; |
| 56 | |
| 57 | typedef struct |
| 58 | { |
| 59 | uint8_t total_segments; /**< The number of long short message*/ |
| 60 | uint8_t seg_number; /**< Current number.*/ |
| 61 | uint8_t reference_number; /**< reference_number.*/ |
| 62 | }ql_sms_user_data_head_t; |
| 63 | |
| 64 | typedef struct |
| 65 | { |
| 66 | /* If sms is stored, it won't parse, you need read it by yourself */ |
| 67 | E_QL_SMS_STORAGE_TYPE_T e_storage; ///specify where stored this msg |
| 68 | |
| 69 | E_QL_SMS_FORMAT_T format; |
| 70 | E_QL_SMS_TYPE_T type; |
| 71 | char sms_number_addr[QL_SMS_MAX_ADDR_LENGTH]; ///Telephone number string |
| 72 | char sca_number_addr[QL_SMS_MAX_ADDR_LENGTH]; //.SMS Center Number |
| 73 | int sms_data_len; |
| 74 | char sms_data[QL_SMS_MAX_MT_MSG_LENGTH]; ///SMS content, data format depends on format |
| 75 | char timestamp[21]; ///Message time stamp (in text mode). string format: "yy/MM/dd,hh:mm:ss+/-TimeZone" |
| 76 | uint8_t user_data_head_valid; //indicate whether long sms. TRUE-long sms; FALSE-short message; |
| 77 | ql_sms_user_data_head_t user_data_head; //long sms user data head info. |
| 78 | E_QL_SMS_MODE_TYPE_T e_mode; ///specify where stored this msg cdma or gw area |
| 79 | uint32_t storage_index; ///storage index, -1 means not store |
| 80 | } ql_sms_info_t; |
| 81 | |
| 82 | |
| 83 | typedef struct |
| 84 | { |
| 85 | E_QL_SMS_STORAGE_TYPE_T e_storage; |
| 86 | E_QL_SMS_MODE_TYPE_T e_mode; |
| 87 | uint32_t storage_idx; |
| 88 | } ql_sms_storage_info_t; |
| 89 | |
| 90 | /* 0 = "REC UNREAD" */ |
| 91 | /* 1 = "REC READ" */ |
| 92 | /* 2 = "STO UNSENT" */ |
| 93 | /* 3 = "STO SENT" */ |
| 94 | typedef enum _ql_SMS_SIM_STATUS |
| 95 | { |
| 96 | REC_UNREAD = 0, |
| 97 | REC_READ = 1, |
| 98 | STO_UNSENT = 2, |
| 99 | STO_SENT = 3 |
| 100 | }ql_SMS_SIM_STATUS; |
| 101 | |
| 102 | typedef enum |
| 103 | { |
| 104 | E_QL_SMS_MESSAGE_CLASS_0 = 0x00, //display only |
| 105 | E_QL_SMS_MESSAGE_CLASS_1 = 0x01, //store in ME |
| 106 | E_QL_SMS_MESSAGE_CLASS_2 = 0x02, //store in SIM |
| 107 | E_QL_SMS_MESSAGE_CLASS_3 = 0x03, // |
| 108 | E_QL_SMS_MESSAGE_CLASS_NONE = 0x04, |
| 109 | E_QL_SMS_MESSAGE_CLASS_CDMA = 0x05, |
| 110 | E_QL_SMS_MESSAGE_CLASS_MAX = 0x06, |
| 111 | }E_QL_SMS_MESSAGE_CLASS_TYPE_T; |
| 112 | |
| 113 | typedef enum |
| 114 | { |
| 115 | E_QL_SMS_UNKNOWN = -1, |
| 116 | E_QL_SMS_DISCARD = 0x00, /* Incoming messages for this route are discarded by the WMS service without |
| 117 | notifying QMI_WMS clients */ |
| 118 | E_QL_SMS_STORE_AND_NOTIFY = 0x01, /* Incoming messages for this route are stored to the specified device |
| 119 | memory, and new message notifications */ |
| 120 | E_QL_SMS_TRANSFER_ONLY = 0x02, /* Incoming messages for this route are transferred to the client, and the |
| 121 | client is expected to send ACK to the network */ |
| 122 | E_QL_SMS_TRANSFER_AND_ACK = 0x03, /* Incoming messages for this route are transferred to the client, and ACK is |
| 123 | sent to the network */ |
| 124 | }E_QL_SMS_RECEPTION_ACTION_TYPE_T; |
| 125 | |
| 126 | typedef struct |
| 127 | { |
| 128 | E_QL_SMS_MESSAGE_CLASS_TYPE_T message_class; |
| 129 | E_QL_SMS_STORAGE_TYPE_T route_storage; |
| 130 | E_QL_SMS_RECEPTION_ACTION_TYPE_T receipt_action; |
| 131 | }ql_sms_route_info_t; /* Type */ |
| 132 | |
| 133 | typedef struct |
| 134 | { |
| 135 | ql_sms_route_info_t route_list[E_QL_SMS_MESSAGE_CLASS_MAX]; |
| 136 | }ql_sms_route_info_list_t; /* Message */ |
| 137 | |
| 138 | #define QL_WMS_MESSAGE_LENGTH_MAX 255 |
| 139 | |
| 140 | typedef enum |
| 141 | { |
| 142 | E_QL_WMS_MESSAGE_FORMAT_CDMA = 0x00, //- 0x00 -- MESSAGE_FORMAT_CDMA -- CDMA \n |
| 143 | E_QL_WMS_MESSAGE_FORMAT_GW_PP = 0x06, //- 0x06 -- MESSAGE_FORMAT_GW_PP -- GW_PP |
| 144 | }E_QL_WMS_MESSAGE_FORMAT_TYPE; |
| 145 | |
| 146 | |
| 147 | typedef struct |
| 148 | { |
| 149 | E_QL_WMS_MESSAGE_FORMAT_TYPE format; |
| 150 | uint32_t raw_message_len; /**< Must be set to # of elements in raw_message */ |
| 151 | uint8_t raw_message[QL_WMS_MESSAGE_LENGTH_MAX]; /**< Raw message data*/ |
| 152 | }ql_wms_send_raw_message_data_t; |
| 153 | |
| 154 | |
| 155 | typedef enum |
| 156 | { |
| 157 | E_QL_WMS_TL_CAUSE_CODE_ADDR_VACANT = 0x00, |
| 158 | E_QL_WMS_TL_CAUSE_CODE_ADDR_TRANSLATION_FAILURE = 0x01, |
| 159 | E_QL_WMS_TL_CAUSE_CODE_NETWORK_RESOURCE_SHORTAGE = 0x02, |
| 160 | E_QL_WMS_TL_CAUSE_CODE_NETWORK_FAILURE = 0x03, |
| 161 | E_QL_WMS_TL_CAUSE_CODE_INVALID_TELESERVICE_ID = 0x04, |
| 162 | E_QL_WMS_TL_CAUSE_CODE_NETWORK_OTHER = 0x05, |
| 163 | E_QL_WMS_TL_CAUSE_CODE_NO_PAGE_RESPONSE = 0x20, |
| 164 | E_QL_WMS_TL_CAUSE_CODE_DEST_BUSY = 0x21, |
| 165 | E_QL_WMS_TL_CAUSE_CODE_NO_ACK = 0x22, |
| 166 | E_QL_WMS_TL_CAUSE_CODE_DEST_RESOURCE_SHORTAGE = 0x23, |
| 167 | E_QL_WMS_TL_CAUSE_CODE_SMS_DELIVERY_POSTPONED = 0x24, |
| 168 | E_QL_WMS_TL_CAUSE_CODE_DEST_OUT_OF_SERV = 0x25, |
| 169 | E_QL_WMS_TL_CAUSE_CODE_DEST_NOT_AT_ADDR = 0x26, |
| 170 | E_QL_WMS_TL_CAUSE_CODE_DEST_OTHER = 0x27, |
| 171 | E_QL_WMS_TL_CAUSE_CODE_RADIO_IF_RESOURCE_SHORTAGE = 0x40, |
| 172 | E_QL_WMS_TL_CAUSE_CODE_RADIO_IF_INCOMPATABILITY = 0x41, |
| 173 | E_QL_WMS_TL_CAUSE_CODE_RADIO_IF_OTHER = 0x42, |
| 174 | E_QL_WMS_TL_CAUSE_CODE_ENCODING = 0x60, |
| 175 | E_QL_WMS_TL_CAUSE_CODE_SMS_ORIG_DENIED = 0x61, |
| 176 | E_QL_WMS_TL_CAUSE_CODE_SMS_TERM_DENIED = 0x62, |
| 177 | E_QL_WMS_TL_CAUSE_CODE_SUPP_SERV_NOT_SUPP = 0x63, |
| 178 | E_QL_WMS_TL_CAUSE_CODE_SMS_NOT_SUPP = 0x64, |
| 179 | E_QL_WMS_TL_CAUSE_CODE_MISSING_EXPECTED_PARAM = 0x65, |
| 180 | E_QL_WMS_TL_CAUSE_CODE_MISSING_MAND_PARAM = 0x66, |
| 181 | E_QL_WMS_TL_CAUSE_CODE_UNRECOGNIZED_PARAM_VAL = 0x67, |
| 182 | E_QL_WMS_TL_CAUSE_CODE_UNEXPECTED_PARAM_VAL = 0x68, |
| 183 | E_QL_WMS_TL_CAUSE_CODE_USER_DATA_SIZE_ERR = 0x69, |
| 184 | E_QL_WMS_TL_CAUSE_CODE_GENERAL_OTHER = 0x6A, |
| 185 | }E_QL_WMS_TL_CAUSE_CODE_TYPE; |
| 186 | |
| 187 | typedef struct |
| 188 | { |
| 189 | uint16_t message_id; /* Message ID */ |
| 190 | uint8_t cause_code_valid; /**< Must be set to true if cause_code is being passed */ |
| 191 | E_QL_WMS_TL_CAUSE_CODE_TYPE cause_code; |
| 192 | }ql_wms_raw_send_resp_t; |
| 193 | |
| 194 | typedef struct |
| 195 | { |
| 196 | char service_center_addr[QL_SMS_MAX_ADDR_LENGTH + 1]; /**< Address of the service center.*/ |
| 197 | uint8_t service_center_addr_type_valid; |
| 198 | char service_center_addr_type[QL_SMS_MAX_SCA_TYPE_LENGTH + 1]; /**< 129 if the SMSC address does not start with a "+" characte; |
| 199 | 145 if the SMSC address starts with a "+" character*/ |
| 200 | }ql_sms_service_center_cfg_t; |
| 201 | |
| 202 | typedef ql_sms_info_t QL_SMS_Msg_t; |
| 203 | typedef ql_sms_info_t* QL_SMS_MsgRef; |
| 204 | |
| 205 | /* Callback function registered to QL_SMS_AddRxMsgHandler, msgRef contains the detail msg infor */ |
| 206 | typedef void (*QL_SMS_RxMsgHandlerFunc_t) |
| 207 | ( |
| 208 | QL_SMS_MsgRef msgRef, |
| 209 | void* contextPtr |
| 210 | ); |
| 211 | |
| 212 | /* Init SMS module and return h_sms, this should be called before any othe ones */ |
| 213 | int QL_SMS_Client_Init(sms_client_handle_type *ph_sms); |
| 214 | |
| 215 | /* Add callback function, if any new msg arrived, it will notify app */ |
| 216 | int QL_SMS_AddRxMsgHandler(QL_SMS_RxMsgHandlerFunc_t handlerPtr, void* contextPtr); |
| 217 | |
| 218 | /* Send sms, you just need to fill format/src_addr/sms_data_len/sms_data, |
| 219 | if format is UCS2, the data should be Unicode-BE format. |
| 220 | */ |
| 221 | int QL_SMS_Send_Sms(sms_client_handle_type h_sms, ql_sms_info_t *pt_sms_info); |
| 222 | |
| 223 | /* DeInit SMS module and release resource, this should be called in the last one. */ |
| 224 | int QL_SMS_Client_Deinit(sms_client_handle_type h_sms); |
| 225 | |
| 226 | /* Delete the SMS specified in the pt_sms_storage */ |
| 227 | int QL_SMS_DeleteFromStorage(sms_client_handle_type h_sms, ql_sms_storage_info_t *pt_sms_storage); |
| 228 | |
| 229 | /* Set route list, normally, sms won't be stored, the route set to transfer_and_ack by default. |
| 230 | If you want to save to storage, you can specify it with this api. |
| 231 | */ |
| 232 | int QL_SMS_SetRouteList(sms_client_handle_type h_sms, ql_sms_route_info_list_t *pt_route_list); |
| 233 | |
| 234 | /* Send sms PDU. |
| 235 | */ |
| 236 | int QL_SMS_Send_SmsPdu( sms_client_handle_type h_sms, |
| 237 | ql_wms_send_raw_message_data_t *raw_message_data, |
| 238 | ql_wms_raw_send_resp_t *rawresp); |
| 239 | |
| 240 | int QL_SMS_Get_By_id(ql_sms_storage_info_t *pt_sms_storage); |
| 241 | |
| 242 | /* Get sms center address. |
| 243 | */ |
| 244 | int QL_SMS_GetSmsCenterAddress( sms_client_handle_type h_sms, |
| 245 | ql_sms_service_center_cfg_t *set_sca_cfg); |
| 246 | |
| 247 | /* Set sms center address. |
| 248 | */ |
| 249 | int QL_SMS_SetSmsCenterAddress( sms_client_handle_type h_sms, |
| 250 | ql_sms_service_center_cfg_t *get_sca_cfg); |
| 251 | |
| 252 | int QL_SMS_Get_Storage(sms_client_handle_type *ph_sms); |
| 253 | |
| 254 | int QL_SMS_Save_Sms(sms_client_handle_type h_sms, ql_sms_info_t *pt_sms_info); |
| 255 | |
| 256 | int QL_SMS_Delete_Sms(sms_client_handle_type h_sms, ql_sms_info_t *pt_sms_info); |
| 257 | /* |
| 258 | Usage 1 (register callback and wait for new sms arrive): |
| 259 | 1, QL_SMS_Client_Init |
| 260 | 2, QL_SMS_AddRxMsgHandler(pf_cb) |
| 261 | 3, wait for sms arrive, pf_cb will pass the detail sms info to app. |
| 262 | 4, QL_SMS_Client_Deinit |
| 263 | |
| 264 | |
| 265 | Usage 2 (Send sms): |
| 266 | 1, QL_SMS_Client_Init |
| 267 | 2, QL_SMS_AddRxMsgHandler(pf_cb) |
| 268 | 3, QL_SMS_Send_Sms |
| 269 | 4, QL_SMS_Client_Deinit |
| 270 | |
| 271 | |
| 272 | Usage 3 (store sms): |
| 273 | 1, QL_SMS_Client_Init |
| 274 | 2, QL_SMS_AddRxMsgHandler(pf_cb) |
| 275 | 3, QL_SMS_SetRouteList (Notice: class-0 not allowed to store, class-2 must be stored to UIM) |
| 276 | 4, pf_cb will be called when new sms arrived, and tell you where the sms stored |
| 277 | 5, you can call QL_SMS_DeleteFromStorage to delete specified sms, the location can be got from pf_cb. |
| 278 | 6, QL_SMS_Client_Deinit |
| 279 | */ |
| 280 | |
| 281 | #endif // __QL_SMS_H__ |
| 282 | |