Community
cancel
Showing results for 
Search instead for 
Did you mean: 
VAre
Beginner
898 Views

WiFi.status() Not working Properly in Intel Edison

Jump to solution

I am trying to connect Intel Edison to WiFi by creating hotspot from my mobile. I am able to connect to WiFi but even after I am switching off my hotspot WiFi.status() is showing that I am connected to WiFi. Please help me out

The code I used is as follows and I am attaching the Libraries.

# include

# include

char ssid[] = "mynetwork"; // your network SSID (name)

char key[] = "12345678"; // your network key

int status = WL_IDLE_STATUS; // the Wifi radio's status

void setup() {

//Initialize serial and wait for port to open:

Serial.begin(9600);

// attempt to connect to Wifi network:

while ( status != WL_CONNECTED) {

Serial.print("Attempting to connect to WPA network, SSID: ");

Serial.println(ssid);

status = WiFi.begin(ssid, key);

// wait 10 seconds for connection:

delay(10000);

}

// once you are connected :

Serial.print("You're connected to the network");

}

void loop() {

//check the network status connection once every 10 seconds:

delay(10000);

Serial.println(WiFi.status());

}

Tags (1)
1 Solution
Diego_V_Intel
Employee
54 Views

Hi Venkatesh_Are,

If you check the WiFI library, you will notice that the WIFI.status() method only returns the last status saved:

uint8_t WiFiClass::status()

{

return _status;

}

In your code, the status is updated when you call the WIFI.begin() method. In that moment the Edison is connected to the network. That status is not updated anymore so, even though the network is not available and the Edison is actually without connection, the status saved hasn't changed and consequently, when you call the WIFI.status() method you get the status that the Edison is still connected.

Your code is not wrong, that's simply the way the WIFI library works with Edison. The libraries you attached are not the ones used by Edison, those libraries are the ones used by the Arduino boards. If you are using the Arduino IDE 1.6.0 version you can check the WIFI libraries for Edison in the following directory: C:\...\arduino-1.6.0+Intel\hardware\intel\i686\libraries\WiFi

I recommend you to check the WIFI status using another way, for example checking if you still have an IP address. The method WIFI.BSSID() might be helpful too. Anyhow, the description of each method is in the WIFI library, check them and choose the most appropriate for your application.

Regards,

Diego

View solution in original post

1 Reply
Diego_V_Intel
Employee
55 Views

Hi Venkatesh_Are,

If you check the WiFI library, you will notice that the WIFI.status() method only returns the last status saved:

uint8_t WiFiClass::status()

{

return _status;

}

In your code, the status is updated when you call the WIFI.begin() method. In that moment the Edison is connected to the network. That status is not updated anymore so, even though the network is not available and the Edison is actually without connection, the status saved hasn't changed and consequently, when you call the WIFI.status() method you get the status that the Edison is still connected.

Your code is not wrong, that's simply the way the WIFI library works with Edison. The libraries you attached are not the ones used by Edison, those libraries are the ones used by the Arduino boards. If you are using the Arduino IDE 1.6.0 version you can check the WIFI libraries for Edison in the following directory: C:\...\arduino-1.6.0+Intel\hardware\intel\i686\libraries\WiFi

I recommend you to check the WIFI status using another way, for example checking if you still have an IP address. The method WIFI.BSSID() might be helpful too. Anyhow, the description of each method is in the WIFI library, check them and choose the most appropriate for your application.

Regards,

Diego

View solution in original post

Reply