16
16
*/
17
17
18
18
#include " TELIT_ME910.h"
19
+ #include " TELIT_ME910_CellularContext.h"
19
20
#include " AT_CellularNetwork.h"
20
- #include " gpio_api .h"
21
- #include " platform/mbed_wait_api .h"
21
+ #include " PinNames .h"
22
+ #include " rtos/ThisThread .h"
22
23
23
24
using namespace mbed ;
25
+ using namespace rtos ;
24
26
using namespace events ;
25
27
28
+ #if !defined(MBED_CONF_TELIT_ME910_PWR)
29
+ #define MBED_CONF_TELIT_ME910_PWR NC
30
+ #endif
31
+
32
+ #if !defined(MBED_CONF_TELIT_ME910_TX)
33
+ #define MBED_CONF_TELIT_ME910_TX NC
34
+ #endif
35
+
36
+ #if !defined(MBED_CONF_TELIT_ME910_RX)
37
+ #define MBED_CONF_TELIT_ME910_RX NC
38
+ #endif
39
+
40
+ #if !defined(MBED_CONF_TELIT_ME910_POLARITY)
41
+ #define MBED_CONF_TELIT_ME910_POLARITY 1 // active high
42
+ #endif
43
+
26
44
static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
27
45
AT_CellularNetwork::RegistrationModeLAC, // C_EREG
28
46
AT_CellularNetwork::RegistrationModeLAC, // C_GREG
@@ -41,11 +59,20 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
41
59
1 , // PROPERTY_AT_CGEREP
42
60
};
43
61
44
- TELIT_ME910::TELIT_ME910 (FileHandle *fh) : AT_CellularDevice(fh)
62
+ TELIT_ME910::TELIT_ME910 (FileHandle *fh, PinName pwr, bool active_high)
63
+ : AT_CellularDevice(fh),
64
+ _active_high(active_high),
65
+ _pwr_key(pwr, !_active_high)
45
66
{
46
67
AT_CellularBase::set_cellular_properties (cellular_properties);
47
68
}
48
69
70
+ AT_CellularContext *TELIT_ME910::create_context_impl (ATHandler &at, const char *apn, bool cp_req, bool nonip_req)
71
+ {
72
+ return new TELIT_ME910_CellularContext (at, this , apn, cp_req, nonip_req);
73
+ }
74
+
75
+
49
76
uint16_t TELIT_ME910::get_send_delay () const
50
77
{
51
78
return DEFAULT_DELAY_BETWEEN_AT_COMMANDS;
@@ -65,6 +92,99 @@ nsapi_error_t TELIT_ME910::init()
65
92
#endif
66
93
_at->cmd_stop_read_resp ();
67
94
95
+ // AT#QSS=1
96
+ // Enable the Query SIM Status unsolicited indication in the ME. The format of the
97
+ // unsolicited indication is the following:
98
+ // #QSS: <status>
99
+ // The ME informs at
100
+ // every SIM status change through the basic unsolicited indication where <status> range is 0...1
101
+ // <status> values:
102
+ // - 0: SIM not inserted
103
+ // - 1: SIM inserted
104
+ _at->cmd_start (" AT#QSS=1" );
105
+ _at->cmd_stop_read_resp ();
106
+
107
+ // AT#PSNT=1
108
+ // Set command enables unsolicited result code for packet service network type (PSNT)
109
+ // having the following format:
110
+ // #PSNT:<nt>
111
+ // <nt> values:
112
+ // - 0: GPRS network
113
+ // - 4: LTE network
114
+ // - 5: unknown or not registered
115
+ _at->cmd_start (" AT#PSNT=1" );
116
+ _at->cmd_stop_read_resp ();
117
+
118
+ // AT+CGEREP=2
119
+ // Set command enables sending of unsolicited result codes in case of certain events
120
+ // occurring in the module or in the network.
121
+ // Current setting: buffer unsolicited result codes in the TA when TA-TE link is reserved (e.g.
122
+ // in on-line data mode) and flush them to the TE when TA-TE link becomes
123
+ // available; otherwise forward them directly to the TE.
124
+ _at->cmd_start (" AT+CGEREP=2" );
125
+ _at->cmd_stop_read_resp ();
126
+
127
+ // AT+CMER=2
128
+ // Set command enables sending of unsolicited result codes from TA to TE in the case of
129
+ // indicator state changes.
130
+ // Current setting: buffer +CIEV Unsolicited Result Codes in the TA when TA-TE link is
131
+ // reserved (e.g. on-line data mode) and flush them to the TE after
132
+ // reservation; otherwise forward them directly to the TE
133
+ _at->cmd_start (" AT+CMER=2" );
134
+ _at->cmd_stop_read_resp ();
135
+
136
+ // AT+CREG=1
137
+ // Set command enables the network registration unsolicited result code and selects one of
138
+ // the two available formats:
139
+ // short format: +CREG: <stat>
140
+ // long format: +CREG: <stat>[,<lac>,<ci>[,<AcT>]]
141
+ // Current setting: enable the network registration unsolicited result code, and selects the
142
+ // short format
143
+ _at->cmd_start (" AT+CREG=1" );
144
+ _at->cmd_stop_read_resp ();
145
+
146
+ // AT+CGREG=1
147
+ // Set command enables/disables the +CGREG: unsolicited result code, and selects one of the
148
+ // available formats:
149
+ // short format:
150
+ // +CGREG:<stat>
151
+ // long format:
152
+ // +CGREG:<stat>[,<lac>,<ci>[,<AcT>,<rac>]]
153
+ // extra long format:
154
+ // +CGREG:<stat>[,[<lac>],[<ci>],[<AcT>],[<rac>][,,[,[<ActiveTime>],[<PeriodicRAU>],[<GPRSREADYtimer>]]]]
155
+ // Current setting: enable the network registration unsolicited result code, and selects the
156
+ // short format
157
+ _at->cmd_start (" AT+CGREG=1" );
158
+ _at->cmd_stop_read_resp ();
159
+
160
+ // AT+CEREG=1
161
+ // Set command enables the EPS network registration unsolicited result code (URC) in LTE,
162
+ // and selects one of the available formats:
163
+ // short format: +CEREG: <stat>
164
+ // long format: +CEREG: <stat>[,[<tac>],[<ci>],[<AcT>]]
165
+ // <tac>, <ci>, and <AcT> are reported by the command only if available.
166
+ // Current setting: enable the network registration unsolicited result code, and select the short
167
+ // format
168
+ _at->cmd_start (" AT+CEREG=1" );
169
+ _at->cmd_stop_read_resp ();
170
+
171
+ // AT+CMEE=2
172
+ // Set command disables the use of result code +CME ERROR: <err> as an indication of an
173
+ // error relating to the +Cxxx command issued. When enabled, device related errors cause the +CME
174
+ // ERROR: <err> final result code instead of the default ERROR final result code. ERROR is returned
175
+ // normally when the error message is related to syntax, invalid parameters or DTE functionality.
176
+ // Current setting: enable and use verbose <err> values
177
+ _at->cmd_start (" AT+CMEE=2" );
178
+ _at->cmd_stop_read_resp ();
179
+
180
+ // AT&W&P
181
+ // - AT&W: Execution command stores on profile <n> the complete configuration of the device. If
182
+ // parameter is omitted, the command has the same behavior of AT&W0.
183
+ // - AT&P: Execution command defines which full profile will be loaded at startup. If parameter
184
+ // is omitted, the command has the same behavior as AT&P0
185
+ _at->cmd_start (" AT&W&P" );
186
+ _at->cmd_stop_read_resp ();
187
+
68
188
return _at->unlock_return_error ();
69
189
}
70
190
@@ -76,7 +196,9 @@ CellularDevice *CellularDevice::get_default_instance()
76
196
#if defined (MBED_CONF_TELIT_ME910_RTS) && defined (MBED_CONF_TELIT_ME910_CTS)
77
197
serial.set_flow_control (SerialBase::RTSCTS, MBED_CONF_TELIT_ME910_RTS, MBED_CONF_TELIT_ME910_CTS);
78
198
#endif
79
- static TELIT_ME910 device (&serial);
199
+ static TELIT_ME910 device (&serial,
200
+ MBED_CONF_TELIT_ME910_PWR,
201
+ MBED_CONF_TELIT_ME910_POLARITY);
80
202
return &device;
81
203
}
82
204
#endif
@@ -90,28 +212,20 @@ nsapi_error_t TELIT_ME910::hard_power_on()
90
212
91
213
nsapi_error_t TELIT_ME910::soft_power_on ()
92
214
{
93
- gpio_t gpio;
94
-
95
- gpio_init_out_ex (&gpio, MDMPWRON, 1 );
96
- wait_ms (500 );
97
- gpio_write (&gpio, 0 );
98
- wait_ms (5000 );
99
- gpio_write (&gpio, 1 );
100
- wait_ms (5000 );
215
+ _pwr_key = _active_high;
216
+ ThisThread::sleep_for (500 );
217
+ _pwr_key = !_active_high;
218
+ ThisThread::sleep_for (5000 );
219
+ _pwr_key = _active_high;
220
+ ThisThread::sleep_for (5000 );
101
221
102
222
return NSAPI_ERROR_OK;
103
223
}
104
224
105
225
nsapi_error_t TELIT_ME910::hard_power_off ()
106
226
{
107
- gpio_t gpio;
108
-
109
- gpio_init_out_ex (&gpio, MDMPWRON, 0 );
110
- /* keep the power line low for more than 10 seconds.
111
- * If 3G_ON_OFF pin is kept low for more than a second, a controlled disconnect and shutdown takes
112
- * place, Due to the network disconnect, shut-off can take up to 30 seconds. However, we wait for 10
113
- * seconds only */
114
- wait_ms (10 * 1000 );
227
+ _pwr_key = !_active_high;
228
+ ThisThread::sleep_for (10000 );
115
229
116
230
return NSAPI_ERROR_OK;
117
231
}
0 commit comments