Skip to content
This repository was archived by the owner on Apr 24, 2019. It is now read-only.

Commit d7afcd7

Browse files
author
Janne Kiiskilä
authored
Merge branch 'master' into update_gw_binaries
2 parents 3c32c01 + a9a3580 commit d7afcd7

15 files changed

+272
-48
lines changed

Jenkinsfile

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
properties ([[$class: 'ParametersDefinitionProperty', parameterDefinitions: [
2+
[$class: 'StringParameterDefinition', name: 'mbed_os_revision', defaultValue: 'latest', description: 'Revision of mbed-os to build']
3+
]]])
4+
5+
try {
6+
echo "Verifying build with mbed-os version ${mbed_os_revision}"
7+
env.MBED_OS_REVISION = "${mbed_os_revision}"
8+
} catch (err) {
9+
def mbed_os_revision = "latest"
10+
echo "Verifying build with mbed-os version ${mbed_os_revision}"
11+
env.MBED_OS_REVISION = "${mbed_os_revision}"
12+
}
13+
114
// List of targets to compile
215
def targets = [
316
"K64F",
@@ -65,6 +78,10 @@ def buildStep(target, compilerLabel, toolchain, configName, connectiontype) {
6578
execute("sed -i 's/\"NANOSTACK\", \"LOWPAN_ROUTER\", \"COMMON_PAL\"/\"NANOSTACK\", \"THREAD_ROUTER\", \"COMMON_PAL\"/' mbed_app.json")
6679
// Change connection type to thread
6780
execute ("sed -i 's/\"value\": \"ETHERNET\"/\"value\": \"MESH_THREAD\"/' mbed_app.json")
81+
// Reuse 6lowpan channel to Thread channel
82+
execute("sed -i 's/\"mbed-mesh-api.6lowpan-nd-channel\": 12/\"mbed-mesh-api.thread-config-channel\": 18/' mbed_app.json")
83+
// Reuse 6lowpan channel page to Thread PANID
84+
execute("sed -i 's/\"mbed-mesh-api.6lowpan-nd-channel-page\": 0/\"mbed-mesh-api.thread-config-panid\": \"0xBAAB\"/' mbed_app.json")
6885
}
6986

7087
if ("${configName}" == "6lp") {
@@ -82,16 +99,16 @@ def buildStep(target, compilerLabel, toolchain, configName, connectiontype) {
8299

83100
// Copy security.h to build
84101
mbed.getSecurityFile()
85-
86-
execute ("mbed deploy --protocol ssh")
87102

103+
// Set mbed-os to revision received as parameter
104+
execute ("mbed deploy --protocol ssh")
88105
dir("mbed-os") {
89-
execute ("git fetch origin latest")
90-
execute ("git checkout FETCH_HEAD")
106+
execute ("git checkout ${env.MBED_OS_REVISION}")
91107
}
92108
execute ("mbed compile --build out/${target}_${toolchain}_${configName}_${connectiontype}/ -m ${target} -t ${toolchain} -c")
93109
}
94110
archive '**/mbed-os-example-client.bin'
111+
step([$class: 'WsCleanup'])
95112
}
96113
}
97114
}

README.md

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,22 +232,45 @@ For example, NUCLEO_F401RE requires a different serial connection:
232232

233233
### IP address setup
234234

235-
This example uses IPv4 to communicate with the [mbed Device Connector Server](https://api.connector.mbed.com) except for 6LoWPAN ND and Thread. The example program should automatically get an IPv4 address from the router when connected over Ethernet.
235+
This example uses IPv4 to communicate with the [mbed Device Connector Server](https://api.connector.mbed.com) except for 6LoWPAN ND and Thread. However, you can easily change it to IPv6
236+
by changing the mbed_app.json you make:
237+
```
238+
"target_overrides": {
239+
"*": {
240+
"target.features_add": ["LWIP", "NANOSTACK", "COMMON_PAL"],
241+
"lwip.ipv4-enabled": false,
242+
"lwip.ipv6-enabled": true,
243+
"mbed-trace.enable": 0
244+
}
245+
```
246+
by modifying the ipv4-enable or ipv6-enable to true/false. Only one should be true.
247+
248+
The example program should automatically get an IP address from the router when connected over Ethernet or WiFi.
236249

237250
If your network does not have DHCP enabled, you have to manually assign a static IP address to the board. We recommend having DHCP enabled to make everything run smoothly.
238251

239252
### Changing socket type
240253

241-
Your device can connect to mbed Device Connector via UDP or TCP binding mode. The default is UDP. The binding mode cannot be changed in 6LoWPAN ND or Thread mode.
254+
Your device can connect to mbed Device Connector via UDP or TCP binding mode. The default and only allowed value is UDP for Thread and 6LowPan. TCP is the default for other connections. The binding mode cannot be changed in 6LoWPAN ND or Thread mode.
242255

243256
To change the binding mode:
244257

245-
1. In the `simpleclient.h` file, find the parameter `SOCKET_MODE`. The default is `M2MInterface::UDP`.
246-
1. To switch to TCP, change it to `M2MInterface::TCP`.
258+
1. In the `simpleclient.h` file, find the parameter `SOCKET_MODE`. The default is `M2MInterface::UDP` for mesh and `M2MInterface::TCP` for others.
259+
1. To switch to UDP, change it to `M2MInterface::UDP`.
247260
1. Rebuild and flash the application.
248261

249262
<span class="tips">**Tip:** The instructions in this document remain the same, irrespective of the socket mode you select.</span>
250263

264+
Possible socket types per connection:
265+
266+
| Network interface | UDP | TCP |
267+
| ------------------------------|:-----:|:-----:|
268+
| Ethernet (IPv4) | X | X |
269+
| Ethernet (IPv6) | X | |
270+
| Wifi (IPv4) | X | X |
271+
| Wifi (IPv6) - Not supported | | |
272+
| 6LoWPAN/Thread (IPv6) | X | |
273+
251274
## Building the example
252275

253276
To build the example using mbed CLI:
@@ -260,7 +283,8 @@ To build the example using mbed CLI:
260283
mbed import mbed-os-example-client
261284
```
262285
263-
3. [Configure](#application-setup) the client application.
286+
3. Copy the relevant example configuration file from configs/xxx.json to mbed_app.json and
287+
[Configure](#application-setup) the client application.
264288
265289
4. To build the application, select the hardware board and build the toolchain using the command:
266290

build_all.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
#
3+
set -e
4+
TOOL=GCC_ARM
5+
6+
echo Compiling with $TOOL
7+
cp configs/eth_v4.json ./mbed_app.json
8+
cp configs/eth-wifi-mbedignore ./.mbedignore
9+
mbed compile -m K64F -t $TOOL
10+
cp BUILD/K64F/GCC_ARM/mbed-os-example-client.bin k64f-$TOOL-eth-v4.bin
11+
mbed compile -m NUCLEO_F439ZI -t $TOOL
12+
cp ./BUILD/NUCLEO_F439ZI/GCC_ARM/mbed-os-example-client.bin f439zi-$TOOL-eth-v4.bin
13+
14+
cp configs/eth_v6.json ./mbed_app.json
15+
cp configs/eth-wifi-mbedignore ./.mbedignore
16+
mbed compile -m K64F -t $TOOL
17+
cp BUILD/K64F/GCC_ARM/mbed-os-example-client.bin k64f-$TOOL-eth-v6.bin
18+
mbed compile -m NUCLEO_F439ZI -t $TOOL
19+
cp ./BUILD/NUCLEO_F439ZI/GCC_ARM/mbed-os-example-client.bin f439zi-$TOOL-eth-v4.bin
20+
21+
cp configs/wifi_v4.json ./mbed_app.json
22+
cp configs/eth-wifi-mbedignore ./.mbedignore
23+
mbed compile -m K64F -t $TOOL
24+
cp BUILD/K64F/GCC_ARM/mbed-os-example-client.bin k64f-$TOOL-wifi-v4.bin
25+
mbed compile -m UBLOX_EVK_ODIN_W2 -t $TOOL
26+
cp ./BUILD/UBLOX_EVK_ODIN_W2/GCC_ARM/mbed-os-example-client.bin ublox-odin-$TOOL-wifi-v4.bin
27+
28+
cp configs/mesh_6lowpan.json ./mbed_app.json
29+
cp configs/mesh-mbedignore ./.mbedignore
30+
mbed compile -m K64F -t $TOOL
31+
cp BUILD/K64F/GCC_ARM/mbed-os-example-client.bin k64f-$TOOL-6lowpan.bin
32+
mbed compile -m NUCLEO_F439ZI -t $TOOL
33+
cp ./BUILD/NUCLEO_F439ZI/GCC_ARM/mbed-os-example-client.bin f439zi-$TOOL-6lowpan.bin
34+
35+
cp configs/mesh_thread.json ./mbed_app.json
36+
cp configs/mesh-mbedignore ./.mbedignore
37+
mbed compile -m K64F -t $TOOL
38+
cp BUILD/K64F/GCC_ARM/mbed-os-example-client.bin k64f-$TOOL-Thread.bin
39+
mbed compile -m NUCLEO_F439ZI -t $TOOL
40+
cp ./BUILD/NUCLEO_F439ZI/GCC_ARM/mbed-os-example-client.bin f439zi-$TOOL-Thread.bin

configs/eth-wifi-mbedignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
atmel-rf-driver/*
2+
mcr20a-rf-driver/*
3+

configs/eth_v4.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"config": {
3+
"network-interface":{
4+
"help": "options are ETHERNET,WIFI,MESH_LOWPAN_ND,MESH_THREAD",
5+
"value": "ETHERNET"
6+
}
7+
},
8+
"macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
9+
"target_overrides": {
10+
"*": {
11+
"target.features_add": ["LWIP", "COMMON_PAL"],
12+
"lwip.ipv4-enabled": true,
13+
"lwip.ipv6-enabled": false,
14+
"mbed-trace.enable": 0
15+
}
16+
}
17+
}

configs/eth_v6.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"config": {
3+
"network-interface":{
4+
"help": "options are ETHERNET,WIFI,MESH_LOWPAN_ND,MESH_THREAD",
5+
"value": "ETHERNET"
6+
}
7+
},
8+
"macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
9+
"target_overrides": {
10+
"*": {
11+
"target.features_add": ["LWIP", "COMMON_PAL"],
12+
"lwip.ipv4-enabled": false,
13+
"lwip.ipv6-enabled": true,
14+
"mbed-trace.enable": 0
15+
}
16+
}
17+
}

configs/mesh-mbedignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
esp8266-driver/*

configs/mesh_6lowpan.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"config": {
3+
"network-interface":{
4+
"help": "options are ETHERNET,WIFI,MESH_LOWPAN_ND,MESH_THREAD",
5+
"value": "MESH_LOWPAN_ND"
6+
},
7+
"mesh_radio_type": {
8+
"help": "options are ATMEL, MCR20",
9+
"value": "ATMEL"
10+
}
11+
},
12+
"macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
13+
"target_overrides": {
14+
"*": {
15+
"target.features_add": ["NANOSTACK", "LOWPAN_ROUTER", "COMMON_PAL"],
16+
"mbed-mesh-api.6lowpan-nd-channel-page": 0,
17+
"mbed-mesh-api.6lowpan-nd-channel": 18,
18+
"mbed-trace.enable": 0
19+
}
20+
}
21+
}

configs/mesh_thread.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"config": {
3+
"network-interface":{
4+
"help": "options are ETHERNET,WIFI,MESH_LOWPAN_ND,MESH_THREAD",
5+
"value": "MESH_THREAD"
6+
},
7+
"mesh_radio_type": {
8+
"help": "options are ATMEL, MCR20",
9+
"value": "ATMEL"
10+
}
11+
},
12+
"macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
13+
"target_overrides": {
14+
"*": {
15+
"target.features_add": ["NANOSTACK", "THREAD_ROUTER", "COMMON_PAL"],
16+
"mbed-mesh-api.thread-config-channel": 18,
17+
"mbed-mesh-api.thread-config-panid": "0xBAAB",
18+
"mbed-trace.enable": 0
19+
}
20+
}
21+
}

configs/wifi_v4.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"config": {
3+
"network-interface":{
4+
"help": "options are ETHERNET,WIFI,MESH_LOWPAN_ND,MESH_THREAD",
5+
"value": "WIFI"
6+
},
7+
"wifi-ssid": {
8+
"help": "WiFi SSID",
9+
"value": "\"SSID\""
10+
},
11+
"wifi-password": {
12+
"help": "WiFi Password",
13+
"value": "\"Password\""
14+
},
15+
"wifi-tx": {
16+
"help": "TX pin for serial connection to external device",
17+
"value": "D1"
18+
},
19+
"wifi-rx": {
20+
"help": "RX pin for serial connection to external device",
21+
"value": "D0"
22+
}
23+
},
24+
"macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
25+
"target_overrides": {
26+
"*": {
27+
"target.features_add": ["LWIP", "COMMON_PAL"],
28+
"lwip.ipv4-enabled": true,
29+
"lwip.ipv6-enabled": false,
30+
"mbed-trace.enable": 0
31+
},
32+
"NUCLEO_F401RE": {
33+
"wifi-tx": "PA_11",
34+
"wifi-rx": "PA_12"
35+
},
36+
"NUCLEO_F411RE": {
37+
"wifi-tx": "PA_11",
38+
"wifi-rx": "PA_12"
39+
}
40+
}
41+
}

esp8266-driver.lib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
https://github.com/ARMmbed/esp8266-driver/#dc37b65ca877d969aa492f348626df6e1b0b1df0
1+
https://github.com/ARMmbed/esp8266-driver/#86ed47c8bf40c86fdc569c7e678a8944f5e01c2a

main.cpp

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015 ARM Limited. All rights reserved.
2+
* Copyright (c) 2015, 2016 ARM Limited. All rights reserved.
33
* SPDX-License-Identifier: Apache-2.0
44
* Licensed under the Apache License, Version 2.0 (the License); you may
55
* not use this file except in compliance with the License.
@@ -26,19 +26,24 @@
2626
#include "rtos.h"
2727

2828
#if MBED_CONF_APP_NETWORK_INTERFACE == WIFI
29-
#include "ESP8266Interface.h"
30-
ESP8266Interface esp(MBED_CONF_APP_WIFI_TX, MBED_CONF_APP_WIFI_RX);
29+
#if TARGET_UBLOX_EVK_ODIN_W2
30+
#include "OdinWiFiInterface.h"
31+
OdinWiFiInterface wifi;
32+
#else
33+
#include "ESP8266Interface.h"
34+
ESP8266Interface wifi(MBED_CONF_APP_WIFI_TX, MBED_CONF_APP_WIFI_RX);
35+
#endif
3136
#elif MBED_CONF_APP_NETWORK_INTERFACE == ETHERNET
32-
#include "EthernetInterface.h"
33-
EthernetInterface eth;
37+
#include "EthernetInterface.h"
38+
EthernetInterface eth;
3439
#elif MBED_CONF_APP_NETWORK_INTERFACE == MESH_LOWPAN_ND
35-
#define MESH
36-
#include "NanostackInterface.h"
37-
LoWPANNDInterface mesh;
40+
#define MESH
41+
#include "NanostackInterface.h"
42+
LoWPANNDInterface mesh;
3843
#elif MBED_CONF_APP_NETWORK_INTERFACE == MESH_THREAD
39-
#define MESH
40-
#include "NanostackInterface.h"
41-
ThreadInterface mesh;
44+
#define MESH
45+
#include "NanostackInterface.h"
46+
ThreadInterface mesh;
4247
#endif
4348

4449
#if defined(MESH)
@@ -52,15 +57,16 @@ NanostackRfPhyMcr20a rf_phy(MCR20A_SPI_MOSI, MCR20A_SPI_MISO, MCR20A_SPI_SCLK, M
5257
#endif //MBED_CONF_APP_RADIO_TYPE
5358
#endif //MESH
5459

55-
#ifndef MESH
56-
// This is address to mbed Device Connector
57-
#define MBED_SERVER_ADDRESS "coap://api.connector.mbed.com:5684"
60+
#ifdef MESH
61+
// Mesh does not have DNS, so must use direct IPV6 address
62+
#define MBED_SERVER_ADDRESS "coaps://[2607:f0d0:2601:52::20]:5684"
5863
#else
59-
// This is address to mbed Device Connector
60-
#define MBED_SERVER_ADDRESS "coaps://[2607:f0d0:2601:52::20]:5684"
64+
// This is address to mbed Device Connector, name based
65+
// assume all other stacks support DNS properly
66+
#define MBED_SERVER_ADDRESS "coap://api.connector.mbed.com:5684"
6167
#endif
6268

63-
Serial output(USBTX, USBRX);
69+
RawSerial output(USBTX, USBRX);
6470

6571
// Status indication
6672
DigitalOut red_led(LED1);
@@ -378,25 +384,29 @@ Add MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES and MBEDTLS_TEST_NULL_ENTROPY in mbed_app
378384
// Sets the console baud-rate
379385
output.baud(115200);
380386
381-
output.printf("Starting mbed Client example...\r\n");
387+
output.printf("\r\nStarting mbed Client example in ");
388+
#if defined (MESH) || (MBED_CONF_LWIP_IPV6_ENABLED==true)
389+
output.printf("IPv6 mode\r\n");
390+
#else
391+
output.printf("IPv4 mode\r\n");
392+
#endif
382393
383394
mbed_trace_init();
384395
mbed_trace_print_function_set(trace_printer);
396+
385397
NetworkInterface *network_interface = 0;
386398
int connect_success = -1;
387399
#if MBED_CONF_APP_NETWORK_INTERFACE == WIFI
388-
output.printf("\n\rUsing WiFi \r\n");
389-
output.printf("\n\rConnecting to WiFi..\r\n");
390-
connect_success = esp.connect(MBED_CONF_APP_WIFI_SSID, MBED_CONF_APP_WIFI_PASSWORD);
391-
network_interface = &esp;
400+
output.printf("\n\rConnecting to WiFi...\r\n");
401+
connect_success = wifi.connect(MBED_CONF_APP_WIFI_SSID, MBED_CONF_APP_WIFI_PASSWORD, NSAPI_SECURITY_WPA_WPA2);
402+
network_interface = &wifi;
392403
#elif MBED_CONF_APP_NETWORK_INTERFACE == ETHERNET
393-
output.printf("Using Ethernet\r\n");
404+
output.printf("\n\rConnecting to ethernet...\r\n");
394405
connect_success = eth.connect();
395406
network_interface = &eth;
396407
#endif
397408
#ifdef MESH
398-
output.printf("Using Mesh\r\n");
399-
output.printf("\n\rConnecting to Mesh..\r\n");
409+
output.printf("\n\rConnecting to Mesh...\r\n");
400410
mesh.initialize(&rf_phy);
401411
connect_success = mesh.connect();
402412
network_interface = &mesh;

mbed-client.lib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
https://github.com/ARMmbed/mbed-client/#1c03b36ac944532688a39d9a6bd7f8a42aecf8f3
1+
https://github.com/ARMmbed/mbed-client/#92bdf6a699581679fcefeb986d1008fc59d0fb03

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/#e435a07d9252f133ea3d9f6c95dfb176f32ab9b6
1+
https://github.com/ARMmbed/mbed-os/#d5de476f74dd4de27012eb74ede078f6330dfc3f

0 commit comments

Comments
 (0)