1
+ /*
2
+ * Copyright (c) 2017, Arm Limited and affiliates.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ #include " TELIT_ME910.h"
19
+ #include " AT_CellularNetwork.h"
20
+ #include " mbed-trace/mbed_trace.h"
21
+ #include " gpio_api.h"
22
+ #include " platform/mbed_wait_api.h"
23
+ #include " PinNames.h"
24
+ #include " mbed.h"
25
+
26
+ #define TRACE_GROUP " ME91"
27
+
28
+ using namespace mbed ;
29
+ using namespace events ;
30
+
31
+ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
32
+ AT_CellularNetwork::RegistrationModeLAC, // C_EREG
33
+ AT_CellularNetwork::RegistrationModeLAC, // C_GREG
34
+ AT_CellularNetwork::RegistrationModeLAC, // C_REG
35
+ 0 , // AT_CGSN_WITH_TYPE
36
+ 0 , // AT_CGDATA
37
+ 1 , // AT_CGAUTH
38
+ 1 , // AT_CNMI
39
+ 1 , // AT_CSMP
40
+ 1 , // AT_CMGF
41
+ 1 , // AT_CSDH
42
+ 1 , // PROPERTY_IPV4_STACK
43
+ 1 , // PROPERTY_IPV6_STACK
44
+ 1 , // PROPERTY_IPV4V6_STACK
45
+ 0 , // PROPERTY_NON_IP_PDP_TYPE
46
+ 1 , // PROPERTY_AT_CGEREP
47
+ };
48
+
49
+ TELIT_ME910::TELIT_ME910 (FileHandle *fh) : AT_CellularDevice(fh)
50
+ {
51
+ AT_CellularBase::set_cellular_properties (cellular_properties);
52
+ }
53
+
54
+ uint16_t TELIT_ME910::get_send_delay () const
55
+ {
56
+ return DEFAULT_DELAY_BETWEEN_AT_COMMANDS;
57
+ }
58
+
59
+ nsapi_error_t TELIT_ME910::init ()
60
+ {
61
+ nsapi_error_t err = AT_CellularDevice::init ();
62
+ if (err != NSAPI_ERROR_OK) {
63
+ return err;
64
+ }
65
+ _at->lock ();
66
+ #if defined (MBED_CONF_TELIT_ME910_RTS) && defined (MBED_CONF_TELIT_ME910_CTS)
67
+ _at->cmd_start (" AT&K3;&C1;&D0" );
68
+ #else
69
+ _at->cmd_start (" AT&K0;&C1;&D0" );
70
+ #endif
71
+ _at->cmd_stop_read_resp ();
72
+
73
+ return _at->unlock_return_error ();
74
+ }
75
+
76
+ #if MBED_CONF_TELIT_ME910_PROVIDE_DEFAULT
77
+ #include " UARTSerial.h"
78
+ CellularDevice *CellularDevice::get_default_instance ()
79
+ {
80
+ static UARTSerial serial (MBED_CONF_TELIT_ME910_TX, MBED_CONF_TELIT_ME910_RX, MBED_CONF_TELIT_ME910_BAUDRATE);
81
+ #if defined (MBED_CONF_TELIT_ME910_RTS) && defined (MBED_CONF_TELIT_ME910_CTS)
82
+ tr_debug (" TELIT_ME910 flow control: RTS %d CTS %d" , MBED_CONF_TELIT_ME910_RTS, MBED_CONF_TELIT_ME910_CTS);
83
+ serial.set_flow_control (SerialBase::RTSCTS, MBED_CONF_TELIT_ME910_RTS, MBED_CONF_TELIT_ME910_CTS);
84
+ #endif
85
+ static TELIT_ME910 device (&serial);
86
+ return &device;
87
+ }
88
+ #endif
89
+
90
+ nsapi_error_t TELIT_ME910::hard_power_on ()
91
+ {
92
+ return AT_CellularDevice::hard_power_on ();
93
+ }
94
+
95
+ nsapi_error_t TELIT_ME910::hard_power_off ()
96
+ {
97
+ return AT_CellularDevice::hard_power_off ();
98
+ }
99
+
100
+ nsapi_error_t TELIT_ME910::soft_power_on ()
101
+ {
102
+ return AT_CellularDevice::soft_power_on ();
103
+ }
104
+
105
+ nsapi_error_t TELIT_ME910::soft_power_off ()
106
+ {
107
+ return AT_CellularDevice::soft_power_off ();
108
+ }
0 commit comments