Mistake on this page?
Report an issue in GitHub or email us
Public Member Functions | Protected Member Functions | Protected Attributes
EMACInterface Class Reference

#include <EMACInterface.h>

Inheritance diagram for EMACInterface:
NetworkInterface DNS EthernetInterface

Public Member Functions

 EMACInterface (EMAC &emac=EMAC::get_default_instance(), OnboardNetworkStack &stack=OnboardNetworkStack::get_default_instance())
 
virtual nsapi_error_t set_network (const char *ip_address, const char *netmask, const char *gateway)
 
virtual nsapi_error_t set_dhcp (bool dhcp)
 
virtual nsapi_error_t connect ()
 
virtual nsapi_error_t disconnect ()
 
virtual const char * get_mac_address ()
 
virtual const char * get_ip_address ()
 
virtual const char * get_netmask ()
 
virtual const char * get_gateway ()
 
virtual void attach (mbed::Callback< void(nsapi_event_t, intptr_t)> status_cb)
 
virtual nsapi_connection_status_t get_connection_status () const
 
virtual nsapi_error_t set_blocking (bool blocking)
 
EMACget_emac () const
 
virtual EMACInterfaceemacInterface ()
 
- Public Member Functions inherited from NetworkInterface
virtual nsapi_error_t gethostbyname (const char *host, SocketAddress *address, nsapi_version_t version=NSAPI_UNSPEC)
 
virtual nsapi_value_or_error_t gethostbyname_async (const char *host, hostbyname_cb_t callback, nsapi_version_t version=NSAPI_UNSPEC)
 
virtual nsapi_error_t gethostbyname_async_cancel (int id)
 
virtual nsapi_error_t add_dns_server (const SocketAddress &address)
 
virtual EthInterfaceethInterface ()
 
virtual WiFiInterfacewifiInterface ()
 
virtual MeshInterfacemeshInterface ()
 
virtual CellularBasecellularBase ()
 

Protected Member Functions

virtual NetworkStackget_stack ()
 

Protected Attributes

EMAC_emac
 
OnboardNetworkStack_stack
 
OnboardNetworkStack::Interface_interface
 
bool _dhcp
 
bool _blocking
 
char _mac_address [18]
 
char _ip_address [40]
 
char _netmask [16]
 
char _gateway [16]
 
Callback< void(nsapi_event_t, intptr_t)> _connection_status_cb
 

Additional Inherited Members

- Public Types inherited from NetworkInterface
typedef mbed::Callback< void(nsapi_error_t result, SocketAddress *address)> hostbyname_cb_t
 
- Public Types inherited from DNS
typedef mbed::Callback< void(nsapi_error_t result, SocketAddress *address)> hostbyname_cb_t
 
- Static Public Member Functions inherited from NetworkInterface
static NetworkInterfaceget_default_instance ()
 
- Static Protected Member Functions inherited from NetworkInterface
static NetworkInterfaceget_target_default_instance ()
 

Detailed Description

EMACInterface class Implementation of the NetworkInterface for an EMAC-based driver

This class provides the necessary glue logic to create a NetworkInterface based on an EMAC and an OnboardNetworkStack. EthernetInterface and EMAC-based Wi-Fi drivers derive from it.

Drivers derived from EMACInterface should be constructed so that their EMAC is functional without the need to call connect(). For example a Wi-Fi driver should permit WiFi::get_emac().power_up() as soon as the credentials have been set. This is necessary to support specialised applications such as 6LoWPAN mesh border routers.

Constructor & Destructor Documentation

EMACInterface::EMACInterface ( EMAC emac = EMAC::get_default_instance(),
OnboardNetworkStack stack = OnboardNetworkStack::get_default_instance() 
)

Create an EMAC-based network interface.

The default arguments obtain the default EMAC, which will be target- dependent (and the target may have some JSON option to choose which is the default, if there are multiple). The default stack is configured by JSON option nsapi.default-stack.

Due to inability to return errors from the constructor, no real work is done until the first call to connect().

Parameters
emacReference to EMAC to use
stackReference to onboard-network stack to use

Member Function Documentation

void EMACInterface::attach ( mbed::Callback< void(nsapi_event_t, intptr_t)>  status_cb)
virtual

Register callback for status reporting

Parameters
status_cbThe callback for status changes

Reimplemented from NetworkInterface.

nsapi_error_t EMACInterface::connect ( )
virtual

Start the interface

Returns
0 on success, negative on failure

Implements NetworkInterface.

nsapi_error_t EMACInterface::disconnect ( void  )
virtual

Stop the interface

Returns
0 on success, negative on failure

Implements NetworkInterface.

virtual EMACInterface* EMACInterface::emacInterface ( )
inlinevirtual

Dynamic downcast to an EMACInterface

Reimplemented from NetworkInterface.

nsapi_connection_status_t EMACInterface::get_connection_status ( ) const
virtual

Get the connection status

Returns
The connection status according to nsapi_connection_status_t

Reimplemented from NetworkInterface.

EMAC& EMACInterface::get_emac ( ) const
inline

Provide access to the EMAC

This should be used with care - normally the network stack would control the EMAC, so manipulating the EMAC while the stack is also using it (ie after connect) will likely cause problems.

Returns
Reference to the EMAC in use
const char * EMACInterface::get_gateway ( )
virtual

Get the local gateways

Returns
Null-terminated representation of the local gateway or null if no network mask has been recieved

Reimplemented from NetworkInterface.

const char * EMACInterface::get_ip_address ( )
virtual

Get the local IP address

Returns
Null-terminated representation of the local IP address or null if no IP address has been recieved

Reimplemented from NetworkInterface.

const char * EMACInterface::get_mac_address ( )
virtual

Get the local MAC address

Provided MAC address is intended for info or debug purposes and may not be provided if the underlying network interface does not provide a MAC address

Returns
Null-terminated representation of the local MAC address or null if no MAC address is available

Reimplemented from NetworkInterface.

const char * EMACInterface::get_netmask ( )
virtual

Get the local network mask

Returns
Null-terminated representation of the local network mask or null if no network mask has been recieved

Reimplemented from NetworkInterface.

NetworkStack * EMACInterface::get_stack ( void  )
protectedvirtual

Provide access to the underlying stack

Returns
The underlying network stack

Implements NetworkInterface.

nsapi_error_t EMACInterface::set_blocking ( bool  blocking)
virtual

Set blocking status of connect() which by default should be blocking

Parameters
blockingtrue if connect is blocking
Returns
0 on success, negative error code on failure

Reimplemented from NetworkInterface.

nsapi_error_t EMACInterface::set_dhcp ( bool  dhcp)
virtual

Enable or disable DHCP on the network

Requires that the network is disconnected

Parameters
dhcpFalse to disable dhcp (defaults to enabled)
Returns
0 on success, negative error code on failure

Reimplemented from NetworkInterface.

nsapi_error_t EMACInterface::set_network ( const char *  ip_address,
const char *  netmask,
const char *  gateway 
)
virtual

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_addressNull-terminated representation of the local IP address
netmaskNull-terminated representation of the local network mask
gatewayNull-terminated representation of the local gateway
Returns
0 on success, negative error code on failure

Reimplemented from NetworkInterface.


The documentation for this class was generated from the following files:
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.