George Djabarov / Mbed OS mbed-os-example-mesh-minimal
Committer:
mbed_official
Date:
Thu Mar 09 11:00:21 2017 +0000
Revision:
49:425a1889434d
Parent:
19:f55c7983f8ab
Child:
52:27692043e962
Merge branch 'oob_test_mbed-os-5.4'

* oob_test_mbed-os-5.4:
Update README.md
Update README.md
Update README.md
Add hardware notes
Updating mbed-os to mbed-os-5.4.0-rc2
- json config created for 6LoWPAN
Build against mbed OS 5.4 RC
Fix Thread channel configs
New Thread network configurations updated.
Add configuration file for Thread
Updating mbed-os to mbed-os-5.4.0-rc1

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

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Seppo Takalo 0:bde1843b9885 1 # Example mesh application for mbed OS
Seppo Takalo 0:bde1843b9885 2
Seppo Takalo 0:bde1843b9885 3 This application is the simplest one to utilize our mesh networking stack. It just joins your device to the unsecure *6LoWPAN-ND* network.
Seppo Takalo 0:bde1843b9885 4
Seppo Takalo 0:bde1843b9885 5 ## Setup
Seppo Takalo 0:bde1843b9885 6
Seppo Takalo 0:bde1843b9885 7 ### Download the application
Seppo Takalo 0:bde1843b9885 8
Seppo Takalo 0:bde1843b9885 9 ```
Seppo Takalo 0:bde1843b9885 10 mbed import mbed-os-example-mesh-minimal
Seppo Takalo 0:bde1843b9885 11 cd mbed-os-example-mesh-minimal
Seppo Takalo 0:bde1843b9885 12 ```
Seppo Takalo 0:bde1843b9885 13
Seppo Takalo 0:bde1843b9885 14 ### Change the channel settings (optional)
Seppo Takalo 0:bde1843b9885 15
Seppo Takalo 0:bde1843b9885 16 See the file `mbed_app.json` for an example of defining an IEEE 802.15.4 channel to use.
Seppo Takalo 0:bde1843b9885 17
mbed_official 19:f55c7983f8ab 18 ### Selecting optimal Nanostack configuration
mbed_official 19:f55c7983f8ab 19
mbed_official 19:f55c7983f8ab 20 If you want to optimize the flash usage, you need to select a proper configuration for Nanostack. The configuration depends mostly on the preferred use case.
mbed_official 19:f55c7983f8ab 21
mbed_official 19:f55c7983f8ab 22 See [6LoWPAN overview](https://docs.mbed.com/docs/arm-ipv66lowpan-stack/en/latest/quick_start_intro/index.html) for the definition of star and mesh networks. These same principles apply also to Thread protocol.
mbed_official 19:f55c7983f8ab 23
mbed_official 19:f55c7983f8ab 24 Select the protocol the network is based on:
mbed_official 19:f55c7983f8ab 25
mbed_official 19:f55c7983f8ab 26 - 6LoWPAN-ND
mbed_official 19:f55c7983f8ab 27 - Thread
mbed_official 19:f55c7983f8ab 28
mbed_official 19:f55c7983f8ab 29 Select the device role:
mbed_official 19:f55c7983f8ab 30
mbed_official 19:f55c7983f8ab 31 - Mesh network. A router. (default)
mbed_official 19:f55c7983f8ab 32 - Star network. Non routing device. Also known as a host, or sleepy host.
mbed_official 19:f55c7983f8ab 33
mbed_official 19:f55c7983f8ab 34 Modify your `mbed_app.json` file to tell which Nanostack build to choose and which configrations to use on [mbed Mesh API](https://github.com/ARMmbed/mbed-os/blob/master/features/nanostack/FEATURE_NANOSTACK/mbed-mesh-api/README.md).
mbed_official 19:f55c7983f8ab 35
mbed_official 19:f55c7983f8ab 36 An example of the `mbed_app.json` file:
mbed_official 19:f55c7983f8ab 37
mbed_official 19:f55c7983f8ab 38 ```
mbed_official 19:f55c7983f8ab 39 ...
mbed_official 19:f55c7983f8ab 40 "mesh-type":{
mbed_official 19:f55c7983f8ab 41 "help": "options are MESH_LOWPAN, MESH_THREAD",
mbed_official 19:f55c7983f8ab 42 "value": "MESH_LOWPAN"
mbed_official 19:f55c7983f8ab 43 }
mbed_official 19:f55c7983f8ab 44 },
mbed_official 19:f55c7983f8ab 45 "target_overrides": {
mbed_official 19:f55c7983f8ab 46 "*": {
mbed_official 19:f55c7983f8ab 47 "target.features_add": ["NANOSTACK", "LOWPAN_ROUTER", "COMMON_PAL"],
mbed_official 19:f55c7983f8ab 48 "mbed-mesh-api.6lowpan-nd-device-type": "NET_6LOWPAN_ROUTER",
mbed_official 19:f55c7983f8ab 49 "mbed-mesh-api.thread-device-type": "MESH_DEVICE_TYPE_THREAD_ROUTER",
mbed_official 19:f55c7983f8ab 50 "mbed-mesh-api.heap-size": 32000,
mbed_official 19:f55c7983f8ab 51 "mbed-trace.enable": false
mbed_official 19:f55c7983f8ab 52 }
mbed_official 19:f55c7983f8ab 53 }
mbed_official 19:f55c7983f8ab 54 ```
mbed_official 19:f55c7983f8ab 55
mbed_official 19:f55c7983f8ab 56 The following tables show the values you should use in the `mbed_app.json` file for your devices in different networks.
mbed_official 19:f55c7983f8ab 57
mbed_official 19:f55c7983f8ab 58 - For 6LoWPAN-ND based network use `mesh-type: MESH_LOWPAN`.
mbed_official 19:f55c7983f8ab 59 - For Thread based network use `mesh-type: MESH_THREAD`.
mbed_official 19:f55c7983f8ab 60
mbed_official 19:f55c7983f8ab 61 **mesh-type: MESH_LOWPAN**
mbed_official 19:f55c7983f8ab 62
mbed_official 19:f55c7983f8ab 63 |Device role|`target.features_add` value|`mbed-mesh-api.6lowpan-nd-device-type`|
mbed_official 19:f55c7983f8ab 64 |-----------|-------------------------|------------------------------------|
mbed_official 19:f55c7983f8ab 65 |Mesh router (default) | LOWPAN_ROUTER | NET_6LOWPAN_ROUTER |
mbed_official 19:f55c7983f8ab 66 |Non routing device | LOWPAN_HOST | NET_6LOWPAN_HOST |
mbed_official 19:f55c7983f8ab 67
mbed_official 19:f55c7983f8ab 68 **mesh-type: MESH_THREAD**
mbed_official 19:f55c7983f8ab 69
mbed_official 19:f55c7983f8ab 70 |Device role|`target.features_add` value|`mbed-mesh-api.thread-device-type`|
mbed_official 19:f55c7983f8ab 71 |-----------|-------------------------|------------------------------------|
mbed_official 19:f55c7983f8ab 72 |Mesh router (default) | THREAD_ROUTER | MESH_DEVICE_TYPE_THREAD_ROUTER |
mbed_official 19:f55c7983f8ab 73 |Non routing device | THREAD_END_DEVICE | MESH_DEVICE_TYPE_THREAD_SLEEPY_END_DEVICE |
mbed_official 19:f55c7983f8ab 74
mbed_official 19:f55c7983f8ab 75 **Note:** You need to recompile your application after modifying the configurations by issuing the command `mbed compile -c`.
mbed_official 19:f55c7983f8ab 76
mbed_official 19:f55c7983f8ab 77 ### Requirements for hardware
mbed_official 19:f55c7983f8ab 78
mbed_official 19:f55c7983f8ab 79 The networking stack used in this example requires TLS functionality to be enabled on mbed TLS.
mbed_official 19:f55c7983f8ab 80 On devices where hardware entropy is not present, TLS is disabled by default. This would result in compile time failures or linking failures.
mbed_official 19:f55c7983f8ab 81
mbed_official 19:f55c7983f8ab 82 To learn why entropy is required, read the [TLS Porting guide](https://docs.mbed.com/docs/mbed-os-handbook/en/5.2/advanced/tls_porting/).
mbed_official 19:f55c7983f8ab 83
mbed_official 49:425a1889434d 84 See [Notes on different hardware](https://github.com/ARMmbed/mbed-os-example-mesh-minimal/blob/master/Hardware.md) for known combinations of development boards and RF shields that have been tested.
mbed_official 49:425a1889434d 85
Seppo Takalo 0:bde1843b9885 86 ### Compile the application
Seppo Takalo 0:bde1843b9885 87
mbed_official 49:425a1889434d 88 #### For 6LoWPAN
Seppo Takalo 0:bde1843b9885 89 ```
mbed_official 49:425a1889434d 90 mbed compile -m K64F -t GCC_ARM --app-config configs/mesh_6lowpan.json
mbed_official 49:425a1889434d 91 ```
mbed_official 49:425a1889434d 92
mbed_official 49:425a1889434d 93 #### For Thread
mbed_official 49:425a1889434d 94
mbed_official 49:425a1889434d 95 ```
mbed_official 49:425a1889434d 96 mbed compile -m K64F -t GCC_ARM --app-config configs/mesh_thread.json
Seppo Takalo 0:bde1843b9885 97 ```
Seppo Takalo 0:bde1843b9885 98
Seppo Takalo 0:bde1843b9885 99 A binary is generated at the end of the build process.
Seppo Takalo 0:bde1843b9885 100
Seppo Takalo 0:bde1843b9885 101 ### Connect the RF shield to the board
Seppo Takalo 0:bde1843b9885 102
Seppo Takalo 0:bde1843b9885 103 By default, we are using the Atmel AT86RF233 and it can be purchased [here](https://firefly-iot.com/product/firefly-arduino-shield-2-4ghz/). Place the shield on top of your board and power it up.
Seppo Takalo 0:bde1843b9885 104
Seppo Takalo 0:bde1843b9885 105 ### Program the target
Seppo Takalo 0:bde1843b9885 106
Seppo Takalo 0:bde1843b9885 107 Drag and drop the binary to the target to program the application.
Seppo Takalo 0:bde1843b9885 108
Seppo Takalo 0:bde1843b9885 109 ### Update the firmware of the border router
Seppo Takalo 0:bde1843b9885 110
mbed_official 19:f55c7983f8ab 111 This example supports the following two border routers:
Seppo Takalo 0:bde1843b9885 112
mbed_official 49:425a1889434d 113 - [Nanostack-border-router](https://github.com/ARMmbed/nanostack-border-router-private), 6LoWPAN only
mbed_official 19:f55c7983f8ab 114 - [mbed gateway](https://firefly-iot.com/product/firefly-6lowpan-gateway-2-4ghz/)
mbed_official 19:f55c7983f8ab 115
mbed_official 19:f55c7983f8ab 116 Read the instructions on updating the firmware of your mbed gateway working as 6LoWPAN [here](https://github.com/ARMmbed/mbed-os-example-client#mbed-gateway).
mbed_official 19:f55c7983f8ab 117
mbed_official 19:f55c7983f8ab 118 Both border routers support static and dynamic backhaul configuration. The static configuration is good for testing but the dynamic one works if your network infrastructure is supplying an IPv6 address. Make sure that you use the appropiate mode.
mbed_official 19:f55c7983f8ab 119
mbed_official 19:f55c7983f8ab 120 Remember to connect the Ethernet cable between the border router and your home/office router. Then power up the board.
Seppo Takalo 0:bde1843b9885 121
Seppo Takalo 0:bde1843b9885 122 ## Testing
Seppo Takalo 0:bde1843b9885 123
Seppo Takalo 0:bde1843b9885 124 As soon as both the border router and the target are up and running you can verify the correct behaviour. Open a serial console and see the IP address obtained by the device.
Seppo Takalo 0:bde1843b9885 125
mbed_official 13:4a0466077538 126 <span class="notes">**Note:** This application uses the baud rate of 115200.</span>
Seppo Takalo 0:bde1843b9885 127
Seppo Takalo 0:bde1843b9885 128 ```
Seppo Takalo 0:bde1843b9885 129 connected. IP = 2001:db8:a0b:12f0::1
Seppo Takalo 0:bde1843b9885 130 ```
Seppo Takalo 0:bde1843b9885 131
Seppo Takalo 0:bde1843b9885 132 You can use this IP address to `ping` from your PC and verify that the connection is working correctly.
Seppo Takalo 0:bde1843b9885 133
Seppo Takalo 0:bde1843b9885 134 ### Changing the radio driver (optional)
Seppo Takalo 0:bde1843b9885 135
Seppo Takalo 0:bde1843b9885 136 To run a 6LoWPAN-ND network, you need a working RF driver for Nanostack. This example uses the Atmel AT86RF233 by default.
Seppo Takalo 0:bde1843b9885 137
Seppo Takalo 0:bde1843b9885 138 To change the RF driver:
Seppo Takalo 0:bde1843b9885 139
Seppo Takalo 0:bde1843b9885 140 1. Uninstall the Atmel RF driver.
Seppo Takalo 0:bde1843b9885 141
Seppo Takalo 0:bde1843b9885 142 mbed remove atmel-rf-driver
Seppo Takalo 0:bde1843b9885 143
Seppo Takalo 0:bde1843b9885 144 2. Install the new driver. (For example, for the FRDM-CR20A radio shield based on the MCR20A device.)
Seppo Takalo 0:bde1843b9885 145
Seppo Takalo 0:bde1843b9885 146 mbed add mcr20a-rf-driver
Seppo Takalo 0:bde1843b9885 147
Seppo Takalo 0:bde1843b9885 148 3. Recompile your application.
Seppo Takalo 0:bde1843b9885 149
Seppo Takalo 0:bde1843b9885 150 mbed compile -m K64F -t GCC_ARM
Seppo Takalo 0:bde1843b9885 151
mbed_official 19:f55c7983f8ab 152 **Note:** Make sure that the `mbed_app.json` file is also updated to reflect the usage of a particular RF driver. For example,
mbed_official 17:ee2610e1cb78 153
mbed_official 17:ee2610e1cb78 154 ```json
mbed_official 17:ee2610e1cb78 155 "radio-type":{
mbed_official 17:ee2610e1cb78 156 "help": "options are ATMEL, MCR20",
mbed_official 17:ee2610e1cb78 157 "value": "ATMEL"
mbed_official 17:ee2610e1cb78 158 },
mbed_official 17:ee2610e1cb78 159 ```