WiFiClass Class

WiFiClass Class

Description
A class of WiFi and network implementation for Ameba.

Syntax
class WiFiClass

Members

Public Constructors 
WiFiClass::WiFiClassConstructs a WiFiClass object and initializes the WiFi libraries and network settings.
Public Methods 
WiFiClass::firmwareVersionGet firmware version.
WiFiClass::beginStart Wi-Fi connection for OPEN/ WEP/ with passphrase networks.
WiFiClass::configConfigure network IP settings.
WiFiClass::setDNSSet the DNS server IP address to use.
WiFiClass::disconnectDisconnect from the network.
WiFiClass::macAddressGet the interface MAC address.
WiFiClass::localIPGet the interface IP address.
WiFiClass::subnetMaskGet the interface subnet mask address.
WiFiClass::gatewayIPGet the gateway IP address.
WiFiClass::SSIDGet the current SSID associated with the network.
WiFiClass::BSSIDGet the current BSSID associated with the network.
WiFiClass::RSSIGet the current RSSI (Received Signal Strength in dBm) associated with the network.
WiFiClass::encryptionTypeGet the encryption type associated with the network.
WiFiClass::scanNetworksGet the SSID discovered during the network scan.
WiFiClass::SSIDGet the encryption type of the networks discovered from scanNetworks.
WiFiClass::encryptionTypeGet the security type and encryption type of the networks discovered from scanNetworks.
WiFiClass::encryptionTypeExGet the security type and encryption type of the networks discovered from scanNetworks.
WiFiClass::RSSIGet the RSSI of the networks discovered from scanNetworks.
WiFiClass::statusGet Connection status.
WiFiClass::hostByNameResolve the given hostname to an IP address.
WiFiClass::apbeginStart AP mode.
WiFiClass::disablePowerSaveDisable power-saving mode.

WiFiClass::WiFiClass

Description
Constructs a WiFiClass object and initializes the WiFi libraries and network settings.

Syntax
WiFiClass(void);

Parameters
NA

Returns
NA

Example Code
NA

Notes and Warnings
An instance of WiFiClass is created as WiFi inside WiFi.h and is extern for direct use. “WiFi.h” must be included to use the class function.

WiFiClass::firmwareVersion

Description
Get firmware version.

Syntax
char* firmwareVersion(void);

Parameters
NA

Returns
This function returns WiFi firmware version.

Example Code
Example: ConnectWithWPA
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/ConnectWithWPA/ConnectWithWPA.ino)

Notes and Warnings
“WiFi.h” must be included to use the class function.

WiFiClass::begin

Description
Start Wi-Fi connection for OPEN/ WEP/ with passphrase networks.

Syntax
int begin(char* ssid);
int begin(char* ssid, uint8_t key_idx, const char* key);
int begin(char* ssid, const char *passphrase);

Parameters
ssid: Pointer to the SSID string
key_idx: The key index to set. Valid values are 0-3.
key: Key input buffer.
passphrase: Passphrase. Valid characters in a passphrase must be between ASCII 32-126 (decimal).

Returns
This function returns the Wi-Fi status.

Example Code
Example: ConnectWithWPA
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/ConnectWithWPA/ConnectWithWPA.ino)

Notes and Warnings
“WiFi.h” must be included to use the class function.

WiFiClass::config

Description
Configure network settings for the Wi-Fi network.

Syntax
void config(IPAddress local_ip);
void config(IPAddress local_ip, IPAddress dns_server);
void config(IPAddress local_ip, IPAddress dns_server, IPAddress gateway);
void config(IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet);

Parameters
local_ip: Local device IP address to use on the network.
dns_server: IP address of the DNS server to use.
gateway: IP address of the gateway device on the network.
subnet: Subnet mask for the network, expressed as an IP address.

Returns
NA

Example Code
NA

Notes and Warnings
This will disable the DHCP client when connecting to a network and will require the network accepts a static IP. The configured IP addresses will also apply to AP mode, but the DHCP server will not be disabled in AP mode. “WiFi.h” must be included to use the class function.

WiFiClass::setDNS

Description
Set the IP address for DNS servers.

Syntax
void setDNS(IPAddress dns_server1);
void setDNS(IPAddress dns_server1, IPAddress dns_server2);

Parameters
dns_server1: IP address for DNS server 1.
dns_server2: IP address for DNS server 2.

Returns
NA

Example Code
NA

Notes and Warnings
“WiFi.h” must be included to use the class function.

WiFiClass::disconnect

Description
Disconnect from the network.

Syntax
int disconnect (void);

Parameters
NA

Returns
This function returns one value of wl_status_t enum as an integer.

Example Code
NA

Notes and Warnings
“WiFi.h” must be included to use the class function.

WiFiClass::macAddress

Description
Get the interface MAC address.

Syntax
uint8_t* WiFiClass::macAddress(uint8_t* mac);

Parameters
mac: an array to store MAC address.

Returns
This function returns uint8_t array containing the macAddress with length WL_MAC_ADDR_LENGTH.

Example Code
Example: ConnectWithWPA
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/ConnectWithWPA/ConnectWithWPA.ino)

Notes and Warnings
“WiFi.h” must be included to use the class function.

WiFiClass::localIP

Description
Get the interface IP address.

Syntax
IPAddress localIP(void);

Parameters
NA

Returns
This function returns the IP address of the interface.

Example Code
Example: ConnectWithWPA
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/ConnectWithWPA/ConnectWithWPA.ino)

Notes and Warnings
“WiFi.h” must be included to use the class function.

WiFiClass::subnetMask

Description
Get the interface subnet mask address.

Syntax
IPAddress subnetMask(void);

Parameters
NA

Returns
This function returns subnet mask address of the interface.

Example Code
Example: ConnectNoEncryption
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/ConnectNoEncryption/ConnectNoEncryption.ino)

Notes and Warnings
“WiFi.h” must be included to use the class function.

WiFiClass::gatewayIP

Description
Get the interface gateway IP address.

Syntax
IPAddress gatewayIP(void);

Parameters
NA

Returns
This function returns the gateway IP address of interface.

Example Code
Example: ConnectNoEncryption
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/ConnectNoEncryption/ConnectNoEncryption.ino)

Notes and Warnings
“WiFi.h” must be included to use the class function.

WiFiClass::SSID

Description
Get the current SSID associated with the network.

Syntax
char* SSID(void);

Parameters
NA

Returns
This function returns current SSID associate with the network.

Example Code
Example: ConnectWithWPA
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/ConnectWithWPA/ConnectWithWPA.ino)

Notes and Warnings
“WiFi.h” must be included to use the class function.

WiFiClass::BSSID

Description
Get the current BSSID associated with the network.

Syntax
uint8_t* BSSID(uint8_t* bssid);

Parameters
bssid: an array to store bssid.

Returns
This function returns the uint8_t array storing BSSID with length WL_MAC_ADDR_LENGTH.

Example Code
Example: ConnectWithWPA
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/ConnectWithWPA/ConnectWithWPA.ino)

Notes and Warnings
“WiFi.h” must be included to use the class function.

WiFiClass::RSSI

Description
Get the current RSSI (Received Signal Strength in dBm) associated with the network.

Syntax
int32_t RSSI(void);

Parameters
NA

Returns
This function returns the current RSSI as a signed-value.

Example Code
Example: ConnectWithWPA
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/ConnectWithWPA/ConnectWithWPA.ino)

Notes and Warnings
“WiFi.h” must be included to use the class function.

WiFiClass::encryptionType

Description
Get the encryption type associated with the network.

Syntax
uint8_t encryptionType(void);

Parameters
NA

Returns
This function returns unsigned integer value of wl_enc_type enum.

Example Code
Example: ConnectWithWPA
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/ConnectWithWPA/ConnectWithWPA.ino)

Notes and Warnings
“WiFi.h” must be included to use the class function.

WiFiClass::scanNetworks

Description
Start scanning for available WiFi networks.

Syntax
int8_t scanNetworks(void);

Parameters
NA

Returns
This function returns the number of discovered networks as an integer.

Example Code
Example: ScanNetworks
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/ScanNetworks/ScanNetworks.ino)

Notes and Warnings
“WiFi.h” must be included to use the class function.

WiFiClass::SSID

Description
Get the SSID discovered during the network scan.

Syntax
char* SSID(uint8_t networkItem);

Parameters
networkItem: specify from which network item want to get the information.

Returns
This function returns the SSID string of the specified item on the network scan list.

Example Code
Example: ScanNetworks
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/ScanNetworks/ScanNetworks.ino)

Notes and Warnings
“WiFi.h” must be included to use the class function.

WiFiClass::encryptionType

Description
Get the encryption type of the networks discovered from scanNetworks.

Syntax
uint8_t encryptionType(uint8_t networkItem);

Parameters
networkItem: specify from which network item want to get the information.

Returns
This function returns the encryption type (enum wl_enc_type) of the specified item on the network scanned list.

Example Code
Example: ScanNetworks
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/ScanNetworks/ScanNetworks.ino)

Notes and Warnings
“WiFi.h” must be included to use the class function.

WiFiClass::encryptionTypeEx

Description
Get the security type and encryption type of the networks discovered from scanNetworks.

Syntax
uint32_t encryptionTypeEx(uint8_t networkItem);

Parameters
networkItem: specify from which network item want to get the information.

Returns
This function returns security and encryption type of the specified item on the network scanned list.

Example Code
Example: ScanNetworks
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/ScanNetworks/ScanNetworks.ino)

Notes and Warnings
“WiFi.h” must be included to use the class function.

WiFiClass::RSSI

Description
Get the RSSI of the networks discovered from scanNetworks.

Syntax
int32_t RSSI(uint8_t networkItem);

Parameters
networkItem: specify from which network item want to get the information.

Returns
This function returns the signed value of RSSI of the specified item on the network scanned list.

Example Code
Example: ScanNetworks
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/ScanNetworks/ScanNetworks.ino)

Notes and Warnings
“WiFi.h” must be included to use the class function.

WiFiClass::status

Description
Get the connection status.

Syntax
uint8_t status(void);

Parameters
NA

Returns
The function returns the values defined in wl_status_t as an unsigned integer.

Example Code
Example: ConnectWithWPA
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/ConnectWithWPA/ConnectWithWPA.ino)

Notes and Warnings
“WiFi.h” must be included to use the class function.

WiFiClass::hostByName

Description
Resolve the given hostname to an IP address.

Syntax
int hostByName(const char* aHostname, IPAddress& aResult);

Parameters
aHostname: Name to be resolved.
aResult: IPAddress structure to store the returned IP address.

Returns
The function returns “1” if aIPAddrString was successfully converted to an IP address, else, it will return as an error code.

Example Code
NA

Notes and Warnings
“WiFi.h” must be included to use the class function.

WiFiClass::apbegin

Description
Start AP mode.

Syntax
int apbegin(char* ssid, char* channel, uint8_t hidden_ssid = 0);
int apbegin(char* ssid, char* password, char* channel, uint8_t hidden_ssid = 0);

Parameters
ssid: SSID of the AP network
channel: AP’s channel, default: 1
password: AP’s password

Returns
This function returns the WiFi status.

Example Code
Example: WiFiAPMode
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/WiFiAPMode/WiFiAPMode.ino)

Notes and Warnings
“WiFi.h” must be included to use the class function.

WiFiClass::disablePowerSave

Description
Disable power-saving mode.

Syntax
int disablePowerSave(void);

Parameters
NA

Returns
This function returns 1 if PowerSave disable successfully, else 0 if disable unsuccessfully.

Example Code
NA

Notes and Warnings
“WiFi.h” must be included to use the class function.

Copyrights ©瑞晟微电子(苏州)有限公司 2021. All rights reserved. 使用条款
请先确认已安装QQ通讯软体