SDK  23.9.2
For IoT System Software Development
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
WiFiClass Class Referenceabstract

WiFi 장치를 제어하기 위한 클래스 More...

#include <WiFi.hpp>

Classes

struct  event_ap_probe_req_rx_t
 
struct  event_ap_staconnected_t
 
struct  event_ap_stadisconnected_t
 
struct  event_sta_authmode_change_t
 
struct  event_sta_connected_t
 
struct  event_sta_disconnected_t
 
struct  event_sta_got_ip_t
 
struct  event_sta_scan_done_t
 
struct  event_sta_wps_er_pin_t
 

Public Types

enum  mode_t {
  MODE_NULL = 0b000000, MODE_STA = 0b000001, MODE_AP = 0b000010, MODE_APSTA = 0b000011,
  MODE_MAX = 0b000100
}
 
enum  status_t {
  STATUS_STOP = 255, STATUS_IDLE = 0, STATUS_NO_SSID_AVAIL = 1, STATUS_SCAN_COMPLETED = 2,
  STATUS_CONNECTED = 3, STATUS_CONNECT_FAILED = 4, STATUS_CONNECTION_LOST = 5, STATUS_DISCONNECTED = 6
}
 
enum  event_id_t {
  EVENT_READY = 0, EVENT_SCAN_DONE, EVENT_STA_START, EVENT_STA_STOP,
  EVENT_STA_CONNECTED, EVENT_STA_DISCONNECTED, EVENT_STA_AUTHMODE_CHANGE, EVENT_STA_GOT_IP,
  EVENT_STA_LOST_IP, EVENT_STA_WPS_ER_SUCCESS, EVENT_STA_WPS_ER_FAILED, EVENT_STA_WPS_ER_TIMEOUT,
  EVENT_STA_WPS_ER_PIN, EVENT_AP_START, EVENT_AP_STOP, EVENT_AP_STACONNECTED,
  EVENT_AP_STADISCONNECTED, EVENT_AP_PROBEREQRECVED, EVENT_MAX
}
 
enum  auth_mode_t {
  AUTH_OPEN = 0, AUTH_WEP, AUTH_WPA_PSK, AUTH_WPA2_PSK,
  AUTH_WPA_WPA2_PSK, AUTH_WPA2_ENTERPRISE, AUTH_MAX
}
 
enum  err_reason_t {
  REASON_UNSPECIFIED = 1, REASON_AUTH_EXPIRE = 2, REASON_AUTH_LEAVE = 3, REASON_ASSOC_EXPIRE = 4,
  REASON_ASSOC_TOOMANY = 5, REASON_NOT_AUTHED = 6, REASON_NOT_ASSOCED = 7, REASON_ASSOC_LEAVE = 8,
  REASON_ASSOC_NOT_AUTHED = 9, REASON_DISASSOC_PWRCAP_BAD = 10, REASON_DISASSOC_SUPCHAN_BAD = 11, REASON_IE_INVALID = 13,
  REASON_MIC_FAILURE = 14, REASON_4WAY_HANDSHAKE_TIMEOUT = 15, REASON_GROUP_KEY_UPDATE_TIMEOUT = 16, REASON_IE_IN_4WAY_DIFFERS = 17,
  REASON_GROUP_CIPHER_INVALID = 18, REASON_PAIRWISE_CIPHER_INVALID = 19, REASON_AKMP_INVALID = 20, REASON_UNSUPP_RSN_IE_VERSION = 21,
  REASON_INVALID_RSN_IE_CAP = 22, REASON_802_1X_AUTH_FAILED = 23, REASON_CIPHER_SUITE_REJECTED = 24, REASON_BEACON_TIMEOUT = 200,
  REASON_NO_AP_FOUND = 201, REASON_AUTH_FAIL = 202, REASON_ASSOC_FAIL = 203, REASON_HANDSHAKE_TIMEOUT = 204
}
 
enum  event_sta_wps_fail_reason_t { WPS_FAIL_REASON_NORMAL = 0, WPS_FAIL_REASON_RECV_M2D, WPS_FAIL_REASON_MAX }
 
typedef void(* EventCb) (event_id_t event)
 
typedef void(* EventFullCb) (event_id_t event, void *info)
 

Public Member Functions

virtual void onEvent (EventCb cbEvent, event_id_t event=EVENT_MAX)
 
virtual void onEvent (EventFullCb cbEvent, event_id_t event=EVENT_MAX)
 
virtual int32_t channel (void)=0
 
virtual void persistent (bool persistent)
 
virtual bool mode (mode_t)=0
 
virtual mode_t getMode ()=0
 
virtual bool enableSTA (bool enable)
 
virtual bool enableAP (bool enable)
 
virtual void _eventCallback (event_id_t event, void *info)
 
virtual int hostByName (const char *aHostname, IPAddress &aResult)=0
 
virtual status_t begin (const char *ssid, const char *passphrase=NULL, int32_t channel=0, const uint8_t *bssid=NULL, bool connect=true)=0
 
virtual status_t begin ()=0
 
virtual bool config (IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1=(uint32_t) 0x00000000, IPAddress dns2=(uint32_t) 0x00000000)=0
 
virtual bool reconnect ()=0
 
virtual bool disconnect (bool wifioff=false)=0
 
virtual bool isConnected ()
 
virtual bool setAutoConnect (bool autoConnect)=0
 
virtual bool getAutoConnect ()=0
 
bool setAutoReconnect (bool autoReconnect)
 
bool getAutoReconnect ()
 
virtual uint8_t waitForConnectResult ()
 
virtual IPAddress localIP ()=0
 
virtual uint8_t * macAddress (uint8_t *mac)=0
 
virtual IPAddress subnetMask ()=0
 
virtual IPAddress gatewayIP ()=0
 
virtual IPAddress dnsIP (uint8_t dns_no=0)=0
 
virtual bool enableIpV6 ()=0
 
virtual IPv6Address localIPv6 ()=0
 
virtual const char * getHostname ()=0
 
virtual bool setHostname (const char *hostname)=0
 
status_t status ()
 
virtual const char * SSID () const =0
 
virtual const char * psk () const =0
 
virtual const uint8_t * BSSID ()=0
 
virtual int16_t RSSI ()=0
 
void _setStatus (status_t status)
 
virtual int8_t scanNetworks (bool async=false, bool show_hidden=false, bool passive=false, uint32_t max_ms_per_chan=300)=0
 
virtual int8_t scanComplete ()
 
virtual void scanDelete ()=0
 
virtual bool getNetworkInfo (uint8_t i, const char **ssid, auth_mode_t *encryptionType, int16_t *RSSI, const uint8_t **BSSID, int32_t *channel)=0
 
const char * SSID (uint8_t i)
 
auth_mode_t encryptionType (uint8_t i)
 
int16_t RSSI (uint8_t i)
 
const uint8_t * BSSID (uint8_t i)
 
int32_t channel (uint8_t i)
 

Protected Member Functions

virtual void * _getScanInfoByIndex (uint8_t i)=0
 
virtual void _scanDone ()=0
 

Protected Attributes

bool _persistent
 
mode_t _forceSleepLastMode
 
status_t _status = STATUS_STOP
 
bool _autoReconnect = true
 
bool _useStaticIp = false
 
bool _scanAsync = false
 
bool _scanStarted = false
 
bool _scanComplete = false
 
uint16_t _scanCount = 0
 
void * _scanResult = NULL
 
bool _dns_busy = false
 

Detailed Description

WiFi 장치를 제어하기 위한 클래스

Member Enumeration Documentation

◆ auth_mode_t

Enumerator
AUTH_OPEN 

authenticate mode : open

AUTH_WEP 

authenticate mode : WEP

AUTH_WPA_PSK 

authenticate mode : WPA_PSK

AUTH_WPA2_PSK 

authenticate mode : WPA2_PSK

AUTH_WPA_WPA2_PSK 

authenticate mode : WPA_WPA2_PSK

AUTH_WPA2_ENTERPRISE 

authenticate mode : WPA2_ENTERPRISE

85  {
86  AUTH_OPEN = 0,
87  AUTH_WEP,
88  AUTH_WPA_PSK,
92  AUTH_MAX
93  } auth_mode_t;

◆ event_id_t

Enumerator
EVENT_READY 

WiFi ready

EVENT_SCAN_DONE 

WiFi finish scanning AP

EVENT_STA_START 

WiFi station start

EVENT_STA_STOP 

WiFi station stop

EVENT_STA_CONNECTED 

WiFi station connected to AP

EVENT_STA_DISCONNECTED 

WiFi station disconnected from AP

EVENT_STA_AUTHMODE_CHANGE 

the auth mode of AP connected by WiFi station changed

EVENT_STA_GOT_IP 

WiFi station got IP from connected AP

EVENT_STA_LOST_IP 

WiFi station lost IP and the IP is reset to 0

EVENT_STA_WPS_ER_SUCCESS 

WiFi station wps succeeds in enrollee mode

EVENT_STA_WPS_ER_FAILED 

WiFi station wps fails in enrollee mode

EVENT_STA_WPS_ER_TIMEOUT 

WiFi station wps timeout in enrollee mode

EVENT_STA_WPS_ER_PIN 

WiFi station wps pin code in enrollee mode

EVENT_AP_START 

WiFi soft-AP start

EVENT_AP_STOP 

WiFi soft-AP stop

EVENT_AP_STACONNECTED 

a station connected to WiFi soft-AP

EVENT_AP_STADISCONNECTED 

a station disconnected from WiFi soft-AP

EVENT_AP_PROBEREQRECVED 

Receive probe request packet in soft-AP interface

62  {
63  EVENT_READY = 0,
81  //EVENT_GOT_IP6, /**< WiFi station or AP IPv6 addr is preferred */
82  EVENT_MAX,
83  } event_id_t;

◆ event_sta_wps_fail_reason_t

Enumerator
WPS_FAIL_REASON_NORMAL 

WPS normal fail reason

WPS_FAIL_REASON_RECV_M2D 

WPS receive M2D frame

127  {
130  WPS_FAIL_REASON_MAX

◆ mode_t

Enumerator
MODE_NULL 

null mode

MODE_STA 

WiFi station mode

MODE_AP 

WiFi soft-AP mode

MODE_APSTA 

WiFi station + soft-AP mode

43  {
44  MODE_NULL = 0b000000,
45  MODE_STA = 0b000001,
46  MODE_AP = 0b000010,
47  MODE_APSTA = 0b000011,
48  MODE_MAX = 0b000100,
49  } mode_t;

Member Function Documentation

◆ _eventCallback()

virtual void WiFiClass::_eventCallback ( event_id_t  event,
void *  info 
)
virtual

callback for WiFi events

Parameters
arg

◆ begin() [1/2]

virtual status_t WiFiClass::begin ( )
pure virtual

Start Wifi connection if passphrase is set the most secure supported mode will be automatically selected

Parameters
ssidconst char* Pointer to the SSID string.
passphraseconst char * Optional. Passphrase. Valid characters in a passphrase must be between ASCII 32-126 (decimal).
bssiduint8_t[6] Optional. BSSID / MAC of AP
channelOptional. Channel of AP
connectOptional. call connect
Returns

◆ begin() [2/2]

virtual status_t WiFiClass::begin ( const char *  ssid,
const char *  passphrase = NULL,
int32_t  channel = 0,
const uint8_t *  bssid = NULL,
bool  connect = true 
)
pure virtual

Start Wifi connection if passphrase is set the most secure supported mode will be automatically selected

Parameters
ssidconst char* Pointer to the SSID string.
passphraseconst char * Optional. Passphrase. Valid characters in a passphrase must be between ASCII 32-126 (decimal).
bssiduint8_t[6] Optional. BSSID / MAC of AP
channelOptional. Channel of AP
connectOptional. call connect
Returns

◆ BSSID() [1/2]

virtual const uint8_t* WiFiClass::BSSID ( )
pure virtual

Return the current bssid / mac associated with the network if configured

Returns
bssid uint8_t *

◆ BSSID() [2/2]

const uint8_t* WiFiClass::BSSID ( uint8_t  i)

return MAC / BSSID of scanned wifi

Parameters
ispecify from which network item index want to get the information
Returns
uint8_t * MAC / BSSID of scanned wifi. If i is out of bound, NULL is returned.

◆ channel() [1/2]

int32_t WiFiClass::channel ( uint8_t  i)

Return the primary channel number of the networks discovered during the scanNetworks

Parameters
ispecify from which network item want to get the information
Returns
Channel number of the specified item on the networks scanned list. If i is out of bound, -1 is returned.

◆ channel() [2/2]

virtual int32_t WiFiClass::channel ( void  )
pure virtual

Return the current channel associated with the network

Returns
channel (1-13)

◆ config()

virtual bool WiFiClass::config ( IPAddress  local_ip,
IPAddress  gateway,
IPAddress  subnet,
IPAddress  dns1 = (uint32_t) 0x00000000,
IPAddress  dns2 = (uint32_t) 0x00000000 
)
pure virtual

Change IP configuration settings disabling the dhcp client

Parameters
local_ipStatic ip configuration
gatewayStatic gateway configuration
subnetStatic Subnet mask
dns1Static DNS server 1
dns2Static DNS server 2

◆ disconnect()

virtual bool WiFiClass::disconnect ( bool  wifioff = false)
pure virtual

Disconnect from the network

Parameters
wifioff
Returns
one value of wl_status_t enum

◆ dnsIP()

virtual IPAddress WiFiClass::dnsIP ( uint8_t  dns_no = 0)
pure virtual

Get the DNS ip address.

Parameters
dns_no
Returns
IPAddress DNS Server IP

◆ enableAP()

virtual bool WiFiClass::enableAP ( bool  enable)
virtual

control AP mode

Parameters
enablebool
Returns
ok

◆ enableIpV6()

virtual bool WiFiClass::enableIpV6 ( )
pure virtual

Enable IPv6 on the station interface.

Returns
true on success

◆ enableSTA()

virtual bool WiFiClass::enableSTA ( bool  enable)
virtual

control STA mode

Parameters
enablebool
Returns
ok

◆ encryptionType()

auth_mode_t WiFiClass::encryptionType ( uint8_t  i)

Return the encryption type of the networks discovered during the scanNetworks

Parameters
ispecify from which network item index want to get the information
Returns
encryption type (enum wl_enc_type) of the specified item on the networks scanned list. If i is out of bound, AUTH_MAX is returned.

◆ gatewayIP()

virtual IPAddress WiFiClass::gatewayIP ( )
pure virtual

Get the gateway ip address.

Returns
IPAddress gatewayIP

◆ getAutoConnect()

virtual bool WiFiClass::getAutoConnect ( )
pure virtual

Checks if the WiFi station mode will connect to AP automatically or not when it is powered on.

Returns
auto connect

◆ getHostname()

virtual const char* WiFiClass::getHostname ( )
pure virtual

Get the station interface Host name.

Returns
char array hostname

◆ getMode()

virtual mode_t WiFiClass::getMode ( )
pure virtual

get WiFi mode

Returns
WiFiMode

◆ getNetworkInfo()

virtual bool WiFiClass::getNetworkInfo ( uint8_t  i,
const char **  ssid,
auth_mode_t encryptionType,
int16_t *  RSSI,
const uint8_t **  BSSID,
int32_t *  channel 
)
pure virtual

loads all infos from a scanned wifi in to the ptr parameters

Parameters
iuint8_t
ssidconst char**
encryptionTypeuint8_t *
RSSIint32_t *
BSSIDuint8_t **
channelint32_t *
Returns
(true if ok)

◆ hostByName()

virtual int WiFiClass::hostByName ( const char *  aHostname,
IPAddress aResult 
)
pure virtual

Resolve the given hostname to an IP address.

Parameters
aHostnameName to be resolved
aResultIPAddress structure to store the returned IP address
Returns
1 if aIPAddrString was successfully converted to an IP address, else error code

◆ isConnected()

virtual bool WiFiClass::isConnected ( )
virtual

is STA interface connected?

Returns
true if STA is connected to an AD

◆ localIP()

virtual IPAddress WiFiClass::localIP ( )
pure virtual

Get the station interface IP address.

Returns
IPAddress station IP

◆ localIPv6()

virtual IPv6Address WiFiClass::localIPv6 ( )
pure virtual

Get the station interface IPv6 address.

Returns
IPv6Address

◆ macAddress()

virtual uint8_t* WiFiClass::macAddress ( uint8_t *  mac)
pure virtual

Get the station interface MAC address.

Parameters
macpointer to uint8_t array with length WL_MAC_ADDR_LENGTH
Returns
pointer to uint8_t *

◆ mode()

virtual bool WiFiClass::mode ( mode_t  )
pure virtual

set new mode

Parameters
mWiFiMode_t

◆ onEvent() [1/2]

virtual void WiFiClass::onEvent ( EventCb  cbEvent,
event_id_t  event = EVENT_MAX 
)
virtual

set callback function

Parameters
cbEventWiFiEventCb
eventoptional filter (WIFI_EVENT_MAX is all events)

◆ onEvent() [2/2]

virtual void WiFiClass::onEvent ( EventFullCb  cbEvent,
event_id_t  event = EVENT_MAX 
)
virtual

set callback function

Parameters
cbEventWiFiEventCb
eventoptional filter (WIFI_EVENT_MAX is all events)

◆ persistent()

virtual void WiFiClass::persistent ( bool  persistent)
virtual

store WiFi config in SDK flash area

Parameters
persistent

◆ psk()

virtual const char* WiFiClass::psk ( ) const
pure virtual

Return the current pre shared key associated with the network

Returns
psk string

◆ reconnect()

virtual bool WiFiClass::reconnect ( )
pure virtual

will force a disconnect an then start reconnecting to AP

Returns
ok

◆ RSSI() [1/2]

virtual int16_t WiFiClass::RSSI ( )
pure virtual

Return the current network RSSI.

Returns
RSSI value

◆ RSSI() [2/2]

int16_t WiFiClass::RSSI ( uint8_t  i)

Return the RSSI of the networks discovered during the scanNetworks

Parameters
ispecify from which network item index want to get the information
Returns
signed value of RSSI of the specified item on the networks scanned list. If i is out of bound, SHRT_MIN value is returned.

◆ scanComplete()

virtual int8_t WiFiClass::scanComplete ( )
virtual

called to get the scan state in Async mode

Returns
scan result or status -1 if scan not fin -2 if scan not triggered

◆ scanDelete()

virtual void WiFiClass::scanDelete ( )
pure virtual

delete last scan result from RAM

◆ scanNetworks()

virtual int8_t WiFiClass::scanNetworks ( bool  async = false,
bool  show_hidden = false,
bool  passive = false,
uint32_t  max_ms_per_chan = 300 
)
pure virtual

Start scan WiFi networks available

Parameters
asyncrun in async mode
show_hiddenshow hidden networks
Returns
Number of discovered networks. If failed, WIFI_SCAN_RUNNING or WIFI_SCAN_FAILED will be returned.

◆ setAutoConnect()

virtual bool WiFiClass::setAutoConnect ( bool  autoConnect)
pure virtual

Setting the WiFi station to connect to the AP (which is recorded) automatically or not when powered on. Enable auto-connect by default.

Parameters
autoConnectbool
Returns
if saved

◆ setHostname()

virtual bool WiFiClass::setHostname ( const char *  hostname)
pure virtual

Set the station interface Host name.

Parameters
hostnamepointer to const string
Returns
true on success

◆ SSID() [1/2]

virtual const char* WiFiClass::SSID ( ) const
pure virtual

Return the current SSID associated with the network

Returns
SSID

◆ SSID() [2/2]

const char* WiFiClass::SSID ( uint8_t  i)

Return the SSID discovered during the network scan.

Parameters
ispecify from which network item want to get the information
Returns
ssid string of the specified item on the networks scanned list. If i is out of bound, NULL is returned.

◆ status()

status_t WiFiClass::status ( )

Return Connection status.

Returns
one of the value defined in wl_status_t

◆ subnetMask()

virtual IPAddress WiFiClass::subnetMask ( )
pure virtual

Get the interface subnet mask address.

Returns
IPAddress subnetMask

◆ waitForConnectResult()

virtual uint8_t WiFiClass::waitForConnectResult ( )
virtual

Wait for WiFi connection to reach a result returns the status reached or disconnect if STA is off

Returns
wl_status_t

The documentation for this class was generated from the following file:
WiFiClass::EVENT_STA_GOT_IP
@ EVENT_STA_GOT_IP
Definition: WiFi.hpp:70
WiFiClass::EVENT_STA_CONNECTED
@ EVENT_STA_CONNECTED
Definition: WiFi.hpp:67
WiFiClass::MODE_APSTA
@ MODE_APSTA
Definition: WiFi.hpp:47
WiFiClass::EVENT_STA_START
@ EVENT_STA_START
Definition: WiFi.hpp:65
WiFiClass::EVENT_STA_STOP
@ EVENT_STA_STOP
Definition: WiFi.hpp:66
WiFiClass::MODE_NULL
@ MODE_NULL
Definition: WiFi.hpp:44
WiFiClass::EVENT_READY
@ EVENT_READY
Definition: WiFi.hpp:63
WiFiClass::AUTH_WPA2_ENTERPRISE
@ AUTH_WPA2_ENTERPRISE
Definition: WiFi.hpp:91
WiFiClass::EVENT_STA_LOST_IP
@ EVENT_STA_LOST_IP
Definition: WiFi.hpp:71
WiFiClass::event_id_t
event_id_t
Definition: WiFi.hpp:62
WiFiClass::MODE_STA
@ MODE_STA
Definition: WiFi.hpp:45
WiFiClass::EVENT_AP_STADISCONNECTED
@ EVENT_AP_STADISCONNECTED
Definition: WiFi.hpp:79
WiFiClass::auth_mode_t
auth_mode_t
Definition: WiFi.hpp:85
WiFiClass::WPS_FAIL_REASON_NORMAL
@ WPS_FAIL_REASON_NORMAL
Definition: WiFi.hpp:128
WiFiClass::MODE_AP
@ MODE_AP
Definition: WiFi.hpp:46
WiFiClass::EVENT_AP_PROBEREQRECVED
@ EVENT_AP_PROBEREQRECVED
Definition: WiFi.hpp:80
WiFiClass::EVENT_STA_DISCONNECTED
@ EVENT_STA_DISCONNECTED
Definition: WiFi.hpp:68
WiFiClass::EVENT_SCAN_DONE
@ EVENT_SCAN_DONE
Definition: WiFi.hpp:64
WiFiClass::EVENT_AP_STOP
@ EVENT_AP_STOP
Definition: WiFi.hpp:77
WiFiClass::AUTH_WEP
@ AUTH_WEP
Definition: WiFi.hpp:87
WiFiClass::EVENT_STA_WPS_ER_TIMEOUT
@ EVENT_STA_WPS_ER_TIMEOUT
Definition: WiFi.hpp:74
WiFiClass::EVENT_AP_START
@ EVENT_AP_START
Definition: WiFi.hpp:76
WiFiClass::AUTH_WPA_WPA2_PSK
@ AUTH_WPA_WPA2_PSK
Definition: WiFi.hpp:90
WiFiClass::EVENT_STA_WPS_ER_PIN
@ EVENT_STA_WPS_ER_PIN
Definition: WiFi.hpp:75
WiFiClass::WPS_FAIL_REASON_RECV_M2D
@ WPS_FAIL_REASON_RECV_M2D
Definition: WiFi.hpp:129
WiFiClass::AUTH_WPA_PSK
@ AUTH_WPA_PSK
Definition: WiFi.hpp:88
WiFiClass::EVENT_STA_AUTHMODE_CHANGE
@ EVENT_STA_AUTHMODE_CHANGE
Definition: WiFi.hpp:69
WiFiClass::EVENT_STA_WPS_ER_SUCCESS
@ EVENT_STA_WPS_ER_SUCCESS
Definition: WiFi.hpp:72
WiFiClass::mode_t
mode_t
Definition: WiFi.hpp:43
WiFiClass::AUTH_OPEN
@ AUTH_OPEN
Definition: WiFi.hpp:86
WiFiClass::event_sta_wps_fail_reason_t
event_sta_wps_fail_reason_t
Definition: WiFi.hpp:127
WiFiClass::AUTH_WPA2_PSK
@ AUTH_WPA2_PSK
Definition: WiFi.hpp:89
WiFiClass::EVENT_AP_STACONNECTED
@ EVENT_AP_STACONNECTED
Definition: WiFi.hpp:78
WiFiClass::EVENT_STA_WPS_ER_FAILED
@ EVENT_STA_WPS_ER_FAILED
Definition: WiFi.hpp:73