From 0156dd4956a33d187c5c7378a193f96b6e4cfb3e Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Sun, 2 Jul 2023 22:02:43 +0200 Subject: [PATCH 1/3] test release --- .github/workflows/test_release.yml | 58 ++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/test_release.yml diff --git a/.github/workflows/test_release.yml b/.github/workflows/test_release.yml new file mode 100644 index 000000000..f907100a6 --- /dev/null +++ b/.github/workflows/test_release.yml @@ -0,0 +1,58 @@ +name: 'test-release' + +on: + workflow_dispatch: + push: + branches: + - 'dev2' + +jobs: + pre-release: + name: 'Automatic test-release build' + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + - uses: actions/setup-node@v3 + with: + node-version: '18' + + - name: Get EMS-ESP source code and version + id: build_info + run: | + version=`grep -E '^#define EMSESP_APP_VERSION' ./src/version.h | awk -F'"' '{print $2}'` + echo "VERSION=$version" >> $GITHUB_OUTPUT + + - name: Install PlatformIO + run: | + python -m pip install --upgrade pip + pip install -U platformio + + - name: Build WebUI + run: | + cd interface + yarn install + yarn run typesafe-i18n --no-watch + sed -i "s/= 'pl'/= 'en'/" ./src/i18n/i18n-util.ts + yarn run build + + - name: Build firmware + run: | + platformio run -e ci + + - name: Build S3 firmware + run: | + platformio run -e ci_s3 + + - name: Create a GH Release + id: 'automatic_releases' + uses: 'marvinpinto/action-automatic-releases@latest' + with: + repo_token: '${{ secrets.GITHUB_TOKEN }}' + title: Test Build v${{steps.build_info.outputs.VERSION}} + automatic_release_tag: 'test' + prerelease: true + files: | + CHANGELOG_LATEST.md + ./build/firmware/*.* From 2094d42c3b0e92869425548ee3dc88b66710bc91 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Sun, 2 Jul 2023 22:09:52 +0200 Subject: [PATCH 2/3] readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 59395c367..c8eb89f25 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ EMS-ESP is a project owned and maintained by [proddy](https://github.com/proddy) - [esp8266-react](https://github.com/rjwats/esp8266-react) by @rjwats for the framework that provides the core of the Web UI - [uuid-\*](https://github.com/nomis/mcu-uuid-console) from @nomis. The console, syslog, telnet and logging are based off these open source libraries - [ArduinoJson](https://github.com/bblanchon/ArduinoJson) for all the JSON -- [AsyncMqttClient](https://github.com/marvinroger/async-mqtt-client) for the MQTT client, with custom modifications from @bertmelis and @proddy +- [espMqttClient](https://github.com/bertmelis/espMqttClient) for the MQTT client, with custom modifications from @MichaelDvP and @proddy - ESPAsyncWebServer and AsyncTCP for the Web server and TCP backends, with custom modifications for performance ## **License** From 3bd21d4486dcb78d1d4ce458ba07d5e2ada0caa4 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Sun, 2 Jul 2023 22:10:34 +0200 Subject: [PATCH 3/3] try to fix standalone --- lib_standalone/AsyncMqttClient.h | 118 -------------------------- lib_standalone/ESP8266React.h | 6 +- lib_standalone/MqttPubSub.h | 0 lib_standalone/espMqttClient.h | 137 +++++++++++++++++++++++++++++++ 4 files changed, 140 insertions(+), 121 deletions(-) delete mode 100644 lib_standalone/AsyncMqttClient.h delete mode 100644 lib_standalone/MqttPubSub.h create mode 100644 lib_standalone/espMqttClient.h diff --git a/lib_standalone/AsyncMqttClient.h b/lib_standalone/AsyncMqttClient.h deleted file mode 100644 index 770480242..000000000 --- a/lib_standalone/AsyncMqttClient.h +++ /dev/null @@ -1,118 +0,0 @@ -#ifndef ASYNCMQTTCLIENT_H_ -#define ASYNCMQTTCLIENT_H_ - -#include "Arduino.h" -#include - -enum class AsyncMqttClientDisconnectReason : int8_t { - TCP_DISCONNECTED = 0, - - MQTT_UNACCEPTABLE_PROTOCOL_VERSION = 1, - MQTT_IDENTIFIER_REJECTED = 2, - MQTT_SERVER_UNAVAILABLE = 3, - MQTT_MALFORMED_CREDENTIALS = 4, - MQTT_NOT_AUTHORIZED = 5, - - ESP8266_NOT_ENOUGH_SPACE = 6, - - TLS_BAD_FINGERPRINT = 7 -}; - -struct AsyncMqttClientMessageProperties { - uint8_t qos; - bool dup; - bool retain; -}; - -namespace AsyncMqttClientInternals { - -typedef std::function OnConnectUserCallback; -typedef std::function OnDisconnectUserCallback; -typedef std::function OnSubscribeUserCallback; -typedef std::function OnUnsubscribeUserCallback; -typedef std::function OnMessageUserCallback; -typedef std::function OnPublishUserCallback; -}; // namespace AsyncMqttClientInternals - -class AsyncMqttClient { - public: - AsyncMqttClient(); - ~AsyncMqttClient(); - - AsyncMqttClient & setKeepAlive(uint16_t keepAlive); - AsyncMqttClient & setClientId(const char * clientId); - AsyncMqttClient & setCleanSession(bool cleanSession); - AsyncMqttClient & setMaxTopicLength(uint16_t maxTopicLength); - AsyncMqttClient & setCredentials(const char * username, const char * password = nullptr); - AsyncMqttClient & setWill(const char * topic, uint8_t qos, bool retain, const char * payload = nullptr, size_t length = 0) { - return *this; - } - AsyncMqttClient & setServer(IPAddress ip, uint16_t port); - AsyncMqttClient & setServer(const char * host, uint16_t port); - - AsyncMqttClient & onConnect(AsyncMqttClientInternals::OnConnectUserCallback callback) { - return *this; - } - AsyncMqttClient & onDisconnect(AsyncMqttClientInternals::OnDisconnectUserCallback callback) { - return *this; - } - AsyncMqttClient & onSubscribe(AsyncMqttClientInternals::OnSubscribeUserCallback callback) { - return *this; - } - AsyncMqttClient & onUnsubscribe(AsyncMqttClientInternals::OnUnsubscribeUserCallback callback) { - return *this; - } - AsyncMqttClient & onMessage(AsyncMqttClientInternals::OnMessageUserCallback callback) { - return *this; - } - AsyncMqttClient & onPublish(AsyncMqttClientInternals::OnPublishUserCallback callback) { - return *this; - } - - bool connected() const { - return false; - } - void connect() { - } - void disconnect(bool force = false) { - } - uint16_t subscribe(const char * topic, uint8_t qos) { - return 1; - } - uint16_t unsubscribe(const char * topic) { - return 1; - } - uint16_t publish(const char * topic, uint8_t qos, bool retain, const char * payload = nullptr, size_t length = 0, bool dup = false, uint16_t message_id = 0) { - return 1; - } - - const char * getClientId() { - return "12"; - } - - private: - bool _connected; - bool _connectPacketNotEnoughSpace; - bool _disconnectOnPoll; - bool _tlsBadFingerprint; - uint32_t _lastClientActivity; - uint32_t _lastServerActivity; - uint32_t _lastPingRequestTime; - char _generatedClientId[18 + 1]; // esp8266-abc123 and esp32-abcdef123456 - IPAddress _ip; - const char * _host; - bool _useIp; - uint16_t _port; - uint16_t _keepAlive; - bool _cleanSession; - const char * _clientId; - const char * _username; - const char * _password; - const char * _willTopic; - const char * _willPayload; - uint16_t _willPayloadLength; - uint8_t _willQos; - bool _willRetain; -}; - -#endif diff --git a/lib_standalone/ESP8266React.h b/lib_standalone/ESP8266React.h index a9eb92da2..b673f41b8 100644 --- a/lib_standalone/ESP8266React.h +++ b/lib_standalone/ESP8266React.h @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include @@ -108,7 +108,7 @@ class ESP8266React { return &_securitySettingsService; } - AsyncMqttClient * getMqttClient() { + espMqttClient * getMqttClient() { return _mqttClient; } @@ -132,7 +132,7 @@ class ESP8266React { DummySettingsService _settings; SecuritySettingsService _securitySettingsService; - AsyncMqttClient * _mqttClient; + espMqttClient * _mqttClient; }; class EMSESPSettingsService { diff --git a/lib_standalone/MqttPubSub.h b/lib_standalone/MqttPubSub.h deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib_standalone/espMqttClient.h b/lib_standalone/espMqttClient.h new file mode 100644 index 000000000..f9a87ba63 --- /dev/null +++ b/lib_standalone/espMqttClient.h @@ -0,0 +1,137 @@ +#ifndef ESPMQTTCLIENT_H_ +#define ESPMQTTCLIENT_H_ + +#include "Arduino.h" +#include + +namespace espMqttClientTypes { + +enum class DisconnectReason : uint8_t { + USER_OK = 0, + MQTT_UNACCEPTABLE_PROTOCOL_VERSION = 1, + MQTT_IDENTIFIER_REJECTED = 2, + MQTT_SERVER_UNAVAILABLE = 3, + MQTT_MALFORMED_CREDENTIALS = 4, + MQTT_NOT_AUTHORIZED = 5, + TLS_BAD_FINGERPRINT = 6, + TCP_DISCONNECTED = 7 +}; +const char* disconnectReasonToString(DisconnectReason reason); + +enum class SubscribeReturncode : uint8_t { + QOS0 = 0x00, + QOS1 = 0x01, + QOS2 = 0x02, + FAIL = 0X80 +}; +const char* subscribeReturncodeToString(SubscribeReturncode returnCode); + +enum class Error : uint8_t { + SUCCESS = 0, + OUT_OF_MEMORY = 1, + MAX_RETRIES = 2, + MALFORMED_PARAMETER = 3, + MISC_ERROR = 4 +}; +const char* errorToString(Error error); + +struct MessageProperties { + uint8_t qos; + bool dup; + bool retain; + uint16_t packetId; +}; + +typedef std::function OnConnectCallback; +typedef std::function OnDisconnectCallback; +typedef std::function OnSubscribeCallback; +typedef std::function OnUnsubscribeCallback; +typedef std::function OnMessageCallback; +typedef std::function OnPublishCallback; +typedef std::function PayloadCallback; +typedef std::function OnErrorCallback; + +} + +class espMqttClient { + public: + espMqttClient(); + ~espMqttClient(); + + espMqttClient & setKeepAlive(uint16_t keepAlive); + espMqttClient & setClientId(const char * clientId); + espMqttClient & setCleanSession(bool cleanSession); + espMqttClient & setMaxTopicLength(uint16_t maxTopicLength); + espMqttClient & setCredentials(const char * username, const char * password = nullptr); + espMqttClient & setWill(const char * topic, uint8_t qos, bool retain, const char * payload = nullptr, size_t length = 0) { + return *this; + } + espMqttClient & setServer(IPAddress ip, uint16_t port); + espMqttClient & setServer(const char * host, uint16_t port); + + espMqttClient & onConnect(espMqttClientTypes::OnConnectCallback callback) { + return *this; + } + espMqttClient & onDisconnect(espMqttClientTypes::OnDisconnectCallback callback) { + return *this; + } + espMqttClient & onSubscribe(espMqttClientTypes::OnSubscribeCallback callback) { + return *this; + } + espMqttClient & onUnsubscribe(espMqttClientTypes::OnUnsubscribeCallback callback) { + return *this; + } + espMqttClient & onMessage(espMqttClientTypes::OnMessageCallback callback) { + return *this; + } + espMqttClient & onPublish(espMqttClientTypes::OnPublishCallback callback) { + return *this; + } + + bool connected() const { + return false; + } + void connect() { + } + void disconnect(bool force = false) { + } + uint16_t subscribe(const char * topic, uint8_t qos) { + return 1; + } + uint16_t unsubscribe(const char * topic) { + return 1; + } + uint16_t publish(const char * topic, uint8_t qos, bool retain, const char * payload = nullptr, size_t length = 0, bool dup = false, uint16_t message_id = 0) { + return 1; + } + + const char * getClientId() { + return "12"; + } + + private: + bool _connected; + bool _connectPacketNotEnoughSpace; + bool _disconnectOnPoll; + bool _tlsBadFingerprint; + uint32_t _lastClientActivity; + uint32_t _lastServerActivity; + uint32_t _lastPingRequestTime; + char _generatedClientId[18 + 1]; // esp8266-abc123 and esp32-abcdef123456 + IPAddress _ip; + const char * _host; + bool _useIp; + uint16_t _port; + uint16_t _keepAlive; + bool _cleanSession; + const char * _clientId; + const char * _username; + const char * _password; + const char * _willTopic; + const char * _willPayload; + uint16_t _willPayloadLength; + uint8_t _willQos; + bool _willRetain; +}; + +#endif