Skip to content

Commit 6d04b8a

Browse files
author
Ari Parkkila
authored
Merge pull request #85 from AriParkkila/merge-mbed-os-5.9.0
Merge mbed os 5.9.0
2 parents b79c43c + 455a3b4 commit 6d04b8a

File tree

4 files changed

+44
-32
lines changed

4 files changed

+44
-32
lines changed

README.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,10 @@ You can choose which socket type the application should use; however, please not
6161

6262
### Turning modem AT echo trace on
6363

64-
If you like details and wish to know about all the AT interactions between the modem and your driver, turn on the modem AT echo trace. Set the `modem_trace` field value to be true.
64+
If you like details and wish to know about all the AT interactions between the modem and your driver, turn on the modem AT echo trace.
6565

6666
```json
67-
"modem_trace": {
68-
"help": "Turns AT command trace on/off from the cellular modem, defaults to off",
69-
"value": true
70-
},
67+
"cellular.debug-at": true
7168
```
7269

7370
### Turning on the tracing and trace level
@@ -76,8 +73,8 @@ If you like to add more traces or follow the current ones you can turn traces on
7673

7774
```"target_overrides": {
7875
"*": {
79-
"target.features_add": ["LWIP", "COMMON_PAL"],
80-
"mbed-trace.enable": false,
76+
"target.features_add": ["LWIP"],
77+
"mbed-trace.enable": true,
8178
```
8279

8380
After you have defined `mbed-trace.enable: true`, you can set trace levels by changing value in `trace-level`
@@ -126,4 +123,12 @@ Success. Exiting
126123

127124
## Troubleshooting
128125

129-
If you have problems, you can review the [documentation](https://os.mbed.com/docs/latest/tutorials/debugging.html) for suggestions on what could be wrong and how to fix it.
126+
* Make sure the fields `sim-pin-code`, `apn`, `username` and `password` from the `mbed_app.json` file are filled in correctly. The correct values should appear in the user manual of the board if using eSIM or in the details of the SIM card if using normal SIM.
127+
* Enable trace flag to have access to debug information `"mbed-trace.enable": true`.
128+
* Try both `TCP` and `UDP` socket types.
129+
* Try both `"lwip.ppp-enabled": true` and `"lwip.ppp-enabled": false`.
130+
* The modem may support only a fixed baud-rate, such as `"platform.default-serial-baud-rate": 9600`.
131+
* The modem and network may only support IPv6 in which case `"lwip.ipv6-enabled": true` shall be defined.
132+
* The SIM and modem must have compatible cellular technology (3G, 4G, NB-IoT, ...) supported and cellular network available.
133+
134+
If you have problems to get started with debugging, you can review the [documentation](https://os.mbed.com/docs/latest/tutorials/debugging.html) for suggestions on what could be wrong and how to fix it.

main.cpp

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "mbed.h"
1818
#include "common_functions.h"
1919
#include "UDPSocket.h"
20-
#include "OnboardCellularInterface.h"
2120
#include "CellularLog.h"
2221

2322
#define UDP 0
@@ -41,16 +40,13 @@
4140
// Number of retries /
4241
#define RETRY_COUNT 3
4342

44-
45-
46-
// CellularInterface object
47-
OnboardCellularInterface iface;
43+
CellularBase *iface;
4844

4945
// Echo server hostname
50-
const char *host_name = "echo.mbedcloudtesting.com";
46+
const char *host_name = MBED_CONF_APP_ECHO_SERVER_HOSTNAME;
5147

5248
// Echo server port (same for TCP and UDP)
53-
const int port = 7;
49+
const int port = MBED_CONF_APP_ECHO_SERVER_PORT;
5450

5551
static rtos::Mutex trace_mutex;
5652

@@ -80,10 +76,16 @@ static void trace_open()
8076

8177
mbed_trace_mutex_wait_function_set(trace_wait);
8278
mbed_trace_mutex_release_function_set(trace_release);
79+
80+
mbed_cellular_trace::mutex_wait_function_set(trace_wait);
81+
mbed_cellular_trace::mutex_release_function_set(trace_release);
8382
}
8483

8584
static void trace_close()
8685
{
86+
mbed_cellular_trace::mutex_wait_function_set(NULL);
87+
mbed_cellular_trace::mutex_release_function_set(NULL);
88+
8789
mbed_trace_free();
8890
}
8991
#endif // #if MBED_CONF_MBED_TRACE_ENABLE
@@ -104,7 +106,7 @@ void dot_event()
104106
{
105107
while (true) {
106108
Thread::wait(4000);
107-
if (!iface.is_connected()) {
109+
if (!iface->is_connected()) {
108110
trace_mutex.lock();
109111
printf(".");
110112
fflush(stdout);
@@ -123,8 +125,8 @@ nsapi_error_t do_connect()
123125
nsapi_error_t retcode = NSAPI_ERROR_OK;
124126
uint8_t retry_counter = 0;
125127

126-
while (!iface.is_connected()) {
127-
retcode = iface.connect();
128+
while (!iface->is_connected()) {
129+
retcode = iface->connect();
128130
if (retcode == NSAPI_ERROR_AUTH_FAILURE) {
129131
print_function("\n\nAuthentication Failure. Exiting application\n");
130132
} else if (retcode == NSAPI_ERROR_OK) {
@@ -154,14 +156,14 @@ nsapi_error_t test_send_recv()
154156
UDPSocket sock;
155157
#endif
156158

157-
retcode = sock.open(&iface);
159+
retcode = sock.open(iface);
158160
if (retcode != NSAPI_ERROR_OK) {
159161
print_function("UDPSocket.open() fails, code: %d\n", retcode);
160162
return -1;
161163
}
162164

163165
SocketAddress sock_addr;
164-
retcode = iface.gethostbyname(host_name, &sock_addr);
166+
retcode = iface->gethostbyname(host_name, &sock_addr);
165167
if (retcode != NSAPI_ERROR_OK) {
166168
print_function("Couldn't resolve remote host: %s, code: %d\n", host_name, retcode);
167169
return -1;
@@ -222,14 +224,14 @@ int main()
222224
#else
223225
dot_thread.start(dot_event);
224226
#endif // #if MBED_CONF_MBED_TRACE_ENABLE
227+
iface = CellularBase::get_default_instance();
228+
MBED_ASSERT(iface);
229+
225230
/* Set Pin code for SIM card */
226-
iface.set_sim_pin(MBED_CONF_APP_SIM_PIN_CODE);
231+
iface->set_sim_pin(MBED_CONF_APP_SIM_PIN_CODE);
227232

228233
/* Set network credentials here, e.g., APN */
229-
iface.set_credentials(MBED_CONF_APP_APN, MBED_CONF_APP_USERNAME, MBED_CONF_APP_PASSWORD);
230-
231-
/* Set the modem debug on/off */
232-
iface.modem_debug_on(MBED_CONF_APP_MODEM_TRACE);
234+
iface->set_credentials(MBED_CONF_APP_APN, MBED_CONF_APP_USERNAME, MBED_CONF_APP_PASSWORD);
233235

234236
nsapi_error_t retcode = NSAPI_ERROR_NO_CONNECTION;
235237

mbed-os.lib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
https://github.com/ARMmbed/mbed-os/#35fa909641fedcad9bbe0c7300d4ccdf15a2b71a
1+
https://github.com/ARMmbed/mbed-os/#866850acc15e86cd4ac11bf4404078a49f921ddd

mbed_app.json

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
{
22
"config": {
33
"sock-type": "TCP",
4-
"modem_trace": {
5-
"help": "Turns AT command trace on/off from the cellular modem, defaults to off",
6-
"value": false
7-
},
84
"sim-pin-code": {
95
"help": "SIM PIN code",
106
"value": "\"1234\""
@@ -21,6 +17,14 @@
2117
"help": "The password string to use for this APN, set to 0 if none",
2218
"value": 0
2319
},
20+
"echo-server-hostname": {
21+
"help": "Echo server host name.",
22+
"value": "\"echo.mbedcloudtesting.com\""
23+
},
24+
"echo-server-port": {
25+
"help": "Echo server port number.",
26+
"value": 7
27+
},
2428
"trace-level": {
2529
"help": "Options are TRACE_LEVEL_ERROR,TRACE_LEVEL_WARN,TRACE_LEVEL_INFO,TRACE_LEVEL_DEBUG",
2630
"macro_name": "MBED_TRACE_MAX_LEVEL",
@@ -29,7 +33,7 @@
2933
},
3034
"target_overrides": {
3135
"*": {
32-
"target.features_add": ["LWIP", "COMMON_PAL"],
36+
"target.features_add": ["LWIP"],
3337
"mbed-trace.enable": false,
3438
"lwip.ipv4-enabled": true,
3539
"lwip.ethernet-enabled": false,
@@ -38,7 +42,8 @@
3842
"platform.stdio-convert-newlines": true,
3943
"platform.stdio-baud-rate": 115200,
4044
"platform.default-serial-baud-rate": 115200,
41-
"platform.stdio-buffered-serial": true
45+
"platform.stdio-buffered-serial": true,
46+
"cellular.debug-at": false
4247
}
4348
}
4449
}

0 commit comments

Comments
 (0)