ON Semiconductor / mbed-os

Dependents:   mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510

Embed: (wiki syntax)

« Back to documentation index

WiFiInterface Class Reference

WiFiInterface class. More...

#include <WiFiInterface.h>

Inherits NetworkInterface.

Public Member Functions

virtual ~WiFiInterface ()
 WiFiInterface lifetime.
virtual nsapi_error_t set_credentials (const char *ssid, const char *pass, nsapi_security_t security=NSAPI_SECURITY_NONE)=0
 Set the WiFi network credentials.
virtual nsapi_error_t set_channel (uint8_t channel)=0
 Set the WiFi network channel.
virtual int8_t get_rssi ()=0
 Gets the current radio signal strength for active connection.
virtual nsapi_error_t connect (const char *ssid, const char *pass, nsapi_security_t security=NSAPI_SECURITY_NONE, uint8_t channel=0)=0
 Start the interface.
virtual nsapi_error_t connect ()=0
 Start the interface.
virtual nsapi_error_t disconnect ()=0
 Stop the interface.
virtual nsapi_size_or_error_t scan (WiFiAccessPoint *res, nsapi_size_t count)=0
 Scan for available networks.
virtual const char * get_mac_address ()
 Get the local MAC address.
virtual const char * get_ip_address ()
 Get the local IP address.
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 NetworkStackget_stack ()=0
 Provide access to the NetworkStack object.

Friends

class Socket
class UDPSocket
class TCPSocket
class TCPServer
class SocketAddress

Detailed Description

WiFiInterface class.

Common interface that is shared between WiFi devices

Definition at line 31 of file WiFiInterface.h.


Constructor & Destructor Documentation

virtual ~WiFiInterface (  ) [virtual]

WiFiInterface lifetime.

Definition at line 36 of file WiFiInterface.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:
addrDestination for the host address
Returns:
0 on success, negative error code on failure

Definition at line 63 of file NetworkInterface.cpp.

virtual nsapi_error_t connect (  ) [pure virtual]

Start the interface.

Attempts to connect to a WiFi network. Requires ssid and passphrase to be set. If passphrase is invalid, NSAPI_ERROR_AUTH_ERROR is returned.

Returns:
0 on success, negative error code on failure

Implements NetworkInterface.

virtual nsapi_error_t connect ( const char *  ssid,
const char *  pass,
nsapi_security_t  security = NSAPI_SECURITY_NONE,
uint8_t  channel = 0 
) [pure virtual]

Start the interface.

Attempts to connect to a WiFi network.

Parameters:
ssidName of the network to connect to
passSecurity passphrase to connect to the network
securityType of encryption for connection (Default: NSAPI_SECURITY_NONE)
channelChannel on which the connection is to be made, or 0 for any (Default: 0)
Returns:
0 on success, or error code on failure
virtual nsapi_error_t disconnect (  ) [pure virtual]

Stop the interface.

Returns:
0 on success, or error code on failure

Implements NetworkInterface.

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 recieved

Reimplemented in EthernetInterface.

Definition at line 38 of file NetworkInterface.cpp.

const char * get_ip_address (  ) [virtual, inherited]

Get the local IP address.

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

Reimplemented in EthernetInterface.

Definition at line 28 of file NetworkInterface.cpp.

const char * get_mac_address (  ) [virtual, inherited]

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 in EthernetInterface.

Definition at line 23 of file NetworkInterface.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 recieved

Reimplemented in EthernetInterface.

Definition at line 33 of file NetworkInterface.cpp.

virtual int8_t get_rssi (  ) [pure virtual]

Gets the current radio signal strength for active connection.

Returns:
Connection strength in dBm (negative value), or 0 if measurement impossible
virtual NetworkStack* get_stack (  ) [protected, pure virtual, inherited]

Provide access to the NetworkStack object.

Returns:
The underlying NetworkStack object

Implemented in EthernetInterface.

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:
addressDestination for the host SocketAddress
hostHostname to resolve
versionIP 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 58 of file NetworkInterface.cpp.

virtual nsapi_size_or_error_t scan ( WiFiAccessPoint res,
nsapi_size_t  count 
) [pure virtual]

Scan for available networks.

This function will block. If the count is 0, function will only return count of available networks, so that user can allocated necessary memory. If the is grater than 0 and the ap is not NULL it'll be populated with discovered networks up to value of count.

Parameters:
apPointer to allocated array to store discovered AP
countSize of allocated res array, or 0 to only count available AP
Returns:
Number of entries in , or if count was 0 number of available networks, negative on error see nsapi_error
virtual nsapi_error_t set_channel ( uint8_t  channel ) [pure virtual]

Set the WiFi network channel.

Parameters:
channelChannel on which the connection is to be made, or 0 for any (Default: 0)
Returns:
0 on success, or error code on failure
virtual nsapi_error_t set_credentials ( const char *  ssid,
const char *  pass,
nsapi_security_t  security = NSAPI_SECURITY_NONE 
) [pure virtual]

Set the WiFi network credentials.

Parameters:
ssidName of the network to connect to
passSecurity passphrase to connect to the network
securityType of encryption for connection (defaults to NSAPI_SECURITY_NONE)
Returns:
0 on success, or error code on failure
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:
dhcpTrue to enable DHCP
Returns:
0 on success, negative error code on failure

Reimplemented in EthernetInterface.

Definition at line 48 of file NetworkInterface.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:
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 in EthernetInterface.

Definition at line 43 of file NetworkInterface.cpp.