Skip to content

Commit

Permalink
fix handling emtpy answer from device
Browse files Browse the repository at this point in the history
  • Loading branch information
softwarecrash committed Dec 27, 2023
1 parent 84a6b50 commit 0d4cf9e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
platform = espressif8266@4.2.1
framework = arduino
monitor_speed = 115200
custom_prog_version = 1.1.4A2
custom_prog_version = 1.1.5
build_flags =
-DVERSION=${this.custom_prog_version}
-DPIO_SRC_NAM="Solar2MQTT"
Expand Down
12 changes: 4 additions & 8 deletions src/PI_Serial/PI_Serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,32 +77,25 @@ bool PI_Serial::loop()
switch (requestCounter)
{
case 0:
PI_DEBUG_PRINTLN("Serial request>"+(String)requestCounter+"<:>6<");
requestCounter = PIXX_QPIGS() ? (requestCounter + 1) : 0;
break;
case 1:
PI_DEBUG_PRINTLN("Serial request>"+(String)requestCounter+"<:>6<");
requestCounter = PIXX_QPIGS2() ? (requestCounter + 1) : 0;
break;
case 2:
PI_DEBUG_PRINTLN("Serial request>"+(String)requestCounter+"<:>6<");
requestCounter = PIXX_QMOD() ? (requestCounter + 1) : 0;
break;
case 3:
PI_DEBUG_PRINTLN("Serial request>"+(String)requestCounter+"<:>6<");
requestCounter = PIXX_Q1() ? (requestCounter + 1) : 0;
break;
case 4:
PI_DEBUG_PRINTLN("Serial request>"+(String)requestCounter+"<:>6<");
// requestCounter = PIXX_QALL() ? (requestCounter + 1) : 0;
requestCounter++;
break;
case 5:
PI_DEBUG_PRINTLN("Serial request>"+(String)requestCounter+"<:>6<");
requestCounter = PIXX_QEX() ? (requestCounter + 1) : 0;
break;
case 6:
PI_DEBUG_PRINTLN("Serial request>"+(String)requestCounter+"<:>6<");
// sendCustomCommand();
requestCallback();
requestCounter = 0;
Expand All @@ -125,7 +118,6 @@ bool PI_Serial::loop()

void PI_Serial::callback(std::function<void()> func)
{
PI_DEBUG_PRINTLN("Data Collect complete, fire up callback");
requestCallback = func;
}

Expand Down Expand Up @@ -239,6 +231,10 @@ String PI_Serial::requestData(String command)
{
commandBuffer = "NAK";
}
else if (commandBuffer == "") // catch empty answer, its similar to NAK
{
commandBuffer = "NAK";
}
else
{
PI_DEBUG_PRINTLN("ERROR Send: >" + command + "< Recive: >" + commandBuffer + "<");
Expand Down
2 changes: 1 addition & 1 deletion src/PI_Serial/QPIGS2.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ bool PI_Serial::PIXX_QPIGS2()
get.raw.qpigs2 = commandAnswer;
byte commandAnswerLength = commandAnswer.length();
String strs[30]; // buffer for string splitting
if (commandAnswer == "NAK" || commandAnswer == "")
if (commandAnswer == "NAK")
{
return true;
}
Expand Down
17 changes: 11 additions & 6 deletions src/webpages/HTML_SETTINGS_EDIT.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ <h1>Edit Configuration</h1>

<div class="input-group mb-2">
<span class="input-group-text w-50" id="httpUserdesc">HTTP Username</span>
<input type="text" class="form-control" aria-describedby="httpUserdesc" id="httpUser" name="post_httpUser" maxlength="40"
maxlength="35" value="%pre_http_user%">
<input type="text" class="form-control" aria-describedby="httpUserdesc" id="httpUser" name="post_httpUser"
maxlength="40" maxlength="35" value="%pre_http_user%">
</div>
<div class="input-group mb-2">
<span class="input-group-text w-50" id="httpPassdesc">HTTP Password</span>
<input type="password" class="form-control" aria-describedby="httpPassdesc" id="httpPass" name="post_httpPass" maxlength="40"
maxlength="35" value="%pre_http_pass%">
<input type="password" class="form-control" aria-describedby="httpPassdesc" id="httpPass" name="post_httpPass"
maxlength="40" maxlength="35" value="%pre_http_pass%">
</div>

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

<script type='text/javascript'>
$(document).ready(function (load) {
haSwitch();
});
function haSwitch() {
document.getElementById('mqttjson').checked = false;
if (document.getElementById('post_hadiscovery').checked) {
document.getElementById('mqttjson').checked = false;
document.getElementById('mqttjson').disabled = true;
}
document.getElementById('mqttjson').disabled = document.getElementById('post_hadiscovery').checked;
document.getElementById('mqttjson').enabled = !(document.getElementById('post_hadiscovery').checked);
}
</script>

Expand Down

0 comments on commit 0d4cf9e

Please sign in to comment.