Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
MeshInterfaceNanostack Class Reference
Nanostack's network interface class. More...
#include <MeshInterfaceNanostack.h>
Inherits MeshInterface.
Inherited by LoWPANNDInterface, NanostackEthernetInterface, and ThreadInterface.
Public Member Functions | |
nsapi_error_t | initialize (NanostackPhy *phy) |
Attach phy and initialize the mesh. | |
virtual nsapi_error_t | connect ()=0 |
Start the interface. | |
virtual nsapi_error_t | disconnect ()=0 |
Stop the interface. | |
virtual const char * | get_ip_address () |
Get the internally stored IP address /return IP address of the interface or null if not yet connected. | |
virtual const char * | get_mac_address () |
Get the internally stored MAC address /return MAC address of the interface. | |
int8_t | get_interface_id () const |
Get the interface ID /return Interface identifier. | |
void | mesh_network_handler (mesh_connection_status_t status) |
Callback from C-layer. | |
virtual void | attach (mbed::Callback< void(nsapi_event_t, intptr_t)> status_cb) |
Register callback for status reporting. | |
virtual nsapi_connection_status_t | get_connection_status () const |
Get the connection status. | |
virtual nsapi_error_t | set_blocking (bool blocking) |
Set blocking status of connect() which by default should be blocking. | |
virtual const char * | get_netmask () |
Get the local network mask. | |
virtual const char * | get_gateway () |
Get the local gateway. | |
virtual nsapi_error_t | set_network (const char *ip_address, const char *netmask, const char *gateway) |
Set a static IP address. | |
virtual nsapi_error_t | set_dhcp (bool dhcp) |
Enable or disable DHCP on the network. | |
virtual nsapi_error_t | gethostbyname (const char *host, SocketAddress *address, nsapi_version_t version=NSAPI_UNSPEC) |
Translates a hostname to an IP address with specific version. | |
virtual nsapi_error_t | add_dns_server (const SocketAddress &address) |
Add a domain name server to list of servers to query. | |
Protected Member Functions | |
virtual bool | getOwnIpAddress (char *address, int8_t len)=0 |
Read own global IP address. | |
Protected Attributes | |
int8_t | _network_interface_id |
Network interface ID. | |
int8_t | _device_id |
Registered device ID. | |
Friends | |
class | Socket |
class | UDPSocket |
class | TCPSocket |
Detailed Description
Nanostack's network interface class.
Common class that is shared between mesh interface classes
Definition at line 29 of file MeshInterfaceNanostack.h.
Member Function Documentation
nsapi_error_t add_dns_server | ( | const SocketAddress & | address ) | [virtual, inherited] |
Add a domain name server to list of servers to query.
- Parameters:
-
address Destination for the host address
- Returns:
- 0 on success, negative error code on failure
Definition at line 60 of file NetworkInterface_stub.cpp.
virtual void attach | ( | mbed::Callback< void(nsapi_event_t, intptr_t)> | status_cb ) | [virtual] |
Register callback for status reporting.
- Parameters:
-
status_cb The callback for status changes
virtual nsapi_error_t connect | ( | ) | [pure virtual] |
Start the interface.
- Returns:
- 0 on success, negative on failure
Implemented in LoWPANNDInterface, NanostackEthernetInterface, and ThreadInterface.
virtual nsapi_error_t disconnect | ( | ) | [pure virtual] |
Stop the interface.
- Returns:
- 0 on success, negative on failure
Implemented in LoWPANNDInterface, NanostackEthernetInterface, and ThreadInterface.
nsapi_connection_status_t get_connection_status | ( | ) | const [virtual] |
Get the connection status.
- Returns:
- The connection status according to ConnectionStatusType
Definition at line 133 of file MeshInterfaceNanostack.cpp.
const char * get_gateway | ( | ) | [virtual, inherited] |
Get the local gateway.
- Returns:
- Null-terminated representation of the local gateway or null if no network mask has been received
Definition at line 39 of file NetworkInterface_stub.cpp.
int8_t get_interface_id | ( | ) | const |
Get the interface ID /return Interface identifier.
Definition at line 66 of file MeshInterfaceNanostack.h.
const char * get_ip_address | ( | ) | [virtual] |
Get the internally stored IP address /return IP address of the interface or null if not yet connected.
Definition at line 114 of file MeshInterfaceNanostack.cpp.
const char * get_mac_address | ( | ) | [virtual] |
Get the internally stored MAC address /return MAC address of the interface.
Definition at line 128 of file MeshInterfaceNanostack.cpp.
const char * get_netmask | ( | ) | [virtual, inherited] |
Get the local network mask.
- Returns:
- Null-terminated representation of the local network mask or null if no network mask has been received
Definition at line 34 of file NetworkInterface_stub.cpp.
nsapi_error_t gethostbyname | ( | const char * | host, |
SocketAddress * | address, | ||
nsapi_version_t | version = NSAPI_UNSPEC |
||
) | [virtual, inherited] |
Translates a hostname to an IP address with specific version.
The hostname may be either a domain name or an IP address. If the hostname is an IP address, no network transactions will be performed.
If no stack-specific DNS resolution is provided, the hostname will be resolve using a UDP socket on the stack.
- Parameters:
-
address Destination for the host SocketAddress host Hostname to resolve version IP version of address to resolve, NSAPI_UNSPEC indicates version is chosen by the stack (defaults to NSAPI_UNSPEC)
- Returns:
- 0 on success, negative error code on failure
Definition at line 55 of file NetworkInterface_stub.cpp.
virtual bool getOwnIpAddress | ( | char * | address, |
int8_t | len | ||
) | [protected, pure virtual] |
Read own global IP address.
- Parameters:
-
address is where the IP address will be copied len is the length of the address buffer, must be at least 40 bytes
- Returns:
- true if address is read successfully, false otherwise
Implemented in LoWPANNDInterface, and NanostackEthernetInterface.
nsapi_error_t initialize | ( | NanostackPhy * | phy ) |
Attach phy and initialize the mesh.
Initializes a mesh interface on the given phy. Not needed if the phy is passed to the mesh's constructor.
- Returns:
- 0 on success, negative on failure
Definition at line 39 of file MeshInterfaceNanostack.cpp.
void mesh_network_handler | ( | mesh_connection_status_t | status ) |
Callback from C-layer.
- Parameters:
-
status state of the network
Definition at line 49 of file MeshInterfaceNanostack.cpp.
nsapi_error_t set_blocking | ( | bool | blocking ) | [virtual] |
Set blocking status of connect() which by default should be blocking.
- Parameters:
-
blocking true if connect is blocking
- Returns:
- 0 on success, negative error code on failure
Definition at line 144 of file MeshInterfaceNanostack.cpp.
nsapi_error_t set_dhcp | ( | bool | dhcp ) | [virtual, inherited] |
Enable or disable DHCP on the network.
Enables DHCP on connecting the network. Defaults to enabled unless a static IP address has been assigned. Requires that the network is disconnected.
- Parameters:
-
dhcp True to enable DHCP
- Returns:
- 0 on success, negative error code on failure
Definition at line 49 of file NetworkInterface_stub.cpp.
nsapi_error_t set_network | ( | const char * | ip_address, |
const char * | netmask, | ||
const char * | gateway | ||
) | [virtual, inherited] |
Set a static IP address.
Configures this network interface to use a static IP address. Implicitly disables DHCP, which can be enabled in set_dhcp. Requires that the network is disconnected.
- Parameters:
-
ip_address Null-terminated representation of the local IP address netmask Null-terminated representation of the local network mask gateway Null-terminated representation of the local gateway
- Returns:
- 0 on success, negative error code on failure
Definition at line 44 of file NetworkInterface_stub.cpp.
Field Documentation
int8_t _device_id [protected] |
Registered device ID.
Definition at line 112 of file MeshInterfaceNanostack.h.
int8_t _network_interface_id [protected] |
Network interface ID.
Definition at line 110 of file MeshInterfaceNanostack.h.
Generated on Tue Jul 12 2022 12:22:48 by
