Getbssid() and rssi() don't return correct values after first call

When I call getbssid() and rssi() after the device first starts, I get the correct values. However, after an idle time (my code is based on the WeatherStation app with April and EnvTail), the value for bssid is “000000000000” and rssi is “0” until the device is restarted.

Am I doing something wrong?

Maybe the Imp isn’t connected to wifi when you get the RSSI values. The Imp only makes a wifi connection when required. Perhaps try a server.log first as a test.

That’s exactly what it was. Thanks for the help.

I saw the same thing! But have found a different solution…
Change the imp.onidle sleep to exit with imp.wakeup (should do the same thing)
as shown below.

// imp.onidle(function() {
//server.sleepfor(300);
imp.wakeup(300,getReadings);
// } );

and add powersave before initial call
imp.setpowersave(true);
getReadings();

now RSSI reading are correct… not positive why, as I never saw wi-fi disconnect
If anyone can explain, would love to know why this worked…

If you enter sleep (server.sleepfor or imp.deepsleepfor) then when the imp wakes wifi is not connected. If your code calls rssi before it does anything to bring the wifi link up, then you’ll get zero.

eg if your first line of code is:

server.log(imp.getrssi());

…this will log zero. The rssi is fetched then the log message (which causes the link to come up) is sent. WiFi was down when imp.getrssi() was evaluated.