This is a simple mbed client example demonstrating, registration of a device with mbed Device Connector and reading and writing values as well as deregistering on different Network Interfaces including Ethernet, WiFi, 6LoWPAN ND and Thread respectively.

Fork of mbed-os-example-client by mbed-os-examples

Files at this revision

API Documentation at this revision

Comitter:
mbed_official
Date:
Tue Dec 13 13:45:11 2016 +0000
Parent:
44:2b472e66a942
Child:
46:9360459cf54e
Commit message:
configs/*.json based configurations (#140)

* configs/*.json based configurations

Per Marcelo Salazar's proposal add configuration examples to a configs-folder.
By default the repo does not anymore have an mbed_app.json at all, but one should
copy one of the example configs, potentially modify it and use it.

Add mbedignore files to avoid the compilation problems.

Reference:
https://github.com/ARMmbed/mbed-os-example-client/issues/137

* Clarify connection types per bearer

Mesh-networking ONLY supports UDP, others support both. Table to
illustrate UPD/TCP modes per network bearer.

.
Commit copied from https://github.com/ARMmbed/mbed-os-example-client

Changed in this revision

README.md Show annotated file Show diff for this revision Revisions of this file
build_all.sh Show annotated file Show diff for this revision Revisions of this file
configs/eth-wifi-mbedignore Show annotated file Show diff for this revision Revisions of this file
configs/eth_v4.json Show annotated file Show diff for this revision Revisions of this file
configs/eth_v6.json Show annotated file Show diff for this revision Revisions of this file
configs/mesh-mbedignore Show annotated file Show diff for this revision Revisions of this file
configs/mesh_6lowpan.json Show annotated file Show diff for this revision Revisions of this file
configs/mesh_thread.json Show annotated file Show diff for this revision Revisions of this file
configs/wifi_v4.json Show annotated file Show diff for this revision Revisions of this file
--- a/README.md	Tue Dec 13 08:45:11 2016 +0000
+++ b/README.md	Tue Dec 13 13:45:11 2016 +0000
@@ -232,22 +232,45 @@
 
 ### 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:
@@ -260,7 +283,8 @@
     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:
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build_all.sh	Tue Dec 13 13:45:11 2016 +0000
@@ -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
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/configs/eth-wifi-mbedignore	Tue Dec 13 13:45:11 2016 +0000
@@ -0,0 +1,3 @@
+atmel-rf-driver/*
+mcr20a-rf-driver/*
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/configs/eth_v4.json	Tue Dec 13 13:45:11 2016 +0000
@@ -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
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/configs/eth_v6.json	Tue Dec 13 13:45:11 2016 +0000
@@ -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
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/configs/mesh-mbedignore	Tue Dec 13 13:45:11 2016 +0000
@@ -0,0 +1,1 @@
+esp8266-driver/*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/configs/mesh_6lowpan.json	Tue Dec 13 13:45:11 2016 +0000
@@ -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
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/configs/mesh_thread.json	Tue Dec 13 13:45:11 2016 +0000
@@ -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
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/configs/wifi_v4.json	Tue Dec 13 13:45:11 2016 +0000
@@ -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"
+        }
+    }
+}