Skip to content

Commit

Permalink
Fix ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
netmindz committed Dec 8, 2023
1 parent d0be37d commit d134fb4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
32 changes: 18 additions & 14 deletions sensor/src/sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,24 @@ ArduinoQueue<String> sendBuffer(10); // TODO: might be better bigger for large
unsigned long msgStartTime;
unsigned long timeSinceMsgStart;

String result = "";
String lastRaw = "";
String lastRaw2 = "";
String lastRaw3 = "";
String lastRaw4 = "";
String lastRaw5 = "";
String lastRaw6 = "";
String lastFB = "";
String lastJSON = "";
uint32_t lastUptime = 0;
String timeString = "";
int msgLength = 0;
boolean panelDetected = false;
const unsigned long readBytesTimeout = 2500; // Timeout in microseconds (2.5 ms)

#include "telnet.h"
#include "webstatus.h"

byte nibble(char c);
void hexCharacterStringToBytes(byte* byteArray, const char* hexString);
void handleMessage(size_t len, uint8_t buf[]);
Expand Down Expand Up @@ -529,20 +547,6 @@ void setup() {
digitalWrite(LED_BUILTIN, LOW);
}

String result = "";
String lastRaw = "";
String lastRaw2 = "";
String lastRaw3 = "";
String lastRaw4 = "";
String lastRaw5 = "";
String lastRaw6 = "";
String lastFB = "";
String lastJSON = "";
uint32_t lastUptime = 0;
String timeString = "";
int msgLength = 0;
boolean panelDetected = false;
const unsigned long readBytesTimeout = 2500; // Timeout in microseconds (2.5 ms)

/*
* waitforGLBytes checks the first byte in the serial buffer
Expand Down
7 changes: 4 additions & 3 deletions sensor/src/webstatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ void handleSend() {
sendBuffer.enqueue(message);
}

String getStatusJSON() {
return "{\"type\": \"status\", \"data\" : { \"temp\": \"" + String(tubTemp,1) + "\", \"heater\": " + (heaterState ? "true" : "false") + ", \"light\": " + (lightState ? "true" : "false") + ", \"mode\": \""+tubMode.getCurrentState()+"\", \"uptime\": " + lastUptime + ", \"state\": \"" + state + "\" } }";
}

void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length) {

switch (type) {
Expand Down Expand Up @@ -44,6 +48,3 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length

}

String getStatusJSON() {
return "{\"type\": \"status\", \"data\" : { \"temp\": \"" + String(tubTemp,1) + "\", \"heater\": " + (heaterState ? "true" : "false") + ", \"light\": " + (lightState ? "true" : "false") + ", \"mode\": \""+tubMode.getCurrentState()+"\", \"uptime\": " + lastUptime + ", \"state\": \"" + state + "\" } }";
}

0 comments on commit d134fb4

Please sign in to comment.