Skip to content

Commit 0d4cf9e

Browse files
committed
fix handling emtpy answer from device
1 parent 84a6b50 commit 0d4cf9e

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

platformio.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
framework = arduino
1414
monitor_speed = 115200
15-
custom_prog_version = 1.1.4A2
15+
custom_prog_version = 1.1.5
1616
build_flags =
1717
-DVERSION=${this.custom_prog_version}
1818
-DPIO_SRC_NAM="Solar2MQTT"

src/PI_Serial/PI_Serial.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,32 +77,25 @@ bool PI_Serial::loop()
7777
switch (requestCounter)
7878
{
7979
case 0:
80-
PI_DEBUG_PRINTLN("Serial request>"+(String)requestCounter+"<:>6<");
8180
requestCounter = PIXX_QPIGS() ? (requestCounter + 1) : 0;
8281
break;
8382
case 1:
84-
PI_DEBUG_PRINTLN("Serial request>"+(String)requestCounter+"<:>6<");
8583
requestCounter = PIXX_QPIGS2() ? (requestCounter + 1) : 0;
8684
break;
8785
case 2:
88-
PI_DEBUG_PRINTLN("Serial request>"+(String)requestCounter+"<:>6<");
8986
requestCounter = PIXX_QMOD() ? (requestCounter + 1) : 0;
9087
break;
9188
case 3:
92-
PI_DEBUG_PRINTLN("Serial request>"+(String)requestCounter+"<:>6<");
9389
requestCounter = PIXX_Q1() ? (requestCounter + 1) : 0;
9490
break;
9591
case 4:
96-
PI_DEBUG_PRINTLN("Serial request>"+(String)requestCounter+"<:>6<");
9792
// requestCounter = PIXX_QALL() ? (requestCounter + 1) : 0;
9893
requestCounter++;
9994
break;
10095
case 5:
101-
PI_DEBUG_PRINTLN("Serial request>"+(String)requestCounter+"<:>6<");
10296
requestCounter = PIXX_QEX() ? (requestCounter + 1) : 0;
10397
break;
10498
case 6:
105-
PI_DEBUG_PRINTLN("Serial request>"+(String)requestCounter+"<:>6<");
10699
// sendCustomCommand();
107100
requestCallback();
108101
requestCounter = 0;
@@ -125,7 +118,6 @@ bool PI_Serial::loop()
125118

126119
void PI_Serial::callback(std::function<void()> func)
127120
{
128-
PI_DEBUG_PRINTLN("Data Collect complete, fire up callback");
129121
requestCallback = func;
130122
}
131123

@@ -239,6 +231,10 @@ String PI_Serial::requestData(String command)
239231
{
240232
commandBuffer = "NAK";
241233
}
234+
else if (commandBuffer == "") // catch empty answer, its similar to NAK
235+
{
236+
commandBuffer = "NAK";
237+
}
242238
else
243239
{
244240
PI_DEBUG_PRINTLN("ERROR Send: >" + command + "< Recive: >" + commandBuffer + "<");

src/PI_Serial/QPIGS2.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ bool PI_Serial::PIXX_QPIGS2()
1313
get.raw.qpigs2 = commandAnswer;
1414
byte commandAnswerLength = commandAnswer.length();
1515
String strs[30]; // buffer for string splitting
16-
if (commandAnswer == "NAK" || commandAnswer == "")
16+
if (commandAnswer == "NAK")
1717
{
1818
return true;
1919
}

src/webpages/HTML_SETTINGS_EDIT.html

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ <h1>Edit Configuration</h1>
6868

6969
<div class="input-group mb-2">
7070
<span class="input-group-text w-50" id="httpUserdesc">HTTP Username</span>
71-
<input type="text" class="form-control" aria-describedby="httpUserdesc" id="httpUser" name="post_httpUser" maxlength="40"
72-
maxlength="35" value="%pre_http_user%">
71+
<input type="text" class="form-control" aria-describedby="httpUserdesc" id="httpUser" name="post_httpUser"
72+
maxlength="40" maxlength="35" value="%pre_http_user%">
7373
</div>
7474
<div class="input-group mb-2">
7575
<span class="input-group-text w-50" id="httpPassdesc">HTTP Password</span>
76-
<input type="password" class="form-control" aria-describedby="httpPassdesc" id="httpPass" name="post_httpPass" maxlength="40"
77-
maxlength="35" value="%pre_http_pass%">
76+
<input type="password" class="form-control" aria-describedby="httpPassdesc" id="httpPass" name="post_httpPass"
77+
maxlength="40" maxlength="35" value="%pre_http_pass%">
7878
</div>
7979

8080
<div class="d-grid gap-2">
@@ -84,10 +84,15 @@ <h1>Edit Configuration</h1>
8484
</form>
8585

8686
<script type='text/javascript'>
87+
$(document).ready(function (load) {
88+
haSwitch();
89+
});
8790
function haSwitch() {
88-
document.getElementById('mqttjson').checked = false;
91+
if (document.getElementById('post_hadiscovery').checked) {
92+
document.getElementById('mqttjson').checked = false;
93+
document.getElementById('mqttjson').disabled = true;
94+
}
8995
document.getElementById('mqttjson').disabled = document.getElementById('post_hadiscovery').checked;
90-
document.getElementById('mqttjson').enabled = !(document.getElementById('post_hadiscovery').checked);
9196
}
9297
</script>
9398

0 commit comments

Comments
 (0)