OPEnSLab-OSU / Loom-V4

Open Source Internet Of Things Rapid Prototyping Framework For Environmental Sensing Applications
8 stars 1 forks source link

Finer control of WiFi module power-on #72

Closed solidstatebird closed 1 year ago

solidstatebird commented 1 year ago

Issue In the current version of Loom, the WiFi module is powered on as Loom_Hypnos::sleep() exits. This causes a delay as the WiFi module will block while attempting to reconnect to its specified network. This delay can range from a few seconds to up to a minute if the WiFi module fails to connect. Despite this large time usage, the reconnection process has no benefit if the WiFi module is not used before the device goes back to sleep. Any excess power-on time is detrimental to the operation time of battery-powered devices, and should be minimized. I would like the option to prevent the WiFi connection sequence from occurring until its functionality is actually required.

Potential solution Ideally, the WiFi module does not reconnect when the device exits from sleep. Instead, it would automatically connect when a function using the WiFi module is invoked. It would also be helpful to specify the number of retry counts permitted in Loom_WIFI::connect_to_network() could be specified in the WiFi module constructor so that the delay caused by failure to connect to the network would be less significant.

WL-Richards commented 1 year ago

You need to put this line wifi.setBatchSD(batchSD); before manager.initialize, where batchSD is the object name of your BatchSD instance

In addition a connectionRetries parameter has been added Loom_WIFI(Manager& man, CommunicationMode mode, const char* name = "", const char* password = "", int connectionRetries = 5)