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->Master #226

Merged
merged 75 commits into from
Mar 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
5482ce2
Merge branch 'feature/4wireUpdate' into develop
torei Jan 22, 2022
d2c9107
Merge branch 'development' into develop
torei Jan 22, 2022
b659f4c
cleanup
torei Jan 22, 2022
b50153d
restarting services after reconnecting wifi
visualapproach Jan 23, 2022
6a15b8c
Add Restart Button to HA
chunkysteveo Jan 24, 2022
34675f5
Merge pull request #201 from chunkysteveo/patch-2
visualapproach Jan 24, 2022
3a075c5
Note 54129 -> 54154 in model.h
visualapproach Jan 24, 2022
aca6ff4
Merge branch 'development' of https://github.com/visualapproach/WiFi-…
visualapproach Jan 24, 2022
cf4c8c4
Merge branch 'development' into develop
torei Jan 25, 2022
4095169
Add timestamp to STATES MQTT messages in /message topic
pdecat Jan 25, 2022
d5da2e9
update legacy name BW_2.0.0 -> layzspa
visualapproach Jan 25, 2022
0a9c4ff
Merge pull request #203 from pdecat/mqtt_message_states_time
visualapproach Jan 25, 2022
a4a2077
Merge branch 'development' of https://github.com/visualapproach/WiFi-…
visualapproach Jan 25, 2022
3f018ba
add timestamp in states message
visualapproach Jan 25, 2022
12de7ff
fix: ciotx formatted as string
visualapproach Jan 25, 2022
0695806
4w: send error state + HA examples.
visualapproach Jan 25, 2022
8dfb501
Add ability to set / update MQTT Telemetry Interval from Web UI
Scoobler Jan 26, 2022
fd58d33
Add ability to set / update MQTT Telemetry Interval from Web UI
Scoobler Jan 26, 2022
3f03970
Merge pull request #205 from Scoobler/development
visualapproach Jan 27, 2022
fb66056
4w show tx status in web interface
visualapproach Jan 27, 2022
21ca422
Merge branch 'development' into develop
torei Jan 28, 2022
4b3a72b
fix typo
torei Jan 28, 2022
14f5e4d
fix MQTT reconnect loop when its disabled
torei Jan 28, 2022
d392fb4
add hint for wifi manager password usage
torei Jan 28, 2022
d82df10
cleanup
torei Jan 28, 2022
ac571ca
Merge pull request #206 from torei/develop
visualapproach Jan 28, 2022
3896b6f
updated build instructions
visualapproach Jan 28, 2022
17de1cf
Fix: Textout bug did not show IP correctly
visualapproach Jan 30, 2022
b339a31
6w all models is selected in config.h
visualapproach Jan 30, 2022
9a08516
4w testfeature: dump serial to ws
visualapproach Feb 3, 2022
aefd7f0
Update README.md
visualapproach Feb 5, 2022
14b3ead
4w testfeature: encode dumped serial
pdecat Feb 6, 2022
3d23eb1
6w bugfixes and new set target method
visualapproach Feb 6, 2022
644cec7
Merge branch 'development' of https://github.com/visualapproach/WiFi-…
visualapproach Feb 6, 2022
272bacd
Update README.md
visualapproach Feb 6, 2022
e346b1a
Merge pull request #210 from pdecat/fix_debug
visualapproach Feb 6, 2022
6b0ea3c
4w stringformat fix
visualapproach Feb 6, 2022
6caba39
4w: Update serial lib + 8266 platform
visualapproach Feb 7, 2022
0f1ce60
6w: fix compiling error for some models
visualapproach Feb 7, 2022
2a1faf5
4w: temp debug version
visualapproach Feb 9, 2022
ecc74ab
4w: attempt to not alert the dog
visualapproach Feb 10, 2022
081cf13
4w: send RSSI to WS
visualapproach Feb 10, 2022
8cb8071
4w: bugfix converting chars
visualapproach Feb 11, 2022
8b12f60
4w: Always answer with last valid message
visualapproach Feb 11, 2022
b042cff
4W: LED on = bad message recvd
visualapproach Feb 11, 2022
d6d7687
4w: remove redundant NTP check
visualapproach Feb 12, 2022
ecf221d
4w: update timestamp again
visualapproach Feb 12, 2022
45d7c90
4 Wire Error State based on character display
chunkysteveo Mar 1, 2022
323c712
Update binary-sensors.yaml
chunkysteveo Mar 2, 2022
eed4b89
Merge pull request #214 from chunkysteveo/patch-3
visualapproach Mar 2, 2022
c125f93
update build instructions
visualapproach Mar 5, 2022
f6eb60f
Merge branch 'development' of https://github.com/visualapproach/WiFi-…
visualapproach Mar 5, 2022
c0b3e21
Update buttons.yaml
Skeletorjus Mar 7, 2022
db3ba62
Update binary-sensors.yaml
Skeletorjus Mar 7, 2022
4b5f953
Update sensors.yaml
Skeletorjus Mar 7, 2022
515739b
Update switches.yaml
Skeletorjus Mar 7, 2022
7e11b47
Create layzspa.yaml
Skeletorjus Mar 7, 2022
e13b5d8
Create readme.md
Skeletorjus Mar 7, 2022
1366734
Update layzspa.yaml
Skeletorjus Mar 7, 2022
07083b9
Update layzspa.yaml
Skeletorjus Mar 7, 2022
522e6da
Update readme.md
Skeletorjus Mar 7, 2022
39fe664
Delete binary-sensors.yaml
Skeletorjus Mar 7, 2022
f0a541b
Delete buttons.yaml
Skeletorjus Mar 7, 2022
d2d0311
Delete sensors.yaml
Skeletorjus Mar 7, 2022
17910a0
Delete switches.yaml
Skeletorjus Mar 7, 2022
b614e13
Update readme.md
Skeletorjus Mar 7, 2022
647b635
Update layzspa.yaml
Skeletorjus Mar 7, 2022
6fd8ae7
Update layzspa.yaml
Skeletorjus Mar 7, 2022
efab473
Update layzspa.yaml
Skeletorjus Mar 7, 2022
9d76fde
Update layzspa.yaml
Skeletorjus Mar 7, 2022
8f13a89
Update layzspa.yaml
Skeletorjus Mar 7, 2022
483530e
Merge pull request #219 from Skeletorjus/development
visualapproach Mar 8, 2022
30dd785
updated table in instructions
visualapproach Mar 8, 2022
18bc18e
Merge branch 'development' of https://github.com/visualapproach/WiFi-…
visualapproach Mar 8, 2022
420f9ff
4w: add rebootinfo to debug msg
visualapproach Mar 9, 2022
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
Binary file modified Build-instructions-Bestway-WiFi-remote.pdf
Binary file not shown.
5 changes: 4 additions & 1 deletion Code/4-wire-version/data/WebSocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function handlemsg(e)
"CONNECT_BAD_CLIENT_ID", // 2 / the server rejected the client identifier
"CONNECT_UNAVAILABLE", // 3 / the server was unable to accept the connection
"CONNECT_BAD_CREDENTIALS", // 4 / the username/password were rejected
"CONNECT_UNAUTHORIZED" // 5 / e client was not authorized to connect
"CONNECT_UNAUTHORIZED" // 5 / the client was not authorized to connect
]
document.getElementById('mqtt').innerHTML = "MQTT: " + mqtt_states[msgobj.MQTT + 4];

Expand All @@ -108,6 +108,9 @@ function handlemsg(e)
document.getElementById('jetstitle').style.display = (jetsAvailable ? 'inherit' : 'none');
document.getElementById('jetsbutton').style.display = (jetsAvailable ? 'inherit' : 'none');
document.getElementById('jetstotals').style.display = (jetsAvailable ? 'inherit' : 'none');

document.getElementById('ciotx').innerHTML = 'CIO TX: ' + (msgobj.CIOTX ? 'Active' : 'Dead');
document.getElementById('dsptx').innerHTML = 'DSP TX: ' + (msgobj.DSPTX ? 'Active' : 'Dead');
}

if (msgobj.CONTENT == "STATES")
Expand Down
2 changes: 2 additions & 0 deletions Code/4-wire-version/data/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ <h2>Totals:</h2>

<footer>
<p class="center"><span id="mqtt">MQTT: loading status...</span></p>
<p class="center"><span id="ciotx">CIO TX: loading status...</span></p>
<p class="center"><span id="dsptx">DSP TX: loading status...</span></p>
</footer>
</div>
</body>
Expand Down
8 changes: 7 additions & 1 deletion Code/4-wire-version/data/mqtt.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
<td>Base Topic:</td>
<td><input type="text" id="mqttBaseTopic"></td>
</tr>
<tr>
<td>Telemetry Interval (s):</td>
<td><input type="text" id="mqttTelemetryInterval"></td>
</tr>
<tr>
<td colspan="2" style="text-align:center"><button id="save" class="button" onclick="saveConfig()">save</button></td>
</tr>
Expand Down Expand Up @@ -97,6 +101,7 @@
document.getElementById("mqttPassword").value = json.mqttPassword;
document.getElementById("mqttClientId").value = json.mqttClientId;
document.getElementById("mqttBaseTopic").value = json.mqttBaseTopic;
document.getElementById("mqttTelemetryInterval").value = json.mqttTelemetryInterval;
}
}
}
Expand All @@ -121,7 +126,8 @@
"mqttUsername":(document.getElementById("mqttUsername").value),
"mqttPassword":(document.getElementById("mqttPassword").value),
"mqttClientId":(document.getElementById("mqttClientId").value),
"mqttBaseTopic":(document.getElementById("mqttBaseTopic").value)
"mqttBaseTopic":(document.getElementById("mqttBaseTopic").value),
"mqttTelemetryInterval":(document.getElementById("mqttTelemetryInterval").value)
};
console.log(json);
Http.send(JSON.stringify(json));
Expand Down
194 changes: 134 additions & 60 deletions Code/4-wire-version/lib/BWC4W/BWC_8266_4w.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ void CIO::begin() {
DSP_RX = D7
Devices are sending on their TX lines, so we read that with RX pins on the ESP
*/
cio_serial.begin(9600, SWSERIAL_8N1, D2, D3, false, 64);
cio_serial.setTimeout(50);
dsp_serial.begin(9600, SWSERIAL_8N1, D6, D7, false, 64);
dsp_serial.setTimeout(50);
cio_serial.begin(9600, SWSERIAL_8N1, D2, D3, false, 63);
cio_serial.setTimeout(20);
dsp_serial.begin(9600, SWSERIAL_8N1, D6, D7, false, 63);
dsp_serial.setTimeout(20);

states[TARGET] = 20;
//Not used. Here for compatibility reasons
states[LOCKEDSTATE] = false;
states[POWERSTATE] = true;
states[UNITSTATE] = true; //Celsius
states[UNITSTATE] = true; //Celsius. can be changed by web gui
states[CHAR1] = ' ';
states[CHAR2] = ' ';
states[CHAR3] = ' ';
Expand All @@ -27,63 +27,102 @@ void CIO::begin() {
}

void CIO::loop(void) {
digitalWrite(D4, LOW); //LED off
//check if CIO has sent a message
int msglen = 0;
if(cio_serial.available()){
if(cio_serial.available())
{
msglen = cio_serial.readBytes(from_CIO_buf, PAYLOADSIZE);
}
//pass message to display
if(msglen == PAYLOADSIZE){
//discard message if checksum is wrong
uint8_t calculatedChecksum;
calculatedChecksum = from_CIO_buf[1]+from_CIO_buf[2]+from_CIO_buf[3]+from_CIO_buf[4];
if(from_CIO_buf[CIO_CHECKSUMINDEX] == calculatedChecksum){
for(int i = 0; i < PAYLOADSIZE; i++){
if(to_DSP_buf[i] != from_CIO_buf[i]) dataAvailable = true;
to_DSP_buf[i] = from_CIO_buf[i];
//copy from_CIO_buf -> to_DSP_buf
if(msglen == PAYLOADSIZE){
//discard message if checksum is wrong
uint8_t calculatedChecksum;
calculatedChecksum = from_CIO_buf[1]+from_CIO_buf[2]+from_CIO_buf[3]+from_CIO_buf[4];
if(from_CIO_buf[CIO_CHECKSUMINDEX] == calculatedChecksum){
for(int i = 0; i < PAYLOADSIZE; i++){
if(to_DSP_buf[i] != from_CIO_buf[i]) dataAvailable = true;
to_DSP_buf[i] = from_CIO_buf[i];
}
}
states[TEMPERATURE] = from_CIO_buf[TEMPINDEX];
states[ERROR] = from_CIO_buf[ERRORINDEX];
cio_tx = true; //show the user that this line works (appears to work)
//check if cio send error msg
states[CHAR1] = ' ';
states[CHAR2] = ' ';
states[CHAR3] = ' ';
if(states[ERROR]){
to_CIO_buf[COMMANDINDEX] = 0; //clear any commands
GODMODE = false;
states[CHAR1] = 'E';
states[CHAR2] = (char)(48+(from_CIO_buf[ERRORINDEX]/10));
states[CHAR3] = (char)(48+(from_CIO_buf[ERRORINDEX]%10));
}
} else
{
digitalWrite(D4, HIGH); //LED on indicates bad message
}
/* debug
else
{
if(msglen)
{
dataAvailable = true;
for(int i = 0; i < msglen; i++)
{
dismissed_from_CIO_buf[i] = from_CIO_buf[i];
}
dismissed_cio_len = msglen;
}
}
states[TEMPERATURE] = from_CIO_buf[TEMPINDEX];
states[ERROR] = from_CIO_buf[ERRORINDEX];
//do stuff here if you want to alter the message
*/
// Do stuff here if you want to alter the message
// Send last good message to DSP
dsp_serial.write(to_DSP_buf, PAYLOADSIZE);
digitalWrite(D4, !digitalRead(D4)); //blink
cio_tx = true; //show the user that this line works (appears to work)
}
//check if cio send error msg
states[CHAR1] = ' ';
states[CHAR2] = ' ';
states[CHAR3] = ' ';
if(states[ERROR]){
to_CIO_buf[COMMANDINDEX] = 0; //clear any commands
GODMODE = false;
states[CHAR1] = 'E';
states[CHAR2] = 48+(to_CIO_buf[ERRORINDEX]/10);
states[CHAR3] = 48+(to_CIO_buf[ERRORINDEX]%10);
}
//check if display sent a message
msglen = 0;
if(dsp_serial.available()){
if(dsp_serial.available())
{
msglen = dsp_serial.readBytes(from_DSP_buf, PAYLOADSIZE);
}
//pass message to CIO
if(msglen == PAYLOADSIZE){
//discard message if checksum is wrong
uint8_t calculatedChecksum;
calculatedChecksum = from_DSP_buf[1]+from_DSP_buf[2]+from_DSP_buf[3]+from_DSP_buf[4];
if(from_DSP_buf[DSP_CHECKSUMINDEX] == calculatedChecksum){
for(int i = 0; i < PAYLOADSIZE; i++){
to_CIO_buf[i] = from_DSP_buf[i];
//copy from_DSP_buf -> to_CIO_buf
if(msglen == PAYLOADSIZE){
//discard message if checksum is wrong
uint8_t calculatedChecksum;
calculatedChecksum = from_DSP_buf[1]+from_DSP_buf[2]+from_DSP_buf[3]+from_DSP_buf[4];
if(from_DSP_buf[DSP_CHECKSUMINDEX] == calculatedChecksum)
{
for(int i = 0; i < PAYLOADSIZE; i++)
{
to_CIO_buf[i] = from_DSP_buf[i];
}
//Do stuff here to command the CIO
if(GODMODE){
updatePayload();
} else {
updateStates();
}
dsp_tx = true; //show the user that this line works (appears to work)
}
} else
{
digitalWrite(D4, HIGH); //LED on indicates bad message
}
//Do stuff here to command the CIO
if(GODMODE){
updatePayload();
} else {
updateStates();
/* debug
else
{
if(msglen)
{
dataAvailable = true;
for(int i = 0; i < msglen; i++)
{
dismissed_from_DSP_buf[i] = from_DSP_buf[i];
}
dismissed_dsp_len = msglen;
}
}
*/
cio_serial.write(to_CIO_buf, PAYLOADSIZE);
dsp_tx = true; //show the user that this line works (appears to work)
}
}

Expand Down Expand Up @@ -126,15 +165,15 @@ void CIO::updatePayload(){

//calc checksum -> byte5
//THIS NEEDS TO BE IMPROVED IF OTHER CHECKSUMS IS USED (FOR OTHER BYTES in different models)
to_CIO_buf[DSP_CHECKSUMINDEX] = to_CIO_buf[1] + to_CIO_buf[2] + to_CIO_buf[3] + to_CIO_buf[4];
if(to_CIO_buf[DSP_CHECKSUMINDEX] != prevchksum) dataAvailable = true;
prevchksum = to_CIO_buf[DSP_CHECKSUMINDEX];
to_CIO_buf[CIO_CHECKSUMINDEX] = to_CIO_buf[1] + to_CIO_buf[2] + to_CIO_buf[3] + to_CIO_buf[4];
if(to_CIO_buf[CIO_CHECKSUMINDEX] != prevchksum) dataAvailable = true;
prevchksum = to_CIO_buf[CIO_CHECKSUMINDEX];
}


void BWC::begin(void){
_cio.begin();
_startNTP();
//_startNTP(); this is done from main.cpp
LittleFS.begin();
_loadSettings();
_loadCommandQueue();
Expand Down Expand Up @@ -166,13 +205,7 @@ void BWC::loop(){
//feed the dog
ESP.wdtFeed();
ESP.wdtDisable();

if (!DateTime.isTimeValid()) {
//Serial.println("Failed to get time from server, retry.");
DateTime.begin();
}
_timestamp = DateTime.now();

_timestamp = DateTime.now();
_updateTimes();
//feed the dog
//ESP.wdtFeed();
Expand Down Expand Up @@ -430,6 +463,7 @@ String BWC::getJSONStates() {

// Set the values in the document
doc["CONTENT"] = "STATES";
doc["TIME"] = _timestamp;
doc["LCK"] = _cio.states[LOCKEDSTATE];
doc["PWR"] = _cio.states[POWERSTATE];
doc["UNT"] = _cio.states[UNITSTATE];
Expand All @@ -443,6 +477,7 @@ String BWC::getJSONStates() {
doc["CH2"] = _cio.states[CHAR2];
doc["CH3"] = _cio.states[CHAR3];
doc["JET"] = _cio.states[JETSSTATE];
doc["ERR"] = _cio.states[ERROR];
doc["GOD"] = _cio.GODMODE;

// Serialize JSON to string
Expand Down Expand Up @@ -559,6 +594,42 @@ String BWC::getJSONCommandQueue(){
return jsonmsg;
}

String BWC::encodeBufferToString(uint8_t buf[7]){
String str = String();
for (unsigned long i = 0; i < 7; i++) {
str += String(buf[i], HEX);
str += " ";
}
return str;
}

String BWC::getSerialBuffers(){
ESP.wdtFeed();
DynamicJsonDocument doc(512);

// Set the values in the document
doc["CONTENT"] = "DEBUG";
doc["TIME"] = _timestamp;
doc["FROMDSP"] = encodeBufferToString(_cio.from_DSP_buf);
doc["TOCIO"] = encodeBufferToString(_cio.to_CIO_buf);
doc["FROMCIO"] = encodeBufferToString(_cio.from_CIO_buf);
doc["TODSP"] = encodeBufferToString(_cio.to_DSP_buf);
doc["REBOOTINFO"] = ESP.getResetReason();
doc["REBOOTTIME"] = DateTime.getBootTime();
/* debug
doc["FROMDSPFAIL"] = encodeBufferToString(_cio.dismissed_from_DSP_buf);
doc["LENDSP"] = _cio.dismissed_dsp_len;
doc["FROMCIOFAIL"] = encodeBufferToString(_cio.dismissed_from_CIO_buf);
doc["LENCIO"] = _cio.dismissed_cio_len;
*/
// Serialize JSON to string
String json;
if (serializeJson(doc, json) == 0) {
json = "{\"error\": \"Failed to serialize message\"}";
}
return json;
}

bool BWC::newData(){
bool result = _cio.dataAvailable;
_cio.dataAvailable = false;
Expand Down Expand Up @@ -631,6 +702,7 @@ void BWC::saveSettingsFlag(){

void BWC::saveSettings(){
//kill the dog
ESP.wdtFeed();
ESP.wdtDisable();
_saveSettingsNeeded = false;
File file = LittleFS.open("settings.txt", "w");
Expand Down Expand Up @@ -674,7 +746,7 @@ void BWC::saveSettings(){
file.close();
//update clock
//DateTime.setTimeZone(_timezone); //deprecated
DateTime.begin();
//DateTime.begin(); //removed to lower risk of wdt reset.
//revive the dog
ESP.wdtEnable(0);

Expand Down Expand Up @@ -713,6 +785,7 @@ void BWC::_loadCommandQueue(){

void BWC::_saveCommandQueue(){
//kill the dog
ESP.wdtFeed();
ESP.wdtDisable();

_saveCmdqNeeded = false;
Expand Down Expand Up @@ -749,6 +822,7 @@ void BWC::_saveCommandQueue(){
void BWC::saveEventlog(){
_saveEventlogNeeded = false;
//kill the dog
ESP.wdtFeed();
ESP.wdtDisable();
File file = LittleFS.open("eventlog.txt", "a");
if (!file) {
Expand Down
Loading