Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development v4 #476

Merged
merged 12 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions Code/data/chkupdatefw.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,27 @@
<p>Only update if:<br>
You have a NodeMCU12E<br>
You are at the spa so you can fix it if something goes wrong<br>
Communication with the pump will pause, so 4-wire pump will throw an error and needs to be restarted.<br>
Communication with the pump will pause, so 4-wire pumps will throw an error and needs to be restarted.<br>
</p>
Do not power off or reset the ESP until finished! It will take a few minutes!
Files will always be downloaded. FW only if different.
</section>
<!-- <section>
<input type="radio" id="master" name="branch" checked="checked">
<label for="master">Master (stable)</label><br>
<input type="radio" id="dev" name="branch">
<label for="dev">Beta (development)</label><br>
</section> -->
<section>
<p id="current">Loading...</p>
<p id="available">Loading...</p>
</section>
<p id="stable">Loading...</p>
<p id="beta">Loading...</p>
</section>

<footer>
<p class="center"><a class="button" href="/">Home</a></p><br>
<p class="center"><a class="button_red" onclick="buttonConfirm(this, 'Wait until main page is loaded!')" href="/update/">Update data files, then firmware</a></p>
<p class="center"><a class="button_red" href="/update/" onclick="buttonConfirm(this, 'Wait until main page is loaded!', 150)">MASTER: Update data files, then firmware</a></p>
<p class="center"><a class="button_red" href="/update_beta/" onclick="buttonConfirm(this, 'Wait until main page is loaded!', 150)">BETA: Update data files, then firmware</a></p>
</footer>
</div>
<script>
Expand All @@ -63,12 +73,21 @@
var json = JSON.parse(req.responseText);
console.log(json);
document.getElementById('current').innerHTML = "Current: " + json.current;
document.getElementById('available').innerHTML = "Available: " + json.available;
document.getElementById('stable').innerHTML = "Master: " + json.available; //name-orgy I know...
document.getElementById('beta').innerHTML = "Beta: " + json.beta;
}
}
}


// function update()
// {
// var req = new XMLHttpRequest();
// if(document.getElementById('master').checked)
// req.open('POST', '/update/');
// else
// req.open('POST', '/update_beta/');
// req.send();
// }
</script>
</body>
</html>
20 changes: 19 additions & 1 deletion Code/data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,28 @@ String.prototype.pad = function(String, len)
return str;
}

function tryParseJSONObject (jsonString){
try {
var o = JSON.parse(jsonString);

// Handle non-exception-throwing cases:
// Neither JSON.parse(false) or JSON.parse(1234) throw errors, hence the type-checking,
// but... JSON.parse(null) returns null, and typeof null === "object",
// so we must check for that, too. Thankfully, null is falsey, so this suffices:
if (o && typeof o === "object") {
return o;
}
}
catch (e) { }

return false;
};

function handlemsg(e)
{
console.log(e.data);
var msgobj = JSON.parse(e.data);
var msgobj = tryParseJSONObject(e.data);
if(!msgobj) return;
console.log(msgobj);

if (msgobj.CONTENT == "OTHER")
Expand Down
Binary file modified Code/datazip/chkupdatefw.html.gz
Binary file not shown.
Binary file modified Code/datazip/config.html.gz
Binary file not shown.
Binary file modified Code/datazip/debug.html.gz
Binary file not shown.
Binary file modified Code/datazip/function.js.gz
Binary file not shown.
Binary file modified Code/datazip/hwconfig.html.gz
Binary file not shown.
Binary file modified Code/datazip/hwtestinfo.html.gz
Binary file not shown.
Binary file modified Code/datazip/index.html.gz
Binary file not shown.
Binary file modified Code/datazip/index.js.gz
Binary file not shown.
Binary file modified Code/datazip/main.css.gz
Binary file not shown.
Binary file modified Code/datazip/mqtt.html.gz
Binary file not shown.
Binary file modified Code/datazip/remove.html.gz
Binary file not shown.
Binary file modified Code/datazip/success.html.gz
Binary file not shown.
Binary file modified Code/datazip/upload.html.gz
Binary file not shown.
Binary file modified Code/datazip/webconfig.html.gz
Binary file not shown.
Binary file modified Code/datazip/wifi.html.gz
Binary file not shown.
Binary file modified Code/fw/firmware.bin
Binary file not shown.
2 changes: 1 addition & 1 deletion Code/fw/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023-03-19-0950
2023-03-19-1908
5 changes: 2 additions & 3 deletions Code/lib/BWC_unified/CIO_6W.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,9 @@ class CIO_6W : public CIO
const uint8_t DSP_DIM_ON = 0x8;
volatile bool _new_packet_available;
bool _packet_transm_active;
sStates _requested_states;
sStates _actual_states;
int _button_que_len = 0; //length of buttonQ
volatile uint16_t _button_code;
uint8_t _pressed_button = NOBTN;
// sToggles _requested_states; //not used
sStates _actual_states;
};

4 changes: 4 additions & 0 deletions Code/lib/BWC_unified/CIO_BASE.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class CIO
virtual bool getHasair() = 0;
String debug();

/*TODO: Should be protected and moved to CIO_6W.h! Public here for debugging only*/
public:
int _button_que_len = 0; //length of buttonQ

protected:
std::vector<uint8_t> _raw_payload_to_cio = {0,0,0,0,0,0,0};
std::vector<uint8_t> _raw_payload_from_cio = {0,0,0,0,0,0,0};
Expand Down
22 changes: 20 additions & 2 deletions Code/lib/BWC_unified/bwc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,21 @@ void BWC::print(const String &txt)
to_dsp_states.text += txt;
}

String BWC::getDebugData()
{
String res = "from cio ";
res += from_cio_states.toString();
res += "to dsp ";
res += to_dsp_states.toString();
res += "from dsp ";
res += from_dsp_states.toString();
res += "to cio ";
res += to_cio_states.toString();
res += "BtnQLen: ";
res += _cio->_button_que_len;
return res;
}

void BWC::setAmbientTemperature(int64_t amb, bool unit)
{
_ambient_temp = (int)amb;
Expand Down Expand Up @@ -1284,9 +1299,12 @@ void BWC::saveRebootInfo(){
StaticJsonDocument<256> doc;

// Set the values in the document
reboot_time = DateTime.format(DateFormatter::SIMPLE);
time_t boot_timestamp = DateTime.getBootTime();
tm * boot_time_tm = localtime(&boot_timestamp);
char boot_time_str[64];
strftime(boot_time_str, 64, DateFormatter::SIMPLE, boot_time_tm);
#ifdef ESP8266
doc["BOOTINFO"] = ESP.getResetReason() + " " + reboot_time;
doc["BOOTINFO"] = ESP.getResetReason() + " " + boot_time_str;
#endif

// Serialize JSON to file
Expand Down
2 changes: 2 additions & 0 deletions Code/lib/BWC_unified/bwc.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ class BWC {
String getModel();
void print(const String& txt);

String getDebugData();

public:
String reboot_time;
sStates from_cio_states, to_dsp_states;
Expand Down
16 changes: 16 additions & 0 deletions Code/lib/BWC_unified/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ struct sStates
String text ="";
int audiofrequency = 0;

String toString()
{
char res[130];
PGM_P resfmt = PSTR("LCK: %d PWR: %d UNT: %d AIR: %d GRN: %d RED: %d HTR: %d FLT: %d TMP: %d TGT: %d JET: %d TIMLED1 %d TIMLED2: %d TIMLEDBTN: %d\n");
sprintf_P(res, resfmt, locked, power, unit, bubbles, heatgrn, heatred, heat, pump, temperature, target, jets, timerled1, timerled2, timerbuttonled);
return String(res);
}

inline bool operator==(const sStates& rhs)
{
bool result = false;
Expand Down Expand Up @@ -195,6 +203,14 @@ struct sToggles
/*Requested state, not toggled*/
uint8_t no_of_heater_elements_on = 0;

String toString()
{
char res[130];
PGM_P resfmt = PSTR("Toggle: LCK: %d PWR: %d UNT: %d AIR: %d HTR: %d FLT: %d JET: %d Set: TGT: %d BTN: %d\n");
sprintf_P(res, resfmt, locked_change, power_change, unit_change, bubbles_change, heat_change, pump_change, jets_change, target, pressed_button);
return String(res);
}

inline bool operator==(const sToggles& rhs)
{
bool result = false;
Expand Down
4 changes: 3 additions & 1 deletion Code/src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
#include <WiFi.h>
#endif
#define DEVICE_NAME "layzspa"
#define FW_VERSION "2023-03-19-0950"
#define FW_VERSION "2023-03-19-1908"

// String FW_VERSION = String(__DATE__) + "-" + __TIME__ + "-beta";
#define HA_PREFIX "homeassistant"
#define PROM_NAMESPACE "layzspa"

Expand Down
1 change: 1 addition & 0 deletions Code/src/ha.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ void setupHA()
doc["name"] = F("Layzspa reboot time");
doc["uniq_id"] = "sensor.layzspa_reboot_time"+mychipid;
doc["stat_t"] = mqttBaseTopic+F("/reboot_time");
doc["val_tpl"] = F("{{as_timestamp(as_datetime(value).isoformat()) | timestamp_custom('%F %T')}}");
doc["avty_t"] = mqttBaseTopic+F("/Status");
doc["pl_avail"] = F("Alive");
doc["pl_not_avail"] = F("Dead");
Expand Down
Loading