mbed-os
Fork of mbed-os by
features/nanostack/FEATURE_NANOSTACK/mbed-mesh-api/README.md@0:f269e3021894, 2016-10-23 (annotated)
- Committer:
- elessair
- Date:
- Sun Oct 23 15:10:02 2016 +0000
- Revision:
- 0:f269e3021894
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
elessair | 0:f269e3021894 | 1 | # mbed mesh API |
elessair | 0:f269e3021894 | 2 | |
elessair | 0:f269e3021894 | 3 | ARM mbed mesh API allows the client to use the IPv6 mesh network. |
elessair | 0:f269e3021894 | 4 | |
elessair | 0:f269e3021894 | 5 | The client can use the `LoWPANNDInterface` or `ThreadInterface` object for connecting to the mesh network and when successfully connected, the client can create a socket by using the [mbed C++ socket API](https://developer.mbed.org/teams/NetworkSocketAPI/code/NetworkSocketAPI/docs/tip/) to start communication with a remote peer. |
elessair | 0:f269e3021894 | 6 | |
elessair | 0:f269e3021894 | 7 | ## Supported mesh networking modes |
elessair | 0:f269e3021894 | 8 | |
elessair | 0:f269e3021894 | 9 | Currently, 6LoWPAN-ND (neighbour discovery) and Thread bootstrap modes are supported. |
elessair | 0:f269e3021894 | 10 | |
elessair | 0:f269e3021894 | 11 | ## Module Configuration |
elessair | 0:f269e3021894 | 12 | |
elessair | 0:f269e3021894 | 13 | This module supports static configuration via **mbed configuration system** by using the `mbed_app.json` file. The application needs to create the configuration file if it wants to use other than default settings. |
elessair | 0:f269e3021894 | 14 | |
elessair | 0:f269e3021894 | 15 | An example of the configuration file: |
elessair | 0:f269e3021894 | 16 | |
elessair | 0:f269e3021894 | 17 | ``` |
elessair | 0:f269e3021894 | 18 | { |
elessair | 0:f269e3021894 | 19 | "target_overrides": { |
elessair | 0:f269e3021894 | 20 | "*": { |
elessair | 0:f269e3021894 | 21 | "target.features_add": ["IPV6"], |
elessair | 0:f269e3021894 | 22 | "mbed-mesh-api.6lowpan-nd-channel": 12, |
elessair | 0:f269e3021894 | 23 | "mbed-mesh-api.6lowpan-nd-channel-mask": "(1<<12)", |
elessair | 0:f269e3021894 | 24 | "mbed-mesh-api.heap-size": 10000 |
elessair | 0:f269e3021894 | 25 | } |
elessair | 0:f269e3021894 | 26 | } |
elessair | 0:f269e3021894 | 27 | } |
elessair | 0:f269e3021894 | 28 | ``` |
elessair | 0:f269e3021894 | 29 | |
elessair | 0:f269e3021894 | 30 | **Configurable parameters in section `mbed-mesh-api`:** |
elessair | 0:f269e3021894 | 31 | |
elessair | 0:f269e3021894 | 32 | | Parameter name | Value | Description | |
elessair | 0:f269e3021894 | 33 | | --------------- | ------------- | ----------- | |
elessair | 0:f269e3021894 | 34 | | heap-size | number [0-0xfffe] | Nanostack's internal heap size | |
elessair | 0:f269e3021894 | 35 | |
elessair | 0:f269e3021894 | 36 | **Thread related configuration parameters:** |
elessair | 0:f269e3021894 | 37 | |
elessair | 0:f269e3021894 | 38 | | Parameter name | Value | Description | |
elessair | 0:f269e3021894 | 39 | | --------------- | ------------- | ----------- | |
elessair | 0:f269e3021894 | 40 | | thread-pskd | string [6-255 chars] | Human-scaled commissioning credentials. | |
elessair | 0:f269e3021894 | 41 | | hread-device-type | enum from mesh_device_type_t | Set device operating mode. | |
elessair | 0:f269e3021894 | 42 | | thread-config-channel-mask | number [0-0x07fff800] | Channel mask, 0x07fff800 scans all channels. | |
elessair | 0:f269e3021894 | 43 | | thread-config-channel-page | number [0, 2]| Channel page, 0 for 2,4 GHz and 2 for sub-GHz radios. | |
elessair | 0:f269e3021894 | 44 | | thread-config-channel | number [0-27] | RF channel to use. | |
elessair | 0:f269e3021894 | 45 | | thread-config-panid | number [0-0xFFFF] | Network identifier. | |
elessair | 0:f269e3021894 | 46 | | thread-master-key | byte array [16]| Network master key. | |
elessair | 0:f269e3021894 | 47 | | thread-config-ml-prefix | byte array [8] | Mesh local prefix. | |
elessair | 0:f269e3021894 | 48 | | thread-config-pskc | byte array [16] | Pre-Shared Key for the Commissioner. | |
elessair | 0:f269e3021894 | 49 | |
elessair | 0:f269e3021894 | 50 | **6LoWPAN related configuration parameters:** |
elessair | 0:f269e3021894 | 51 | |
elessair | 0:f269e3021894 | 52 | | Parameter name | Type | Description | |
elessair | 0:f269e3021894 | 53 | | --------------- | ---------| ----------- | |
elessair | 0:f269e3021894 | 54 | | 6lowpan-nd-channel-mask | number [0-0x07fff800] | Channel mask, bit-mask of channels to use | |
elessair | 0:f269e3021894 | 55 | | 6lowpan-nd-channel-page | number [0, 2] | 0 for 2,4 GHz and 2 for sub-GHz radios | |
elessair | 0:f269e3021894 | 56 | | 6lowpan-nd-channel | number [0-27] | RF channel to use when `channel_mask` is not defined | |
elessair | 0:f269e3021894 | 57 | | 6lowpan-nd-security-mode | "NONE" or "PSK" | To use either no security, or Pre shared network key | |
elessair | 0:f269e3021894 | 58 | | 6lowpan-nd-psk-key-id | number | PSK key id when PSK is enabled | |
elessair | 0:f269e3021894 | 59 | | 6lowpan-nd-psk-key | byte array [16] | Pre shared network key | |
elessair | 0:f269e3021894 | 60 | | 6lowpan-nd-sec-level | number [1-7] | Network security level. Use default `5` | |
elessair | 0:f269e3021894 | 61 | | 6lowpan-nd-device-type | "NET_6LOWPAN_ROUTER" or "NET_6LOWPAN_HOST" | Device mode. Router is routing packets from other device, creating a mesh network. | |
elessair | 0:f269e3021894 | 62 | |
elessair | 0:f269e3021894 | 63 | ## Usage notes |
elessair | 0:f269e3021894 | 64 | |
elessair | 0:f269e3021894 | 65 | This module should not be used directly by the applications. The applications should use the `LoWPANNDInterface` or `ThreadInterface` directly. |
elessair | 0:f269e3021894 | 66 | |
elessair | 0:f269e3021894 | 67 | ### Network connection states |
elessair | 0:f269e3021894 | 68 | |
elessair | 0:f269e3021894 | 69 | After the initialization, the network state is `MESH_DISCONNECTED`. After a successful connection, the state changes to `MESH_CONNECTED` and when disconnected from the network the state is changed back to `MESH_DISCONNECTED`. |
elessair | 0:f269e3021894 | 70 | |
elessair | 0:f269e3021894 | 71 | In case of connection errors, the state is changed to some of the connection error states. In an error state, there is no need to make a `disconnect` request and the client is allowed to attempt connecting again. |
elessair | 0:f269e3021894 | 72 | |
elessair | 0:f269e3021894 | 73 | ## Getting started |
elessair | 0:f269e3021894 | 74 | |
elessair | 0:f269e3021894 | 75 | See the example application [mbed-os-example-mesh-minimal](https://github.com/ARMmbed/mbed-os-example-mesh-minimal) for usage. |
elessair | 0:f269e3021894 | 76 | |
elessair | 0:f269e3021894 | 77 | ## Usage example for 6LoWPAN ND mode |
elessair | 0:f269e3021894 | 78 | |
elessair | 0:f269e3021894 | 79 | **Create a network interface:** |
elessair | 0:f269e3021894 | 80 | |
elessair | 0:f269e3021894 | 81 | ``` |
elessair | 0:f269e3021894 | 82 | LoWPANNDInterface mesh; |
elessair | 0:f269e3021894 | 83 | ``` |
elessair | 0:f269e3021894 | 84 | |
elessair | 0:f269e3021894 | 85 | **Connect:** |
elessair | 0:f269e3021894 | 86 | |
elessair | 0:f269e3021894 | 87 | ``` |
elessair | 0:f269e3021894 | 88 | if (mesh.connect()) { |
elessair | 0:f269e3021894 | 89 | printf("Connection failed!\r\n"); |
elessair | 0:f269e3021894 | 90 | return -1; |
elessair | 0:f269e3021894 | 91 | } |
elessair | 0:f269e3021894 | 92 | |
elessair | 0:f269e3021894 | 93 | printf("connected. IP = %s\r\n", mesh.get_ip_address()); |
elessair | 0:f269e3021894 | 94 | ``` |
elessair | 0:f269e3021894 | 95 | |
elessair | 0:f269e3021894 | 96 | ## Usage example for 6LoWPAN Thread mode |
elessair | 0:f269e3021894 | 97 | |
elessair | 0:f269e3021894 | 98 | Basically the same as for ND, but the network interface uses different class: |
elessair | 0:f269e3021894 | 99 | |
elessair | 0:f269e3021894 | 100 | ``` |
elessair | 0:f269e3021894 | 101 | ThreadInterface mesh; |
elessair | 0:f269e3021894 | 102 | mesh.connect(); |
elessair | 0:f269e3021894 | 103 | ``` |