MKR1000 as AP states detection


hi,
i making basic wifi hello world program let me know when mkr1000 connected , disconnected wifi , when connected client , when disconnected. not working. using wifi101 library , modifying basic ap example. put serial.println @ different steps show me statuses. can share basic code show me when mkr1000 (as ap) connected via wifi , when disconnected(wifi of phone gets off) , when client connected , disconnected(andoid app crashes) wifi on

i solved problem , thought share public.
accidentally, noticed rssi value changes wifi status. if wifi connected rssi around -100dbm , in connected state -40dbm. put threshold of -60dbm testing purpose , solved 1st issue :)
for 2nd issue, able detect client connectivity :)
below code:

void loop() {
 wificlient client = server.available();
  if (wifi.rssi() >= -60){  //wifi 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 client...");
      client.stop();
    }
  }
  else if (wifi.rssi() <= -60){   //wifi disconnected or out of range
    serial.println("waiting wifi...");
    client.stop();
    server.begin();
  }
}


Arduino Forum > Products > MKR Boards > MKR1000 (Moderator: AndreaRichetta) > MKR1000 as AP states detection


arduino

Comments

Popular posts from this blog

Error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode - Raspberry Pi Forums

class MPU6050 has no member named begin

missing filename after '-o'