Fireduino/WiFi Connect

来自Firefly wiki
跳转至: 导航搜索

WiFi Internet connection

Three stages of WiFi access process

STA (workstation) startup initialization,formally began using the AP transmit data frames,go through three stages to access (802.11 MAC layer is responsible for the communication between the client and AP, the features include scanning,access,authentication,encryption,roaming and synchronization etc.):



802.11 MAC get AP with scanning operation,STA search for and connect to a AP,when the STA roaming for connection to a new AP,STA will search for each of the available channel.

1)Passive Scanning(Features: find for a long time,but the STA lower power)
  By listening for AP sends a Beacon frame to find network regularly,the frame provides information about the AP and the BSS: "I'm here"...

  2)Active Scanning (Features:can quickly find)
    STA in 13 channel in turn the Probe Request frame,and look for the AP which with the STA belong to the same SSID,if can't find the AP with the same SSID,has been scanning down...


When the STA has found the AP with the same SSID,in the SSID that matches the AP,according to the received AP signal strength,choose a strongest AP signal,and then entered the stage of certification.Only the identity authentication has already passed for wireless can be accessed.AP provides the following authentication methods:

  1)open-system authentication
  2)shared-key authentication
  3)WPA PSK authentication(Pre-shared key)
  4)802.1X EAP authentication


When the AP returned authentication response information to the STA,after approved by identity authentication,entered the stage of association.

  1) STA sends an association request to the AP
  2) AP returns the associated response to the STA

  At this point,the process of access to complete,the STA has been initialized,you can start delivering data frames to the AP.

Fireduino WiFi associated network

Fireduino SDK provides access to the AP interface function,please refer to the following specific interface functions:


       Initialize the WiFi libraries and access wi-fi hotspots.
Syntax WiFi.begin(ssid); WiFi.begin(ssid, pass);
Parameter ssid : access point pass:key
Return WiFi current state

Reference Example

as follows:

  // attempt to connect to Wifi network:
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, pass);
    // wait 10 seconds for connection:

Fireduino WiFi network configuration

After Fireduino has joined the network,the default will open the internal DHCP to automatically obtain IP,generally able to get the IP address of the router allocation,Fireduino can use this IP address for network communication.

Fireduino SDK also provides the API of network configuration function, specific as follows:


       Configure the network.
Syntax WiFi.config(ip); WiFi.config(ip, dns); WiFi.config(ip, dns, gateway); WiFi.config(ip, dns, gateway, subnet);
Parameter ip :the IP address of the device dns :The DNS server address gateway :gateway address subnet :network subnet mask
Return None

Reference Example

As follows:

//config ip
//config ip,dns
//config ip,dns,gateway
//config ip,dns,gateway,subne