-
Notifications
You must be signed in to change notification settings - Fork 1
/
gsm_settings.h
291 lines (260 loc) · 8.84 KB
/
gsm_settings.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
/**
******************************************************************************
*
* @file gsm_settings.h
* @author Lonewolf
* @brief GSM Settings and Strings
* @see The GNU Public License (GPL) Version 3
*
*****************************************************************************/
#ifndef GSM_SETTINGS_H_
#define GSM_SETTINGS_H_
#include "settings.h"
/* Final Result Codes and Unsolicited Responses */
const uint8_t frc1[] PROGMEM = "+CME ERROR:";
const uint8_t frc2[] PROGMEM = "+CMS ERROR:";
const uint8_t frc3[] PROGMEM = "OK";
const uint8_t frc4[] PROGMEM = "ERROR";
/* Hardware Configuration */
#define GSM_PWR_DDR DDRB
#define GSM_BAUD 115200
#define GSM_PWR_PORT PORTB
#define GSM_PWRKEY (1 << 1)
enum frc_codes
{
EMPTY = 0,
CME,
CMS,
OK
};
enum gsm_operations
{
GSM_OP_NONE = 1,
GSM_OP_SMS,
GSM_OP_NETWORK,
GSM_OP_ACC,
GSM_OP_GPRS
};
PROGMEM const char READY [] = "Call Ready";
PROGMEM const char ATE_0[] = "ATE0\r\n";
PROGMEM const char AT_IPR_115200[] = "AT+IPR=115200";
PROGMEM const char AT_IPR_19200[] = "AT+IPR=19200";
PROGMEM const char CREG [] = "AT+CREG?\r\n";
PROGMEM const char _CREG0[] = "+CREG: 0,0";
PROGMEM const char _CREG1[] = "+CREG: 0,1";
PROGMEM const char _CREG2[] = "+CREG: 0,2";
PROGMEM const char _CREG3[] = "+CREG: 0,3";
PROGMEM const char _CREG5[] = "+CREG: 0,5";
PROGMEM const char CNMI[] = "AT+CNMI=2,1\r\n";
PROGMEM const char CMGS[] = "AT+CMGS=\"";
PROGMEM const char _CMGS[] = "+CMGS";
PROGMEM const char _CMGS1[] = "+CMGS:";
PROGMEM const char _CMGR_UN[] = "+CMGR: \"REC UNREAD\"";
PROGMEM const char _CMGR_READ[] = "+CMGR: \"REC READ\"";
PROGMEM const char _CMGR1[] = "+CMGR:";
PROGMEM const char _CMGL1[] = "+CMGL:";
PROGMEM const char CMGF[] = "AT+CMGF=1\r\n";
PROGMEM const char CPMS[] = "AT+CPMS=\"SM\",\"SM\",\"SM\"\r\n";
PROGMEM const char _CPMS[] = "+CPMS";
PROGMEM const char CPMS_REQ[] = "AT+CPMS?";
PROGMEM const char CMGL_UNREAD[] = "AT+CMGL=\"REC UNREAD\"";
PROGMEM const char CMGL_READ[] = "AT+CMGL=\"REC READ\"";
PROGMEM const char CMGL_ALL[] = "AT+CMGL=\"ALL\"";
PROGMEM const char _CMGL[] = "+CMGL:";
PROGMEM const char CMGR[] = "AT+CMGR=";
PROGMEM const char _CMGR[] = "+CMGR";
PROGMEM const char ERROR[] = "ERROR";
PROGMEM const char UNREAD[] = "\"REC UNREAD\"";
PROGMEM const char READ[] = "\"REC READ\"";
PROGMEM const char CMGD[] = "AT+CMGD=";
PROGMEM const char CMGDA[] = "AT+CMGDA=\"DEL ALL\"\r\n";
PROGMEM const char CCLK[] = "AT+CCLK=";
PROGMEM const char CCLK_REQ[] = "AT+CCLK?\r\n";
PROGMEM const char _CCLK[] = "+CCLK";
PROGMEM const char CGATT[] = "AT+CGATT=1\r\n";
PROGMEM const char _CGATT0[] = "+CGATT: 0";
PROGMEM const char _CGATT1[] = "+CGATT: 1";
PROGMEM const char CSTT[] = "AT+CSTT=";
PROGMEM const char _CSTT[] = "AT+CSTT\r\n";
PROGMEM const char CIICR[] = "AT+CIICR\r\n";
PROGMEM const char CIFSR[] = "AT+CIFSR\r\n";
PROGMEM const char CIPSTART[] = "AT+CIPSTART=";
PROGMEM const char CIPSEND[] = "AT+CIPSEND\r\n";
PROGMEM const char CIPSHUT[] = "AT+CIPSHUT\r\n";
PROGMEM const char CIPCLOSE[] = "AT+CIPCLOSE\r\n";
PROGMEM const char _CONN_OK[] = "CONNECT OK";
PROGMEM const char _SHUT_OK[] = "SHUT OK";
PROGMEM const char _SEND_OK[] = "SEND OK";
PROGMEM const char _CLOSE_OK[] = "CLOSE OK";
PROGMEM const char CIPSTATUS[] = "AT+CIPSTATUS\r\n";
PROGMEM const char _S_INI[] = "STATE: IP INITIAL";
PROGMEM const char _S_STAR[] = "STATE: IP START";
PROGMEM const char _S_GPRS[] = "STATE: IP GPRSACT";
PROGMEM const char _S_STAT[] = "STATE: IP STATUS";
PROGMEM const char _CO_FAIL[] = "CONNECT FAIL";
PROGMEM const char _S_PDP[] = "STATE: PDP DEACT";
PROGMEM const char _S_CONF[] = "STATE: IP CONFIG";
PROGMEM const char _S_TCLOS[] = "STATE: TCP CLOSED";
PROGMEM const char _OK[] = "OK";
PROGMEM const char _CMTI[] = "+CMTI:";
PROGMEM const char _CMS[] = "+CMS ERROR:";
PROGMEM const char _CME[] = "+CME ERROR:";
PROGMEM const char _PR[] = "> ";
PROGMEM const char Newline[] = "\r\n";
#if 0
enum gsm_driver_messages
{
GSM_MSG_NONE = 1,
// general
GSM_MSG_OK,
//GSM_MSG_AT,
//GSM_MSG_ATE0,
GSM_MSG_ERROR,
GSM_MSG_ERROR_NETWORK_IS_DOWN,
GSM_MSG_ERROR_OPERATION_FAILURE,
GSM_MSG_ERROR_SIMCARD_NOT_INSERTED,
GSM_MSG_ERROR_SIMCARD_PIN_DENNY,
GSM_MSG_ERROR_SMS_IX_NOT_ALLOWED,
// pin
GSM_MSG_PIN_READY,
GSM_MSG_PIN_SIM,
GSM_MSG_PIN_SIM_2,
GSM_MSG_PIN_PUK,
GSM_MSG_PIN_PUK_2,
/* CREG -- NETWORK REGISTRATION */
GSM_MSG_CREG_NEWTWORK_SEARCHING_IN_IDLE,
GSM_MSG_CREG_NETWORK_READY_LOCAL,
GSM_MSG_CREG_SEARCHING_NETWORK,
GSM_MSG_CREG_NETWORK_ACCESS_DENIED,
GSM_MSG_CREG_NETWORK_READY_ROAMING,
// SISI : service (socket) status
GSM_MSG_SOCKET_UP,
GSM_MSG_SOCKET_DOWN,
GSM_MSG_NO_SOCKET_OPERATION,
GSM_MSG_SOCKET_CONNECTING,
GSM_MSG_SOCKET_CLOSING,
//
GSM_CLOCK_READ,
//GSM_MSG_DATA_STREAM,
SMS_UNREAD,
SMS_READ,
SMS_ALL,
GSM_MSG_SCID_INFO,
GSM_MSG_SMS_PROMPT,
GSM_MSG_SMS_QUEUED,
GSM_MSG_BAD_SMS_MESSAGE,
GSM_MSG_SMS_REC_READ,
GSM_MSG_SMS_REC_UNREAD,
GSM_MSG_SMS_UNKOWN_MESAGE,
GSM_MSG_SMS_NO_MESAGE,
GSM_MSG_SMS_LIST,
GSM_MSG_SOCKET_NOT_READY,
GSM_MSG_DATA_TRANSFER_STATUS,
//GSM_MSG_GPRS_CONNECTED_STATUS_READY,
GSM_MSG_GPRS_CONNECTED_STATUS_NOT_READY,
GSM_MSG_GPRS_DEATTACHED,
GSM_MSG_SIGNAL_LEVEL,
GSM_MSG_HW_TEMPERATURE,
GSM_MSG_GPRS_STATUS,
GSM_MSG_ERROR_GPTS_NOT_ALLOWED,
GSM_MSG_CONTEXT_STATUS,
GSM_MSG_APP_PAYLOAD_AVAILABLE,
//
// gsm internal state machine
// power
GSM_MSG_POWER_DOWN_REQUEST_ACKNOWLOGED,
GSM_MSG_POWER_DOWN_PROCESSING,
GSM_MSG_POWER_ON_DONE,
GSM_MSG_SIMCARD_INITIALIZNG_IN_PROCESS,
GSM_MSG_SIMCARD_INITIALIZNG_DONE,
GSM_MSG_NETWORK_CONNECTION_STATUS_READY,
GSM_MSG_NETWORK_CONNECTION_STATUS_NOT_CONNECTED,
GSM_MSG_NETWORK_NOT_ATTACHED,
GSM_MSG_NETWORK_ATTACHED
};
#endif
typedef struct final_result_codes_t
{
uint8_t *p_string;
uint8_t event_id;
} final_result_codes;
struct at_response_code
{
const char *p_string;
uint8_t event_id;
uint8_t message_id;
};
struct at_response_code frc_table[] =
{
_OK, EVENT_GSM_ACK_RESPONSE, GSM_MSG_OK,
_CMTI, EVENT_GSM_SMS_RECIEVE_URC, 0,
_CMS, EVENT_GSM_ERROR_RESPONSE, GSM_MSG_ERROR,
_CME, EVENT_GSM_ERROR_RESPONSE, GSM_MSG_ERROR,
ERROR, EVENT_GSM_ERROR_RESPONSE, GSM_MSG_ERROR,
// array terminator !!!
0, 0, 0
};
struct at_response_code sms_table[] =
{
_PR, EVENT_GSM_SMS_RESPONSE, GSM_MSG_SMS_PROMPT,
_CMGS1, EVENT_GSM_SMS_RESPONSE, GSM_MSG_SMS_QUEUED,
_CMGR_UN, EVENT_GSM_SMS_RESPONSE, GSM_MSG_SMS_REC_UNREAD,
_CMGR_READ, EVENT_GSM_SMS_RESPONSE, GSM_MSG_SMS_REC_READ,
_CMGR1, EVENT_GSM_SMS_RESPONSE, GSM_MSG_SMS_UNKOWN_MESAGE,
_CMGL1, EVENT_GSM_SMS_RESPONSE, GSM_MSG_SMS_LIST,
// array terminator !!!
(char *) 0, 0, 0
};
/* To accomodate those which donot have a closing \r\n */
struct at_response_code special_table[] =
{
_PR, EVENT_GSM_SMS_RESPONSE, GSM_MSG_SMS_PROMPT
};
/* 160 bytes of string */
struct at_response_code gprs_table[] =
{
_PR, EVENT_GSM_GPRS_RESPONSE, GSM_GPRS_PROMPT,
_CONN_OK, EVENT_GSM_GPRS_RESPONSE, GSM_GPRS_CONNECT,
_SHUT_OK, EVENT_GSM_GPRS_RESPONSE, GSM_GPRS_CLOSE,
_SEND_OK, EVENT_GSM_GPRS_RESPONSE, GSM_GPRS_SEND_ACK,
_CLOSE_OK, EVENT_GSM_GPRS_RESPONSE, GSM_GPRS_CLOSED,
_S_INI, EVENT_GSM_GPRS_STATUS_RESPONSE, GSM_GPRS_STATUS_INITIAL,
_S_STAR, EVENT_GSM_GPRS_STATUS_RESPONSE, GSM_GPRS_STATUS_START,
_S_GPRS, EVENT_GSM_GPRS_STATUS_RESPONSE, GSM_GPRS_STATUS_GPRSACT,
_S_STAT, EVENT_GSM_GPRS_STATUS_RESPONSE, GSM_GPRS_STATUS_STATUS,
_CO_FAIL, EVENT_GSM_GPRS_STATUS_RESPONSE, GSM_GPRS_CONNECT_ERROR,
_S_PDP, EVENT_GSM_GPRS_STATUS_RESPONSE, GSM_GPRS_CLOSED,
_S_CONF, EVENT_GSM_GPRS_STATUS_RESPONSE, GSM_GPRS_STATUS_STATUS,
_S_TCLOS, EVENT_GSM_GPRS_STATUS_RESPONSE, GSM_GPRS_TCP_CLOSED,
// array terminator !!!
(char *) 0, 0, 0
};
struct at_response_code acc_table[] =
{
_CCLK, EVENT_GSM_CLOCK_RESPONSE, GSM_CLOCK_READ,
// array terminator !!!
(char *) 0, 0, 0
};
struct at_response_code network_table[] =
{
_CREG0, EVENT_GSM_NETWORK_RESPONSE, GSM_MSG_CREG_NEWTWORK_SEARCHING_IN_IDLE,
_CREG1, EVENT_GSM_NETWORK_RESPONSE, GSM_MSG_CREG_NETWORK_READY_LOCAL,
_CREG2, EVENT_GSM_NETWORK_RESPONSE, GSM_MSG_CREG_SEARCHING_NETWORK,
_CREG3, EVENT_GSM_NETWORK_RESPONSE, GSM_MSG_CREG_NETWORK_ACCESS_DENIED,
_CREG5, EVENT_GSM_NETWORK_RESPONSE, GSM_MSG_CREG_NETWORK_READY_ROAMING,
_CGATT0, EVENT_GSM_NETWORK_RESPONSE, GSM_MSG_NETWORK_NOT_ATTACHED,
_CGATT1, EVENT_GSM_NETWORK_RESPONSE, GSM_MSG_NETWORK_ATTACHED,
// array terminator !!!
(char *) 0, 0, 0
};
const uint8_t *module_init_table[] =
{
(uint8_t *)ATE_0,
/* SMS Related */
(uint8_t *) CNMI,
(uint8_t *) CMGF,
(uint8_t *) CPMS,
(uint8_t *) CMGDA,
(uint8_t *)""
};
#endif /* gsm_settings.h */