From 14826c10cd5c71e2dc0e5b2e7645791d5c930c05 Mon Sep 17 00:00:00 2001 From: Yurii Date: Tue, 23 Sep 2025 04:03:36 +0300 Subject: [PATCH] chore: ``byte`` to ``uint8_t`` --- lib/CustomOpenTherm/CustomOpenTherm.h | 11 +++++------ lib/NetworkUtils/NetworkMgr.h | 12 ++++++------ src/HaHelper.h | 8 ++++---- src/MqttTask.h | 2 +- src/OpenThermTask.h | 8 ++++---- src/Settings.h | 22 +++++++++++----------- 6 files changed, 31 insertions(+), 32 deletions(-) diff --git a/lib/CustomOpenTherm/CustomOpenTherm.h b/lib/CustomOpenTherm/CustomOpenTherm.h index 82f59c1..6fd6db1 100644 --- a/lib/CustomOpenTherm/CustomOpenTherm.h +++ b/lib/CustomOpenTherm/CustomOpenTherm.h @@ -4,8 +4,8 @@ class CustomOpenTherm : public OpenTherm { public: typedef std::function DelayCallback; - typedef std::function BeforeSendRequestCallback; - typedef std::function AfterSendRequestCallback; + typedef std::function BeforeSendRequestCallback; + typedef std::function AfterSendRequestCallback; CustomOpenTherm(int inPin = 4, int outPin = 5, bool isSlave = false, bool alwaysReceive = false) : OpenTherm(inPin, outPin, isSlave, alwaysReceive) {} ~CustomOpenTherm() {} @@ -106,15 +106,14 @@ public: return isValidResponse(response) && isValidResponseId(response, OpenThermMessageID::RemoteRequest); } - static bool isCh2Active(unsigned long response) - { + static bool isCh2Active(unsigned long response) { return response & 0x20; } static bool isValidResponseId(unsigned long response, OpenThermMessageID id) { - byte responseId = (response >> 16) & 0xFF; + uint8_t responseId = (response >> 16) & 0xFF; - return (byte)id == responseId; + return (uint8_t)id == responseId; } static uint8_t getResponseMessageTypeId(unsigned long response) { diff --git a/lib/NetworkUtils/NetworkMgr.h b/lib/NetworkUtils/NetworkMgr.h index 30de4c7..aadf3dd 100644 --- a/lib/NetworkUtils/NetworkMgr.h +++ b/lib/NetworkUtils/NetworkMgr.h @@ -35,7 +35,7 @@ namespace NetworkUtils { return this; } - NetworkMgr* setApCredentials(const char* ssid, const char* password = nullptr, byte channel = 0) { + NetworkMgr* setApCredentials(const char* ssid, const char* password = nullptr, uint8_t channel = 0) { this->apName = ssid; this->apPassword = password; this->apChannel = channel; @@ -43,7 +43,7 @@ namespace NetworkUtils { return this; } - NetworkMgr* setStaCredentials(const char* ssid = nullptr, const char* password = nullptr, byte channel = 0) { + NetworkMgr* setStaCredentials(const char* ssid = nullptr, const char* password = nullptr, uint8_t channel = 0) { this->staSsid = ssid; this->staPassword = password; this->staChannel = channel; @@ -140,7 +140,7 @@ namespace NetworkUtils { return this->staPassword; } - byte getStaChannel() { + uint8_t getStaChannel() { return this->staChannel; } @@ -377,7 +377,7 @@ namespace NetworkUtils { } } - static byte rssiToSignalQuality(short int rssi) { + static uint8_t rssiToSignalQuality(short int rssi) { return constrain(map(rssi, -100, -50, 0, 100), 0, 100); } @@ -397,11 +397,11 @@ namespace NetworkUtils { const char* hostname = "esp"; const char* apName = "ESP"; const char* apPassword = nullptr; - byte apChannel = 1; + uint8_t apChannel = 1; const char* staSsid = nullptr; const char* staPassword = nullptr; - byte staChannel = 0; + uint8_t staChannel = 0; bool useDhcp = true; IPAddress staticIp; diff --git a/src/HaHelper.h b/src/HaHelper.h index 689d3ec..69ba800 100644 --- a/src/HaHelper.h +++ b/src/HaHelper.h @@ -3,8 +3,8 @@ class HaHelper : public HomeAssistantHelper { public: - static const byte TEMP_SOURCE_HEATING = 0; - static const byte TEMP_SOURCE_INDOOR = 1; + static const uint8_t TEMP_SOURCE_HEATING = 0; + static const uint8_t TEMP_SOURCE_INDOOR = 1; static const char AVAILABILITY_OT_CONN[]; static const char AVAILABILITY_SENSOR_CONN[]; @@ -1170,7 +1170,7 @@ public: } - bool publishClimateHeating(UnitSystem unit = UnitSystem::METRIC, byte minTemp = 20, byte maxTemp = 90, bool enabledByDefault = true) { + bool publishClimateHeating(UnitSystem unit = UnitSystem::METRIC, uint8_t minTemp = 20, uint8_t maxTemp = 90, bool enabledByDefault = true) { JsonDocument doc; doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str(); doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; @@ -1222,7 +1222,7 @@ public: return this->publish(this->makeConfigTopic(FPSTR(HA_ENTITY_CLIMATE), F("heating"), '_').c_str(), doc); } - bool publishClimateDhw(UnitSystem unit = UnitSystem::METRIC, byte minTemp = 40, byte maxTemp = 60, bool enabledByDefault = true) { + bool publishClimateDhw(UnitSystem unit = UnitSystem::METRIC, uint8_t minTemp = 40, uint8_t maxTemp = 60, bool enabledByDefault = true) { JsonDocument doc; doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str(); doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; diff --git a/src/MqttTask.h b/src/MqttTask.h index da29d0a..7578f72 100644 --- a/src/MqttTask.h +++ b/src/MqttTask.h @@ -557,7 +557,7 @@ protected: } bool publishNonStaticHaEntities(bool force = false) { - static byte _heatingMinTemp, _heatingMaxTemp, _dhwMinTemp, _dhwMaxTemp = 0; + static uint8_t _heatingMinTemp, _heatingMaxTemp, _dhwMinTemp, _dhwMaxTemp = 0; static bool _indoorTempControl, _dhwSupport = false; bool published = false; diff --git a/src/OpenThermTask.h b/src/OpenThermTask.h index 4b7543b..fd5e1d8 100644 --- a/src/OpenThermTask.h +++ b/src/OpenThermTask.h @@ -19,8 +19,8 @@ protected: CustomOpenTherm* instance = nullptr; unsigned long instanceCreatedTime = 0; - byte instanceInGpio = 0; - byte instanceOutGpio = 0; + uint8_t instanceInGpio = 0; + uint8_t instanceOutGpio = 0; bool initialized = false; unsigned long connectedTime = 0; unsigned long disconnectedTime = 0; @@ -31,7 +31,7 @@ protected: unsigned long heatingSetTempTime = 0; unsigned long dhwSetTempTime = 0; unsigned long ch2SetTempTime = 0; - byte configuredRxLedGpio = GPIO_IS_NOT_CONFIGURED; + uint8_t configuredRxLedGpio = GPIO_IS_NOT_CONFIGURED; #if defined(ARDUINO_ARCH_ESP32) const char* getTaskName() override { @@ -90,7 +90,7 @@ protected: Log.sinfoln(FPSTR(L_OT), F("Started. GPIO IN: %hhu, GPIO OUT: %hhu"), settings.opentherm.inGpio, settings.opentherm.outGpio); - this->instance->setAfterSendRequestCallback([this](unsigned long request, unsigned long response, OpenThermResponseStatus status, byte attempt) { + this->instance->setAfterSendRequestCallback([this](unsigned long request, unsigned long response, OpenThermResponseStatus status, uint8_t attempt) { Log.sverboseln( FPSTR(L_OT), F("ID: %4d Request: %8lx Response: %8lx Msg type: %s Attempt: %2d Status: %s"), diff --git a/src/Settings.h b/src/Settings.h index 17cdad1..1fded9f 100644 --- a/src/Settings.h +++ b/src/Settings.h @@ -12,13 +12,13 @@ struct NetworkSettings { struct { char ssid[33] = DEFAULT_AP_SSID; char password[65] = DEFAULT_AP_PASSWORD; - byte channel = 6; + uint8_t channel = 6; } ap; struct { char ssid[33] = DEFAULT_STA_SSID; char password[65] = DEFAULT_STA_PASSWORD; - byte channel = 0; + uint8_t channel = 0; } sta; } networkSettings; @@ -42,7 +42,7 @@ struct Settings { } ntp; UnitSystem unitSystem = UnitSystem::METRIC; - byte statusLedGpio = DEFAULT_STATUS_LED_GPIO; + uint8_t statusLedGpio = DEFAULT_STATUS_LED_GPIO; } system; struct { @@ -54,9 +54,9 @@ struct Settings { struct { UnitSystem unitSystem = UnitSystem::METRIC; - byte inGpio = DEFAULT_OT_IN_GPIO; - byte outGpio = DEFAULT_OT_OUT_GPIO; - byte rxLedGpio = DEFAULT_OT_RX_LED_GPIO; + uint8_t inGpio = DEFAULT_OT_IN_GPIO; + uint8_t outGpio = DEFAULT_OT_OUT_GPIO; + uint8_t rxLedGpio = DEFAULT_OT_RX_LED_GPIO; uint8_t memberId = 0; uint8_t flags = 0; float minPower = 0.0f; @@ -105,8 +105,8 @@ struct Settings { float target = DEFAULT_HEATING_TARGET_TEMP; float hysteresis = 0.5f; float turboFactor = 7.5f; - byte minTemp = DEFAULT_HEATING_MIN_TEMP; - byte maxTemp = DEFAULT_HEATING_MAX_TEMP; + uint8_t minTemp = DEFAULT_HEATING_MIN_TEMP; + uint8_t maxTemp = DEFAULT_HEATING_MAX_TEMP; uint8_t maxModulation = 100; struct { @@ -123,8 +123,8 @@ struct Settings { struct { bool enabled = true; float target = DEFAULT_DHW_TARGET_TEMP; - byte minTemp = DEFAULT_DHW_MIN_TEMP; - byte maxTemp = DEFAULT_DHW_MAX_TEMP; + uint8_t minTemp = DEFAULT_DHW_MIN_TEMP; + uint8_t maxTemp = DEFAULT_DHW_MAX_TEMP; uint8_t maxModulation = 100; struct { @@ -161,7 +161,7 @@ struct Settings { struct { bool use = false; - byte gpio = DEFAULT_EXT_PUMP_GPIO; + uint8_t gpio = DEFAULT_EXT_PUMP_GPIO; unsigned short postCirculationTime = 600; unsigned int antiStuckInterval = 2592000; unsigned short antiStuckTime = 300;