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 two types of IPv6 based mesh networks:
- 6LoWPAN_ND, loosely following the Zigbee-IP specification.
- Wi-SUN, following the specification from Wi-SUN alliance.
Nanostack is the networking stack that provides these protocols. For more information on the stack internals, please refer to the Wi-SUN and 6LowPAN sections. Application developers use Nanostack through the Mbed Mesh API.
The application can use the LoWPANNDInterface
and WisunInterface
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
- Create a network interface and driver objects.
- Initialize the interface with given PHY driver.
- Connect to network.
Supported mesh networking modes
Currently, 6LoWPAN-ND (neighbor discovery) and Wi-SUN FAN 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 MeshInterface * | meshInterface () |
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 EthInterface * | ethInterface () |
Return pointer to an EthInterface. More... | |
virtual WiFiInterface * | wifiInterface () |
Return pointer to a WiFiInterface. More... | |
virtual CellularInterface * | cellularBase () |
Return pointer to a CellularInterface. More... | |
virtual EMACInterface * | emacInterface () |
Return pointer to an EMACInterface. More... | |
virtual void | set_default_parameters () |
defined(DOXYGEN_ONLY) More... | |
virtual CellularInterface * | cellularInterface () |
Return pointer to a CellularInterface. More... |
Static Public Member Functions | |
static MeshInterface * | get_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 or Wi-SUN network.
Related content
- Wi-SUN technology reference material.
- 6LowPAN technology reference material.
- 6LoWPAN and Wi-SUN Mesh configuration documentation.
- Light control tutorial.