123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553 |
- /**
- @file
- ql_sms.h
- @brief
- This file provides the definitions for sms API functions.
- */
- /*============================================================================
- Copyright (c) 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved.
- Quectel Wireless Solution Proprietary and Confidential.
- =============================================================================*/
- /*===========================================================================
- EDIT HISTORY FOR MODULE
- This section contains comments describing changes made to the module.
- Notice that changes are listed in reverse chronological order.
- WHEN WHO WHAT, WHERE, WHY
- ---------- ------------ ----------------------------------------------------
- marvin create
- =============================================================================*/
- #ifndef QL_API_SMS_H
- #define QL_API_SMS_H
- #include <stdint.h>
- #include <stdbool.h>
- #include "sockets.h"
- #include "ql_api_common.h"
- #include "ql_api_osi.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- /*========================================================================
- * Marco Definition
- *========================================================================*/
- #define QL_SMS_LOG_LEVEL QL_LOG_LEVEL_INFO
- #define QL_SMS_LOG(msg, ...) QL_LOG_TAG(QL_LOG_LEVEL_INFO, QL_LOG_TAG_SMS, "ql_sms", msg, ##__VA_ARGS__)
- #define QL_SMS_MIN_LEN 1
- #define MAX_LONGSMS_SEGMENT 8
- #define MAX_SMS_LENGTH (160*4)
- #define SMS_BUF_LEN (MAX_SMS_LENGTH + 32)
- #define MAX_LONGSMS_LENGTH (160*4*MAX_LONGSMS_SEGMENT)
- #define QL_TEL_MAX_LEN 21
- #define QL_SMS_PDU_MAX_LEN 176
-
- /*========================================================================
- * Enumeration Definition
- *========================================================================*/
- typedef enum
- {
- QL_SMS_SUCCESS = 0,
- QL_SMS_ERROR = 1 | (QL_COMPONENT_SMS << 16),
- QL_SMS_NOT_INIT_ERR,
- QL_SMS_PARA_ERR,
- QL_SMS_NO_MEMORY_ERR,
- QL_SMS_SEM_CREATE_ERR,
- QL_SMS_SEM_TIMEOUT_ERR,
- QL_SMS_NO_MSG_ERR,
- }ql_sms_errcode_e;
- typedef enum
- {
- QL_SMS_INIT_OK_IND = 1| (QL_COMPONENT_SMS << 16),
- QL_SMS_NEW_MSG_IND,
- QL_SMS_LIST_IND,
- QL_SMS_LIST_END_IND,
- QL_SMS_LIST_EX_IND,
- QL_SMS_MEM_FULL_IND,
- QL_SMS_REPORT_IND,
- }ql_sms_event_id_e;
- typedef enum
- {
- ME = 1, //Mobile Equipment message storage
- SM = 2,//SIM message storage
- }ql_sms_stor_e;
- typedef enum
- {
- GSM = 0,
- UCS2 = 1,
- }ql_sms_code_e;
- typedef enum
- {
- PDU = 0,
- TEXT = 1
- }ql_sms_format_e;
- typedef enum
- {
- QL_SMS_UNREAD = 0,
- QL_SMS_READ = 1,
- QL_SMS_UNSENT = 2,
- QL_SMS_SENT = 3,
- QL_SMS_ALL,
- }ql_sms_status_e;
- typedef enum {
- QL_SMS_DEL_INDEX = 0, /* Delete the message specified in <index> */
- QL_SMS_DEL_RECV_READ, /* Delete all read messages from <mem1> storage */
- QL_SMS_DEL_RECV_READ_SENT, /* Delete all read messages from <mem1> storage and sent mobile originated messages */
- QL_SMS_DEL_RECV_READ_MO, /* Delete all read messages from <mem1> storage, sent and unsent mobile originated messages */
- QL_SMS_DEL_ALL, /* Delete all messages from <mem1> storage */
- QL_SMS_DEL_MODES_NUMS
- }QL_SMS_DELETE_MODE;
- typedef enum
- {
- QL_CS_GSM,
- QL_CS_IRA,
- QL_CS_UCS2,
- QL_CS_ALL,
- } ql_sms_cscs_e;
- /*========================================================================
- * Struct Definition
- *========================================================================*/
- typedef struct{
- uint8_t status;
- uint8_t index;
- char* buf;
- uint16_t buf_len;
- }ql_sms_msg_s;
-
- typedef struct{
- uint8_t index;
- uint8_t mem;
- }ql_sms_new_s;
- typedef struct
- {
- uint16_t usedSlotSM;
- uint16_t totalSlotSM;
- uint16_t unReadRecordsSM;
- uint16_t usedSlotME;
- uint16_t totalSlotME;
- uint16_t unReadRecordsME;
- ql_sms_stor_e newSmsStorId;
- }ql_sms_stor_info_s;
- typedef struct
- {
- ql_sms_stor_e mem1; //messages to be read and deleted from this memory storage.
- ql_sms_stor_e mem2; //messages will be written and sent to this memory storage.
- ql_sms_stor_e mem3; //received messages will be placed in this memory storage if routing to PC is not set.
- }ql_sms_mem_info_t;
- typedef struct
- {
- uint16_t uYear; //Only the last two digits
- uint8_t uMonth;
- uint8_t uDay;
- uint8_t uHour;
- uint8_t uMinute;
- uint8_t uSecond;
- int8_t iZone;
- }ql_sms_time_stamp_s;
-
- typedef struct
- {
- uint8_t index; //Index in storage
- char oa[QL_TEL_MAX_LEN*4+1];//Originating Address
- uint8_t tooa; //Type of originating Address
- ql_sms_time_stamp_s scts; //Service Centre Time Stamp
- ql_sms_status_e status;
- uint8_t fo; //First octet of PDU
- uint8_t dcs; //Data Coding Scheme
- uint16_t uid; //Message identification of a concatenated message
- uint8_t msg_seg; //Sequence number of a concatenated message
- uint8_t msg_total; //The total number of the segments of one concatenated message.
- uint16_t dataLen; //number of bytes
- uint8_t data[QL_SMS_PDU_MAX_LEN*2+1];
- }ql_sms_recv_s;
- typedef struct
- {
- bool srr; //Status Report Request
- uint8_t vp; //Validiy Period
- ql_sms_code_e code;
- uint8_t mr; //[out] Message Reference
- }ql_sms_cfg_s;
-
- typedef struct
- {
- uint8_t ra[TEL_NUMBER_MAX_LEN];
- uint8_t ra_size;
- uint8_t tora;
- uint8_t fo;
- uint8_t mr;
- uint8_t st;
- ql_sms_time_stamp_s scts;
- ql_sms_time_stamp_s dt;
- } ql_sms_report_s;
- /*========================================================================
- * Callback Definition
- *========================================================================*/
- typedef void (*ql_sms_event_handler_t)(uint8_t sim_id, int event_id, void *ctx);
- extern ql_sms_event_handler_t ql_sms_callback;
- /*========================================================================
- * function Definition
- *========================================================================*/
- /*****************************************************************
- * Function: ql_sms_send_msg
- *
- * Description:
- * 发送文本格式的短消息
- *
- * Parameters:
- * nSim [in] SIM卡索引,取值0-1。
- * phone_num [in] 目的手机号码。
- * data [in] 短消息数据。
- * code [in] 短消息发送时采用的格式,可取值GSM或者UCS2
- *
- * Return:ql_sms_errcode_e
- *
- *****************************************************************/
- ql_sms_errcode_e ql_sms_send_msg(uint8_t nSim, char *phone_num, char *data, ql_sms_code_e code);
- /*****************************************************************
- * Function: ql_sms_send_msg_ex
- *
- * Description:
- * 发送文本格式的短消息,可配置短信报告请求
- *
- * Parameters:
- * nSim [in] SIM卡索引,取值0-1。
- * phone_num [in] 目的手机号码。
- * data [in] 短消息数据。
- * cfg [in/out] 短消息发送时的配置,其中mr为[out]参数
- *
- * Return:ql_sms_errcode_e
- *
- *****************************************************************/
- ql_sms_errcode_e ql_sms_send_msg_ex(uint8_t nSim, char *phone_num, char *data, ql_sms_cfg_s *cfg);
- /*****************************************************************
- * Function: ql_sms_send_pdu
- *
- * Description:
- * 发送PDU格式的短消息
- *
- * Parameters:
- * nSim [in] SIM卡索引,取值0-1。
- * pdu [in] 短消息数据。
- *
- * Return:ql_sms_errcode_e
- *
- *****************************************************************/
- ql_sms_errcode_e ql_sms_send_pdu(uint8_t nSim, char *pdu);
- /*****************************************************************
- * Function: ql_sms_get_msg_list
- *
- * Description:
- * 获取短消息列表
- *
- * Parameters:
- * nSim [in] SIM卡索引,取值0-1。
- * format [in] PDU或者TEXT格式
- * Return:ql_sms_errcode_e
- *
- *****************************************************************/
- ql_sms_errcode_e ql_sms_read_msg_list(uint8_t nSim, ql_sms_format_e format);
- /*****************************************************************
- * Function: ql_sms_read_msg
- *
- * Description:
- * 文本方式读取单条短消息
- *
- * Parameters:
- * nSim [in] SIM卡索引,取值0-1。
- * index [in] 短信索引号。
- * buf [out] 用于接收短信内容,其基本组成形式为"<oa>,<scts>,<data>"。
- * buf_len [out] 数组长度。
- * format [in] 短信格式。文本或者PDU格式。
- *
- * Return:ql_sms_errcode_e
- *
- *****************************************************************/
- ql_sms_errcode_e ql_sms_read_msg(uint8_t nSim, uint8_t index, char *buf, uint16_t buf_len, ql_sms_format_e format);
- /*****************************************************************
- * Function: ql_sms_read_msg_ex
- *
- * Description:
- * 读取单条短消息
- *
- * Parameters:
- * nSim [in] SIM卡索引,取值0-1。
- * index [in] 短信索引号。
- * format [in] 短信格式。文本或者PDU格式。
- * msg [out] 参考ql_sms_recv_s结构体。
- * Return:ql_sms_errcode_e
- *
- *****************************************************************/
- ql_sms_errcode_e ql_sms_read_msg_ex(uint8_t nSim, uint8_t index, ql_sms_format_e format, ql_sms_recv_s *msg);
- /*****************************************************************
- * Function: ql_sms_delete_msg
- *
- * Description:
- * 删除单条消息
- *
- * Parameters:
- * nSim [in] SIM卡索引,取值0-1。
- * index [in] 短消息序列号。
- * Return:ql_sms_errcode_e
- *
- *****************************************************************/
- ql_sms_errcode_e ql_sms_delete_msg(uint8_t nSim, uint8_t index);
- /*****************************************************************
- * Function: ql_sms_delete_msg_ex
- *
- * Description:
- * 删除单条消息
- *
- * Parameters:
- * nSim [in] SIM卡索引,取值0-1。
- * index [in] 短消息序列号。
- * del_mode [in] QL_SMS_DELETE_MODE类型数据.
- * Return:ql_sms_errcode_e
- *
- *****************************************************************/
- ql_sms_errcode_e ql_sms_delete_msg_ex(uint8_t nSim, uint8_t index, QL_SMS_DELETE_MODE del_mode);
- /*****************************************************************
- * Function: ql_sms_get_center_address
- *
- * Description:
- * 获取短消息中心号码
- *
- * Parameters:
- * nSim [in] SIM卡索引,取值0-1。
- * address [out] 短消息中心号码。
- * len [in] 接收短消息中心号码的数组长度.
- *
- * Return:ql_sms_errcode_e
- *
- *****************************************************************/
- ql_sms_errcode_e ql_sms_get_center_address(uint8_t nSim, char* address, uint8_t len);
- /*****************************************************************
- * Function: ql_sms_set_center_address
- *
- * Description:
- * 设置短消息中心号码
- *
- * Parameters:
- * nSim [in] SIM卡索引,取值0-1。
- * address [in] 短消息中心号码。
- *
- * Return:ql_sms_errcode_e
- *
- *****************************************************************/
- ql_sms_errcode_e ql_sms_set_center_address(uint8_t nSim, char* address);
- /*****************************************************************
- * Function: ql_sms_get_storage_info
- *
- * Description:
- * 获取SM与ME的存储信息
- *
- * Parameters:
- * nSim [in] SIM卡索引,取值0-1。
- * stor_info [out] 用于保存短信存储信息的结构体。
- *
- * Return:ql_sms_errcode_e
- *
- *****************************************************************/
- ql_sms_errcode_e ql_sms_get_storage_info(uint8_t nSim, ql_sms_stor_info_s *stor_info);
- /*****************************************************************
- * Function: ql_sms_set_storage
- *
- * Description:
- * 设置短信存储位置
- *
- * Parameters:
- * nSim [in] SIM卡索引,取值0-1。
- * mem1 [in] 读取和删除消息所在内存空间。
- * mem2 [in] 写入和发送消息的内存空间。
- * mem3 [in] 接收消息的存储位置。
- *
- * Return:ql_sms_errcode_e
- *
- *****************************************************************/
- ql_sms_errcode_e ql_sms_set_storage(uint8_t nSim, ql_sms_stor_e mem1,ql_sms_stor_e mem2, ql_sms_stor_e mem3);
- /*****************************************************************
- * Function: ql_sms_get_storage
- *
- * Description:
- * 获取短信存储位置
- *
- * Parameters:
- * nSim [in] SIM卡索引,取值0-1。
- * mem_info [in] 见ql_sms_mem_info_t结构体。
- *
- * Return:ql_sms_errcode_e
- *
- *****************************************************************/
- ql_sms_errcode_e ql_sms_get_storage(uint8_t nSim, ql_sms_mem_info_t *mem_info);
- /*****************************************************************
- * Function: ql_sms_set_code_mode
- *
- * Description:
- * 设置字符编码
- *
- * Parameters:
- * cscs [in] 字符编码,参考ql_sms_cscs_e联合体。
- * Return:ql_sms_errcode_e
- *
- *****************************************************************/
- ql_sms_errcode_e ql_sms_set_code_mode(ql_sms_cscs_e cscs);
- /*****************************************************************
- * Function: ql_sms_get_code_mode
- *
- * Description:
- * 获取字符编码
- *
- * Parameters:
- * cscs [out] 返回当前字符编码。
- * Return:ql_sms_errcode_e
- *
- *****************************************************************/
- ql_sms_errcode_e ql_sms_get_code_mode(ql_sms_cscs_e* cscs);
- /*****************************************************************
- * Function: ql_sms_set_retry_count
- *
- * Description:
- * 用于设置smc层与smr层短消息发送失败后的重试次数
- *
- * Parameters:
- * nSim [in] SIM卡索引,取值0-1。
- * smc_count [in] smc层重试次数,取值0-2。
- * smr_count [in] smr层重试次数,取值0-2。
- *
- * Return:ql_sms_errcode_e
- *
- *****************************************************************/
- ql_sms_errcode_e ql_sms_set_retry_count(uint8_t nSim, uint8_t smc_count, uint8_t smr_count);
- /*****************************************************************
- * Function: ql_sms_get_ignore_cscs
- *
- * Description:
- * 用于获取在读取短信时, 当短信的编码为8bit或者16bit时,是否忽略CSCS值。
- *
- * Parameters:
- * nSim [in] SIM卡索引,取值0-1。
- * enable [out] 是否忽略cscs值。
- *
- * Return:ql_sms_errcode_e
- *
- *****************************************************************/
- ql_sms_errcode_e ql_sms_get_ignore_cscs(uint8_t nSim, bool *enable);
- /*****************************************************************
- * Function: ql_sms_set_ignore_cscs
- *
- * Description:
- * 用于设置在读取短信时, 当短信的编码为8bit或者16bit时,是否忽略CSCS值。
- *
- * Parameters:
- * nSim [in] SIM卡索引,取值0-1。
- * enable [in] 是否忽略cscs值。
- *
- * Return:ql_sms_errcode_e
- *
- *****************************************************************/
- ql_sms_errcode_e ql_sms_set_ignore_cscs(uint8_t nSim, bool enable);
- /*****************************************************************
- * Function: ql_sms_get_storage_info
- *
- * Description:
- * 获取短信模块初始化状态
- *
- * Parameters:
- * nSim [in] SIM卡索引,取值0-1。
- * status [out] 短信初始化状态
- *
- * Return:ql_sms_errcode_e
- *
- *****************************************************************/
- ql_sms_errcode_e ql_sms_get_init_status(uint8_t nSim, uint8_t *status);
- /*****************************************************************
- * Function: ql_sms_get_storage_info
- *
- * Description:
- * 注册短信回调函数
- *
- * Parameters:
- * cb [in] 回调函数
- *
- * Return:ql_sms_errcode_e
- *
- *****************************************************************/
- void ql_sms_callback_register(ql_sms_event_handler_t cb);
- #ifdef __cplusplus
- }/*"C" */
- #endif
- #endif /*QL_API_SMS_H*/
|