wifi.status() not changing values

Hi,
I made a simple app to show me value to wifi.status() at different steps but it doesnt change. i configured my MKR as access point and let me andoid mobile connect to it. it is successfully connected but when i turn off wifi, my wifi.status() doesnt show new value.

void loop() {
Serial.println(WiFi.status());
}

above code keeps on showing me 3 no matter my wifi is connected or not. i want to detect if wifi of device to which MKR is connected gets off

Hi @zeesh1979,

This is the expected behaviour of the library currently. In AP mode WiFi.status() will always return connected.

Feel free to start a discussion on Github about changing this behaviour. Issues · arduino-libraries/WiFi101 · GitHub

can you please share a simple code snippet to check wifi.status() at different stages as may be i am doing something wrong?

thanks

sandeepmistry:
Hi @zeesh1979,

This is the expected behaviour of the library currently. In AP mode WiFi.status() will always return connected.

Feel free to start a discussion on Github about changing this behaviour. Issues · arduino-libraries/WiFi101 · GitHub

if i use MKR as client, should wifi.status() change its values? i want to detect:

  1. if wifi of my connected client/server gets off
  2. if connected client(if MKR as AP) or server (if MKR as client) gets disconnected

zeesh1979:
if i use MKR as client, should wifi.status() change its values? i want to detect:

  1. if wifi of my connected client/server gets off
  2. if connected client(if MKR as AP) or server (if MKR as client) gets disconnected

i solved my problem and thought to share with public.
Accidentally, I noticed that RSSI value changes with WiFi status. if wifi is connected then RSSI is around -100dbm and in connected state it is -40dbm. so i put a threshold of -60dbm for testing purpose and it solved 1st issue :slight_smile:
for 2nd issue, i am able to detect client connectivity as well :slight_smile:
below is the code:

void loop() {
WiFiClient client = server.available();
if (WiFi.RSSI() >= -60){ //WiFi is connected or within range
if (client) { //server ready
if (client.connected()) { //client connected
if (client.available()) { //client sent data
Serial.print("data: ");
Serial.println(client.read());
delay(1000);
}
}
}
else if (!client){ //server not ready
Serial.println("waiting for client...");
client.stop();
}
}
else if (WiFi.RSSI() <= -60){ //WiFi is disconnected or out of range
Serial.println("waiting for WiFi...");
client.stop();
server.begin();
}
}