blob: cf5c872ba34c6d38359d3bbc4757e0e2c9266f89 [file] [log] [blame]
liubin281ac462023-07-19 14:22:54 +08001/*****************************************************************************
2 * Copyright Statement:
3 * --------------------
4 * This software is protected by Copyright and the information contained
5 * herein is confidential. The software may not be copied and the information
6 * contained herein may not be used or disclosed except with the written
7 * permission of Quectel Co., Ltd. 2016
8 *
9 *****************************************************************************/
10/*****************************************************************************
11 *
12 * Filename:
13 * ---------
14 * ql_sms.h
15 *
16 * Project:
17 * --------
18 * OpenLinux
19 *
20 * Description:
21 * ------------
22 * API definition for SMS.
23 *
24 *============================================================================
25 * HISTORY
26 *----------------------------------------------------------------------------
27 * WHO WHEN WHAT
28 *----------------------------------------------------------------------------
29 * Pony.ma 19/09/2019 Create
30 ****************************************************************************/
31
32#ifndef __QL_SMS_H__
33#define __QL_SMS_H__
34
35#include <stdlib.h>
36#include <stdint.h>
37#include <string.h>
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42#define MAX_ADDR_LEN 24
43#define FALSE 0
44#define TRUE 1
45
46#define QL_SMS_MIN_LEN 1
47#define MAX_LONGSMS_SEGMENT 8
48#define MAX_SMS_LENGTH (160*4)
49#define SMS_BUF_LEN (MAX_SMS_LENGTH + 32)
50#define MAX_LONGSMS_LENGTH (160*4*MAX_LONGSMS_SEGMENT)
51#define CI_MAX_COUNT_SMS_OF_SIM 50
52
53
54typedef unsigned char UINT8;
55typedef unsigned short UINT16;
56typedef unsigned int UINT32;
57
58typedef enum{
59 QL_SMS_SUCCESS,
60 QL_SMS_GENERIC_FAILURE,
61 QL_SMS_PRAR_ERROR,
62 QL_GET_RESPONSE_ERROR,
63}QL_SMS_ERROR_CODE;
64
65typedef enum
66{
67 QL_SMS_RECV_EVENT = 0, /**< SMS come event. */
68 QL_SMS_RECV_INDEX_EVENT, /**< SMS come event for index. */
69}QL_SMS_NFY_MSG_ID;
70
71typedef enum
72{
73 QL_SMS_MODE_GSM = 0, //GSM
74 QL_SMS_MODE_UCS2 //UCS2
75}QL_SMS_CODE_MODE;
76
77typedef struct
78{
79 char number[32];
80 char body[280]; // 姣忔潯鏀跺埌鐨勭煭淇¢暱搴︽渶澶т负280
81 char time[32];
82 int body_len;
83 QL_SMS_CODE_MODE code_mode;
84 char *pdu_str;
85}QL_SMS_STATUS_INFO;
86
87typedef struct
88{
89 int item;
90 char *name;
91}ql_sms_item;
92
93typedef void (*QL_SMS_StatusIndMsgHandlerFunc_t)
94 (
95 QL_SMS_NFY_MSG_ID msg_id,
96 void *pv_data,
97 int pv_data_len,
98 void *contextPtr
99 );
100
101typedef enum{
102 QL_SMS_ClientInit = 0,
103 QL_SMS_ClientRelease,
104 //QL_SMS_SendSMS,
105 QL_SMS_DeleteSMS,
106 QL_SMS_SearchSMSTextMessage,
107 QL_SMS_SearchSMSPduMessage,
108 QL_SMS_AddSMSEventHandler,
109 QL_SMS_GetSMSCenterAddress,
110 QL_SMS_SetSMSCenterAddress,
111 QL_SMS_SetSaveLocation,
112 QL_SMS_GetSaveLocation,
113 QL_SMS_SetSMSNotSave,
114 QL_SMS_SetSMSMsgMode,
115 QL_SMS_GetSMSMsgMode,
116 QL_SMS_SetSMSCodeMode,
117 QL_SMS_GetSMSCodeMode,
118 QL_SMS_SetSMSReceiveDealmode,
119 QL_SMS_SendTextSMS,
120 QL_SMS_SendPduSMS,
121 QL_SMS_GetSimNum,
122 QL_SMS_GetIndex,
123 QL_SMS_OptionMax,
124}QL_SMS_OPTION;
125
126typedef struct
127{
128 char mem[5];
129 int cur_num; //current sms numbers
130 int max_nums; //Maximum number of messages that can be stored
131}sms_mem_t;
132
133typedef struct
134{
135 sms_mem_t mem1; //messages to be read and deleted from this memory storage.
136 sms_mem_t mem2; //messages will be written and sent to this memory storage.
137 sms_mem_t mem3; //received messages will be placed in this memory storage if routing to PC is not set.
138}ql_sms_mem_info_t;
139
140typedef struct recvmessage_struct{
141 char num[32];
142 char buf[400];
143 int buflen;
144}recvmessage;
145typedef struct{
146 int storage_index; // 存贮索引
147} ql_sms_recv_index_event_t;
148
149
150typedef struct{
151 int sms_index[CI_MAX_COUNT_SMS_OF_SIM];
152 int count;
153} ql_auto_sms_index;
154
155
156
157
158/* init sms client */
159QL_SMS_ERROR_CODE ql_sms_init();
160/* deinit sms clint */
161QL_SMS_ERROR_CODE ql_sms_release();
162/* send message api */
163//QL_SMS_ERROR_CODE ql_sms_send_msg(uint8_t *destNum,uint8_t *data,size_t dataLen,int sms_type);
164/* get smsc api */
165QL_SMS_ERROR_CODE ql_sms_get_sms_center_address(uint8_t *sms_center_addree);
166/* register sms event header api*/
167QL_SMS_ERROR_CODE ql_sms_add_event_handler(QL_SMS_StatusIndMsgHandlerFunc_t handlerPtr, void* contextPtr);
168/* set smsc api */
169QL_SMS_ERROR_CODE ql_sms_set_sms_center_address(unsigned char *destNum);
170/* delete message api */
171QL_SMS_ERROR_CODE ql_sms_delete_msg(size_t index);
172/* set sms storage api */
173QL_SMS_ERROR_CODE ql_sms_set_sms_pref_storage(size_t location);
174/* set sms not storage api */
175QL_SMS_ERROR_CODE ql_sms_set_sms_desave();
176QL_SMS_ERROR_CODE ql_set_sms_msg_mode(int messagemode);
177QL_SMS_ERROR_CODE ql_get_sms_msg_mode(int *messagemode);
178QL_SMS_ERROR_CODE ql_set_sms_code_mode(char* codemode);
179QL_SMS_ERROR_CODE ql_get_sms_code_mode(char *codemode);
180QL_SMS_ERROR_CODE ql_sms_get_sms_pref_storage(ql_sms_mem_info_t *mem_info);
181//QL_SMS_ERROR_CODE ql_search_sms_message(int index, recvmessage* payload);
182QL_SMS_ERROR_CODE ql_search_sms_text_message(int index, recvmessage* payload);
183QL_SMS_ERROR_CODE ql_search_sms_pdu_message(int index, recvmessage* payload);
184QL_SMS_ERROR_CODE ql_set_sms_recive_dealmode(int dealmode);
185QL_SMS_ERROR_CODE ql_sms_send_pdu_msg(uint8_t *phone_num,uint8_t *data,int sms_type);
186QL_SMS_ERROR_CODE ql_sms_send_text_msg(uint8_t *phone_num,uint8_t *data,int sms_type);
187QL_SMS_ERROR_CODE ql_sms_get_sim_num(uint8_t *sim_num);
188QL_SMS_ERROR_CODE ql_get_sms_index( int *sms_msg_info_ptr,int *smsnum);
189QL_SMS_ERROR_CODE ql_sms_list_sms(int stat, int index, char *data);
190
191#ifdef __cplusplus
192}
193#endif
194
195#endif
196