Skip to content

Commit 00041a5

Browse files
committed
Updated logging to short mode
1 parent 16e66c3 commit 00041a5

8 files changed

Lines changed: 23 additions & 17 deletions

File tree

PCB/DaughterBoard.dch

94.3 KB
Binary file not shown.

PCB/DaughterBoard.dip

87 KB
Binary file not shown.

Pictures/$-Relay board Pinout.pdf

641 KB
Binary file not shown.

code/ESP32/include/Log.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ void inline printHexString(char* ptr, int len)
1818
#endif
1919

2020
#if APP_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
21-
#define logd(format, ...) log_printf(ARDUHAL_LOG_FORMAT(D, format), ##__VA_ARGS__)
21+
#define logd(format, ...) log_printf(ARDUHAL_SHORT_LOG_FORMAT(D, format), ##__VA_ARGS__)
2222
#else
2323
#define logd(format, ...)
2424
#endif
2525

2626
#if APP_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
27-
#define logi(format, ...) log_printf(ARDUHAL_LOG_FORMAT(I, format), ##__VA_ARGS__)
27+
#define logi(format, ...) log_printf(ARDUHAL_SHORT_LOG_FORMAT(I, format), ##__VA_ARGS__)
2828
#else
2929
#define logi(format, ...)
3030
#endif

code/ESP32/platformio.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ build_flags =
2828
-D 'CONFIG_VERSION="V1.0.1"' ; major.minor.build (major or minor will invalidate the configuration)
2929
-D 'NTP_SERVER="pool.ntp.org"'
3030
-D 'HOME_ASSISTANT_PREFIX="homeassistant"' ; Home Assistant Auto discovery root topic
31-
-D WIFI_STATUS_PIN=2 ;LED Pin on the Dev board
32-
; -D WIFI_STATUS_PIN=23 ;LED Pin on the ESP32 X4 Relay board
31+
; -D WIFI_STATUS_PIN=2 ;LED Pin on the Dev board
32+
-D WIFI_STATUS_PIN=23 ;LED Pin on the ESP32 X4 Relay board
3333
-D FACTORY_RESET_PIN=4 ; Clear NVRAM
3434

3535
; 4-20 Sensor using 2 X 270Ω resistors in parallel to get 135Ω

code/ESP32/src/Oled.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ namespace HydroFloat
4444
strcpy(buffer, "Overflow");
4545
_oled.setCursor(xOffset(2, strlen(buffer)), STATUS_Y);
4646
_oled.print(buffer);
47-
logd("State: %s", buffer);
47+
// logd("State: %s", buffer);
4848
sprintf(buffer, "%d%%", level);
49-
logd("Level: %s", buffer);
49+
// logd("Level: %s", buffer);
5050
_oled.setCursor(xOffset(5, strlen(buffer)), LEVEL_Y);
5151
_oled.setTextSize(LEVEL_FONT);
5252
_oled.setTextColor(SSD1306_WHITE);
@@ -57,7 +57,7 @@ namespace HydroFloat
5757
uint8_t Oled::xOffset(uint8_t textSize, uint8_t numberOfCharaters) {
5858
uint8_t textPixels = textSize * 6;
5959
uint8_t rVal = (SCREEN_WIDTH - (numberOfCharaters * textPixels)) / 2;
60-
logd("Offset: %d", rVal);
60+
// logd("Offset: %d", rVal);
6161
return rVal;
6262

6363
}

code/ESP32/src/Tank.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ namespace HydroFloat {
2020
pinMode(FACTORY_RESET_PIN, INPUT_PULLUP);
2121
pinMode(WIFI_STATUS_PIN, OUTPUT);
2222
_oled.begin();
23+
_oled.update(0, off);
2324
EEPROM.begin(EEPROM_SIZE);
2425
if (digitalRead(FACTORY_RESET_PIN) == LOW)
2526
{
@@ -82,11 +83,11 @@ namespace HydroFloat {
8283
_webSocket.onEvent([this](uint8_t num, WStype_t type, uint8_t *payload, size_t length)
8384
{
8485
if (type == WStype_DISCONNECTED) {
85-
logi("[%u] Home Page Disconnected!\n", num);
86+
logi("[%u] Home Page Disconnected!", num);
8687
_networkStatus = APMode;
8788
}
8889
else if (type == WStype_CONNECTED) {
89-
logi("[%u] Home Page Connected!\n", num);
90+
logi("[%u] Home Page Connected!", num);
9091
_lastWaterLevel = -1; //force a broadcast
9192
_networkStatus = WSMode;
9293
}
@@ -102,12 +103,14 @@ namespace HydroFloat {
102103
});
103104

104105
_asyncServer.onNotFound([this](AsyncWebServerRequest *request) {
105-
logd("Not found: %s", request->url().c_str());
106-
String page = redirect_html;
107-
page.replace("{n}", _SSID);
108-
IPAddress IP = WiFi.softAPIP();
109-
page.replace("{ip}", IP.toString().c_str());
110-
request->send(200, "text/html", page);
106+
if (APMode == _networkStatus) {
107+
logd("Redirecting from: %s", request->url().c_str());
108+
String page = redirect_html;
109+
page.replace("{n}", _SSID);
110+
IPAddress IP = WiFi.softAPIP();
111+
page.replace("{ip}", IP.toString().c_str());
112+
request->send(200, "text/html", page);
113+
}
111114
});
112115

113116
_asyncServer.on("/settings", HTTP_GET, [this](AsyncWebServerRequest *request) {
@@ -215,7 +218,7 @@ namespace HydroFloat {
215218
serializeJson(doc, s);
216219
_webSocket.broadcastTXT(s);
217220
_oled.update(waterLevel, s4 ? overflow : s3 ? slag : s2 ? slead : s1 ? stop : off);
218-
logd("Water Level: %f JSON: %s", waterLevel, s.c_str());
221+
logd("broadcast JSON: %s", s.c_str());
219222
}
220223
_webSocket.loop();
221224
_dnsServer.processNextRequest();

code/ESP32/src/main.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ void setup() {
2525
_tank->setup();
2626
if (timer == NULL) {
2727
timer = timerBegin(0, 80, true); // timer 0, div 80
28-
timerAttachInterrupt(timer, []() { esp_restart(); }, true); // attach callback
28+
timerAttachInterrupt(timer, []() {
29+
ets_printf("watchdog timer expired - rebooting\n");
30+
esp_restart();
31+
}, true); // attach callback
2932
timerAlarmWrite(timer, WATCHDOG_TIMER * 1000, false); // set time in us
3033
timerAlarmEnable(timer); // enable interrupt
3134
}

0 commit comments

Comments
 (0)