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

configs/*.json based configurations #140

Merged
merged 7 commits into from
Dec 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 28 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,22 +232,45 @@ For example, NUCLEO_F401RE requires a different serial connection:

### IP address setup

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.
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
by changing the mbed_app.json you make:
```
"target_overrides": {
"*": {
"target.features_add": ["LWIP", "NANOSTACK", "COMMON_PAL"],
"lwip.ipv4-enabled": false,
"lwip.ipv6-enabled": true,
"mbed-trace.enable": 0
}
```
by modifying the ipv4-enable or ipv6-enable to true/false. Only one should be true.

The example program should automatically get an IP address from the router when connected over Ethernet or WiFi.

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.

### Changing socket type

Your device can connect to mbed Device Connector via UDP or TCP binding mode. The default is TCP. The binding mode cannot be changed in 6LoWPAN ND or Thread mode.
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.

To change the binding mode:

1. In the `simpleclient.h` file, find the parameter `SOCKET_MODE`. The default is `M2MInterface::TCP`.
1. In the `simpleclient.h` file, find the parameter `SOCKET_MODE`. The default is `M2MInterface::UDP` for mesh and `M2MInterface::TCP` for others.
1. To switch to UDP, change it to `M2MInterface::UDP`.
1. Rebuild and flash the application.

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

Possible socket types per connection:

| Network interface | UDP | TCP |
| ------------------------------|:-----:|:-----:|
| Ethernet (IPv4) | X | X |
| Ethernet (IPv6) | X | |
| Wifi (IPv4) | X | X |
| Wifi (IPv6) - Not supported | | |
| 6LoWPAN/Thread (IPv6) | X | |

## Building the example

To build the example using mbed CLI:
Expand All @@ -260,7 +283,8 @@ To build the example using mbed CLI:
mbed import mbed-os-example-client
```

3. [Configure](#application-setup) the client application.
3. Copy the relevant example configuration file from configs/xxx.json to mbed_app.json and
[Configure](#application-setup) the client application.

4. To build the application, select the hardware board and build the toolchain using the command:

Expand Down
40 changes: 40 additions & 0 deletions build_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
#
set -e
TOOL=GCC_ARM

echo Compiling with $TOOL
cp configs/eth_v4.json ./mbed_app.json
cp configs/eth-wifi-mbedignore ./.mbedignore
mbed compile -m K64F -t $TOOL
cp BUILD/K64F/GCC_ARM/mbed-os-example-client.bin k64f-$TOOL-eth-v4.bin
mbed compile -m NUCLEO_F439ZI -t $TOOL
cp ./BUILD/NUCLEO_F439ZI/GCC_ARM/mbed-os-example-client.bin f439zi-$TOOL-eth-v4.bin

cp configs/eth_v6.json ./mbed_app.json
cp configs/eth-wifi-mbedignore ./.mbedignore
mbed compile -m K64F -t $TOOL
cp BUILD/K64F/GCC_ARM/mbed-os-example-client.bin k64f-$TOOL-eth-v6.bin
mbed compile -m NUCLEO_F439ZI -t $TOOL
cp ./BUILD/NUCLEO_F439ZI/GCC_ARM/mbed-os-example-client.bin f439zi-$TOOL-eth-v4.bin

cp configs/wifi_v4.json ./mbed_app.json
cp configs/eth-wifi-mbedignore ./.mbedignore
mbed compile -m K64F -t $TOOL
cp BUILD/K64F/GCC_ARM/mbed-os-example-client.bin k64f-$TOOL-wifi-v4.bin
mbed compile -m UBLOX_EVK_ODIN_W2 -t $TOOL
cp ./BUILD/UBLOX_EVK_ODIN_W2/GCC_ARM/mbed-os-example-client.bin ublox-odin-$TOOL-wifi-v4.bin

cp configs/mesh_6lowpan.json ./mbed_app.json
cp configs/mesh-mbedignore ./.mbedignore
mbed compile -m K64F -t $TOOL
cp BUILD/K64F/GCC_ARM/mbed-os-example-client.bin k64f-$TOOL-6lowpan.bin
mbed compile -m NUCLEO_F439ZI -t $TOOL
cp ./BUILD/NUCLEO_F439ZI/GCC_ARM/mbed-os-example-client.bin f439zi-$TOOL-6lowpan.bin

cp configs/mesh_thread.json ./mbed_app.json
cp configs/mesh-mbedignore ./.mbedignore
mbed compile -m K64F -t $TOOL
cp BUILD/K64F/GCC_ARM/mbed-os-example-client.bin k64f-$TOOL-Thread.bin
mbed compile -m NUCLEO_F439ZI -t $TOOL
cp ./BUILD/NUCLEO_F439ZI/GCC_ARM/mbed-os-example-client.bin f439zi-$TOOL-Thread.bin
3 changes: 3 additions & 0 deletions configs/eth-wifi-mbedignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
atmel-rf-driver/*
mcr20a-rf-driver/*

17 changes: 17 additions & 0 deletions configs/eth_v4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"config": {
"network-interface":{
"help": "options are ETHERNET,WIFI,MESH_LOWPAN_ND,MESH_THREAD",
"value": "ETHERNET"
}
},
"macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
"target_overrides": {
"*": {
"target.features_add": ["LWIP", "COMMON_PAL"],
"lwip.ipv4-enabled": true,
"lwip.ipv6-enabled": false,
"mbed-trace.enable": 0
}
}
}
17 changes: 17 additions & 0 deletions configs/eth_v6.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"config": {
"network-interface":{
"help": "options are ETHERNET,WIFI,MESH_LOWPAN_ND,MESH_THREAD",
"value": "ETHERNET"
}
},
"macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
"target_overrides": {
"*": {
"target.features_add": ["LWIP", "COMMON_PAL"],
"lwip.ipv4-enabled": false,
"lwip.ipv6-enabled": true,
"mbed-trace.enable": 0
}
}
}
1 change: 1 addition & 0 deletions configs/mesh-mbedignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
esp8266-driver/*
21 changes: 21 additions & 0 deletions configs/mesh_6lowpan.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"config": {
"network-interface":{
"help": "options are ETHERNET,WIFI,MESH_LOWPAN_ND,MESH_THREAD",
"value": "MESH_LOWPAN_ND"
},
"mesh_radio_type": {
"help": "options are ATMEL, MCR20",
"value": "ATMEL"
}
},
"macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
"target_overrides": {
"*": {
"target.features_add": ["NANOSTACK", "LOWPAN_ROUTER", "COMMON_PAL"],
"mbed-mesh-api.6lowpan-nd-channel-page": 0,
"mbed-mesh-api.6lowpan-nd-channel": 18,
"mbed-trace.enable": 0
}
}
}
21 changes: 21 additions & 0 deletions configs/mesh_thread.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"config": {
"network-interface":{
"help": "options are ETHERNET,WIFI,MESH_LOWPAN_ND,MESH_THREAD",
"value": "MESH_THREAD"
},
"mesh_radio_type": {
"help": "options are ATMEL, MCR20",
"value": "ATMEL"
}
},
"macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
"target_overrides": {
"*": {
"target.features_add": ["NANOSTACK", "THREAD_ROUTER", "COMMON_PAL"],
"mbed-mesh-api.thread-config-channel": 18,
"mbed-mesh-api.thread-config-panid": "0xBAAB",
"mbed-trace.enable": 0
}
}
}
41 changes: 41 additions & 0 deletions configs/wifi_v4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"config": {
"network-interface":{
"help": "options are ETHERNET,WIFI,MESH_LOWPAN_ND,MESH_THREAD",
"value": "WIFI"
},
"wifi-ssid": {
"help": "WiFi SSID",
"value": "\"SSID\""
},
"wifi-password": {
"help": "WiFi Password",
"value": "\"Password\""
},
"wifi-tx": {
"help": "TX pin for serial connection to external device",
"value": "D1"
},
"wifi-rx": {
"help": "RX pin for serial connection to external device",
"value": "D0"
}
},
"macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
"target_overrides": {
"*": {
"target.features_add": ["LWIP", "COMMON_PAL"],
"lwip.ipv4-enabled": true,
"lwip.ipv6-enabled": false,
"mbed-trace.enable": 0
},
"NUCLEO_F401RE": {
"wifi-tx": "PA_11",
"wifi-rx": "PA_12"
},
"NUCLEO_F411RE": {
"wifi-tx": "PA_11",
"wifi-rx": "PA_12"
}
}
}