Skip to content

Commit b0015c4

Browse files
committed
fix missing SoftwareSerial dependency: upgrade some dependencies
1 parent f0bd916 commit b0015c4

File tree

2 files changed

+94
-78
lines changed

2 files changed

+94
-78
lines changed

platformio.ini

+5-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
; https://docs.platformio.org/page/projectconf.html
1010

1111
[env:esp32dev]
12-
platform = espressif32@2.1.0
12+
platform = espressif32@3.4.0
1313
framework = arduino
1414

1515
board = esp32doit-devkit-v1
@@ -29,8 +29,9 @@ upload_port = COM3 # /dev/ttyUSB0
2929
# --auth=waaatering
3030

3131
lib_deps =
32-
https://github.com/marvinroger/async-mqtt-client.git
33-
https://github.com/tobiasschuerg/MH-Z-CO2-Sensors.git
34-
ArduinoJson@6.16.0
32+
https://github.com/marvinroger/async-mqtt-client.git#v0.9.0
33+
https://github.com/tobiasschuerg/MH-Z-CO2-Sensors.git#7be7cf0f22e8c3bcd9c7357b2a1ef2f70d8d0c8a
34+
bblanchon/ArduinoJson @ ^6.18.5
3535
juerd/ESP-WiFiSettings @ ^3.6.0
3636
adafruit/Adafruit SSD1306 @ ^2.4.3
37+
plerup/EspSoftwareSerial @ ^6.15.1

src/main.cpp

+89-74
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <Adafruit_GFX.h>
1010
#include <Adafruit_SSD1306.h>
1111
#include <Adafruit_I2CDevice.h>
12+
#include <SoftwareSerial.h>
1213

1314
#include "config.h"
1415

@@ -18,7 +19,14 @@ extern "C"
1819
#include "freertos/timers.h"
1920
}
2021

21-
#define Sprintf(f, ...) ({ char* s; asprintf(&s, f, __VA_ARGS__); String r = s; free(s); r; })
22+
#define Sprintf(f, ...) ( \
23+
{ \
24+
char *s; \
25+
asprintf(&s, f, __VA_ARGS__); \
26+
String r = s; \
27+
free(s); \
28+
r; \
29+
})
2230
#define DEVICE_ID (Sprintf("%06" PRIx64, ESP.getEfuseMac() >> 24)) // unique device ID
2331
#define uS_TO_S_FACTOR 1000000 // Conversion factor for micro seconds to seconds
2432

@@ -318,76 +326,80 @@ void setupOTA()
318326
ArduinoOTA
319327
.setHostname(WiFiSettings.hostname.c_str())
320328
.setPassword(WiFiSettings.password.c_str())
321-
.onStart([]() {
322-
isUpdating = true;
323-
324-
String type;
325-
326-
if (ArduinoOTA.getCommand() == U_FLASH)
327-
{
328-
type = "sketch";
329-
}
330-
else
331-
{ // U_FS
332-
type = "filesystem";
333-
}
334-
335-
// NOTE: if updating FS this would be the place to unmount FS using FS.end()
336-
Serial.println("Start updating " + type);
337-
338-
display.clearDisplay();
339-
display.setTextSize(1);
340-
display.print("updating...");
341-
342-
display.display();
343-
})
344-
.onEnd([]() {
345-
Serial.println("\nEnd");
346-
347-
isUpdating = false;
348-
})
349-
.onProgress([](unsigned int progress, unsigned int total) {
350-
unsigned int percentValue = progress / (total / 100);
351-
352-
Serial.printf("Progress: %u%%\r", percentValue);
353-
354-
display.clearDisplay();
355-
356-
display.setCursor(0, 0);
357-
display.setTextSize(1);
358-
display.print("updating...");
359-
360-
display.setCursor(0, 40);
361-
display.setTextSize(2);
362-
display.print(percentValue);
363-
display.print("%");
364-
365-
display.display();
366-
})
367-
.onError([](ota_error_t error) {
368-
Serial.printf("Error[%u]: ", error);
369-
370-
if (error == OTA_AUTH_ERROR)
371-
{
372-
Serial.println("Auth Failed");
373-
}
374-
else if (error == OTA_BEGIN_ERROR)
375-
{
376-
Serial.println("Begin Failed");
377-
}
378-
else if (error == OTA_CONNECT_ERROR)
379-
{
380-
Serial.println("Connect Failed");
381-
}
382-
else if (error == OTA_RECEIVE_ERROR)
383-
{
384-
Serial.println("Receive Failed");
385-
}
386-
else if (error == OTA_END_ERROR)
387-
{
388-
Serial.println("End Failed");
389-
}
390-
})
329+
.onStart([]()
330+
{
331+
isUpdating = true;
332+
333+
String type;
334+
335+
if (ArduinoOTA.getCommand() == U_FLASH)
336+
{
337+
type = "sketch";
338+
}
339+
else
340+
{ // U_FS
341+
type = "filesystem";
342+
}
343+
344+
// NOTE: if updating FS this would be the place to unmount FS using FS.end()
345+
Serial.println("Start updating " + type);
346+
347+
display.clearDisplay();
348+
display.setTextSize(1);
349+
display.print("updating...");
350+
351+
display.display();
352+
})
353+
.onEnd([]()
354+
{
355+
Serial.println("\nEnd");
356+
357+
isUpdating = false;
358+
})
359+
.onProgress([](unsigned int progress, unsigned int total)
360+
{
361+
unsigned int percentValue = progress / (total / 100);
362+
363+
Serial.printf("Progress: %u%%\r", percentValue);
364+
365+
display.clearDisplay();
366+
367+
display.setCursor(0, 0);
368+
display.setTextSize(1);
369+
display.print("updating...");
370+
371+
display.setCursor(0, 40);
372+
display.setTextSize(2);
373+
display.print(percentValue);
374+
display.print("%");
375+
376+
display.display();
377+
})
378+
.onError([](ota_error_t error)
379+
{
380+
Serial.printf("Error[%u]: ", error);
381+
382+
if (error == OTA_AUTH_ERROR)
383+
{
384+
Serial.println("Auth Failed");
385+
}
386+
else if (error == OTA_BEGIN_ERROR)
387+
{
388+
Serial.println("Begin Failed");
389+
}
390+
else if (error == OTA_CONNECT_ERROR)
391+
{
392+
Serial.println("Connect Failed");
393+
}
394+
else if (error == OTA_RECEIVE_ERROR)
395+
{
396+
Serial.println("Receive Failed");
397+
}
398+
else if (error == OTA_END_ERROR)
399+
{
400+
Serial.println("End Failed");
401+
}
402+
})
391403
.begin();
392404
}
393405

@@ -445,18 +457,21 @@ void setup()
445457
WiFiSettings.password = PASSWORD;
446458

447459
// Set callbacks to start OTA when the portal is active
448-
WiFiSettings.onPortal = []() {
460+
WiFiSettings.onPortal = []()
461+
{
449462
isPortalActive = true;
450463

451464
Serial.println("WiFi config portal active");
452465

453466
setupOTA();
454467
};
455-
WiFiSettings.onPortalWaitLoop = []() {
468+
WiFiSettings.onPortalWaitLoop = []()
469+
{
456470
ArduinoOTA.handle();
457471
};
458472

459-
WiFiSettings.onConfigSaved = []() {
473+
WiFiSettings.onConfigSaved = []()
474+
{
460475
ESP.restart();
461476
};
462477

0 commit comments

Comments
 (0)