From 608fdcb0a6eeca2f48c2dbb8c345bbe6e568c38e Mon Sep 17 00:00:00 2001 From: Bert Melis Date: Tue, 28 Mar 2023 20:15:56 +0200 Subject: [PATCH] build on esp8266 --- examples/simple-esp8266/data/config.json | 8 ++++++++ examples/simple-esp8266/simple-esp8266.ino | 22 ++++++++++++++++++++++ library.json | 5 ++++- scripts/CI/platformio_esp8266.ini | 19 +++++++++++++++++++ 4 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 examples/simple-esp8266/data/config.json create mode 100644 examples/simple-esp8266/simple-esp8266.ino create mode 100644 scripts/CI/platformio_esp8266.ini diff --git a/examples/simple-esp8266/data/config.json b/examples/simple-esp8266/data/config.json new file mode 100644 index 0000000..3e5bb8a --- /dev/null +++ b/examples/simple-esp8266/data/config.json @@ -0,0 +1,8 @@ +{ + "SSID": "network-ssid", + "PSK": "network-psk", + "IPAddress": [0,0,0,0], + "hostname" : "mqtt.domain.tld", + "port": 1883, + "devicename": "testdevice" +} \ No newline at end of file diff --git a/examples/simple-esp8266/simple-esp8266.ino b/examples/simple-esp8266/simple-esp8266.ino new file mode 100644 index 0000000..dec2e97 --- /dev/null +++ b/examples/simple-esp8266/simple-esp8266.ino @@ -0,0 +1,22 @@ +#include + +#include + +void setup() { + delay(10000); + Serial.begin(115200); + espMqttManager::setup(); + espMqttManager::start(); +} + +void loop() { + static uint32_t lastMillis = 0; + if (millis() - lastMillis > 10000) { + lastMillis = millis(); + uint8_t signalQuality = espMqttManagerHelpers::signalQuality(); + char sqStr[5]; + snprintf(sqStr, sizeof(sqStr), "%d%", signalQuality); + espMqttManager::mqttClient.publish("test/topic", 0, false, sqStr); + } + espMqttManager::loop(); +} diff --git a/library.json b/library.json index abaa38c..9c01f3a 100644 --- a/library.json +++ b/library.json @@ -16,7 +16,10 @@ }, "version": "0.0.1", "frameworks": "arduino", - "platforms": ["espressif32"], + "platforms": [ + "espressif32", + "espressif8266" + ], "headers": ["espMqttManager.h"], "dependencies": [ { diff --git a/scripts/CI/platformio_esp8266.ini b/scripts/CI/platformio_esp8266.ini new file mode 100644 index 0000000..d523d27 --- /dev/null +++ b/scripts/CI/platformio_esp8266.ini @@ -0,0 +1,19 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:esp8266] +platform = espressif8266 +board = d1_mini +framework = arduino +build_flags = + ;-Werror + -Wall + -Wextra + -Werror