Skip to content

Commit 2b78b04

Browse files
author
Hasnain Virk
committed
Using Reference driver
* Makes the example app use ReferenceCellular driver instead of vendor specific drivers.
1 parent 97106fb commit 2b78b04

File tree

5 files changed

+14
-49
lines changed

5 files changed

+14
-49
lines changed

Jenkinsfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,6 @@ def buildStep(target_family, target, compilerLabel, toolchain) {
8989
checkout scm
9090
def config_file = "mbed_app.json"
9191

92-
// Change target type
93-
execute("sed -i 's/\"platform\": .*/\"platform\": \"${target_family}\"/' ${config_file}")
94-
9592
// Activate traces
9693
execute("sed -i 's/\"mbed-trace.enable\": false/\"mbed-trace.enable\": true/' ${config_file}")
9794

README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
11
# mbed-os-example-cellular
22

3-
For MTS Dragonfly, please change platform section in mbed_app.json as:
43

5-
```json
6-
"config": {
7-
"platform": "MTS_DRAGONFLY"
8-
},
9-
```

main.cpp

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,7 @@
22
#include <inttypes.h>
33
#include "mbed.h"
44
#include "BufferedSerial.h"
5-
6-
#define UBLOX 0
7-
#define MTS_DRAGONFLY 1
8-
9-
#if MBED_CONF_APP_PLATFORM == UBLOX
10-
#include "ublox_modem_driver/UbloxCellularInterface.h"
11-
UbloxCellularInterface *iface;
12-
#elif MBED_CONF_APP_PLATFORM == MTS_DRAGONFLY
13-
#include "dragonfly_modem_driver/DragonFlyCellularInterface.h"
14-
DragonFlyCellularInterface *iface;
15-
#endif
5+
#include "ReferenceCellularInterface.h"
166
#include "UDPSocket.h"
177
#include "common_functions.h"
188
#if defined(FEATURE_COMMON_PAL)
@@ -24,6 +14,7 @@ DragonFlyCellularInterface *iface;
2414
#define tr_error(...) (void(0)) //dummies if feature common pal is not added
2515
#endif //defined(FEATURE_COMMON_PAL)
2616

17+
ReferenceCellularInterface iface;
2718
UDPSocket *socket;
2819
static const char *host_name = "2.pool.ntp.org";
2920
static const int port = 123;
@@ -58,24 +49,21 @@ static void unlock()
5849
mtx.unlock();
5950
}
6051

61-
// main() runs in its own thread in the OS
62-
63-
6452
int do_ntp()
6553
{
6654
int ntp_values[12] = { 0 };
6755
time_t TIME1970 = 2208988800U;
6856

6957
UDPSocket sock;
7058

71-
int ret = sock.open(iface);
59+
int ret = sock.open(&iface);
7260
if (ret) {
7361
tr_error("UDPSocket.open() fails, code: %d", ret);
7462
return -1;
7563
}
7664

7765
SocketAddress nist;
78-
ret = iface->gethostbyname(host_name, &nist);
66+
ret = iface.gethostbyname(host_name, &nist);
7967
if (ret) {
8068
tr_error("Couldn't resolve remote host: %s, code: %d", host_name, ret);
8169
return -1;
@@ -126,24 +114,14 @@ int do_ntp()
126114
return -1;
127115
}
128116

129-
#ifndef MODEM_DEBUG_TRACE
130-
#define MODEM_DEBUG_TRACE false
131-
#endif
132-
133-
#if MBED_CONF_APP_PLATFORM == UBLOX
134-
UbloxCellularInterface my_iface(false, MODEM_DEBUG_TRACE);
135-
#elif MBED_CONF_APP_PLATFORM == MTS_DRAGONFLY
136-
DragonFlyCellularInterface my_iface(false, MODEM_DEBUG_TRACE);
137-
#endif
138-
139117
nsapi_error_t connection()
140118
{
141119
nsapi_error_t retcode;
142120
bool disconnected = false;
143121

144-
while (!iface->isConnected()) {
122+
while (!iface.isConnected()) {
145123

146-
retcode = iface->connect();
124+
retcode = iface.connect();
147125
if (retcode == NSAPI_ERROR_AUTH_FAILURE) {
148126
printf("\n\nAuthentication Failure. Exiting application\n");
149127
return retcode;
@@ -163,7 +141,7 @@ nsapi_error_t connection()
163141
int getTime()
164142
{
165143
int retcode = -1;
166-
if (iface->isConnected()) {
144+
if (iface.isConnected()) {
167145
retcode = do_ntp();
168146
} else {
169147
/* Determine why the network is down */
@@ -193,12 +171,11 @@ int main()
193171

194172
nsapi_error_t retcode = NSAPI_ERROR_OK;
195173

196-
iface = &my_iface;
197-
iface->set_SIM_pin("1234");
174+
iface.set_SIM_pin("1234");
198175

199-
iface->set_credentials("internet");
176+
iface.set_credentials("internet");
200177

201-
iface->connection_lost_notification_cb(ppp_connection_down_cb);
178+
iface.connection_status_cb(ppp_connection_down_cb);
202179

203180
tr_debug("Connecting...");
204181
retcode = connection();

mbed-os.lib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
https://github.com/hasnainvirk/mbed-os/#b80fc6bd40a103cd50029617657971d1e7baec96
1+
https://github.com/hasnainvirk/mbed-os/#5d21ab458702ab6f195ac06948ce5c226296e481

mbed_app.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
{
2-
"config": {
3-
"platform": "UBLOX"
4-
},
5-
"macros": ["OS_MAINSTKSIZE=512", "MODEM_DEBUG_TRACE=true"],
2+
"macros": ["OS_MAINSTKSIZE=512"],
63
"target_overrides": {
74
"*": {
85
"lwip.ipv4-enabled": true,
@@ -15,8 +12,8 @@
1512
"platform.stdio-baud-rate": 115200,
1613
"platform.default-serial-baud-rate": 115200,
1714
"lwip.debug-enabled":false,
18-
"lwip.enable-ppp-trace": true,
19-
"lwip.use-mbed-trace": true,
15+
"lwip.enable-ppp-trace": false,
16+
"lwip.use-mbed-trace": false,
2017
"mbed-trace.enable": 1
2118
}
2219
}

0 commit comments

Comments
 (0)