Skip to content

Commit

Permalink
added build option FORCE_WIFI_SLEEP to test alternatives for setting …
Browse files Browse the repository at this point in the history
…the water temperature without interrupting MQTT connection
  • Loading branch information
jnsbyr committed Jun 18, 2023
1 parent adbec47 commit 8500722
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
30 changes: 24 additions & 6 deletions PureSpaIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,14 +416,18 @@ void PureSpaIO::setDesiredWaterTempCelsius(int temp)
if (isPowerOn() == true && state.error == ERROR_NONE)
{
// try to get initial temp
#ifdef FORCE_WIFI_SLEEP
WiFi.forceSleepBegin();
#endif
int setTemp = getDesiredWaterTempCelsius();
//DEBUG_MSG("\nBset %d", setTemp);
bool modifying = false;
if (setTemp == UNDEF::INT)
{
// trigger temp modification
//WiFi.setSleepMode(WIFI_LIGHT_SLEEP);
#ifndef FORCE_WIFI_SLEEP
WiFi.setSleepMode(WIFI_LIGHT_SLEEP);
#endif
changeWaterTemp(-1);
modifying = true;

Expand All @@ -436,14 +440,18 @@ void PureSpaIO::setDesiredWaterTempCelsius(int temp)
setTemp = getDesiredWaterTempCelsius();
tries--;
} while (setTemp == UNDEF::INT && tries);
//WiFi.setSleepMode(WIFI_NONE_SLEEP);
#ifndef FORCE_WIFI_SLEEP
WiFi.setSleepMode(WIFI_NONE_SLEEP);
#endif

// check success
if (setTemp == UNDEF::INT)
{
// error, abort
#ifdef FORCE_WIFI_SLEEP
WiFi.forceSleepWake();
delay(1);
#endif
DEBUG_MSG("\naborted\n");
return;
}
Expand All @@ -458,9 +466,13 @@ void PureSpaIO::setDesiredWaterTempCelsius(int temp)
if (deltaTemp > 0)
{
//DEBUG_MSG("\nBU");
//WiFi.setSleepMode(WIFI_LIGHT_SLEEP);
#ifndef FORCE_WIFI_SLEEP
WiFi.setSleepMode(WIFI_LIGHT_SLEEP);
#endif
changeWaterTemp(1);
//WiFi.setSleepMode(WIFI_NONE_SLEEP);
#ifndef FORCE_WIFI_SLEEP
WiFi.setSleepMode(WIFI_NONE_SLEEP);
#endif
if (modifying)
{
deltaTemp--;
Expand All @@ -470,9 +482,13 @@ void PureSpaIO::setDesiredWaterTempCelsius(int temp)
else
{
//DEBUG_MSG("\nBD");
//WiFi.setSleepMode(WIFI_LIGHT_SLEEP);
#ifndef FORCE_WIFI_SLEEP
WiFi.setSleepMode(WIFI_LIGHT_SLEEP);
#endif
changeWaterTemp(-1);
//WiFi.setSleepMode(WIFI_NONE_SLEEP);
#ifndef FORCE_WIFI_SLEEP
WiFi.setSleepMode(WIFI_NONE_SLEEP);
#endif
if (modifying)
{
deltaTemp++;
Expand All @@ -481,8 +497,10 @@ void PureSpaIO::setDesiredWaterTempCelsius(int temp)
}
modifying = true;
}
#ifdef FORCE_WIFI_SLEEP
WiFi.forceSleepWake();
delay(1);
#endif
}
}
}
Expand Down
15 changes: 14 additions & 1 deletion common.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,28 @@
#include <climits>
#include <../d1_mini/pins_arduino.h>

/*****************************************************************************

C O N F I G U R A T I O N

*****************************************************************************/

// select Intex PureSpa model by commenting in the desired variant
//#define MODEL_SB_H20
//#define MODEL_SJB_HS

// if changing the water temperature setpoint does not work reliably, commenting
// in the following option may improve the behaviour at the cost of a short
// disconnect to the MQTT server
#define FORCE_WIFI_SLEEP

//#define SERIAL_DEBUG

/*****************************************************************************/

namespace CONFIG
{
const char WIFI_VERSION[] = "1.0.5.0"; // 18.06.2023
const char WIFI_VERSION[] = "1.0.5.1"; // 18.06.2023

// WiFi parameters
const unsigned long WIFI_MAX_DISCONNECT_DURATION = 900000; // [ms] 5 min until reboot
Expand Down

0 comments on commit 8500722

Please sign in to comment.