mirror of
https://github.com/Laxilef/OTGateway.git
synced 2026-05-18 23:38:16 +05:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bdfa793c49 | |||
| 25280bf9b1 | |||
| 9c2e420ec7 | |||
| af2d4624b3 | |||
| 14d2262d2f | |||
| db99746ee9 |
@@ -0,0 +1,152 @@
|
||||
name: Build
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
paths-ignore:
|
||||
- "assets/**"
|
||||
- "tools/**"
|
||||
- "**/*.md"
|
||||
- "LICENSE"
|
||||
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- "assets/**"
|
||||
- "tools/**"
|
||||
- "**/*.md"
|
||||
- "LICENSE"
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
prepare:
|
||||
name: Prepare (get envs)
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
envs: ${{ steps.envs.outputs.envs }}
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Python
|
||||
uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: "3.x"
|
||||
|
||||
- name: Install PlatformIO Core
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install --upgrade platformio
|
||||
pip install --upgrade intelhex
|
||||
|
||||
- name: Get environments
|
||||
id: envs
|
||||
shell: bash
|
||||
run: |
|
||||
ENVS=$(
|
||||
pio project config --json-output \
|
||||
| jq -c '
|
||||
.[]
|
||||
| select(type == "array")
|
||||
| .[0]
|
||||
| select(startswith("env:"))
|
||||
| sub("^env:"; "")
|
||||
' | jq -s -c '.'
|
||||
)
|
||||
|
||||
echo "envs=$ENVS" >> "$GITHUB_OUTPUT"
|
||||
echo "$ENVS"
|
||||
|
||||
build:
|
||||
name: Build ${{ matrix.env }}
|
||||
runs-on: ubuntu-latest
|
||||
needs: prepare
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
env: ${{ fromJson(needs.prepare.outputs.envs) }}
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Python
|
||||
uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: "3.x"
|
||||
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: "22"
|
||||
|
||||
- name: Install PlatformIO Core
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install --upgrade platformio
|
||||
pip install --upgrade intelhex
|
||||
|
||||
- name: Full clean
|
||||
run: |
|
||||
pio run -e ${{ matrix.env }} -t fullclean
|
||||
|
||||
- name: Build firmware & filesystem
|
||||
env:
|
||||
PIOENV: ${{ matrix.env }}
|
||||
run: |
|
||||
pio run -e ${{ matrix.env }}
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: ${{ matrix.env }}
|
||||
if-no-files-found: error
|
||||
path: |
|
||||
build/*.bin
|
||||
build/*.elf
|
||||
|
||||
release:
|
||||
name: Release Dev
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
permissions:
|
||||
contents: write
|
||||
if: ${{ github.repository_owner == 'Laxilef' && github.ref == 'refs/heads/async' }}
|
||||
|
||||
steps:
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v5
|
||||
with:
|
||||
path: artifacts
|
||||
merge-multiple: true
|
||||
|
||||
- name: Delete old release assets
|
||||
uses: mknejp/delete-release-assets@v1
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
tag: dev
|
||||
fail-if-no-assets: false
|
||||
fail-if-no-release: false
|
||||
assets: |
|
||||
*.bin
|
||||
*.elf
|
||||
|
||||
- name: Publish Dev release
|
||||
uses: softprops/action-gh-release@v3
|
||||
with:
|
||||
tag_name: dev
|
||||
target_commitish: async
|
||||
name: Dev (unstable)
|
||||
prerelease: true
|
||||
make_latest: false
|
||||
generate_release_notes: true
|
||||
files: |
|
||||
artifacts/*.bin
|
||||
artifacts/*.elf
|
||||
@@ -0,0 +1,110 @@
|
||||
name: CI
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
validate-json:
|
||||
name: Validate JSON
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Install jq
|
||||
run: sudo apt-get update && sudo apt-get install -y jq
|
||||
|
||||
- name: Validate
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
echo "Searching JSON files in src_data..."
|
||||
|
||||
files=$(find src_data -type f -iname "*.json")
|
||||
|
||||
if [ -z "$files" ]; then
|
||||
echo "No JSON files found."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
failed=0
|
||||
|
||||
for file in $files; do
|
||||
echo "Validating: $file"
|
||||
|
||||
if ! jq empty "$file" >/dev/null 2>&1; then
|
||||
echo "❌ Invalid JSON: $file"
|
||||
failed=1
|
||||
else
|
||||
echo "✅ Valid JSON: $file"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$failed" -ne 0 ]; then
|
||||
echo ""
|
||||
echo "JSON validation failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "All JSON files are valid."
|
||||
|
||||
cpplint:
|
||||
name: cpplint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Cache
|
||||
uses: actions/cache@v5
|
||||
with:
|
||||
key: ${{ runner.os }}-cpplint
|
||||
path: ~/.cache/pip
|
||||
|
||||
- name: Python
|
||||
uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: "3.x"
|
||||
|
||||
- name: Install cpplint
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install --upgrade cpplint
|
||||
|
||||
- name: cpplint
|
||||
run: |
|
||||
FILTERS="-legal/copyright,\
|
||||
-runtime/int,\
|
||||
-runtime/references,\
|
||||
-runtime/indentation_namespace,\
|
||||
-runtime/arrays,\
|
||||
-runtime/printf,\
|
||||
-whitespace/line_length,\
|
||||
-whitespace/braces,\
|
||||
-whitespace/comments,\
|
||||
-whitespace/indent,\
|
||||
-whitespace/newline,\
|
||||
-whitespace/parens,\
|
||||
-whitespace/blank_line,\
|
||||
-readability/braces,\
|
||||
-readability/todo,\
|
||||
-readability/namespace,\
|
||||
-build/header_guard,\
|
||||
-build/include_subdir,\
|
||||
-build/include_what_you_use,\
|
||||
-build/namespaces,\
|
||||
-build/c++11"
|
||||
|
||||
cpplint \
|
||||
--repository=. \
|
||||
--recursive \
|
||||
--quiet \
|
||||
--filter="$FILTERS" \
|
||||
include lib src
|
||||
@@ -1,9 +1,9 @@
|
||||
class BufferedWebServer {
|
||||
public:
|
||||
BufferedWebServer(WebServer* webServer, size_t bufferSize = 64) {
|
||||
explicit BufferedWebServer(WebServer* webServer, size_t bufferSize = 64) {
|
||||
this->webServer = webServer;
|
||||
this->bufferSize = bufferSize;
|
||||
this->buffer = (uint8_t*)malloc(bufferSize * sizeof(*this->buffer));
|
||||
this->buffer = static_cast<uint8_t*>(malloc(bufferSize * sizeof(*this->buffer)));
|
||||
}
|
||||
|
||||
~BufferedWebServer() {
|
||||
|
||||
@@ -7,7 +7,7 @@ public:
|
||||
typedef std::function<void(unsigned long, uint8_t)> BeforeSendRequestCallback;
|
||||
typedef std::function<void(unsigned long, unsigned long, OpenThermResponseStatus, uint8_t)> AfterSendRequestCallback;
|
||||
|
||||
CustomOpenTherm(int inPin = 4, int outPin = 5, bool isSlave = false, bool alwaysReceive = false) : OpenTherm(inPin, outPin, isSlave, alwaysReceive) {}
|
||||
explicit CustomOpenTherm(int inPin = 4, int outPin = 5, bool isSlave = false, bool alwaysReceive = false) : OpenTherm(inPin, outPin, isSlave, alwaysReceive) {}
|
||||
~CustomOpenTherm() {}
|
||||
|
||||
CustomOpenTherm* setDelayCallback(DelayCallback callback = nullptr) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#ifndef PROGMEM
|
||||
#define PROGMEM
|
||||
#define PROGMEM // NOLINT
|
||||
#endif
|
||||
|
||||
const char HA_ENTITY_BINARY_SENSOR[] PROGMEM = "binary_sensor";
|
||||
|
||||
@@ -12,10 +12,10 @@ public:
|
||||
typedef std::function<void(const char*, size_t, size_t, bool)> PublishEventCallback;
|
||||
typedef std::function<void(size_t, size_t)> FlushEventCallback;
|
||||
|
||||
MqttWriter(MqttClient* client, size_t bufferSize = 64) {
|
||||
explicit MqttWriter(MqttClient* client, size_t bufferSize = 64) {
|
||||
this->client = client;
|
||||
this->bufferSize = bufferSize;
|
||||
this->buffer = (uint8_t*) malloc(bufferSize * sizeof(*this->buffer));
|
||||
this->buffer = static_cast<uint8_t*>(malloc(bufferSize * sizeof(*this->buffer)));
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
this->mutex = new std::mutex();
|
||||
|
||||
@@ -1,224 +0,0 @@
|
||||
#include <FS.h>
|
||||
|
||||
|
||||
class DynamicPage : public RequestHandler {
|
||||
public:
|
||||
typedef std::function<bool(HTTPMethod, const String&)> CanHandleCallback;
|
||||
typedef std::function<bool()> BeforeSendCallback;
|
||||
typedef std::function<String(const char*)> TemplateCallback;
|
||||
|
||||
DynamicPage(const char* uri, FS* fs, const char* path, const char* cacheHeader = nullptr) {
|
||||
this->uri = uri;
|
||||
this->fs = fs;
|
||||
this->path = path;
|
||||
this->cacheHeader = cacheHeader;
|
||||
}
|
||||
|
||||
DynamicPage* setCanHandleCallback(CanHandleCallback callback = nullptr) {
|
||||
this->canHandleCallback = callback;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
DynamicPage* setBeforeSendCallback(BeforeSendCallback callback = nullptr) {
|
||||
this->beforeSendCallback = callback;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
DynamicPage* setTemplateCallback(TemplateCallback callback = nullptr) {
|
||||
this->templateCallback = callback;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
bool canHandle(WebServer &server, HTTPMethod method, const String &uri) override {
|
||||
return this->canHandle(method, uri);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool canHandle(HTTPMethod method, const String& uri) override {
|
||||
return uri.equals(this->uri) && (!this->canHandleCallback || this->canHandleCallback(method, uri));
|
||||
}
|
||||
|
||||
bool handle(WebServer& server, HTTPMethod method, const String& uri) override {
|
||||
if (!this->canHandle(method, uri)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this->beforeSendCallback && !this->beforeSendCallback()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
File file = this->fs->open(this->path, "r");
|
||||
if (!file) {
|
||||
return false;
|
||||
|
||||
} else if (file.isDirectory()) {
|
||||
file.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this->cacheHeader != nullptr) {
|
||||
server.sendHeader(F("Cache-Control"), this->cacheHeader);
|
||||
}
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
if (!server.chunkedResponseModeStart(200, F("text/html"))) {
|
||||
server.send(505, F("text/html"), F("HTTP1.1 required"));
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
server.setContentLength(CONTENT_LENGTH_UNKNOWN);
|
||||
server.send(200, "text/html", emptyString);
|
||||
#endif
|
||||
|
||||
uint8_t* argStartPos = nullptr;
|
||||
uint8_t* argEndPos = nullptr;
|
||||
uint8_t argName[16];
|
||||
size_t sizeArgName = 0;
|
||||
bool argNameProcess = false;
|
||||
while (file.available()) {
|
||||
uint8_t buf[64];
|
||||
size_t length = file.read(buf, sizeof(buf));
|
||||
size_t offset = 0;
|
||||
|
||||
if (argNameProcess) {
|
||||
argEndPos = (uint8_t*) memchr(buf, '}', length);
|
||||
|
||||
if (argEndPos != nullptr) {
|
||||
size_t fullSizeArgName = sizeArgName + (argEndPos - buf);
|
||||
if (fullSizeArgName < sizeof(argName)) {
|
||||
// copy full arg name
|
||||
if (argEndPos - buf > 0) {
|
||||
memcpy(argName + sizeArgName, buf, argEndPos - buf);
|
||||
}
|
||||
argName[fullSizeArgName] = '\0';
|
||||
|
||||
// send arg value
|
||||
String argValue = this->templateCallback((const char*) argName);
|
||||
if (argValue.length()) {
|
||||
server.sendContent(argValue.c_str());
|
||||
|
||||
} else if (fullSizeArgName > 0) {
|
||||
server.sendContent("{");
|
||||
server.sendContent((const char*) argName);
|
||||
server.sendContent("}");
|
||||
}
|
||||
|
||||
offset = size_t(argEndPos - buf + 1);
|
||||
sizeArgName = 0;
|
||||
argNameProcess = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (argNameProcess) {
|
||||
server.sendContent("{");
|
||||
|
||||
if (sizeArgName > 0) {
|
||||
argName[sizeArgName] = '\0';
|
||||
server.sendContent((const char*) argName);
|
||||
}
|
||||
|
||||
argNameProcess = false;
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
uint8_t* currentBuf = buf + offset;
|
||||
size_t currentLength = length - offset;
|
||||
|
||||
argStartPos = (uint8_t*) memchr(currentBuf, '{', currentLength);
|
||||
|
||||
// send all content
|
||||
if (argStartPos == nullptr) {
|
||||
if (currentLength > 0) {
|
||||
server.sendContent((const char*) currentBuf, currentLength);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
argEndPos = (uint8_t*) memchr(argStartPos, '}', length - (argStartPos - buf));
|
||||
if (argEndPos != nullptr) {
|
||||
sizeArgName = argEndPos - argStartPos - 1;
|
||||
|
||||
// send all content if arg len > space
|
||||
if (sizeArgName >= sizeof(argName)) {
|
||||
if (currentLength > 0) {
|
||||
server.sendContent((const char*) currentBuf, currentLength);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// arg name
|
||||
memcpy(argName, argStartPos + 1, sizeArgName);
|
||||
argName[sizeArgName] = '\0';
|
||||
|
||||
// send arg value
|
||||
String argValue = this->templateCallback((const char*) argName);
|
||||
if (argValue.length()) {
|
||||
// send content before var
|
||||
if (argStartPos - buf > 0) {
|
||||
server.sendContent((const char*) currentBuf, argStartPos - buf);
|
||||
}
|
||||
|
||||
server.sendContent(argValue.c_str());
|
||||
|
||||
} else {
|
||||
server.sendContent((const char*) currentBuf, argEndPos - currentBuf + 1);
|
||||
}
|
||||
|
||||
offset = size_t(argEndPos - currentBuf + 1);
|
||||
|
||||
} else {
|
||||
sizeArgName = length - size_t(argStartPos - currentBuf) - 1;
|
||||
|
||||
// send all content if arg len > space
|
||||
if (sizeArgName >= sizeof(argName)) {
|
||||
if (currentLength) {
|
||||
server.sendContent((const char*) currentBuf, currentLength);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// send content before var
|
||||
if (argStartPos - buf > 0) {
|
||||
server.sendContent((const char*) currentBuf, argStartPos - buf);
|
||||
}
|
||||
|
||||
// copy arg name chunk
|
||||
if (sizeArgName > 0) {
|
||||
memcpy(argName, argStartPos + 1, sizeArgName);
|
||||
}
|
||||
|
||||
argNameProcess = true;
|
||||
|
||||
break;
|
||||
}
|
||||
} while(true);
|
||||
}
|
||||
|
||||
file.close();
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
server.chunkedResponseFinalize();
|
||||
#else
|
||||
server.sendContent(emptyString);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected:
|
||||
FS* fs = nullptr;
|
||||
CanHandleCallback canHandleCallback;
|
||||
BeforeSendCallback beforeSendCallback;
|
||||
TemplateCallback templateCallback;
|
||||
const char* uri = nullptr;
|
||||
const char* path = nullptr;
|
||||
const char* cacheHeader = nullptr;
|
||||
};
|
||||
@@ -29,9 +29,9 @@ public:
|
||||
typedef std::function<bool(AsyncWebServerRequest *request, UpgradeType)> BeforeUpgradeCallback;
|
||||
typedef std::function<void(AsyncWebServerRequest *request, const UpgradeResult&, const UpgradeResult&)> AfterUpgradeCallback;
|
||||
|
||||
UpgradeHandler(AsyncURIMatcher uri) : uri(uri) {}
|
||||
explicit UpgradeHandler(AsyncURIMatcher uri) : uri(uri) {}
|
||||
|
||||
bool canHandle(AsyncWebServerRequest *request) const override final {
|
||||
bool canHandle(AsyncWebServerRequest *request) const final {
|
||||
if (!request->isHTTP()) {
|
||||
return false;
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
return this;
|
||||
}
|
||||
|
||||
void handleRequest(AsyncWebServerRequest *request) override final {
|
||||
void handleRequest(AsyncWebServerRequest *request) final {
|
||||
if (this->afterUpgradeCallback) {
|
||||
this->afterUpgradeCallback(request, this->firmwareResult, this->filesystemResult);
|
||||
}
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
this->filesystemResult.error.clear();
|
||||
}
|
||||
|
||||
void handleUpload(AsyncWebServerRequest *request, const String &fileName, size_t index, uint8_t *data, size_t dataLength, bool isFinal) override final {
|
||||
void handleUpload(AsyncWebServerRequest *request, const String &fileName, size_t index, uint8_t *data, size_t dataLength, bool isFinal) final {
|
||||
UpgradeResult* result = nullptr;
|
||||
|
||||
if (!request->hasParam(asyncsrv::T_name, true, true)) {
|
||||
@@ -194,7 +194,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
bool isRequestHandlerTrivial() const override final {
|
||||
bool isRequestHandlerTrivial() const final {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -35,9 +35,9 @@ namespace CrashRecorder {
|
||||
} ext_t;
|
||||
|
||||
|
||||
__NOINIT_ATTR volatile static backtrace_t backtrace;
|
||||
__NOINIT_ATTR volatile static epc_t epc;
|
||||
__NOINIT_ATTR volatile static ext_t ext;
|
||||
__NOINIT_ATTR volatile static backtrace_t backtrace; // NOLINT
|
||||
__NOINIT_ATTR volatile static epc_t epc; // NOLINT
|
||||
__NOINIT_ATTR volatile static ext_t ext; // NOLINT
|
||||
|
||||
uint8_t backtraceMaxLength = sizeof(backtrace.data) / sizeof(*backtrace.data);
|
||||
uint8_t epcMaxLength = sizeof(epc.data) / sizeof(*epc.data);
|
||||
@@ -98,7 +98,7 @@ extern "C" void custom_crash_callback(struct rst_info *info, uint32_t stack, uin
|
||||
CrashRecorder::backtrace.continues = false;
|
||||
uint32_t value;
|
||||
for (uint32_t i = stack; i < stack_end; i += 4) {
|
||||
value = *((uint32_t*) i);
|
||||
value = *((uint32_t*) i); // NOLINT
|
||||
|
||||
// keep only addresses in code area
|
||||
if ((value >= 0x40000000) && (value < 0x40300000)) {
|
||||
|
||||
+3
-3
@@ -10,7 +10,7 @@ extern FileData fsNetworkSettings, fsSettings, fsSensorsSettings;
|
||||
|
||||
class MainTask : public Task {
|
||||
public:
|
||||
MainTask(bool _enabled = false, unsigned long _interval = 0) : Task(_enabled, _interval) {
|
||||
explicit MainTask(bool _enabled = false, unsigned long _interval = 0) : Task(_enabled, _interval) {
|
||||
this->blinker = new Blinker();
|
||||
|
||||
network->setDelayCallback([this](unsigned int time) {
|
||||
@@ -253,7 +253,7 @@ protected:
|
||||
|
||||
if (availableSensors) {
|
||||
if (vars.master.heating.freezing) {
|
||||
if (lowTemp - (float) settings.heating.freezeProtection.highTemp + 0.0001f >= 0.0f) {
|
||||
if (lowTemp - static_cast<float>(settings.heating.freezeProtection.highTemp) + 0.0001f >= 0.0f) {
|
||||
vars.master.heating.freezing = false;
|
||||
|
||||
Log.sinfoln(
|
||||
@@ -264,7 +264,7 @@ protected:
|
||||
}
|
||||
|
||||
} else {
|
||||
if ((float) settings.heating.freezeProtection.lowTemp - lowTemp + 0.0001f >= 0.0f) {
|
||||
if (static_cast<float>(settings.heating.freezeProtection.lowTemp) - lowTemp + 0.0001f >= 0.0f) {
|
||||
vars.master.heating.freezing = true;
|
||||
|
||||
if (!settings.heating.enabled) {
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@ extern FileData fsSettings;
|
||||
|
||||
class MqttTask : public Task {
|
||||
public:
|
||||
MqttTask(bool _enabled = false, unsigned long _interval = 0) : Task(_enabled, _interval) {
|
||||
explicit MqttTask(bool _enabled = false, unsigned long _interval = 0) : Task(_enabled, _interval) {
|
||||
this->wifiClient = new MqttWiFiClient();
|
||||
this->client = new MqttClient(this->wifiClient);
|
||||
this->writer = new MqttWriter(this->client, 256);
|
||||
@@ -443,7 +443,7 @@ protected:
|
||||
} else if (payload[i] == 10) {
|
||||
Log.print(F("\r\n> "));
|
||||
} else {
|
||||
Log.print((char) payload[i]);
|
||||
Log.print(static_cast<char>(payload[i]));
|
||||
}
|
||||
}
|
||||
Log.print(F("\r\n\n"));
|
||||
|
||||
+7
-7
@@ -3,7 +3,7 @@ extern FileData fsSettings;
|
||||
|
||||
class OpenThermTask : public Task {
|
||||
public:
|
||||
OpenThermTask(bool _enabled = false, unsigned long _interval = 0) : Task(_enabled, _interval) {}
|
||||
explicit OpenThermTask(bool _enabled = false, unsigned long _interval = 0) : Task(_enabled, _interval) {}
|
||||
|
||||
~OpenThermTask() {
|
||||
delete this->instance;
|
||||
@@ -1401,7 +1401,7 @@ protected:
|
||||
);
|
||||
|
||||
if (vars.master.heating.overheat) {
|
||||
if ((float) settings.heating.overheatProtection.lowTemp - highTemp + 0.0001f >= 0.0f) {
|
||||
if (static_cast<float>(settings.heating.overheatProtection.lowTemp) - highTemp + 0.0001f >= 0.0f) {
|
||||
vars.master.heating.overheat = false;
|
||||
|
||||
Log.sinfoln(
|
||||
@@ -1411,7 +1411,7 @@ protected:
|
||||
}
|
||||
|
||||
} else if (vars.slave.heating.active) {
|
||||
if (highTemp - (float) settings.heating.overheatProtection.highTemp + 0.0001f >= 0.0f) {
|
||||
if (highTemp - static_cast<float>(settings.heating.overheatProtection.highTemp) + 0.0001f >= 0.0f) {
|
||||
vars.master.heating.overheat = true;
|
||||
|
||||
Log.swarningln(
|
||||
@@ -1441,7 +1441,7 @@ protected:
|
||||
);
|
||||
|
||||
if (vars.master.dhw.overheat) {
|
||||
if ((float) settings.dhw.overheatProtection.lowTemp - highTemp + 0.0001f >= 0.0f) {
|
||||
if (static_cast<float>(settings.dhw.overheatProtection.lowTemp) - highTemp + 0.0001f >= 0.0f) {
|
||||
vars.master.dhw.overheat = false;
|
||||
|
||||
Log.sinfoln(
|
||||
@@ -1451,7 +1451,7 @@ protected:
|
||||
}
|
||||
|
||||
} else if (vars.slave.dhw.active) {
|
||||
if (highTemp - (float) settings.dhw.overheatProtection.highTemp + 0.0001f >= 0.0f) {
|
||||
if (highTemp - static_cast<float>(settings.dhw.overheatProtection.highTemp) + 0.0001f >= 0.0f) {
|
||||
vars.master.dhw.overheat = true;
|
||||
|
||||
Log.swarningln(
|
||||
@@ -2432,7 +2432,7 @@ protected:
|
||||
return false;
|
||||
}
|
||||
|
||||
const float value = (float) CustomOpenTherm::getInt(response);
|
||||
const float value = CustomOpenTherm::getInt(response);
|
||||
if (!isValidTemp(value, settings.opentherm.unitSystem, -40, 500)) {
|
||||
return false;
|
||||
}
|
||||
@@ -2456,7 +2456,7 @@ protected:
|
||||
return false;
|
||||
}
|
||||
|
||||
const float value = (float) CustomOpenTherm::getInt(response);
|
||||
const float value = CustomOpenTherm::getInt(response);
|
||||
if (value <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
+7
-3
@@ -18,7 +18,7 @@ extern WebSerial* webSerial;
|
||||
|
||||
class PortalTask : public LeanTask {
|
||||
public:
|
||||
PortalTask(bool _enabled = false, unsigned long _interval = 0) : LeanTask(_enabled, _interval) {
|
||||
explicit PortalTask(bool _enabled = false, unsigned long _interval = 0) : LeanTask(_enabled, _interval) {
|
||||
this->webServer = new AsyncWebServer(80);
|
||||
this->dnsServer = new DNSServer();
|
||||
}
|
||||
@@ -810,9 +810,13 @@ protected:
|
||||
|
||||
static void getFilename(char* filename, size_t maxSizeFilename, const char* type) {
|
||||
const time_t now = time(nullptr);
|
||||
const tm* localNow = localtime(&now);
|
||||
|
||||
tm localNow {};
|
||||
localtime_r(&now, &localNow);
|
||||
|
||||
char localNowValue[20];
|
||||
strftime(localNowValue, sizeof(localNowValue), PSTR("%Y-%m-%d-%H-%M-%S"), localNow);
|
||||
strftime(localNowValue, sizeof(localNowValue), PSTR("%Y-%m-%d-%H-%M-%S"), &localNow);
|
||||
|
||||
snprintf_P(filename, maxSizeFilename, PSTR("%s_%s_%s.json"), networkSettings.hostname, localNowValue, type);
|
||||
}
|
||||
};
|
||||
+1
-1
@@ -5,7 +5,7 @@ GyverPID pidRegulator(0, 0, 0);
|
||||
|
||||
class RegulatorTask : public LeanTask {
|
||||
public:
|
||||
RegulatorTask(bool _enabled = false, unsigned long _interval = 0) : LeanTask(_enabled, _interval) {}
|
||||
explicit RegulatorTask(bool _enabled = false, unsigned long _interval = 0) : LeanTask(_enabled, _interval) {}
|
||||
|
||||
protected:
|
||||
float prevHeatingTarget = 0.0f;
|
||||
|
||||
+5
-5
@@ -74,7 +74,7 @@ public:
|
||||
}
|
||||
|
||||
static bool parseAtcData(const NimBLEAdvertisedDevice* device, uint8_t sensorId) {
|
||||
NimBLEUUID serviceUuid((uint16_t) 0x181A);
|
||||
NimBLEUUID serviceUuid(static_cast<uint16_t>(0x181A));
|
||||
|
||||
auto serviceData = device->getServiceData(serviceUuid);
|
||||
if (!serviceData.size()) {
|
||||
@@ -125,7 +125,7 @@ public:
|
||||
}
|
||||
|
||||
static bool parsePvvxData(const NimBLEAdvertisedDevice* device, uint8_t sensorId) {
|
||||
NimBLEUUID serviceUuid((uint16_t) 0x181A);
|
||||
NimBLEUUID serviceUuid(static_cast<uint16_t>(0x181A));
|
||||
|
||||
auto serviceData = device->getServiceData(serviceUuid);
|
||||
if (!serviceData.size()) {
|
||||
@@ -178,7 +178,7 @@ public:
|
||||
}
|
||||
|
||||
static bool parseBTHomeData(const NimBLEAdvertisedDevice* device, uint8_t sensorId) {
|
||||
NimBLEUUID serviceUuid((uint16_t) 0xFCD2);
|
||||
NimBLEUUID serviceUuid(static_cast<uint16_t>(0xFCD2));
|
||||
|
||||
auto serviceData = device->getServiceData(serviceUuid);
|
||||
if (!serviceData.size()) {
|
||||
@@ -304,7 +304,7 @@ public:
|
||||
|
||||
class SensorsTask : public LeanTask {
|
||||
public:
|
||||
SensorsTask(bool _enabled = false, unsigned long _interval = 0) : LeanTask(_enabled, _interval) {
|
||||
explicit SensorsTask(bool _enabled = false, unsigned long _interval = 0) : LeanTask(_enabled, _interval) {
|
||||
this->gpioLastPollingTime.reserve(2);
|
||||
|
||||
// OneWire
|
||||
@@ -830,7 +830,7 @@ protected:
|
||||
}
|
||||
|
||||
const float sensorResistance = value > 1
|
||||
? DEFAULT_NTC_REF_RESISTANCE / (DEFAULT_NTC_VREF / (float) value - 1.0f)
|
||||
? DEFAULT_NTC_REF_RESISTANCE / (DEFAULT_NTC_VREF / static_cast<float>(value) - 1.0f)
|
||||
: 0.0f;
|
||||
const float rawTemp = 1.0f / (
|
||||
1.0f / (DEFAULT_NTC_NOMINAL_TEMP + 273.15f) +
|
||||
|
||||
+1
-1
@@ -147,7 +147,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef PROGMEM
|
||||
#define PROGMEM
|
||||
#define PROGMEM // NOLINT
|
||||
#endif
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#ifndef PROGMEM
|
||||
#define PROGMEM
|
||||
#define PROGMEM // NOLINT
|
||||
#endif
|
||||
|
||||
const char L_SETTINGS[] PROGMEM = "SETTINGS";
|
||||
|
||||
+2
-2
@@ -139,7 +139,7 @@ inline bool isValidTemp(const float value, UnitSystem unit, const float min = 0.
|
||||
|
||||
float roundf(float value, uint8_t decimals = 2) {
|
||||
if (decimals == 0) {
|
||||
return (int)(value + 0.5f);
|
||||
return static_cast<int>(value + 0.5f);
|
||||
|
||||
} else if (abs(value) < 0.00000001f) {
|
||||
return 0.0f;
|
||||
@@ -147,7 +147,7 @@ float roundf(float value, uint8_t decimals = 2) {
|
||||
|
||||
float multiplier = pow10(decimals);
|
||||
value += 0.5f / multiplier * (value < 0.0f ? -1.0f : 1.0f);
|
||||
return (int)(value * multiplier) / multiplier;
|
||||
return static_cast<int>(value * multiplier) / multiplier;
|
||||
}
|
||||
|
||||
inline size_t getTotalHeap() {
|
||||
|
||||
Reference in New Issue
Block a user