Skip to content

Commit fda544a

Browse files
authored
Merge pull request #11566 from trowbridgec/add-default-connectivity-config-for-ep-agora
EP_AGORA: Add config logic to enable BLE, cell, and LoRa by default
2 parents f5b5989 + eb6a474 commit fda544a

File tree

5 files changed

+273
-3
lines changed

5 files changed

+273
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2006-2019 ARM Limited
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+
#if MBED_CONF_NSAPI_PRESENT
19+
20+
#if EP_AGORA_ENABLE_CELL
21+
22+
#include "cellular/onboard_modem_api.h"
23+
#include "UARTSerial.h"
24+
#include "ONBOARD_TELIT_ME910.h"
25+
#include "ThisThread.h"
26+
#include "CellularLog.h"
27+
28+
using namespace mbed;
29+
30+
ONBOARD_TELIT_ME910::ONBOARD_TELIT_ME910(FileHandle *fh) : TELIT_ME910(fh, PIN_NAME_CELL_ON_OFF, true)
31+
{
32+
}
33+
34+
nsapi_error_t ONBOARD_TELIT_ME910::hard_power_on()
35+
{
36+
::onboard_modem_init();
37+
return NSAPI_ERROR_OK;
38+
}
39+
40+
nsapi_error_t ONBOARD_TELIT_ME910::hard_power_off()
41+
{
42+
::onboard_modem_deinit();
43+
return NSAPI_ERROR_OK;
44+
}
45+
46+
nsapi_error_t ONBOARD_TELIT_ME910::soft_power_on()
47+
{
48+
::onboard_modem_power_up();
49+
// From Telit_xE910 Global form factor App note: It is mandatory to avoid sending data to the serial ports during the first 200ms of the module start-up.
50+
rtos::ThisThread::sleep_for(200);
51+
return NSAPI_ERROR_OK;
52+
}
53+
54+
nsapi_error_t ONBOARD_TELIT_ME910::soft_power_off()
55+
{
56+
::onboard_modem_power_down();
57+
return NSAPI_ERROR_OK;
58+
}
59+
60+
nsapi_error_t ONBOARD_TELIT_ME910::init()
61+
{
62+
nsapi_error_t err = AT_CellularDevice::init();
63+
if (err != NSAPI_ERROR_OK) {
64+
return err;
65+
}
66+
_at->lock();
67+
#if DEVICE_SERIAL_FC
68+
_at->at_cmd_discard("&K3;&C1;&D0", "");
69+
#else
70+
_at->at_cmd_discard("&K0;&C1;&D0", "");
71+
#endif
72+
73+
// AT#QSS=1
74+
// Enable the Query SIM Status unsolicited indication in the ME. The format of the
75+
// unsolicited indication is the following:
76+
// #QSS: <status>
77+
// The ME informs at
78+
// every SIM status change through the basic unsolicited indication where <status> range is 0...1
79+
// <status> values:
80+
// - 0: SIM not inserted
81+
// - 1: SIM inserted
82+
_at->at_cmd_discard("#QSS", "=1");
83+
84+
// AT#PSNT=1
85+
// Set command enables unsolicited result code for packet service network type (PSNT)
86+
// having the following format:
87+
// #PSNT:<nt>
88+
// <nt> values:
89+
// - 0: GPRS network
90+
// - 4: LTE network
91+
// - 5: unknown or not registered
92+
_at->at_cmd_discard("#PSNT", "=1");
93+
94+
// AT+CMER=2
95+
// Set command enables sending of unsolicited result codes from TA to TE in the case of
96+
// indicator state changes.
97+
// Current setting: buffer +CIEV Unsolicited Result Codes in the TA when TA-TE link is
98+
// reserved (e.g. on-line data mode) and flush them to the TE after
99+
// reservation; otherwise forward them directly to the TE
100+
_at->at_cmd_discard("+CMER", "=2");
101+
102+
// AT+CMEE=2
103+
// Set command disables the use of result code +CME ERROR: <err> as an indication of an
104+
// error relating to the +Cxxx command issued. When enabled, device related errors cause the +CME
105+
// ERROR: <err> final result code instead of the default ERROR final result code. ERROR is returned
106+
// normally when the error message is related to syntax, invalid parameters or DTE functionality.
107+
// Current setting: enable and use verbose <err> values
108+
_at->at_cmd_discard("+CMEE", "=2");
109+
110+
// AT#PORTCFG=0
111+
// Set command allows to connect Service Access Points to the external physical ports giving a great
112+
// flexibility. Examples of Service Access Points: AT Parser Instance #1, #2, #3, etc..
113+
_at->at_cmd_discard("#PORTCFG", "=3");
114+
115+
// AT&W&P
116+
// - AT&W: Execution command stores on profile <n> the complete configuration of the device. If
117+
// parameter is omitted, the command has the same behavior of AT&W0.
118+
// - AT&P: Execution command defines which full profile will be loaded at startup. If parameter
119+
// is omitted, the command has the same behavior as AT&P0
120+
_at->at_cmd_discard("&W&P", "");
121+
122+
return _at->unlock_return_error();
123+
}
124+
125+
CellularDevice *CellularDevice::get_target_default_instance()
126+
{
127+
static UARTSerial serial(MDMTXD, MDMRXD, 115200);
128+
#if DEVICE_SERIAL_FC
129+
if (MDMRTS != NC && MDMCTS != NC) {
130+
tr_debug("Modem flow control: RTS %d CTS %d", MDMRTS, MDMCTS);
131+
serial.set_flow_control(SerialBase::RTSCTS, MDMRTS, MDMCTS);
132+
}
133+
#endif
134+
static ONBOARD_TELIT_ME910 device(&serial);
135+
return &device;
136+
}
137+
138+
#endif // EP_AGORA_ENABLE_CELL
139+
140+
#endif // MBED_CONF_NSAPI_PRESENT
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2006-2019 ARM Limited
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+
#ifndef ONBOARD_TELIT_ME910_
19+
#define ONBOARD_TELIT_ME910_
20+
21+
#include "TELIT_ME910.h"
22+
23+
namespace mbed {
24+
25+
class ONBOARD_TELIT_ME910 : public TELIT_ME910 {
26+
public:
27+
ONBOARD_TELIT_ME910(FileHandle *fh);
28+
29+
virtual nsapi_error_t init();
30+
virtual nsapi_error_t hard_power_on();
31+
virtual nsapi_error_t hard_power_off();
32+
virtual nsapi_error_t soft_power_on();
33+
virtual nsapi_error_t soft_power_off();
34+
};
35+
36+
} // namespace mbed
37+
38+
#endif // ONBOARD_TELIT_ME910_
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "ep-agora",
3+
"config": {
4+
"enable-cell" : {
5+
"help" : "Enable the cell module on the EP_AGORA board",
6+
"macro_name" : "EP_AGORA_ENABLE_CELL",
7+
"value" : true
8+
}
9+
},
10+
"target_overrides": {
11+
"EP_AGORA": {
12+
"target.network-default-interface-type": "CELLULAR"
13+
}
14+
}
15+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2006-2019 ARM Limited
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+
#if MBED_CONF_NSAPI_PRESENT
19+
20+
#include "cellular/onboard_modem_api.h"
21+
#include "gpio_api.h"
22+
#include "platform/mbed_thread.h"
23+
#include "PinNames.h"
24+
25+
#if MODEM_ON_BOARD
26+
27+
static void press_power_button(int time_ms)
28+
{
29+
gpio_t gpio;
30+
31+
gpio_init_out_ex(&gpio, PIN_NAME_CELL_ON_OFF, 1);
32+
gpio_write(&gpio, 0);
33+
thread_sleep_for(time_ms);
34+
gpio_write(&gpio, 1);
35+
}
36+
37+
void onboard_modem_init()
38+
{
39+
gpio_t gpio;
40+
41+
gpio_init_out_ex(&gpio, PIN_NAME_CELL_POWER_ENABLE, 0);
42+
gpio_write(&gpio, 1);
43+
}
44+
45+
void onboard_modem_deinit()
46+
{
47+
gpio_t gpio;
48+
49+
gpio_init_out_ex(&gpio, PIN_NAME_CELL_POWER_ENABLE, 1);
50+
gpio_write(&gpio, 0);
51+
}
52+
53+
void onboard_modem_power_up()
54+
{
55+
/* keep the power line low for 5 seconds */
56+
press_power_button(5000);
57+
/* give modem a little time to respond */
58+
thread_sleep_for(20 * 1000);
59+
}
60+
61+
void onboard_modem_power_down()
62+
{
63+
gpio_t gpio;
64+
65+
gpio_init_out_ex(&gpio, PIN_NAME_CELL_ON_OFF, 0);
66+
/* keep the power line low for more than 3 seconds.
67+
* If 3G_ON_OFF pin is kept low for more than a second, a controlled disconnect and shutdown takes
68+
* place, Due to the network disconnect, shut-off can take up to 30 seconds. However, we wait for 10
69+
* seconds only */
70+
thread_sleep_for(10 * 1000);
71+
}
72+
#endif //MODEM_ON_BOARD
73+
#endif //MBED_CONF_NSAPI_PRESENT

targets/targets.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9338,18 +9338,22 @@
93389338
"config": {
93399339
"modem_is_on_board": {
93409340
"help": "Value: Tells the build system that the modem is on-board as oppose to a plug-in shield/module.",
9341-
"value": 0,
9341+
"value": 1,
93429342
"macro_name": "MODEM_ON_BOARD"
93439343
},
93449344
"modem_data_connection_type": {
93459345
"help": "Value: Defines how an on-board modem is wired up to the MCU, e.g., data connection can be a UART or USB and so forth.",
9346-
"value": 0,
9346+
"value": 1,
93479347
"macro_name": "MODEM_ON_BOARD_UART"
93489348
}
93499349
},
93509350
"components_add": ["SPIF"],
93519351
"components_remove": ["QSPIF"],
9352-
"release_versions": ["5"]
9352+
"release_versions": ["5"],
9353+
"macros_add": [
9354+
"CONFIG_GPIO_AS_PINRESET",
9355+
"NRF52_ERRATA_20"
9356+
]
93539357
},
93549358
"IM880B": {
93559359
"inherits": ["FAMILY_STM32"],

0 commit comments

Comments
 (0)