mirror of
https://github.com/tbnobody/OpenDTU.git
synced 2025-12-10 16:59:52 +01:00
Apply automatic code formatting
This commit is contained in:
@@ -2,10 +2,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "PinMapping.h"
|
||||
#include <cstdint>
|
||||
#include <TaskSchedulerDeclarations.h>
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
#include <cstdint>
|
||||
#include <mutex>
|
||||
|
||||
#define CONFIG_FILENAME "/config.json"
|
||||
#define CONFIG_VERSION 0x00011d00 // 0.1.29 // make sure to clean all after change
|
||||
|
||||
@@ -37,7 +37,6 @@ enum CategoryType {
|
||||
};
|
||||
const char* const category_name[] = { 0, "config", "diagnostic" };
|
||||
|
||||
|
||||
typedef struct {
|
||||
FieldId_t fieldId; // field id
|
||||
DeviceClassType deviceClsId; // device class
|
||||
|
||||
@@ -9,5 +9,5 @@ public:
|
||||
void init(AsyncWebServer& server, Scheduler& scheduler);
|
||||
|
||||
private:
|
||||
void responseBinaryDataWithETagCache(AsyncWebServerRequest* request, const String &contentType, const String &contentEncoding, const uint8_t *content, size_t len);
|
||||
void responseBinaryDataWithETagCache(AsyncWebServerRequest* request, const String& contentType, const String& contentEncoding, const uint8_t* content, size_t len);
|
||||
};
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
// The referenced values are generated by pio-scripts/auto_firmware_version.py
|
||||
|
||||
|
||||
extern const char *__COMPILED_GIT_HASH__;
|
||||
extern const char *__COMPILED_GIT_BRANCH__;
|
||||
extern const char* __COMPILED_GIT_HASH__;
|
||||
extern const char* __COMPILED_GIT_BRANCH__;
|
||||
// extern const char *__COMPILED_DATE_TIME_UTC_STR__;
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
#ifndef __CMT2300A_HAL_H
|
||||
#define __CMT2300A_HAL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <Arduino.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "cmt_spi3.h"
|
||||
#include <Arduino.h>
|
||||
#include <driver/spi_master.h>
|
||||
#include <SpiManager.h>
|
||||
#include <driver/spi_master.h>
|
||||
|
||||
SemaphoreHandle_t paramLock = NULL;
|
||||
#define SPI_PARAM_LOCK() \
|
||||
@@ -9,11 +9,13 @@ SemaphoreHandle_t paramLock = NULL;
|
||||
} while (xSemaphoreTake(paramLock, portMAX_DELAY) != pdPASS)
|
||||
#define SPI_PARAM_UNLOCK() xSemaphoreGive(paramLock)
|
||||
|
||||
static void IRAM_ATTR pre_cb(spi_transaction_t *trans) {
|
||||
static void IRAM_ATTR pre_cb(spi_transaction_t* trans)
|
||||
{
|
||||
gpio_set_level(*reinterpret_cast<gpio_num_t*>(trans->user), 0);
|
||||
}
|
||||
|
||||
static void IRAM_ATTR post_cb(spi_transaction_t *trans) {
|
||||
static void IRAM_ATTR post_cb(spi_transaction_t* trans)
|
||||
{
|
||||
gpio_set_level(*reinterpret_cast<gpio_num_t*>(trans->user), 1);
|
||||
}
|
||||
|
||||
@@ -27,8 +29,7 @@ void cmt_spi3_init(const int8_t pin_sdio, const int8_t pin_clk, const int8_t pin
|
||||
auto bus_config = std::make_shared<SpiBusConfig>(
|
||||
static_cast<gpio_num_t>(pin_sdio),
|
||||
GPIO_NUM_NC,
|
||||
static_cast<gpio_num_t>(pin_clk)
|
||||
);
|
||||
static_cast<gpio_num_t>(pin_clk));
|
||||
|
||||
spi_device_interface_config_t device_config {
|
||||
.command_bits = 0, // set by transactions individually
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* Copyright (C) 2022-2024 Thomas Basler and others
|
||||
* Copyright (C) 2022-2025 Thomas Basler and others
|
||||
*/
|
||||
#include "Hoymiles.h"
|
||||
#include "Utils.h"
|
||||
@@ -119,7 +119,7 @@ void HoymilesClass::loop()
|
||||
iv->sendGridOnProFileParaRequest();
|
||||
}
|
||||
|
||||
_messageOutput->printf("Queue size - NRF: %" PRId32 " CMT: %" PRId32 "\r\n", _radioNrf->getQueueSize(), _radioCmt->getQueueSize());
|
||||
_messageOutput->printf("Queue size - NRF: %" PRId32 " CMT: %" PRId32 "\r\n", _radioNrf->getQueueSize(), _radioCmt->getQueueSize());
|
||||
_lastPoll = millis();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* Copyright (C) 2022-2024 Thomas Basler and others
|
||||
* Copyright (C) 2022-2025 Thomas Basler and others
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -61,11 +61,11 @@ void ActivePowerControlCommand::setActivePowerLimit(const float limit, const Pow
|
||||
|
||||
// limit
|
||||
_payload[12] = (l >> 8) & 0xff;
|
||||
_payload[13] = (l)&0xff;
|
||||
_payload[13] = (l) & 0xff;
|
||||
|
||||
// type
|
||||
_payload[14] = (type >> 8) & 0xff;
|
||||
_payload[15] = (type)&0xff;
|
||||
_payload[15] = (type) & 0xff;
|
||||
|
||||
udpateCRC(CRC_SIZE);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#pragma once
|
||||
|
||||
#include "CommandAbstract.h"
|
||||
#include "../HoymilesRadio_CMT.h"
|
||||
#include "CommandAbstract.h"
|
||||
|
||||
class ChannelChangeCommand : public CommandAbstract {
|
||||
public:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* Copyright (C) 2022-2024 Thomas Basler and others
|
||||
* Copyright (C) 2022-2025 Thomas Basler and others
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -27,9 +27,9 @@ Source Address: 80 12 23 04
|
||||
Target Addr Source Addr CRC8
|
||||
*/
|
||||
#include "CommandAbstract.h"
|
||||
#include "../inverters/InverterAbstract.h"
|
||||
#include "crc.h"
|
||||
#include <string.h>
|
||||
#include "../inverters/InverterAbstract.h"
|
||||
|
||||
CommandAbstract::CommandAbstract(InverterAbstract* inv, const uint64_t router_address)
|
||||
{
|
||||
|
||||
@@ -13,7 +13,7 @@ class InverterAbstract;
|
||||
|
||||
enum class QueueInsertType {
|
||||
AllowMultiple,
|
||||
// Remove from beginning of the queue
|
||||
// Remove from beginning of the queue
|
||||
RemoveOldest,
|
||||
|
||||
// Don't insert command if it already exist
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* Copyright (C) 2022-2024 Thomas Basler and others
|
||||
* Copyright (C) 2022-2025 Thomas Basler and others
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -111,7 +111,7 @@ bool MultiDataCommand::handleResponse(const fragment_t fragment[], const uint8_t
|
||||
|
||||
void MultiDataCommand::udpateCRC()
|
||||
{
|
||||
const uint16_t crc = crc16(&_payload[10], 14); // From data_type till password
|
||||
const uint16_t crc = crc16(&_payload[10], 14); // From data_type till password
|
||||
_payload[24] = static_cast<uint8_t>(crc >> 8);
|
||||
_payload[25] = static_cast<uint8_t>(crc);
|
||||
}
|
||||
|
||||
@@ -153,6 +153,7 @@ public:
|
||||
|
||||
bool getYieldDayCorrection() const;
|
||||
void setYieldDayCorrection(const bool enabled);
|
||||
|
||||
private:
|
||||
void zeroFields(const FieldId_t* fields);
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#pragma once
|
||||
|
||||
#include <deque>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <deque>
|
||||
|
||||
template <typename T>
|
||||
class ThreadSafeQueue {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* Copyright (C) 2022-2024 Thomas Basler and others
|
||||
* Copyright (C) 2022-2025 Thomas Basler and others
|
||||
*/
|
||||
#include "Configuration.h"
|
||||
#include "MessageOutput.h"
|
||||
@@ -489,7 +489,9 @@ void ConfigurationClass::deleteInverterById(const uint8_t id)
|
||||
void ConfigurationClass::loop()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(sWriterMutex);
|
||||
if (sWriterCount == 0) { return; }
|
||||
if (sWriterCount == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
sWriterCv.notify_all();
|
||||
sWriterCv.wait(lock, [] { return sWriterCount == 0; });
|
||||
@@ -507,9 +509,12 @@ ConfigurationClass::WriteGuard::WriteGuard()
|
||||
sWriterCv.wait(_lock);
|
||||
}
|
||||
|
||||
ConfigurationClass::WriteGuard::~WriteGuard() {
|
||||
ConfigurationClass::WriteGuard::~WriteGuard()
|
||||
{
|
||||
sWriterCount--;
|
||||
if (sWriterCount == 0) { sWriterCv.notify_all(); }
|
||||
if (sWriterCount == 0) {
|
||||
sWriterCv.notify_all();
|
||||
}
|
||||
}
|
||||
|
||||
ConfigurationClass Configuration;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* Copyright (C) 2022-2024 Thomas Basler and others
|
||||
* Copyright (C) 2022-2025 Thomas Basler and others
|
||||
*/
|
||||
#include "MqttHandleDtu.h"
|
||||
#include "Configuration.h"
|
||||
#include "MqttSettings.h"
|
||||
#include "NetworkSettings.h"
|
||||
#include <Hoymiles.h>
|
||||
#include <CpuTemperature.h>
|
||||
#include <Hoymiles.h>
|
||||
|
||||
MqttHandleDtuClass MqttHandleDtu;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* Copyright (C) 2022-2024 Thomas Basler and others
|
||||
* Copyright (C) 2022-2025 Thomas Basler and others
|
||||
*/
|
||||
#include "MqttHandleHass.h"
|
||||
#include "MqttHandleInverter.h"
|
||||
@@ -70,7 +70,7 @@ void MqttHandleHassClass::publishConfig()
|
||||
publishDtuSensor("Yield Total", "ac/yieldtotal", "kWh", "", DEVICE_CLS_ENERGY, STATE_CLS_TOTAL_INCREASING, CATEGORY_NONE);
|
||||
publishDtuSensor("Yield Day", "ac/yieldday", "Wh", "", DEVICE_CLS_ENERGY, STATE_CLS_TOTAL_INCREASING, CATEGORY_NONE);
|
||||
publishDtuSensor("AC Power", "ac/power", "W", "", DEVICE_CLS_PWR, STATE_CLS_MEASUREMENT, CATEGORY_NONE);
|
||||
publishDtuSensor("DC Power", "dc/power", "W", "", DEVICE_CLS_PWR, STATE_CLS_MEASUREMENT, CATEGORY_NONE);
|
||||
publishDtuSensor("DC Power", "dc/power", "W", "", DEVICE_CLS_PWR, STATE_CLS_MEASUREMENT, CATEGORY_NONE);
|
||||
|
||||
publishDtuBinarySensor("Status", config.Mqtt.Lwt.Topic, config.Mqtt.Lwt.Value_Online, config.Mqtt.Lwt.Value_Offline, DEVICE_CLS_CONNECTIVITY, STATE_CLS_NONE, CATEGORY_DIAGNOSTIC);
|
||||
|
||||
@@ -324,7 +324,7 @@ void MqttHandleHassClass::addCommonMetadata(
|
||||
doc["dev_cla"] = deviceClass_name[device_class];
|
||||
}
|
||||
if (state_class != STATE_CLS_NONE) {
|
||||
doc["stat_cla"] = stateClass_name[state_class];;
|
||||
doc["stat_cla"] = stateClass_name[state_class];
|
||||
}
|
||||
if (category != CATEGORY_NONE) {
|
||||
doc["ent_cat"] = category_name[category];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* Copyright (C) 2022-2024 Thomas Basler and others
|
||||
* Copyright (C) 2022-2025 Thomas Basler and others
|
||||
*/
|
||||
#include "WebApi_gridprofile.h"
|
||||
#include "WebApi.h"
|
||||
@@ -33,13 +33,13 @@ void WebApiGridProfileClass::onGridProfileStatus(AsyncWebServerRequest* request)
|
||||
auto jsonSections = root["sections"].to<JsonArray>();
|
||||
auto profSections = inv->GridProfile()->getProfile();
|
||||
|
||||
for (auto &profSection : profSections) {
|
||||
for (auto& profSection : profSections) {
|
||||
auto jsonSection = jsonSections.add<JsonObject>();
|
||||
jsonSection["name"] = profSection.SectionName;
|
||||
|
||||
auto jsonItems = jsonSection["items"].to<JsonArray>();
|
||||
|
||||
for (auto &profItem : profSection.items) {
|
||||
for (auto& profItem : profSection.items) {
|
||||
auto jsonItem = jsonItems.add<JsonObject>();
|
||||
|
||||
jsonItem["n"] = profItem.Name;
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* Copyright (C) 2022-2024 Thomas Basler and others
|
||||
* Copyright (C) 2022-2025 Thomas Basler and others
|
||||
*/
|
||||
#include "WebApi_prometheus.h"
|
||||
#include "Configuration.h"
|
||||
#include "MessageOutput.h"
|
||||
#include "NetworkSettings.h"
|
||||
#include "WebApi.h"
|
||||
#include <Hoymiles.h>
|
||||
#include "__compiled_constants.h"
|
||||
#include <Hoymiles.h>
|
||||
|
||||
void WebApiPrometheusClass::init(AsyncWebServer& server, Scheduler& scheduler)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* Copyright (C) 2022-2024 Thomas Basler and others
|
||||
* Copyright (C) 2022-2025 Thomas Basler and others
|
||||
*/
|
||||
#include "WebApi_sysstatus.h"
|
||||
#include "Configuration.h"
|
||||
@@ -59,7 +59,9 @@ void WebApiSysstatusClass::onSystemStatus(AsyncWebServerRequest* request)
|
||||
};
|
||||
for (char const* task_name : task_names) {
|
||||
TaskHandle_t const handle = xTaskGetHandle(task_name);
|
||||
if (!handle) { continue; }
|
||||
if (!handle) {
|
||||
continue;
|
||||
}
|
||||
JsonObject task = taskDetails.add<JsonObject>();
|
||||
task["name"] = task_name;
|
||||
task["stack_watermark"] = uxTaskGetStackHighWaterMark(handle);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* Copyright (C) 2022-2024 Thomas Basler and others
|
||||
* Copyright (C) 2022-2025 Thomas Basler and others
|
||||
*/
|
||||
#include "WebApi_webapp.h"
|
||||
#include <MD5Builder.h>
|
||||
@@ -19,11 +19,11 @@ extern const uint8_t file_zones_json_end[] asm("_binary_webapp_dist_zones_json_g
|
||||
extern const uint8_t file_app_js_end[] asm("_binary_webapp_dist_js_app_js_gz_end");
|
||||
extern const uint8_t file_site_webmanifest_end[] asm("_binary_webapp_dist_site_webmanifest_end");
|
||||
|
||||
void WebApiWebappClass::responseBinaryDataWithETagCache(AsyncWebServerRequest *request, const String &contentType, const String &contentEncoding, const uint8_t *content, size_t len)
|
||||
void WebApiWebappClass::responseBinaryDataWithETagCache(AsyncWebServerRequest* request, const String& contentType, const String& contentEncoding, const uint8_t* content, size_t len)
|
||||
{
|
||||
auto md5 = MD5Builder();
|
||||
md5.begin();
|
||||
md5.add(const_cast<uint8_t *>(content), len);
|
||||
md5.add(const_cast<uint8_t*>(content), len);
|
||||
md5.calculate();
|
||||
|
||||
String expectedEtag;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* Copyright (C) 2022-2024 Thomas Basler and others
|
||||
* Copyright (C) 2022-2025 Thomas Basler and others
|
||||
*/
|
||||
#include "WebApi_ws_console.h"
|
||||
#include "Configuration.h"
|
||||
@@ -34,7 +34,9 @@ void WebApiWsConsoleClass::reload()
|
||||
|
||||
auto const& config = Configuration.get();
|
||||
|
||||
if (config.Security.AllowReadonly) { return; }
|
||||
if (config.Security.AllowReadonly) {
|
||||
return;
|
||||
}
|
||||
|
||||
_ws.enable(false);
|
||||
_simpleDigestAuth.setPassword(config.Security.Password);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* Copyright (C) 2022-2024 Thomas Basler and others
|
||||
* Copyright (C) 2022-2025 Thomas Basler and others
|
||||
*/
|
||||
#include "WebApi_ws_live.h"
|
||||
#include "Datastore.h"
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <AsyncJson.h>
|
||||
|
||||
#ifndef PIN_MAPPING_REQUIRED
|
||||
#define PIN_MAPPING_REQUIRED 0
|
||||
#define PIN_MAPPING_REQUIRED 0
|
||||
#endif
|
||||
|
||||
WebApiWsLiveClass::WebApiWsLiveClass()
|
||||
@@ -52,7 +52,9 @@ void WebApiWsLiveClass::reload()
|
||||
|
||||
auto const& config = Configuration.get();
|
||||
|
||||
if (config.Security.AllowReadonly) { return; }
|
||||
if (config.Security.AllowReadonly) {
|
||||
return;
|
||||
}
|
||||
|
||||
_ws.enable(false);
|
||||
_simpleDigestAuth.setPassword(config.Security.Password);
|
||||
|
||||
Reference in New Issue
Block a user