I am using a P1 module on version 0.5.2.
I’ve run into an issue with the sleep mode. After waking up from sleep, the P1 tries to reconnect to wifi and blocks, this should not be the expected behavior based on the below code. Please see the below for the minimal code.
1st clear all WiFi creds and enter new wifi creds for another network. This is to simulate that the device is portable and leaves a network.
The expected behavior of the below code should be.
-Wifi turns on and trys to connect after 4 sec all attempts are stopped by disconnecting from the cloud or wifi trying to connect.
-then the wifi module is turned off.
-then the P1 is put into sleep mode.
-expected to be once the P1 wakes up the wifi module should be off and the led flashes white, no wifi connections should be attempted
-actual behavior is that P1 wakes up then turns on wifi module then trys to connect to wifi. this also blocks the code for a while.
do you have any thoughts why this is happening?
I’m trying to implement a battery mode for my product but this behavior eats up battery quickly.
#include "application.h"
SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(SEMI_AUTOMATIC);
void setup() {
WiFi.on();
Particle.connect();
delay(4000);
if(WiFi.connecting()){
WiFi.disconnect();
}
if (WiFi.ready() && Particle.connected()) {
Particle.disconnect();
WiFi.disconnect();
}
WiFi.off();
delay(100);
}
void loop() {
System.sleep(D4, FALLING, 4);
delay(1000);
}