mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
58
.github/workflows/test_release.yml
vendored
Normal file
58
.github/workflows/test_release.yml
vendored
Normal file
@@ -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/*.*
|
||||
@@ -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**
|
||||
|
||||
@@ -1,118 +0,0 @@
|
||||
#ifndef ASYNCMQTTCLIENT_H_
|
||||
#define ASYNCMQTTCLIENT_H_
|
||||
|
||||
#include "Arduino.h"
|
||||
#include <functional>
|
||||
|
||||
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<void(bool sessionPresent)> OnConnectUserCallback;
|
||||
typedef std::function<void(AsyncMqttClientDisconnectReason reason)> OnDisconnectUserCallback;
|
||||
typedef std::function<void(uint16_t packetId, uint8_t qos)> OnSubscribeUserCallback;
|
||||
typedef std::function<void(uint16_t packetId)> OnUnsubscribeUserCallback;
|
||||
typedef std::function<void(char * topic, char * payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total)> OnMessageUserCallback;
|
||||
typedef std::function<void(uint16_t packetId)> 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
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <ArduinoJson.h>
|
||||
#include <AsyncJson.h>
|
||||
|
||||
#include <AsyncMqttClient.h>
|
||||
#include <espMqttClient.h>
|
||||
#include <ESPAsyncWebServer.h>
|
||||
|
||||
#include <list>
|
||||
@@ -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 {
|
||||
|
||||
137
lib_standalone/espMqttClient.h
Normal file
137
lib_standalone/espMqttClient.h
Normal file
@@ -0,0 +1,137 @@
|
||||
#ifndef ESPMQTTCLIENT_H_
|
||||
#define ESPMQTTCLIENT_H_
|
||||
|
||||
#include "Arduino.h"
|
||||
#include <functional>
|
||||
|
||||
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<void(bool sessionPresent)> OnConnectCallback;
|
||||
typedef std::function<void(DisconnectReason reason)> OnDisconnectCallback;
|
||||
typedef std::function<void(uint16_t packetId, const SubscribeReturncode* returncodes, size_t len)> OnSubscribeCallback;
|
||||
typedef std::function<void(uint16_t packetId)> OnUnsubscribeCallback;
|
||||
typedef std::function<void(const MessageProperties& properties, const char* topic, const uint8_t* payload, size_t len, size_t index, size_t total)> OnMessageCallback;
|
||||
typedef std::function<void(uint16_t packetId)> OnPublishCallback;
|
||||
typedef std::function<size_t(uint8_t* data, size_t maxSize, size_t index)> PayloadCallback;
|
||||
typedef std::function<void(uint16_t packetId, Error error)> 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
|
||||
Reference in New Issue
Block a user