Skip to content

Commit 72f3fd0

Browse files
author
Teppo Järvelin
committed
Changed to use NSAPI default values for pin, apn, plmn and credentials.
1 parent 9d76c74 commit 72f3fd0

File tree

2 files changed

+8
-38
lines changed

2 files changed

+8
-38
lines changed

main.cpp

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,6 @@
2222
#define UDP 0
2323
#define TCP 1
2424

25-
// SIM pin code goes here
26-
#ifndef MBED_CONF_APP_SIM_PIN_CODE
27-
# define MBED_CONF_APP_SIM_PIN_CODE "1234"
28-
#endif
29-
30-
#ifndef MBED_CONF_APP_APN
31-
# define MBED_CONF_APP_APN "internet"
32-
#endif
33-
#ifndef MBED_CONF_APP_USERNAME
34-
# define MBED_CONF_APP_USERNAME NULL
35-
#endif
36-
#ifndef MBED_CONF_APP_PASSWORD
37-
# define MBED_CONF_APP_PASSWORD NULL
38-
#endif
39-
4025
// Number of retries /
4126
#define RETRY_COUNT 3
4227

@@ -228,15 +213,11 @@ int main()
228213
#else
229214
dot_thread.start(dot_event);
230215
#endif // #if MBED_CONF_MBED_TRACE_ENABLE
216+
217+
// sim pin, apn, credentials and possible plmn are taken atuomtically from json when using get_default_instance()
231218
iface = CellularBase::get_default_instance();
232219
MBED_ASSERT(iface);
233220

234-
/* Set Pin code for SIM card */
235-
iface->set_sim_pin(MBED_CONF_APP_SIM_PIN_CODE);
236-
237-
/* Set network credentials here, e.g., APN */
238-
iface->set_credentials(MBED_CONF_APP_APN, MBED_CONF_APP_USERNAME, MBED_CONF_APP_PASSWORD);
239-
240221
nsapi_error_t retcode = NSAPI_ERROR_NO_CONNECTION;
241222

242223
/* Attempt to connect to a cellular network */

mbed_app.json

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,6 @@
11
{
22
"config": {
33
"sock-type": "TCP",
4-
"sim-pin-code": {
5-
"help": "SIM PIN code, set to 0 if none",
6-
"value": "\"1234\""
7-
},
8-
"apn": {
9-
"help": "The APN string to use for this SIM/network, set to 0 if none",
10-
"value": "\"internet\""
11-
},
12-
"username": {
13-
"help": "The user name string to use for this APN, set to zero if none",
14-
"value": 0
15-
},
16-
"password": {
17-
"help": "The password string to use for this APN, set to 0 if none",
18-
"value": 0
19-
},
204
"echo-server-hostname": {
215
"help": "Echo server host name.",
226
"value": "\"echo.mbedcloudtesting.com\""
@@ -42,7 +26,12 @@
4226
"platform.stdio-baud-rate": 115200,
4327
"platform.default-serial-baud-rate": 115200,
4428
"platform.stdio-buffered-serial": true,
45-
"cellular.debug-at": false
29+
"cellular.debug-at": false,
30+
"nsapi.default-cellular-plmn": 0,
31+
"nsapi.default-cellular-sim-pin": "\"1234\"",
32+
"nsapi.default-cellular-apn": 0,
33+
"nsapi.default-cellular-username": 0,
34+
"nsapi.default-cellular-password": 0
4635
}
4736
}
4837
}

0 commit comments

Comments
 (0)