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:

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

The application can use the LoWPANNDInterface, WisunInterface or ThreadInterface object to connect 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 use the Network status API to monitor changes in the network status.

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

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

The following code snippet illustrates how you can use the MeshInterface API:

#include "mbed.h"

int main(void)
{
    MeshInterface *mesh = MeshInterface::get_default_instance();

    int status = mesh->connect();
    if (status) {
        printf("Connection failed! error %d\n", status);
        return status;
    }

    printf("Connected!\n");

    UDPSocket sock;
    status = sock.open(mesh);
    if (status) {
        printf("Failed to open socket, error %d\n", status);
    }

    // Now the interface is connected, and I can communicate with Sockets
}

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.