-
Notifications
You must be signed in to change notification settings - Fork 3
/
ME310_AT_Test.ino
252 lines (211 loc) · 7.7 KB
/
ME310_AT_Test.ino
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
/*Copyright (C) 2020 Telit Communications S.p.A. Italy - All Rights Reserved.*/
/* See LICENSE file in the project root for full license information. */
/**
@file
ME310.cpp
string.h
stdio.h
@brief
Driver Library for ME310 Telit Modem
@details
The library contains a single class that implements a C++ interface to all ME310 AT Commands.
It makes it easy to build Arduino applications that use the full power of ME310 module
@version
1.0.0
@note
@author
BlackIoT Sagl
@date
28/10/2020
*/
#include <ME310.h>
#ifndef ARDUINO_TELIT_SAMD_CHARLIE
#define ON_OFF 6 /*Select the GPIO to control ON_OFF*/
#endif
using namespace me310;
/*
* If a Telit-Board Charlie is not in use, the ME310 class needs the Uart Serial instance in the constructor, that will be used to communicate with the modem.\n
* Please refer to your board configuration in variant.h file.
* Example:
* Uart Serial1(&sercom4, PIN_MODULE_RX, PIN_MODULE_TX, PAD_MODULE_RX, PAD_MODULE_TX, PIN_MODULE_RTS, PIN_MODULE_CTS);
* ME310 myME310 (Serial1);
*/
ME310 myME310;
ME310::return_t rc; //Enum of return value methods
void print_buffer(ME310 &aME310, const char *term = "OK");
void setup() {
pinMode(ON_OFF, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(115200);
myME310.begin(115200);
delay(1000);
Serial.println("SERCOMM Telit Test AT");
myME310.powerOn();
Serial.println("ME310 ON");
Serial.println();
Serial.println("AT Command");
ME310::return_t rc = myME310.attention(); // issue command and wait for answer or timeout
Serial.println(myME310.buffer_cstr()); // print first line of modem answer
Serial.print(ME310::return_string(rc)); // print return value
Serial.println(" answer from ME310 MODULE");
if(rc != ME310::RETURN_VALID) // exit on error
return;
Serial.println();
Serial.print("Soft Reset Command : ");
rc = myME310.soft_reset (); // issue command and wait for answer or timeout
Serial.println(ME310::return_string(rc)); // print return value
if(rc != ME310::RETURN_VALID) // exit on error
return;
Serial.println();
Serial.println("Display Config Profile : ");
rc = myME310.display_config_profile(); // issue command and wait for answer or timeout
if(rc == ME310::RETURN_VALID) // print all rows returned from ME310 except command echo (index = 0)
print_buffer(myME310);
else return; // exit on error
Serial.println();
Serial.print("Query SIM Status : ");
myME310.query_sim_status();
Serial.println(myME310.buffer_cstr(1));
Serial.println();
Serial.println("Read Query SIM Status : ");
rc = myME310.read_query_sim_status();
if(rc == ME310::RETURN_VALID) // print all rows returned from ME310 except command echo (index = 0)
{
Serial.println(myME310.buffer_cstr(1));
char *resp = (char* )myME310.buffer_cstr(1);
if(resp != NULL)
{
if(strstr(resp,"#QSS: 0,1"))
{
Serial.println("SIM is inserted");
rc = myME310.read_enter_pin();
if(rc == ME310::RETURN_VALID) // print all rows returned from ME310 except command echo (index = 0)
{
resp = (char*) myME310.buffer_cstr(1);
if(resp != NULL)
{
if(strstr(resp,"READY"))
Serial.println("PIN not required");
else
Serial.println("PIN required");
}
}
else return;
Serial.println();
Serial.print("Print ICCID : ");
rc = myME310.read_iccid();
if(rc == ME310::RETURN_VALID)
{
resp = (char*) myME310.buffer_cstr(1);
if(resp != NULL)
{
const char *pLabel = strstr(resp,"+CCID: ");
if(pLabel)
{
Serial.print("[");
Serial.write(pLabel+7,19);
Serial.println("]");
}
}
}
else return;
Serial.print("Print IMSI : ");
rc = myME310.imsi(); // no command echo
if(rc == ME310::RETURN_VALID)
Serial.println(myME310.buffer_cstr(1));
else return;
Serial.println();
Serial.println("List Capabilities : ");
rc = myME310.capabilities_list();
if(rc == ME310::RETURN_VALID) // print all rows returned from ME310 except command echo (index = 0)
Serial.println(myME310.buffer_cstr(1));
else return;
}
else
Serial.println("SIM not inserted");
}
}
else return; // exit on error
Serial.println();
Serial.print("Manufacturer Identification : ");
rc = myME310.manufacturer_identification();
if(rc == ME310::RETURN_VALID)
Serial.println(myME310.buffer_cstr(1));
else return;
Serial.print("Model Identification : ");
rc = myME310.model_identification();
if(rc == ME310::RETURN_VALID)
Serial.println(myME310.buffer_cstr(1));
else return;
Serial.print("Revision Identification : ");
rc = myME310.revision_identification();
if(rc == ME310::RETURN_VALID)
Serial.println(myME310.buffer_cstr(1));
else return;
Serial.print("Serial Number : ");
rc = myME310.serial_number();
if(rc == ME310::RETURN_VALID)
Serial.println(myME310.buffer_cstr(1));
else return;
Serial.print("Request Manufacturer Ident. : ");
rc = myME310.request_manufacturer_identification();
if(rc == ME310::RETURN_VALID)
Serial.println(myME310.buffer_cstr(1));
else return;
Serial.print("Request Model Ident. : ");
rc = myME310.request_model_identification();
if(rc == ME310::RETURN_VALID)
Serial.println(myME310.buffer_cstr(1));
else return;
Serial.print("Request Revision Ident. : ");
rc = myME310.request_revision_identification();
if(rc == ME310::RETURN_VALID)
Serial.println(myME310.buffer_cstr(1));
else return;
Serial.print("Product Serial Number : ");
rc = myME310.request_psn_identification();
if(rc == ME310::RETURN_VALID)
Serial.println(myME310.buffer_cstr(1));
else return;
Serial.print("Product Code : ");
rc = myME310.request_product_code();
if(rc == ME310::RETURN_VALID)
Serial.println(myME310.buffer_cstr(1));
else return;
Serial.println();
Serial.println("Software Package Version : ");
rc = myME310.request_software_package_version();
if(rc == ME310::RETURN_VALID)
print_buffer(myME310);
else return;
}
void loop() {
Serial.println();
Serial.println("Transparent Bridge Started");
while(1){
while (SerialModule.available()) {
Serial.write(SerialModule.read());
}
while (Serial.available()) {
SerialModule.write(Serial.read());
}
}
}
void print_buffer(ME310 &aME310, const char *term)
{
for(int index = 1;;index++)
{
const char * tmp = aME310.buffer_cstr(index);
if(tmp)
{
if(term)
{
if(strcmp(tmp,term))
Serial.println(tmp); // print if not null
else
break;
}
}
else break; // exit loop if null
}
}