Another try to fix exception

Another try to fix exception (#14067)
This commit is contained in:
Theo Arends 2021-12-22 18:11:35 +01:00
parent 9c3fb8fc82
commit 7bf6e5a773

View File

@ -80,7 +80,7 @@ bool Rg15Poll(void) {
if (++Rg15.time == RG15_EVENT_TIMEOUT) { if (++Rg15.time == RG15_EVENT_TIMEOUT) {
Rg15.acc = 0; Rg15.acc = 0;
Rg15.rate = 0; Rg15.rate = 0;
MqttPublishSensor(); // MqttPublishSensor();
} }
return false; return false;
@ -96,7 +96,7 @@ bool Rg15Poll(void) {
Rg15Process(rg15_buffer); Rg15Process(rg15_buffer);
} }
MqttPublishSensor(); // MqttPublishSensor();
return true; return true;
} }
@ -142,14 +142,15 @@ float Rg15Parse(char* buffer, const char* item) {
char* start = strstr(buffer, item); char* start = strstr(buffer, item);
if (start != nullptr) { if (start != nullptr) {
char* end = strstr(start, " mm"); char* end = strstr(start, " mm");
char tmp = end[0]; if (end != nullptr) {
end[0] = '\0'; char tmp = end[0];
float result = CharToFloat (start + strlen(item)); end[0] = '\0';
end[0] = tmp; float result = CharToFloat (start + strlen(item));
return result; end[0] = tmp;
} else { return result;
return 0.0f; }
} }
return 0.0f;
} }
bool Rg15Command(void) { bool Rg15Command(void) {
@ -167,6 +168,7 @@ bool Rg15Command(void) {
char rg15_buffer[255]; char rg15_buffer[255];
if (Rg15ReadLine(rg15_buffer)) { if (Rg15ReadLine(rg15_buffer)) {
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("HRG: Received %*_H"), strlen(rg15_buffer), rg15_buffer);
Response_P(PSTR("{\"" D_JSON_SERIALRECEIVED "\":\"%s\"}"), rg15_buffer); Response_P(PSTR("{\"" D_JSON_SERIALRECEIVED "\":\"%s\"}"), rg15_buffer);
Rg15Process(rg15_buffer); Rg15Process(rg15_buffer);
} }