Mistake on this page?
Report an issue in GitHub or email us

Mesh

MeshInterface class hierarchy

The Arm Mbed Mesh API allows the application to use the IPv6 mesh network topologies through the Nanostack networking stack.

Mbed OS provides three types of IPv6 based mesh networks:

  • 6LoWPAN_ND, loosely following the Zigbee-IP specification.
  • Wi-SUN, following the specification from Wi-SUN alliance.
  • Thread, following the specification from Thread Group.

Nanostack is the networking stack that provides these protocols. For more information on the stack internals, please refer to the Thread, Wi-SUN and 6LowPAN sections. Application developers use Nanostack through the Mbed Mesh API.

The application can use the LoWPANNDInterface, WisunInterface or ThreadInterface object for connecting to the mesh network. When successfully connected, the application can use the Mbed C++ socket APIs to create a socket to start communication with a remote peer.

You can configure the mesh interface by providing values in mbed_app.json, as the mesh configuration section documents.

Usage

  1. Create a network interface and driver objects.
  2. Initialize the interface with given PHY driver.
  3. Connect to network.

Supported mesh networking modes

Currently, 6LoWPAN-ND (neighbor discovery), Wi-SUN FAN and Thread bootstrap modes are supported.

Network connection states

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.

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 application is allowed to attempt connecting again.

Getting started

See the example application mbed-os-example-mesh-minimal for usage.

Mesh class reference

Public Types
typedef mbed::Callback< void(nsapi_error_t result, SocketAddress *address)> hostbyname_cb_t
 Hostname translation callback (for use with gethostbyname_async()). More...
Public Member Functions
virtual MeshInterfacemeshInterface ()
 Return pointer to a MeshInterface. More...
virtual void set_as_default ()
 Set network interface as default one. More...
virtual const char * get_mac_address ()
 Get the local MAC address. More...
virtual const char * get_ip_address ()
 Get the local IP address. More...
virtual const char * get_netmask ()
 Get the local network mask. More...
virtual const char * get_gateway ()
 Get the local gateway. More...
virtual char * get_interface_name (char *interface_name)
 Get the network interface name. More...
virtual nsapi_error_t set_network (const char *ip_address, const char *netmask, const char *gateway)
 Configure this network interface to use a static IP address. More...
virtual nsapi_error_t set_dhcp (bool dhcp)
 Enable or disable DHCP on connecting the network. More...
virtual nsapi_error_t connect ()=0
 Connect to a network. More...
virtual nsapi_error_t disconnect ()=0
 Disconnect from the network. More...
virtual nsapi_error_t gethostbyname (const char *host, SocketAddress *address, nsapi_version_t version=NSAPI_UNSPEC, const char *interface_name=NULL)
 Translate a hostname to an IP address with specific version using network interface name. More...
virtual nsapi_value_or_error_t gethostbyname_async (const char *host, hostbyname_cb_t callback, nsapi_version_t version=NSAPI_UNSPEC, const char *interface_name=NULL)
 Translate a hostname to an IP address (asynchronous) using network interface name. More...
virtual nsapi_error_t gethostbyname_async_cancel (int id)
 Cancel asynchronous hostname translation. More...
virtual nsapi_error_t add_dns_server (const SocketAddress &address, const char *interface_name)
 Add a domain name server to list of servers to query. More...
virtual void attach (mbed::Callback< void(nsapi_event_t, intptr_t)> status_cb)
 Register callback for status reporting. More...
void add_event_listener (mbed::Callback< void(nsapi_event_t, intptr_t)> status_cb)
 Add event listener for interface. More...
void remove_event_listener (mbed::Callback< void(nsapi_event_t, intptr_t)> status_cb)
 Remove event listener from interface. More...
virtual nsapi_connection_status_t get_connection_status () const
 Get the connection status. More...
virtual nsapi_error_t set_blocking (bool blocking)
 Set asynchronous operation of connect() and disconnect() calls. More...
virtual EthInterfaceethInterface ()
 Return pointer to an EthInterface. More...
virtual WiFiInterfacewifiInterface ()
 Return pointer to a WiFiInterface. More...
virtual CellularInterfacecellularBase ()
 Return pointer to a CellularInterface. More...
virtual EMACInterfaceemacInterface ()
 Return pointer to an EMACInterface. More...
virtual void set_default_parameters ()
 defined(DOXYGEN_ONLY) More...
virtual CellularInterfacecellularInterface ()
 Return pointer to a CellularInterface. More...
Static Public Member Functions
static MeshInterfaceget_default_instance ()
 Get the default Mesh interface. More...

Mesh example

To learn how to use mesh, please see our light control tutorial, which demonstrates a light control application, where devices can control the LED status of all devices in the network. You can build the application for the unsecure 6LoWPAN-ND, Wi-SUN or Thread network.

Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.