Documentation

Mistake on this page? Email us

Wi-SUN tutorial

This tutorial provides guidelines on how to create your own Wi-SUN Field Area Network (FAN) mesh network and register your devices to Pelion Device Management.

Wi-SUN FAN has been designed for wireless outdoor networks, such as smart metering and street lighting systems. Its performance is optimized for large-scale networks rather than small networks. Therefore, when connecting the devices, be patient; the network formation takes time.

Network topologyNetwork topology

Constraints

This Wi-SUN reference deployment is meant for indoor or laboratory environments:

  • The reference deployment consists of uncased development boards.
  • RF coverage is limited, as the RF shield does not include additional amplifiers.

In RF signaling, the radio EUI64 MAC address must be globally unique, or the devices cannot operate in the same region. You can do this using a separate chip on your own EUI64 range. The Ethernet address (EUI48) must also be unique.

For small-scale testing, use TRNG-randomized EUI64 and EUI48 values. For larger-scale deployments, you must ensure address uniqueness. For more information about obtaining globally unique MAC/Ethernet address see IEEE faqs.

Hardware requirements

To build a Wi-SUN FAN, you need the following Arm reference hardware:

  • Wi-SUN devices (for example, 10 pieces).

  • RF shields (for each Wi-SUN device and border router).

    The default SPI SCLK pin configuration is D13. On the X-Nucleo-S2868A2, resistor R6 must be soldered instead of R11. For more information, please see the UM2638 user manual.

    Resistor soldering to R6Resistor soldering to R6

  • A Wi-SUN border router.

    • Ethernet connection (recommended) for the border router, with IPv6 connectivity with stateless address auto configuration (SLAAC) enabled.

    • LTE connection (optionally) for the border router.

      Note: You must ensure you use the correct variant of this modem to work in your country.

Required accounts

You need the following accounts:

Setting up and running the border router

There are two alternative border routers available:

From the mesh network point of view, these border routers are the same. The main difference is Pelion Border Router also contains Device Management Client, which means this border router can register to and use services of Device Management.

To set up the border router:

  1. Clone the pelion-border-router or nanostack-border-router repository.
  2. Run mbed deploy.
  3. Select the target platform.
  4. Select the toolchain.
  5. Build with Wi-SUN configurations.

Note: Run mbed detect to list connected targets and supported toolchains.

Pelion Border Router example:

$ mbed deploy

$ mbed target DISCO_F769NI

$ mbed toolchain GCC_ARM

$ mbed compile --app-config mbed_app.json

Nanostack Border Router example:

$ mbed deploy

$ mbed target DISCO_F769NI

$ mbed toolchain GCC_ARM

$ mbed compile --app-config configs/Wisun_Stm_s2lp_RF.json

If you are not using Ethernet with Nanostack Border Router, use configs for LTE backbone instead.

Running the border router application

To run the border router application:

  1. Find the binary file pelion-border-router.bin or nanostack-border-router.binin the BUILD folder.

  2. Copy the binary to the USB mass storage root of the development board. It automatically flashes to the target MCU. When the flashing is complete, the board restarts itself.

  3. Press the reset button of the development board if it does not restart automatically.

  4. The program begins execution.

  5. Open the serial connection, for example with PuTTY.

See more detailed instructions in:

Tip: Use the same Mbed OS version in the border router and the application (Device Management Client).

Border router with LTE back endBorder router with LTE backbone

Setting up the Wi-SUN devices and connect

Please follow the Pelion Device Management Client tutorial for the prerequisites and basic steps. The key difference is to use the application configuration file for Wi-SUN (configs/mesh_wisun.json) when compiling the client with Nanostack Border Router.

  1. If you are using Nanostack Border Router, copy the configs/mesh_wisun.json file on top of the mbed_app.json in example root folder. For Pelion Border Router, the file mbed_app.jsonalready contains the Wi-SUN configuration settings.

  2. Use the Wi-SUN certificate definitions file configs/wisun_certificates.h, or generate your own Wi-SUN certificates (recommended) file to the same location.

  3. Ensure required Wi-SUN certificates (in file wisun_certificates.h) are valid (WISUN_ROOT_CERTIFICATE, WISUN_CLIENT_CERTIFICATE, WISUN_CLIENT_KEY), and match the settings you are using with the border router. Invalid certificates or certificates that don't match prevent mesh network formation.

  4. In the mbed_cloud_client_user_config.h file, change MBED_CLOUD_CLIENT_TRANSPORT_MODE_TCP to MBED_CLOUD_CLIENT_TRANSPORT_MODE_UDP to use the UDP protocol instead of the default TCP.

  5. Select the appropriate application startup delay parameters for your network. These parameters help stabilize network formation with more even distribution of client traffic peaks. Specify the parameters in the application configuration file. For a network of 100 connected devices, you could specify for example:

    "client_app.startup_min_random_delay"       : 100,
    "client_app.startup_max_random_delay"       : 7200,
    
  6. Optimize the DNS API configuration to fit for high latency networks. If the client cannot connect to Device Management due to DnsResolvingFailed errors, we recommend that you fine-tune the Mbed OS DNS API configurations. The Mbed OS defaults are more suitable for low latency networks. For a network of 100 connected devices, specify for example:

    "nsapi.dns-response-wait-time"              : 100000,
    "nsapi.dns-total-attempts"                  : 3,
    "nsapi.dns-retries"                         : 3,
    

Tip: Use the same Mbed OS version in the border router and the application (Device Management Client).

Note: When you go to production, please do not use the example Wi-SUN certificate files provided as is due to security reasons.

Wi-SUN device

Validating

To validate the formation of your Wi-SUN network and the registration of devices to Device Management, open Device Management Portal, and check the devices have been registered:

Devices in Device Management Portal

Troubleshooting

This is a living list of possible issues and solutions to them.

Additional tools

You can use an Ethernet and RF sniffer to capture traces, then analyze them using Wireshark.

Use a managed switch to capture all traffic through the Ethernet interface. You can configure the switch to mirror all traffic to a single port connected to a computer running Wireshark.

Registration failing

If the device does not register successfully to Pelion Device Management, check the soldering is done properly.

To enable traces, modify the application configuration file:

  • configs/mesh_wisun_S2LP.json if you use Nanostack Border Router.
  • mbed_app.json if you use Pelion Border Router`.
"mbed-trace.enable": true

Then ensure you do NOT see this error in the logs:

[ERR ][s2lp]: Failed to change state from 0 to: 30

A Failed to change state error either indicates an antenna circuit failure or a communication issue between the S2-LP transceiver and MCU.

First, check your soldering, and make sure the resistor is properly connected to R6. If you still see the issue, the antenna may not be suitable for use with this configuration.

Problem connecting to Device Management after forming the Wi-SUN network

When the Wi-SUN network has formed but the registration to Device Management is failing, make sure the device has received a routable global address. There should be a NSAPI_STATUS_GLOBAL_UP trace in the logs:

[INFO][plat]: NSAPI_STATUS_GLOBAL_UP
IP: fd00:7283:7e00:0:90af:a769:ada8:9f3c
MAC Address: 92:af:a7:69:ad:a8:9f:3c

If the address of the device is in the form fc00:: or fd00:: it is a Unicast Local Address (ULA) and not globally routable. This can be an indication of the backbone connection from border router not working properly.

In some configurations, where the Wi-SUN network is behind a VPN tunnel or an On Premises deployment, the ULA address is fully functional and there are no issues. Check the address to which the devices are assigned and make sure it matches the deployment type.