From a75cde2913302145070bb029e94b251a9d352882 Mon Sep 17 00:00:00 2001 From: TD-er Date: Sat, 3 Jul 2021 00:49:15 +0200 Subject: [PATCH 1/3] [Cleanup] Use of "byte" as a type. uint8_t or (C++17) std::byte are better As discussed here: https://github.com/esp8266/Arduino/issues/8089#issuecomment-851430885 --- src/ESPEasy-Globals.h | 6 +- src/_Plugin_Helper.cpp | 6 +- src/_Plugin_Helper.h | 6 +- src/src/Commands/Blynk.cpp | 2 +- src/src/Commands/Common.cpp | 2 +- src/src/Commands/Common.h | 2 +- src/src/Commands/Diagnostic.cpp | 2 +- src/src/Commands/GPIO.cpp | 130 ++++++++--------- src/src/Commands/GPIO.h | 2 +- src/src/Commands/Tasks.cpp | 2 +- src/src/Commands/UDP.cpp | 2 +- src/src/Commands/i2c.cpp | 2 +- src/src/Commands/wd.cpp | 2 +- .../ControllerQueue/C015_queue_element.cpp | 6 +- src/src/ControllerQueue/C015_queue_element.h | 6 +- .../ControllerQueue/C016_queue_element.cpp | 10 +- src/src/ControllerQueue/C016_queue_element.h | 6 +- .../ControllerDelayHandlerStruct.h | 6 +- .../queue_element_formatted_uservar.cpp | 4 +- .../queue_element_formatted_uservar.h | 2 +- .../queue_element_single_value_base.cpp | 8 +- .../queue_element_single_value_base.h | 6 +- src/src/DataStructs/C013_p2p_dataStructs.h | 16 +-- src/src/DataStructs/Caches.h | 2 +- .../DataStructs/ControllerSettingsStruct.cpp | 10 +- .../DataStructs/ControllerSettingsStruct.h | 2 +- src/src/DataStructs/DeviceStruct.h | 12 +- src/src/DataStructs/ESPEasy_EventStruct.h | 6 +- .../DataStructs/ESPEasy_packed_raw_data.cpp | 14 +- src/src/DataStructs/ESPEasy_packed_raw_data.h | 6 +- .../DataStructs/ExtraTaskSettingsStruct.cpp | 10 +- src/src/DataStructs/ExtraTaskSettingsStruct.h | 4 +- src/src/DataStructs/LogStruct.cpp | 4 +- src/src/DataStructs/LogStruct.h | 6 +- src/src/DataStructs/NodeStruct.cpp | 4 +- src/src/DataStructs/NodeStruct.h | 8 +- .../DataStructs/NotificationSettingsStruct.h | 4 +- src/src/DataStructs/NotificationStruct.h | 4 +- src/src/DataStructs/ProtocolStruct.h | 2 +- src/src/DataStructs/RTCStruct.cpp | 2 +- src/src/DataStructs/RTCStruct.h | 20 +-- .../DataStructs/RTC_cache_handler_struct.cpp | 14 +- .../DataStructs/RTC_cache_handler_struct.h | 2 +- src/src/DataStructs/SecurityStruct.h | 6 +- src/src/DataStructs/SettingsStruct.cpp | 32 ++--- src/src/DataStructs/SettingsStruct.h | 56 ++++---- src/src/DataStructs/UnitMessageCount.h | 8 +- src/src/DataStructs/UserVarStruct.cpp | 8 +- src/src/DataStructs/UserVarStruct.h | 6 +- src/src/DataStructs/WiFiEventData.cpp | 4 +- src/src/DataStructs/WiFiEventData.h | 2 +- src/src/DataStructs/WiFi_AP_Candidate.cpp | 2 +- src/src/DataStructs/WiFi_AP_Candidate.h | 6 +- src/src/DataTypes/ControllerIndex.h | 2 +- src/src/DataTypes/EventValueSource.h | 4 +- src/src/DataTypes/ProtocolIndex.h | 2 +- src/src/DataTypes/TaskIndex.h | 2 +- src/src/ESPEasyCore/Controller.cpp | 10 +- src/src/ESPEasyCore/Controller.h | 2 +- src/src/ESPEasyCore/ESPEasyGPIO.cpp | 56 ++++---- src/src/ESPEasyCore/ESPEasyGPIO.h | 16 +-- src/src/ESPEasyCore/ESPEasyRules.cpp | 26 ++-- src/src/ESPEasyCore/ESPEasyRules.h | 8 +- src/src/ESPEasyCore/ESPEasy_Log.cpp | 32 ++--- src/src/ESPEasyCore/ESPEasy_Log.h | 26 ++-- src/src/ESPEasyCore/ESPEasy_setup.cpp | 2 +- src/src/ESPEasyCore/Serial.cpp | 2 +- src/src/ESPEasyCore/Serial.h | 2 +- src/src/Globals/C016_ControllerCache.cpp | 6 +- src/src/Globals/C016_ControllerCache.h | 6 +- src/src/Globals/MainLoopCommand.cpp | 2 +- src/src/Globals/MainLoopCommand.h | 2 +- src/src/Globals/NPlugins.cpp | 2 +- src/src/Globals/NPlugins.h | 6 +- src/src/Globals/NetworkState.cpp | 2 +- src/src/Globals/NetworkState.h | 2 +- src/src/Globals/Plugins.cpp | 6 +- src/src/Globals/Plugins.h | 4 +- src/src/Helpers/Audio.cpp | 8 +- src/src/Helpers/Convert.cpp | 2 +- src/src/Helpers/Convert.h | 2 +- src/src/Helpers/Dallas1WireHelper.cpp | 54 +++---- src/src/Helpers/Dallas1WireHelper.h | 8 +- src/src/Helpers/ESPEasyRTC.cpp | 18 +-- src/src/Helpers/ESPEasyStatistics.cpp | 2 +- src/src/Helpers/ESPEasyStatistics.h | 2 +- src/src/Helpers/ESPEasy_Storage.cpp | 66 ++++----- src/src/Helpers/ESPEasy_Storage.h | 38 ++--- src/src/Helpers/ESPEasy_time.cpp | 4 +- src/src/Helpers/ESPEasy_time.h | 14 +- src/src/Helpers/ESPEasy_time_calc.cpp | 2 +- src/src/Helpers/Hardware.cpp | 32 ++--- src/src/Helpers/Hardware.h | 6 +- src/src/Helpers/I2C_access.cpp | 32 ++--- src/src/Helpers/I2C_access.h | 24 ++-- src/src/Helpers/Misc.cpp | 12 +- src/src/Helpers/Misc.h | 8 +- src/src/Helpers/Modbus_RTU.cpp | 132 +++++++++--------- src/src/Helpers/Modbus_RTU.h | 90 ++++++------ src/src/Helpers/Networking.cpp | 66 ++++----- src/src/Helpers/Networking.h | 14 +- src/src/Helpers/PeriodicalActions.cpp | 4 +- src/src/Helpers/PeriodicalActions.h | 2 +- src/src/Helpers/PortStatus.cpp | 18 +-- src/src/Helpers/PortStatus.h | 8 +- src/src/Helpers/Scheduler.cpp | 44 +++--- src/src/Helpers/Scheduler.h | 24 ++-- src/src/Helpers/StringConverter.cpp | 42 +++--- src/src/Helpers/StringConverter.h | 28 ++-- src/src/Helpers/StringGenerator_System.cpp | 2 +- src/src/Helpers/StringGenerator_System.h | 2 +- src/src/Helpers/StringGenerator_WiFi.cpp | 2 +- src/src/Helpers/StringGenerator_WiFi.h | 2 +- src/src/Helpers/StringParser.cpp | 24 ++-- src/src/Helpers/StringParser.h | 8 +- src/src/Helpers/WiFi_AP_CandidatesList.cpp | 4 +- src/src/Helpers/WiFi_AP_CandidatesList.h | 2 +- src/src/Helpers/_CPlugin_DomoticzHelper.cpp | 8 +- src/src/Helpers/_CPlugin_DomoticzHelper.h | 4 +- src/src/Helpers/_CPlugin_Helper.cpp | 4 +- src/src/Helpers/_CPlugin_Helper_webform.cpp | 4 +- src/src/Helpers/_CPlugin_LoRa_TTN_helper.cpp | 4 +- .../Helpers/_Internal_GPIO_pulseHelper.cpp | 6 +- src/src/Helpers/_Internal_GPIO_pulseHelper.h | 12 +- src/src/Helpers/_Plugin_Helper_serial.cpp | 30 ++-- src/src/Helpers/_Plugin_Helper_serial.h | 10 +- src/src/Helpers/_Plugin_SensorTypeHelper.cpp | 64 ++++----- src/src/Helpers/_Plugin_SensorTypeHelper.h | 16 +-- src/src/PluginStructs/P004_data_struct.cpp | 4 +- src/src/PluginStructs/P012_data_struct.cpp | 14 +- src/src/PluginStructs/P012_data_struct.h | 12 +- src/src/PluginStructs/P015_data_struct.cpp | 6 +- src/src/PluginStructs/P015_data_struct.h | 10 +- src/src/PluginStructs/P020_data_struct.cpp | 2 +- src/src/PluginStructs/P020_data_struct.h | 4 +- src/src/PluginStructs/P022_data_struct.cpp | 18 +-- src/src/PluginStructs/P022_data_struct.h | 4 +- src/src/PluginStructs/P023_data_struct.cpp | 6 +- src/src/PluginStructs/P023_data_struct.h | 20 +-- src/src/PluginStructs/P028_data_struct.cpp | 4 +- src/src/PluginStructs/P028_data_struct.h | 4 +- src/src/PluginStructs/P044_data_struct.cpp | 2 +- src/src/PluginStructs/P044_data_struct.h | 4 +- src/src/PluginStructs/P062_data_struct.cpp | 2 +- src/src/PluginStructs/P079_data_struct.cpp | 14 +- src/src/PluginStructs/P082_data_struct.h | 4 +- src/src/PluginStructs/P087_data_struct.cpp | 4 +- src/src/PluginStructs/P087_data_struct.h | 2 +- src/src/PluginStructs/P090_data_struct.cpp | 4 +- src/src/PluginStructs/P094_data_struct.cpp | 2 +- src/src/PluginStructs/P094_data_struct.h | 2 +- src/src/PluginStructs/P099_data_struct.h | 2 +- src/src/PluginStructs/P111_data_struct.cpp | 16 +-- src/src/PluginStructs/P111_data_struct.h | 14 +- src/src/PluginStructs/P112_data_struct.h | 2 +- src/src/WebServer/AdvancedConfigPage.cpp | 2 +- src/src/WebServer/CacheControllerPages.cpp | 8 +- src/src/WebServer/ConfigPage.cpp | 8 +- src/src/WebServer/ControllerPage.cpp | 12 +- src/src/WebServer/ControllerPage.h | 6 +- src/src/WebServer/CustomPage.cpp | 18 +-- src/src/WebServer/DevicesPage.cpp | 36 ++--- src/src/WebServer/DevicesPage.h | 6 +- src/src/WebServer/I2C_Scanner.cpp | 6 +- src/src/WebServer/I2C_Scanner.h | 2 +- src/src/WebServer/JSON.cpp | 14 +- src/src/WebServer/Log.cpp | 4 +- src/src/WebServer/Markup.cpp | 8 +- src/src/WebServer/Markup.h | 2 +- src/src/WebServer/Markup_Forms.cpp | 10 +- src/src/WebServer/Markup_Forms.h | 8 +- src/src/WebServer/NotificationPage.cpp | 16 +-- src/src/WebServer/Rules.cpp | 6 +- src/src/WebServer/SetupPage.cpp | 6 +- src/src/WebServer/SetupPage.h | 2 +- src/src/WebServer/UploadPage.cpp | 4 +- src/src/WebServer/WebServer.cpp | 26 ++-- src/src/WebServer/WebServer.h | 20 +-- 178 files changed, 1079 insertions(+), 1079 deletions(-) diff --git a/src/ESPEasy-Globals.h b/src/ESPEasy-Globals.h index 4cd5b871f..8e1118d44 100644 --- a/src/ESPEasy-Globals.h +++ b/src/ESPEasy-Globals.h @@ -60,9 +60,9 @@ struct pinStatesStruct { pinStatesStruct() : value(0), plugin(0), index(0), mode(0) {} uint16_t value; - byte plugin; - byte index; - byte mode; + uint8_t plugin; + uint8_t index; + uint8_t mode; } pinStates[PINSTATE_TABLE_MAX]; */ diff --git a/src/_Plugin_Helper.cpp b/src/_Plugin_Helper.cpp index 8734fb948..8a6e10733 100644 --- a/src/_Plugin_Helper.cpp +++ b/src/_Plugin_Helper.cpp @@ -86,12 +86,12 @@ String getPluginCustomArgName(int varNr) { // if the regular values should also be displayed. // The call to PLUGIN_WEBFORM_SHOW_VALUES should only return success = true when no regular values should be displayed // Note that the varNr of the custom values should not conflict with the existing variable numbers (e.g. start at VARS_PER_TASK) -void pluginWebformShowValue(taskIndex_t taskIndex, byte varNr, const __FlashStringHelper * label, const String& value, bool addTrailingBreak) { +void pluginWebformShowValue(taskIndex_t taskIndex, uint8_t varNr, const __FlashStringHelper * label, const String& value, bool addTrailingBreak) { pluginWebformShowValue(taskIndex, varNr, String(label), value, addTrailingBreak); } void pluginWebformShowValue(taskIndex_t taskIndex, - byte varNr, + uint8_t varNr, const String& label, const String& value, bool addTrailingBreak) { @@ -123,7 +123,7 @@ void pluginWebformShowValue(const String& valName, const String& valName_id, con } } -bool pluginOptionalTaskIndexArgumentMatch(taskIndex_t taskIndex, const String& string, byte paramNr) { +bool pluginOptionalTaskIndexArgumentMatch(taskIndex_t taskIndex, const String& string, uint8_t paramNr) { if (!validTaskIndex(taskIndex)) { return false; } diff --git a/src/_Plugin_Helper.h b/src/_Plugin_Helper.h index fc5af06e8..2dea469ab 100644 --- a/src/_Plugin_Helper.h +++ b/src/_Plugin_Helper.h @@ -114,13 +114,13 @@ String getPluginCustomArgName(int varNr); // The call to PLUGIN_WEBFORM_SHOW_VALUES should only return success = true when no regular values should be displayed // Note that the varNr of the custom values should not conflict with the existing variable numbers (e.g. start at VARS_PER_TASK) void pluginWebformShowValue(taskIndex_t taskIndex, - byte varNr, + uint8_t varNr, const __FlashStringHelper * label, const String& value, bool addTrailingBreak = false); void pluginWebformShowValue(taskIndex_t taskIndex, - byte varNr, + uint8_t varNr, const String& label, const String& value, bool addTrailingBreak = false); @@ -141,7 +141,7 @@ void pluginWebformShowValue(const String& valName, // Return if parameter at given paramNr matches given taskIndex. bool pluginOptionalTaskIndexArgumentMatch(taskIndex_t taskIndex, const String& string, - byte paramNr); + uint8_t paramNr); bool pluginWebformShowGPIOdescription(taskIndex_t taskIndex, const String& newline); diff --git a/src/src/Commands/Blynk.cpp b/src/src/Commands/Blynk.cpp index e1c41c94b..952c0b430 100644 --- a/src/src/Commands/Blynk.cpp +++ b/src/src/Commands/Blynk.cpp @@ -143,7 +143,7 @@ bool Blynk_get(const String& command, controllerIndex_t controllerIndex, float * if (data && line.startsWith("[")) { String strValue = line; - byte pos = strValue.indexOf('"', 2); + uint8_t pos = strValue.indexOf('"', 2); strValue = strValue.substring(2, pos); strValue.trim(); *data = 0.0f; diff --git a/src/src/Commands/Common.cpp b/src/src/Commands/Common.cpp index 32965c020..2316e6038 100644 --- a/src/src/Commands/Common.cpp +++ b/src/src/Commands/Common.cpp @@ -62,7 +62,7 @@ const __FlashStringHelper * return_see_serial(struct EventStruct *event) String Command_GetORSetIP(struct EventStruct *event, const String & targetDescription, const char *Line, - byte *IP, + uint8_t *IP, const IPAddress & dhcpIP, int arg) { diff --git a/src/src/Commands/Common.h b/src/src/Commands/Common.h index 4b5775f7f..aadf799f8 100644 --- a/src/src/Commands/Common.h +++ b/src/src/Commands/Common.h @@ -22,7 +22,7 @@ bool IsNumeric(const char *source); String Command_GetORSetIP(struct EventStruct *event, const String & targetDescription, const char *Line, - byte *IP, + uint8_t *IP, const IPAddress& dhcpIP, int arg); diff --git a/src/src/Commands/Diagnostic.cpp b/src/src/Commands/Diagnostic.cpp index b76bfe426..f20afbee9 100644 --- a/src/src/Commands/Diagnostic.cpp +++ b/src/src/Commands/Diagnostic.cpp @@ -159,7 +159,7 @@ const __FlashStringHelper * Command_Debug(struct EventStruct *event, const char const __FlashStringHelper * Command_logentry(struct EventStruct *event, const char *Line) { - byte level = LOG_LEVEL_INFO; + uint8_t level = LOG_LEVEL_INFO; // An extra optional parameter to set log level. if (event->Par2 > LOG_LEVEL_NONE && event->Par2 <= LOG_LEVEL_DEBUG_MORE) { level = event->Par2; } addLog(level, tolerantParseStringKeepCase(Line, 2)); diff --git a/src/src/Commands/GPIO.cpp b/src/src/Commands/GPIO.cpp index f2712b4ab..dbfc2ff80 100644 --- a/src/src/Commands/GPIO.cpp +++ b/src/src/Commands/GPIO.cpp @@ -21,7 +21,7 @@ // Forward declarations of functions used in this module // Normally those would be declared in the .h file as private members // But since these are not part of a class, forward declare them in the .cpp -//void createAndSetPortStatus_Mode_State(uint32_t key, byte newMode, int8_t newState); +//void createAndSetPortStatus_Mode_State(uint32_t key, uint8_t newMode, int8_t newState); bool getPluginIDAndPrefix(char selection, pluginID_t &pluginID, String &logPrefix); void logErrorGpioOffline(const String& prefix, int port); void logErrorGpioOutOfRange(const String& prefix, int port, const char* Line = nullptr); @@ -31,13 +31,13 @@ bool gpio_monitor_helper(int port, struct EventStruct *event, const char* Line); bool gpio_unmonitor_helper(int port, struct EventStruct *event, const char* Line); bool mcpgpio_range_pattern_helper(struct EventStruct *event, const char* Line, bool isWritePattern); bool pcfgpio_range_pattern_helper(struct EventStruct *event, const char* Line, bool isWritePattern); -bool gpio_mode_range_helper(byte pin, byte pinMode, struct EventStruct *event, const char* Line); -byte getPcfAddress(uint8_t pin); -bool setGPIOMode(byte pin, byte mode); -bool setPCFMode(byte pin, byte mode); -bool setMCPMode(byte pin, byte mode); -bool mcpgpio_plugin_range_helper(byte pin1, byte pin2, uint16_t &result); -bool pcfgpio_plugin_range_helper(byte pin1, byte pin2, uint16_t &result); +bool gpio_mode_range_helper(uint8_t pin, uint8_t pinMode, struct EventStruct *event, const char* Line); +uint8_t getPcfAddress(uint8_t pin); +bool setGPIOMode(uint8_t pin, uint8_t mode); +bool setPCFMode(uint8_t pin, uint8_t mode); +bool setMCPMode(uint8_t pin, uint8_t mode); +bool mcpgpio_plugin_range_helper(uint8_t pin1, uint8_t pin2, uint16_t &result); +bool pcfgpio_plugin_range_helper(uint8_t pin1, uint8_t pin2, uint16_t &result); /*************************************************************************/ @@ -56,7 +56,7 @@ const __FlashStringHelper * Command_GPIO_MonitorRange(struct EventStruct *event, { bool success = true; - for (byte i = event->Par2; i <= event->Par3; i++) { + for (uint8_t i = event->Par2; i <= event->Par3; i++) { success &= gpio_monitor_helper(i, event, Line); } return success ? return_command_success() : return_command_failed(); @@ -115,7 +115,7 @@ const __FlashStringHelper * Command_GPIO_UnMonitorRange(struct EventStruct *even { bool success = true; - for (byte i = event->Par2; i <= event->Par3; i++) { + for (uint8_t i = event->Par2; i <= event->Par3; i++) { success &= gpio_unmonitor_helper(i, event, Line); } return success ? return_command_success() : return_command_failed(); @@ -193,7 +193,7 @@ const __FlashStringHelper * Command_GPIO_Status(struct EventStruct *event, const { bool success = true; bool sendStatusFlag; - byte pluginID = 0; + uint8_t pluginID = 0; switch (tolower(parseString(Line, 2).charAt(0))) { @@ -278,7 +278,7 @@ const __FlashStringHelper * Command_GPIO_Tone(struct EventStruct *event, const c if (tone_espEasy(event->Par1, event->Par2, duration)) { if (mustScheduleToneOff) { // For now, we only support the internal GPIO pins. - byte pluginID = PLUGIN_GPIO; + uint8_t pluginID = PLUGIN_GPIO; Scheduler.setGPIOTimer(event->Par3, pluginID, event->Par1, 0); } return return_command_success(); @@ -318,7 +318,7 @@ const __FlashStringHelper * Command_GPIO_Pulse(struct EventStruct *event, const { const __FlashStringHelper * logPrefix = F(""); bool success = false; - byte pluginID = INVALID_PLUGIN_ID; + uint8_t pluginID = INVALID_PLUGIN_ID; switch (tolower(Line[0])) { @@ -383,7 +383,7 @@ const __FlashStringHelper * Command_GPIO_Toggle(struct EventStruct *event, const // WARNING: operator [] creates an entry in the map if key does not exist // So the next command should be part of each command: - byte mode; + uint8_t mode; int8_t state; auto it = globalMapPortStatus.find(key); @@ -438,7 +438,7 @@ const __FlashStringHelper * Command_GPIO(struct EventStruct *event, const char * if (success && checkValidPortRange(pluginID, event->Par1)) { int8_t state = 0; - byte mode; + uint8_t mode; if (event->Par2 == 2) { // INPUT mode = PIN_MODE_INPUT_PULLUP; @@ -529,7 +529,7 @@ void logErrorGpioNotOutput(const String& prefix, int port) logErrorGpio(prefix, port, F(" is not an output port")); } -void createAndSetPortStatus_Mode_State(uint32_t key, byte newMode, int8_t newState) +void createAndSetPortStatus_Mode_State(uint32_t key, uint8_t newMode, int8_t newState) { // WARNING: operator [] creates an entry in the map if key does not exist @@ -594,20 +594,20 @@ struct range_pattern_helper_data { uint32_t write = 0; uint32_t mask = 0; - byte firstPin = 0; - byte lastPin = 0; - byte numBytes = 0; - byte deltaStart = 0; - byte numBits = 0; - byte firstAddress = 0; - byte firstBank = 0; - byte initVal = 0; + uint8_t firstPin = 0; + uint8_t lastPin = 0; + uint8_t numBytes = 0; + uint8_t deltaStart = 0; + uint8_t numBits = 0; + uint8_t firstAddress = 0; + uint8_t firstBank = 0; + uint8_t initVal = 0; bool isMask = false; bool valid = false; }; -range_pattern_helper_data range_helper_shared(pluginID_t plugin, byte pin1, byte pin2) +range_pattern_helper_data range_helper_shared(pluginID_t plugin, uint8_t pin1, uint8_t pin2) { range_pattern_helper_data data; @@ -774,20 +774,20 @@ bool mcpgpio_range_pattern_helper(struct EventStruct *event, const char *Line, b bool onLine = false; String log; - for (byte i = 0; i < data.numBytes; i++) { + for (uint8_t i = 0; i < data.numBytes; i++) { uint8_t readValue; - byte currentVal = data.initVal + i; - byte currentAddress = static_cast(currentVal / 2); - byte currentMask = (data.mask >> (8 * i)) & 0xFF; - byte currentInvertedMask = 0xFF - currentMask; - byte currentWrite = (data.write >> (8 * i)) & 0xFF; - byte currentGPIORegister = ((currentVal % 2) == 0) ? MCP23017_GPIOA : MCP23017_GPIOB; - byte currentIOModeRegister = ((currentVal % 2) == 0) ? MCP23017_IODIRA : MCP23017_IODIRB; - byte writeGPIOValue = 0; + uint8_t currentVal = data.initVal + i; + uint8_t currentAddress = static_cast(currentVal / 2); + uint8_t currentMask = (data.mask >> (8 * i)) & 0xFF; + uint8_t currentInvertedMask = 0xFF - currentMask; + uint8_t currentWrite = (data.write >> (8 * i)) & 0xFF; + uint8_t currentGPIORegister = ((currentVal % 2) == 0) ? MCP23017_GPIOA : MCP23017_GPIOB; + uint8_t currentIOModeRegister = ((currentVal % 2) == 0) ? MCP23017_IODIRA : MCP23017_IODIRB; + uint8_t writeGPIOValue = 0; if (GPIO_MCP_ReadRegister(currentAddress, currentIOModeRegister, &readValue)) { // set type to output only for the pins of the mask - byte writeModeValue = (readValue & currentInvertedMask); + uint8_t writeModeValue = (readValue & currentInvertedMask); GPIO_MCP_WriteRegister(currentAddress, currentIOModeRegister, writeModeValue); GPIO_MCP_ReadRegister(currentAddress, currentGPIORegister, &readValue); @@ -800,16 +800,16 @@ bool mcpgpio_range_pattern_helper(struct EventStruct *event, const char *Line, b onLine = false; } - byte mode = (onLine) ? PIN_MODE_OUTPUT : PIN_MODE_OFFLINE; + uint8_t mode = (onLine) ? PIN_MODE_OUTPUT : PIN_MODE_OFFLINE; int8_t state; - for (byte j = 0; j < 8; j++) { - // if ((currentMask & (byte(pow(2,j)))) >> j) { //only for the pins in the mask + for (uint8_t j = 0; j < 8; j++) { + // if ((currentMask & (uint8_t(pow(2,j)))) >> j) { //only for the pins in the mask if ((currentMask & (1 << j)) >> j) { // only for the pins in the mask - byte currentPin = data.firstPin + j + 8 * i; + uint8_t currentPin = data.firstPin + j + 8 * i; const uint32_t key = createKey(PLUGIN_MCP, currentPin); - // state = onLine ? ((writeGPIOValue & byte(pow(2,j))) >> j) : -1; + // state = onLine ? ((writeGPIOValue & uint8_t(pow(2,j))) >> j) : -1; state = onLine ? ((writeGPIOValue & (1 << j)) >> j) : -1; createAndSetPortStatus_Mode_State(key, mode, state); @@ -822,9 +822,9 @@ bool mcpgpio_range_pattern_helper(struct EventStruct *event, const char *Line, b return onLine; } -byte getPcfAddress(uint8_t pin) +uint8_t getPcfAddress(uint8_t pin) { - byte retValue = static_cast((pin - 1) / 8) + 0x20; + uint8_t retValue = static_cast((pin - 1) / 8) + 0x20; if (retValue > 0x27) { retValue += 0x10; } return retValue; @@ -841,24 +841,24 @@ bool pcfgpio_range_pattern_helper(struct EventStruct *event, const char *Line, b bool onLine = false; String log; - for (byte i = 0; i < data.numBytes; i++) { + for (uint8_t i = 0; i < data.numBytes; i++) { uint8_t readValue; - byte currentAddress = getPcfAddress(event->Par1 + 8 * i); + uint8_t currentAddress = getPcfAddress(event->Par1 + 8 * i); - byte currentMask = (data.mask >> (8 * i)) & 0xFF; - byte currentInvertedMask = 0xFF - currentMask; - byte currentWrite = (data.write >> (8 * i)) & 0xFF; - byte writeGPIOValue = 255; + uint8_t currentMask = (data.mask >> (8 * i)) & 0xFF; + uint8_t currentInvertedMask = 0xFF - currentMask; + uint8_t currentWrite = (data.write >> (8 * i)) & 0xFF; + uint8_t writeGPIOValue = 255; onLine = GPIO_PCF_ReadAllPins(currentAddress, &readValue); if (onLine) { writeGPIOValue = (readValue & currentInvertedMask) | (currentWrite & data.mask); } - byte mode = (onLine) ? PIN_MODE_OUTPUT : PIN_MODE_OFFLINE; + uint8_t mode = (onLine) ? PIN_MODE_OUTPUT : PIN_MODE_OFFLINE; int8_t state; - for (byte j = 0; j < 8; j++) { - byte currentPin = data.firstPin + j + 8 * i; + for (uint8_t j = 0; j < 8; j++) { + uint8_t currentPin = data.firstPin + j + 8 * i; const uint32_t key = createKey(PLUGIN_PCF, currentPin); if ((currentMask & (1 << j)) >> j) { // only for the pins in the mask @@ -888,7 +888,7 @@ bool pcfgpio_range_pattern_helper(struct EventStruct *event, const char *Line, b return onLine; } -bool setGPIOMode(byte pin, byte mode) +bool setGPIOMode(uint8_t pin, uint8_t mode) { if (checkValidPortRange(PLUGIN_GPIO, pin)) { switch (mode) { @@ -908,7 +908,7 @@ bool setGPIOMode(byte pin, byte mode) } } -bool setMCPMode(byte pin, byte mode) +bool setMCPMode(uint8_t pin, uint8_t mode) { if (checkValidPortRange(PLUGIN_MCP, pin)) { switch (mode) { @@ -928,7 +928,7 @@ bool setMCPMode(byte pin, byte mode) } } -bool setPCFMode(byte pin, byte mode) +bool setPCFMode(uint8_t pin, uint8_t mode) { if (checkValidPortRange(PLUGIN_PCF, pin)) { switch (mode) { @@ -967,13 +967,13 @@ const __FlashStringHelper * Command_GPIO_ModeRange(struct EventStruct *event, co { bool success = true; - for (byte i = event->Par1; i <= event->Par2; i++) { + for (uint8_t i = event->Par1; i <= event->Par2; i++) { success &= gpio_mode_range_helper(i, event->Par3, event, Line); } return success ? return_command_success() : return_command_failed(); } -bool gpio_mode_range_helper(byte pin, byte pinMode, struct EventStruct *event, const char *Line) +bool gpio_mode_range_helper(uint8_t pin, uint8_t pinMode, struct EventStruct *event, const char *Line) { String logPrefix; // = new char; String logPostfix; // = new char; @@ -985,7 +985,7 @@ bool gpio_mode_range_helper(byte pin, byte pinMode, struct EventStruct *event, c if (success && checkValidPortRange(pluginID, pin)) { // int8_t state=0; - byte mode = 255; + uint8_t mode = 255; // bool setSuccess=false; @@ -1158,7 +1158,7 @@ bool getGPIOPinStateValues(String& str) { return success; } -bool mcpgpio_plugin_range_helper(byte pin1, byte pin2, uint16_t& result) +bool mcpgpio_plugin_range_helper(uint8_t pin1, uint8_t pin2, uint16_t& result) { const range_pattern_helper_data data = range_helper_shared(PLUGIN_MCP, pin1, pin2); @@ -1172,11 +1172,11 @@ bool mcpgpio_plugin_range_helper(byte pin1, byte pin2, uint16_t& result) bool success = false; uint32_t tempResult = 0; - for (byte i = 0; i < data.numBytes; i++) { + for (uint8_t i = 0; i < data.numBytes; i++) { uint8_t readValue = 0; - const byte currentVal = data.initVal + i; - const byte currentAddress = static_cast(currentVal / 2); - const byte currentGPIORegister = ((currentVal % 2) == 0) ? MCP23017_GPIOA : MCP23017_GPIOB; + const uint8_t currentVal = data.initVal + i; + const uint8_t currentAddress = static_cast(currentVal / 2); + const uint8_t currentGPIORegister = ((currentVal % 2) == 0) ? MCP23017_GPIOA : MCP23017_GPIOB; const bool onLine = GPIO_MCP_ReadRegister(currentAddress, currentGPIORegister, &readValue); @@ -1193,7 +1193,7 @@ bool mcpgpio_plugin_range_helper(byte pin1, byte pin2, uint16_t& result) return success; } -bool pcfgpio_plugin_range_helper(byte pin1, byte pin2, uint16_t& result) +bool pcfgpio_plugin_range_helper(uint8_t pin1, uint8_t pin2, uint16_t& result) { const range_pattern_helper_data data = range_helper_shared(PLUGIN_PCF, pin1, pin2); @@ -1208,9 +1208,9 @@ bool pcfgpio_plugin_range_helper(byte pin1, byte pin2, uint16_t& result) bool success = false; uint32_t tempResult = 0; - for (byte i = 0; i < data.numBytes; i++) { + for (uint8_t i = 0; i < data.numBytes; i++) { uint8_t readValue = 0; - const byte currentAddress = getPcfAddress(pin1 + 8 * i); + const uint8_t currentAddress = getPcfAddress(pin1 + 8 * i); const bool onLine = GPIO_PCF_ReadAllPins(currentAddress, &readValue); diff --git a/src/src/Commands/GPIO.h b/src/src/Commands/GPIO.h index a1be38fbe..155513c3c 100644 --- a/src/src/Commands/GPIO.h +++ b/src/src/Commands/GPIO.h @@ -15,7 +15,7 @@ // FIXME TD-er: This fwd declaration should not be in .h file. // Only needed till GPIO can be set from ESPEasy core. -void createAndSetPortStatus_Mode_State(uint32_t key, byte newMode, int8_t newState); +void createAndSetPortStatus_Mode_State(uint32_t key, uint8_t newMode, int8_t newState); const __FlashStringHelper * Command_GPIO(struct EventStruct *event, const char* Line); diff --git a/src/src/Commands/Tasks.cpp b/src/src/Commands/Tasks.cpp index aa5d25f07..3e5a80462 100644 --- a/src/src/Commands/Tasks.cpp +++ b/src/src/Commands/Tasks.cpp @@ -58,7 +58,7 @@ bool validateAndParseTaskValueArguments(struct EventStruct * event, const char * String valueName; if ((event->Par2 <= 0 || event->Par2 >= VARS_PER_TASK) && event->Par1 - 1 != INVALID_TASK_INDEX && GetArgv(Line, valueName, 3)) { - byte tmpVarNr = findDeviceValueIndexByName(valueName, event->Par1 - 1); + uint8_t tmpVarNr = findDeviceValueIndexByName(valueName, event->Par1 - 1); if (tmpVarNr != VARS_PER_TASK) { event->Par2 = tmpVarNr + 1; } diff --git a/src/src/Commands/UDP.cpp b/src/src/Commands/UDP.cpp index 280b944b0..b1799b1db 100644 --- a/src/src/Commands/UDP.cpp +++ b/src/src/Commands/UDP.cpp @@ -15,7 +15,7 @@ const __FlashStringHelper * Command_UDP_Test(struct EventStruct *event, const char *Line) { - for (byte x = 0; x < event->Par2; x++) + for (uint8_t x = 0; x < event->Par2; x++) { String eventName = "Test "; eventName += x; diff --git a/src/src/Commands/i2c.cpp b/src/src/Commands/i2c.cpp index bab7bdc96..eb64ce74c 100644 --- a/src/src/Commands/i2c.cpp +++ b/src/src/Commands/i2c.cpp @@ -9,7 +9,7 @@ const __FlashStringHelper * Command_i2c_Scanner(struct EventStruct *event, const char* Line) { - byte error, address; + uint8_t error, address; for (address = 1; address <= 127; address++) { Wire.beginTransmission(address); error = Wire.endTransmission(); diff --git a/src/src/Commands/wd.cpp b/src/src/Commands/wd.cpp index 8f775b984..165eb4286 100644 --- a/src/src/Commands/wd.cpp +++ b/src/src/Commands/wd.cpp @@ -28,7 +28,7 @@ String Command_WD_Read(EventStruct *event, const char* Line) Wire.endTransmission(); if ( Wire.requestFrom(static_cast(event->Par1), static_cast(1)) == 1 ) { - byte value = Wire.read(); + uint8_t value = Wire.read(); serialPrintln(); String result = F("I2C Read address "); result += formatToHex(event->Par1); diff --git a/src/src/ControllerQueue/C015_queue_element.cpp b/src/src/ControllerQueue/C015_queue_element.cpp index 0b72317e5..9ea5e72c2 100644 --- a/src/src/ControllerQueue/C015_queue_element.cpp +++ b/src/src/ControllerQueue/C015_queue_element.cpp @@ -9,13 +9,13 @@ C015_queue_element::C015_queue_element(C015_queue_element&& other) , controller_idx(other.controller_idx), valuesSent(other.valuesSent) , valueCount(other.valueCount) { - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { txt[i] = std::move(other.txt[i]); vPin[i] = other.vPin[i]; } } -C015_queue_element::C015_queue_element(const struct EventStruct *event, byte value_count) : +C015_queue_element::C015_queue_element(const struct EventStruct *event, uint8_t value_count) : idx(event->idx), TaskIndex(event->TaskIndex), controller_idx(event->ControllerIndex), @@ -44,7 +44,7 @@ bool C015_queue_element::isDuplicate(const C015_queue_element& other) const { return false; } - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { if (other.txt[i] != txt[i]) { return false; } diff --git a/src/src/ControllerQueue/C015_queue_element.h b/src/src/ControllerQueue/C015_queue_element.h index cee9083ec..c30d353dc 100644 --- a/src/src/ControllerQueue/C015_queue_element.h +++ b/src/src/ControllerQueue/C015_queue_element.h @@ -25,7 +25,7 @@ public: C015_queue_element(C015_queue_element&& other); - C015_queue_element(const struct EventStruct *event, byte value_count); + C015_queue_element(const struct EventStruct *event, uint8_t value_count); bool checkDone(bool succesfull) const; @@ -41,8 +41,8 @@ public: unsigned long _timestamp = millis(); taskIndex_t TaskIndex = INVALID_TASK_INDEX; controllerIndex_t controller_idx = INVALID_CONTROLLER_INDEX; - mutable byte valuesSent = 0; // Value must be set by const function checkDone() - byte valueCount = 0; + mutable uint8_t valuesSent = 0; // Value must be set by const function checkDone() + uint8_t valueCount = 0; }; #endif //USES_C015 diff --git a/src/src/ControllerQueue/C016_queue_element.cpp b/src/src/ControllerQueue/C016_queue_element.cpp index 6721f5a68..6321a762a 100644 --- a/src/src/ControllerQueue/C016_queue_element.cpp +++ b/src/src/ControllerQueue/C016_queue_element.cpp @@ -16,19 +16,19 @@ C016_queue_element::C016_queue_element(C016_queue_element&& other) , sensorType(other.sensorType) , valueCount(other.valueCount) { - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { values[i] = other.values[i]; } } -C016_queue_element::C016_queue_element(const struct EventStruct *event, byte value_count, unsigned long unixTime) : +C016_queue_element::C016_queue_element(const struct EventStruct *event, uint8_t value_count, unsigned long unixTime) : _timestamp(unixTime), TaskIndex(event->TaskIndex), controller_idx(event->ControllerIndex), sensorType(event->sensorType), valueCount(value_count) { - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { if (i < value_count) { values[i] = UserVar[event->BaseVarIndex + i]; } else { @@ -43,7 +43,7 @@ C016_queue_element& C016_queue_element::operator=(C016_queue_element&& other) { controller_idx = other.controller_idx; sensorType = other.sensorType; valueCount = other.valueCount; - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { values[i] = other.values[i]; } return *this; @@ -61,7 +61,7 @@ bool C016_queue_element::isDuplicate(const C016_queue_element& other) const { return false; } - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { if (other.values[i] != values[i]) { return false; } diff --git a/src/src/ControllerQueue/C016_queue_element.h b/src/src/ControllerQueue/C016_queue_element.h index cae74dbe6..72f2b66d3 100644 --- a/src/src/ControllerQueue/C016_queue_element.h +++ b/src/src/ControllerQueue/C016_queue_element.h @@ -16,7 +16,7 @@ struct EventStruct; * C016_queue_element for queueing requests for C016: Cached HTTP. \*********************************************************************************************/ -// TD-er: This one has a fixed byte order and is stored. +// TD-er: This one has a fixed uint8_t order and is stored. // This also means the order of members should not be changed! class C016_queue_element { public: @@ -26,7 +26,7 @@ public: C016_queue_element(C016_queue_element&& other); C016_queue_element(const struct EventStruct *event, - byte value_count, + uint8_t value_count, unsigned long unixTime); C016_queue_element& operator=(C016_queue_element&& other); @@ -43,7 +43,7 @@ public: taskIndex_t TaskIndex = INVALID_TASK_INDEX; controllerIndex_t controller_idx = INVALID_CONTROLLER_INDEX; Sensor_VType sensorType = Sensor_VType::SENSOR_TYPE_NONE; - byte valueCount = 0; + uint8_t valueCount = 0; }; #endif //USES_C016 diff --git a/src/src/ControllerQueue/ControllerDelayHandlerStruct.h b/src/src/ControllerQueue/ControllerDelayHandlerStruct.h index adb3fe347..629bc868f 100644 --- a/src/src/ControllerQueue/ControllerDelayHandlerStruct.h +++ b/src/src/ControllerQueue/ControllerDelayHandlerStruct.h @@ -244,9 +244,9 @@ struct ControllerDelayHandlerStruct { unsigned long lastSend; unsigned int minTimeBetweenMessages; unsigned long expire_timeout = 0; - byte max_queue_depth; - byte attempt; - byte max_retries; + uint8_t max_queue_depth; + uint8_t attempt; + uint8_t max_retries; bool delete_oldest; bool must_check_reply; bool deduplicate; diff --git a/src/src/ControllerQueue/queue_element_formatted_uservar.cpp b/src/src/ControllerQueue/queue_element_formatted_uservar.cpp index cf247f927..19a9b1127 100644 --- a/src/src/ControllerQueue/queue_element_formatted_uservar.cpp +++ b/src/src/ControllerQueue/queue_element_formatted_uservar.cpp @@ -27,7 +27,7 @@ queue_element_formatted_uservar::queue_element_formatted_uservar(EventStruct *ev { valueCount = getValueCountForTask(TaskIndex); - for (byte i = 0; i < valueCount; ++i) { + for (uint8_t i = 0; i < valueCount; ++i) { txt[i] = formatUserVarNoCheck(event, i); } } @@ -67,7 +67,7 @@ bool queue_element_formatted_uservar::isDuplicate(const queue_element_formatted_ return false; } - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { if (other.txt[i] != txt[i]) { return false; } diff --git a/src/src/ControllerQueue/queue_element_formatted_uservar.h b/src/src/ControllerQueue/queue_element_formatted_uservar.h index 97daf3983..fed79983b 100644 --- a/src/src/ControllerQueue/queue_element_formatted_uservar.h +++ b/src/src/ControllerQueue/queue_element_formatted_uservar.h @@ -38,7 +38,7 @@ public: taskIndex_t TaskIndex = INVALID_TASK_INDEX; controllerIndex_t controller_idx = INVALID_CONTROLLER_INDEX; Sensor_VType sensorType = Sensor_VType::SENSOR_TYPE_NONE; - byte valueCount = 0; + uint8_t valueCount = 0; }; #endif // CONTROLLERQUEUE_QUEUE_ELEMENT_FORMATTED_USERVAR_H diff --git a/src/src/ControllerQueue/queue_element_single_value_base.cpp b/src/src/ControllerQueue/queue_element_single_value_base.cpp index f5760df2f..a22e30342 100644 --- a/src/src/ControllerQueue/queue_element_single_value_base.cpp +++ b/src/src/ControllerQueue/queue_element_single_value_base.cpp @@ -2,7 +2,7 @@ #include "../DataStructs/ESPEasy_EventStruct.h" -queue_element_single_value_base::queue_element_single_value_base(const struct EventStruct *event, byte value_count) : +queue_element_single_value_base::queue_element_single_value_base(const struct EventStruct *event, uint8_t value_count) : idx(event->idx), TaskIndex(event->TaskIndex), controller_idx(event->ControllerIndex), @@ -14,7 +14,7 @@ queue_element_single_value_base::queue_element_single_value_base(queue_element_s controller_idx(rval.controller_idx), valuesSent(rval.valuesSent), valueCount(rval.valueCount) { - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { txt[i] = std::move(rval.txt[i]); } } @@ -30,7 +30,7 @@ queue_element_single_value_base& queue_element_single_value_base::operator=(queu HeapSelectIram ephemeral; #endif // ifdef USE_SECOND_HEAP - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { txt[i] = std::move(rval.txt[i]); } return *this; @@ -58,7 +58,7 @@ bool queue_element_single_value_base::isDuplicate(const queue_element_single_val return false; } - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { if (other.txt[i] != txt[i]) { return false; } diff --git a/src/src/ControllerQueue/queue_element_single_value_base.h b/src/src/ControllerQueue/queue_element_single_value_base.h index b5fc5d3ed..67990184b 100644 --- a/src/src/ControllerQueue/queue_element_single_value_base.h +++ b/src/src/ControllerQueue/queue_element_single_value_base.h @@ -20,7 +20,7 @@ public: queue_element_single_value_base() = default; queue_element_single_value_base(const struct EventStruct *event, - byte value_count); + uint8_t value_count); queue_element_single_value_base(const queue_element_single_value_base& rval) = delete; @@ -44,8 +44,8 @@ public: unsigned long _timestamp = millis(); taskIndex_t TaskIndex = INVALID_TASK_INDEX; controllerIndex_t controller_idx = INVALID_CONTROLLER_INDEX; - mutable byte valuesSent = 0; // Value must be set by const function checkDone() - byte valueCount = 0; + mutable uint8_t valuesSent = 0; // Value must be set by const function checkDone() + uint8_t valueCount = 0; }; diff --git a/src/src/DataStructs/C013_p2p_dataStructs.h b/src/src/DataStructs/C013_p2p_dataStructs.h index 12b324d01..e8b11fe36 100644 --- a/src/src/DataStructs/C013_p2p_dataStructs.h +++ b/src/src/DataStructs/C013_p2p_dataStructs.h @@ -15,10 +15,10 @@ struct C013_SensorInfoStruct bool isValid() const; - byte header = 255; - byte ID = 3; - byte sourceUnit = 0; - byte destUnit = 0; + uint8_t header = 255; + uint8_t ID = 3; + uint8_t sourceUnit = 0; + uint8_t destUnit = 0; taskIndex_t sourceTaskIndex = INVALID_TASK_INDEX; taskIndex_t destTaskIndex = INVALID_TASK_INDEX; pluginID_t deviceNumber = INVALID_PLUGIN_ID; @@ -32,10 +32,10 @@ struct C013_SensorDataStruct bool isValid() const; - byte header = 255; - byte ID = 5; - byte sourceUnit = 0; - byte destUnit = 0; + uint8_t header = 255; + uint8_t ID = 5; + uint8_t sourceUnit = 0; + uint8_t destUnit = 0; taskIndex_t sourceTaskIndex = INVALID_TASK_INDEX; taskIndex_t destTaskIndex = INVALID_TASK_INDEX; float Values[VARS_PER_TASK]; diff --git a/src/src/DataStructs/Caches.h b/src/src/DataStructs/Caches.h index f75d18153..4960c0436 100644 --- a/src/src/DataStructs/Caches.h +++ b/src/src/DataStructs/Caches.h @@ -6,7 +6,7 @@ #include "../Globals/Plugins.h" typedef std::mapTaskIndexNameMap; -typedef std::map TaskIndexValueNameMap; +typedef std::map TaskIndexValueNameMap; typedef std::map FilePresenceMap; struct Caches { diff --git a/src/src/DataStructs/ControllerSettingsStruct.cpp b/src/src/DataStructs/ControllerSettingsStruct.cpp index ebb4b21cd..1f54f11ce 100644 --- a/src/src/DataStructs/ControllerSettingsStruct.cpp +++ b/src/src/DataStructs/ControllerSettingsStruct.cpp @@ -31,7 +31,7 @@ void ControllerSettingsStruct::reset() { SampleSetInitiator = INVALID_TASK_INDEX; VariousFlags = 0; - for (byte i = 0; i < 4; ++i) { + for (uint8_t i = 0; i < 4; ++i) { IP[i] = 0; } ZERO_FILL(HostName); @@ -119,7 +119,7 @@ bool ControllerSettingsStruct::connectToHost(WiFiClient& client) { if (!checkHostReachable(true)) { return false; // Host not reachable } - byte retry = 2; + uint8_t retry = 2; bool connected = false; while (retry > 0 && !connected) { @@ -139,7 +139,7 @@ bool ControllerSettingsStruct::beginPacket(WiFiUDP& client) { if (!checkHostReachable(true)) { return false; // Host not reachable } - byte retry = 2; + uint8_t retry = 2; while (retry > 0) { --retry; FeedSW_watchdog(); @@ -164,7 +164,7 @@ String ControllerSettingsStruct::getHostPortString() const { } bool ControllerSettingsStruct::ipSet() const { - for (byte i = 0; i < 4; ++i) { + for (uint8_t i = 0; i < 4; ++i) { if (IP[i] != 0) { return true; } } return false; @@ -179,7 +179,7 @@ bool ControllerSettingsStruct::updateIPcache() { IPAddress tmpIP; if (resolveHostByName(HostName, tmpIP, ClientTimeout)) { - for (byte x = 0; x < 4; x++) { + for (uint8_t x = 0; x < 4; x++) { IP[x] = tmpIP[x]; } return true; diff --git a/src/src/DataStructs/ControllerSettingsStruct.h b/src/src/DataStructs/ControllerSettingsStruct.h index 25c1d64e5..694acd020 100644 --- a/src/src/DataStructs/ControllerSettingsStruct.h +++ b/src/src/DataStructs/ControllerSettingsStruct.h @@ -143,7 +143,7 @@ struct ControllerSettingsStruct void deduplicate(bool value); boolean UseDNS; - byte IP[4]; + uint8_t IP[4]; unsigned int Port; char HostName[65]; char Publish[129]; diff --git a/src/src/DataStructs/DeviceStruct.h b/src/src/DataStructs/DeviceStruct.h index b26a6af4a..4daaa2566 100644 --- a/src/src/DataStructs/DeviceStruct.h +++ b/src/src/DataStructs/DeviceStruct.h @@ -32,7 +32,7 @@ #define I2C_FLAGS_MUX_MULTICHANNEL 1 // Allow multiple multiplexer channels when set -enum class Sensor_VType : byte { +enum class Sensor_VType : uint8_t { SENSOR_TYPE_NONE = 0, SENSOR_TYPE_SINGLE = 1, SENSOR_TYPE_TEMP_HUM = 2, @@ -51,7 +51,7 @@ enum class Sensor_VType : byte { SENSOR_TYPE_NOT_SET = 255 }; -enum class Output_Data_type_t : byte { +enum class Output_Data_type_t : uint8_t { Default = 0, Simple, // SENSOR_TYPE_SINGLE, _DUAL, _TRIPLE, _QUAD All @@ -71,11 +71,11 @@ struct DeviceStruct bool configurableDecimals() const; - byte Number; // Plugin ID number. (PLUGIN_ID_xxx) - byte Type; // How the device is connected. e.g. DEVICE_TYPE_SINGLE => connected through 1 datapin + uint8_t Number; // Plugin ID number. (PLUGIN_ID_xxx) + uint8_t Type; // How the device is connected. e.g. DEVICE_TYPE_SINGLE => connected through 1 datapin Sensor_VType VType; // Type of value the plugin will return. e.g. SENSOR_TYPE_STRING - byte Ports; // Port to use when device has multiple I/O pins (N.B. not used much) - byte ValueCount; // The number of output values of a plugin. The value should match the number of keys PLUGIN_VALUENAME1_xxx + uint8_t Ports; // Port to use when device has multiple I/O pins (N.B. not used much) + uint8_t ValueCount; // The number of output values of a plugin. The value should match the number of keys PLUGIN_VALUENAME1_xxx Output_Data_type_t OutputDataType; // Subset of selectable output data types (Default = no selection) bool PullUpOption : 1; // Allow to set internal pull-up resistors. diff --git a/src/src/DataStructs/ESPEasy_EventStruct.h b/src/src/DataStructs/ESPEasy_EventStruct.h index 48965b859..8f602a8df 100644 --- a/src/src/DataStructs/ESPEasy_EventStruct.h +++ b/src/src/DataStructs/ESPEasy_EventStruct.h @@ -50,7 +50,7 @@ public: String String3; String String4; String String5; - byte *Data = nullptr; + uint8_t *Data = nullptr; int idx = 0; int Par1 = 0; int Par2 = 0; @@ -63,9 +63,9 @@ public: taskIndex_t TaskIndex = INVALID_TASK_INDEX; // index position in TaskSettings array, 0-11 controllerIndex_t ControllerIndex = INVALID_CONTROLLER_INDEX; // index position in Settings.Controller, 0-3 notifierIndex_t NotificationIndex = INVALID_NOTIFIER_INDEX; // index position in Settings.Notification, 0-3 - byte BaseVarIndex = 0; + uint8_t BaseVarIndex = 0; Sensor_VType sensorType = Sensor_VType::SENSOR_TYPE_NOT_SET; - byte OriginTaskIndex = 0; + uint8_t OriginTaskIndex = 0; }; #endif // ESPEASY_EVENTSTRUCT_H diff --git a/src/src/DataStructs/ESPEasy_packed_raw_data.cpp b/src/src/DataStructs/ESPEasy_packed_raw_data.cpp index 335147b6d..317c995a2 100644 --- a/src/src/DataStructs/ESPEasy_packed_raw_data.cpp +++ b/src/src/DataStructs/ESPEasy_packed_raw_data.cpp @@ -34,21 +34,21 @@ uint8_t getPackedDataTypeSize(PackedData_enum dtype, float& factor, float& offse return 0; } -void LoRa_uintToBytes(uint64_t value, uint8_t byteSize, byte *data, uint8_t& cursor) { +void LoRa_uintToBytes(uint64_t value, uint8_t byteSize, uint8_t *data, uint8_t& cursor) { // Clip values to upper limit const uint64_t upperlimit = (1ull << (8*byteSize)) - 1; if (value > upperlimit) { value = upperlimit; } for (uint8_t x = 0; x < byteSize; x++) { - byte next = 0; + uint8_t next = 0; if (sizeof(value) > x) { - next = static_cast((value >> (x * 8)) & 0xFF); + next = static_cast((value >> (x * 8)) & 0xFF); } data[cursor] = next; ++cursor; } } -void LoRa_intToBytes(int64_t value, uint8_t byteSize, byte *data, uint8_t& cursor) { +void LoRa_intToBytes(int64_t value, uint8_t byteSize, uint8_t *data, uint8_t& cursor) { // Clip values to lower limit const int64_t lowerlimit = (1ull << ((8*byteSize) - 1)) * -1; if (value < lowerlimit) { value = lowerlimit; } @@ -58,7 +58,7 @@ void LoRa_intToBytes(int64_t value, uint8_t byteSize, byte *data, uint8_t& curso LoRa_uintToBytes(value, byteSize, data, cursor); } -String LoRa_base16Encode(byte *data, size_t size) { +String LoRa_base16Encode(uint8_t *data, size_t size) { String output; output.reserve(size * 2); char buffer[3]; @@ -74,7 +74,7 @@ String LoRa_base16Encode(byte *data, size_t size) { String LoRa_addInt(uint64_t value, PackedData_enum datatype) { float factor, offset; uint8_t byteSize = getPackedDataTypeSize(datatype, factor, offset); - byte data[4] = {0}; + uint8_t data[4] = {0}; uint8_t cursor = 0; LoRa_uintToBytes((value + offset) * factor, byteSize, &data[0], cursor); return LoRa_base16Encode(data, cursor); @@ -84,7 +84,7 @@ String LoRa_addInt(uint64_t value, PackedData_enum datatype) { String LoRa_addFloat(float value, PackedData_enum datatype) { float factor, offset; uint8_t byteSize = getPackedDataTypeSize(datatype, factor, offset); - byte data[4] = {0}; + uint8_t data[4] = {0}; uint8_t cursor = 0; LoRa_intToBytes((value + offset) * factor, byteSize, &data[0], cursor); return LoRa_base16Encode(data, cursor); diff --git a/src/src/DataStructs/ESPEasy_packed_raw_data.h b/src/src/DataStructs/ESPEasy_packed_raw_data.h index 1764d4be2..2512c11e8 100644 --- a/src/src/DataStructs/ESPEasy_packed_raw_data.h +++ b/src/src/DataStructs/ESPEasy_packed_raw_data.h @@ -69,11 +69,11 @@ typedef uint32_t PackedData_enum; uint8_t getPackedDataTypeSize(PackedData_enum dtype, float& factor, float& offset); -void LoRa_uintToBytes(uint64_t value, uint8_t byteSize, byte *data, uint8_t& cursor); +void LoRa_uintToBytes(uint64_t value, uint8_t byteSize, uint8_t *data, uint8_t& cursor); -void LoRa_intToBytes(int64_t value, uint8_t byteSize, byte *data, uint8_t& cursor); +void LoRa_intToBytes(int64_t value, uint8_t byteSize, uint8_t *data, uint8_t& cursor); -String LoRa_base16Encode(byte *data, size_t size); +String LoRa_base16Encode(uint8_t *data, size_t size); String LoRa_addInt(uint64_t value, PackedData_enum datatype); diff --git a/src/src/DataStructs/ExtraTaskSettingsStruct.cpp b/src/src/DataStructs/ExtraTaskSettingsStruct.cpp index 6f28976e1..eb5b18494 100644 --- a/src/src/DataStructs/ExtraTaskSettingsStruct.cpp +++ b/src/src/DataStructs/ExtraTaskSettingsStruct.cpp @@ -10,13 +10,13 @@ void ExtraTaskSettingsStruct::clear() { TaskIndex = INVALID_TASK_INDEX; ZERO_FILL(TaskDeviceName); - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { TaskDeviceValueDecimals[i] = 2; ZERO_FILL(TaskDeviceFormula[i]); ZERO_FILL(TaskDeviceValueNames[i]); } - for (byte i = 0; i < PLUGIN_EXTRACONFIGVAR_MAX; ++i) { + for (uint8_t i = 0; i < PLUGIN_EXTRACONFIGVAR_MAX; ++i) { TaskDevicePluginConfigLong[i] = 0; TaskDevicePluginConfig[i] = 0; } @@ -25,7 +25,7 @@ void ExtraTaskSettingsStruct::clear() { void ExtraTaskSettingsStruct::validate() { ZERO_TERMINATE(TaskDeviceName); - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { ZERO_TERMINATE(TaskDeviceFormula[i]); ZERO_TERMINATE(TaskDeviceValueNames[i]); } @@ -44,8 +44,8 @@ bool ExtraTaskSettingsStruct::checkUniqueValueNames() const { return true; } -void ExtraTaskSettingsStruct::clearUnusedValueNames(byte usedVars) { - for (byte i = usedVars; i < VARS_PER_TASK; ++i) { +void ExtraTaskSettingsStruct::clearUnusedValueNames(uint8_t usedVars) { + for (uint8_t i = usedVars; i < VARS_PER_TASK; ++i) { TaskDeviceValueDecimals[i] = 2; ZERO_FILL(TaskDeviceFormula[i]); ZERO_FILL(TaskDeviceValueNames[i]); diff --git a/src/src/DataStructs/ExtraTaskSettingsStruct.h b/src/src/DataStructs/ExtraTaskSettingsStruct.h index 550d9fbb7..7da577043 100644 --- a/src/src/DataStructs/ExtraTaskSettingsStruct.h +++ b/src/src/DataStructs/ExtraTaskSettingsStruct.h @@ -24,7 +24,7 @@ struct ExtraTaskSettingsStruct bool checkUniqueValueNames() const; - void clearUnusedValueNames(byte usedVars); + void clearUnusedValueNames(uint8_t usedVars); bool checkInvalidCharInNames(const char* name) const; @@ -35,7 +35,7 @@ struct ExtraTaskSettingsStruct char TaskDeviceFormula[VARS_PER_TASK][NAME_FORMULA_LENGTH_MAX + 1]; char TaskDeviceValueNames[VARS_PER_TASK][NAME_FORMULA_LENGTH_MAX + 1]; long TaskDevicePluginConfigLong[PLUGIN_EXTRACONFIGVAR_MAX]; - byte TaskDeviceValueDecimals[VARS_PER_TASK]; + uint8_t TaskDeviceValueDecimals[VARS_PER_TASK]; int16_t TaskDevicePluginConfig[PLUGIN_EXTRACONFIGVAR_MAX]; }; diff --git a/src/src/DataStructs/LogStruct.cpp b/src/src/DataStructs/LogStruct.cpp index c48e38fb3..98eca1554 100644 --- a/src/src/DataStructs/LogStruct.cpp +++ b/src/src/DataStructs/LogStruct.cpp @@ -5,7 +5,7 @@ -void LogStruct::add(const byte loglevel, const char *line) { +void LogStruct::add(const uint8_t loglevel, const char *line) { write_idx = (write_idx + 1) % LOG_STRUCT_MESSAGE_LINES; if (write_idx == read_idx) { @@ -44,7 +44,7 @@ bool LogStruct::get(String& output, const String& lineEnd) { return !isEmpty(); } -bool LogStruct::getNext(bool& logLinesAvailable, unsigned long& timestamp, String& message, byte& loglevel) { +bool LogStruct::getNext(bool& logLinesAvailable, unsigned long& timestamp, String& message, uint8_t& loglevel) { lastReadTimeStamp = millis(); logLinesAvailable = false; diff --git a/src/src/DataStructs/LogStruct.h b/src/src/DataStructs/LogStruct.h index 3112bd4ab..2e626194c 100644 --- a/src/src/DataStructs/LogStruct.h +++ b/src/src/DataStructs/LogStruct.h @@ -23,13 +23,13 @@ struct LogStruct { - void add(const byte loglevel, const char *line); + void add(const uint8_t loglevel, const char *line); // Read the next item and append it to the given string. // Returns whether new lines are available. bool get(String& output, const String& lineEnd); - bool getNext(bool& logLinesAvailable, unsigned long& timestamp, String& message, byte& loglevel); + bool getNext(bool& logLinesAvailable, unsigned long& timestamp, String& message, uint8_t& loglevel); bool isEmpty(); @@ -45,7 +45,7 @@ struct LogStruct { int write_idx = 0; int read_idx = 0; unsigned long lastReadTimeStamp = 0; - byte log_level[LOG_STRUCT_MESSAGE_LINES] = {0}; + uint8_t log_level[LOG_STRUCT_MESSAGE_LINES] = {0}; }; diff --git a/src/src/DataStructs/NodeStruct.cpp b/src/src/DataStructs/NodeStruct.cpp index 871a38109..31f15a1c7 100644 --- a/src/src/DataStructs/NodeStruct.cpp +++ b/src/src/DataStructs/NodeStruct.cpp @@ -1,6 +1,6 @@ #include "NodeStruct.h" -const __FlashStringHelper * getNodeTypeDisplayString(byte nodeType) { +const __FlashStringHelper * getNodeTypeDisplayString(uint8_t nodeType) { switch (nodeType) { case NODE_TYPE_ID_ESP_EASY_STD: return F("ESP Easy"); @@ -16,5 +16,5 @@ const __FlashStringHelper * getNodeTypeDisplayString(byte nodeType) { NodeStruct::NodeStruct() : build(0), age(0), nodeType(0), webgui_portnumber(0) { - for (byte i = 0; i < 4; ++i) { ip[i] = 0; } + for (uint8_t i = 0; i < 4; ++i) { ip[i] = 0; } } diff --git a/src/src/DataStructs/NodeStruct.h b/src/src/DataStructs/NodeStruct.h index 2f8d43413..86bd888b5 100644 --- a/src/src/DataStructs/NodeStruct.h +++ b/src/src/DataStructs/NodeStruct.h @@ -13,7 +13,7 @@ #define NODE_TYPE_ID_ARDUINO_EASY_STD 65 #define NODE_TYPE_ID_NANO_EASY_STD 81 -const __FlashStringHelper * getNodeTypeDisplayString(byte nodeType); +const __FlashStringHelper * getNodeTypeDisplayString(uint8_t nodeType); /*********************************************************************************************\ * NodeStruct @@ -25,11 +25,11 @@ struct NodeStruct String nodeName; IPAddress ip; uint16_t build; - byte age; - byte nodeType; + uint8_t age; + uint8_t nodeType; uint16_t webgui_portnumber; }; -typedef std::map NodesMap; +typedef std::map NodesMap; #endif // DATASTRUCTS_NODESTRUCT_H diff --git a/src/src/DataStructs/NotificationSettingsStruct.h b/src/src/DataStructs/NotificationSettingsStruct.h index cfccda1ba..b418bb758 100644 --- a/src/src/DataStructs/NotificationSettingsStruct.h +++ b/src/src/DataStructs/NotificationSettingsStruct.h @@ -20,8 +20,8 @@ struct NotificationSettingsStruct char Receiver[65]; char Subject[129]; char Body[513]; - byte Pin1; - byte Pin2; + uint8_t Pin1; + uint8_t Pin2; char User[49]; char Pass[33]; //its safe to extend this struct, up to 4096 bytes, default values in config are 0 diff --git a/src/src/DataStructs/NotificationStruct.h b/src/src/DataStructs/NotificationStruct.h index 182c4a45d..0f9ad48f7 100644 --- a/src/src/DataStructs/NotificationStruct.h +++ b/src/src/DataStructs/NotificationStruct.h @@ -10,8 +10,8 @@ struct NotificationStruct NotificationStruct() : Number(0), usesGPIO(0), usesMessaging(false) {} - byte Number; - byte usesGPIO; + uint8_t Number; + uint8_t usesGPIO; bool usesMessaging; }; diff --git a/src/src/DataStructs/ProtocolStruct.h b/src/src/DataStructs/ProtocolStruct.h index 40785bd86..5f97dd845 100644 --- a/src/src/DataStructs/ProtocolStruct.h +++ b/src/src/DataStructs/ProtocolStruct.h @@ -16,7 +16,7 @@ struct ProtocolStruct bool useExtendedCredentials() const; uint16_t defaultPort; - byte Number; + uint8_t Number; bool usesMQTT : 1; bool usesAccount : 1; bool usesPassword : 1; diff --git a/src/src/DataStructs/RTCStruct.cpp b/src/src/DataStructs/RTCStruct.cpp index b35f77c22..0d5bd67b3 100644 --- a/src/src/DataStructs/RTCStruct.cpp +++ b/src/src/DataStructs/RTCStruct.cpp @@ -18,7 +18,7 @@ } void RTCStruct::clearLastWiFi() { - for (byte i = 0; i < 6; ++i) { + for (uint8_t i = 0; i < 6; ++i) { lastBSSID[i] = 0; } lastWiFiChannel = 0; diff --git a/src/src/DataStructs/RTCStruct.h b/src/src/DataStructs/RTCStruct.h index 69f8dddf7..541f704fe 100644 --- a/src/src/DataStructs/RTCStruct.h +++ b/src/src/DataStructs/RTCStruct.h @@ -38,20 +38,20 @@ struct RTCStruct bool lastWiFi_set() const; - byte ID1 = 0; - byte ID2 = 0; - byte lastWiFiChannel = 0; - byte factoryResetCounter = 0; - byte deepSleepState = 0; - byte bootFailedCount = 0; - byte flashDayCounter = 0; - byte lastWiFiSettingsIndex = 0; + uint8_t ID1 = 0; + uint8_t ID2 = 0; + uint8_t lastWiFiChannel = 0; + uint8_t factoryResetCounter = 0; + uint8_t deepSleepState = 0; + uint8_t bootFailedCount = 0; + uint8_t flashDayCounter = 0; + uint8_t lastWiFiSettingsIndex = 0; unsigned long flashCounter = 0; unsigned long bootCounter = 0; unsigned long lastMixedSchedulerId = 0; uint8_t lastBSSID[6] = { 0 }; - byte unused1 = 0; // Force alignment to 4 bytes - byte unused2 = 0; + uint8_t unused1 = 0; // Force alignment to 4 bytes + uint8_t unused2 = 0; unsigned long lastSysTime = 0; }; diff --git a/src/src/DataStructs/RTC_cache_handler_struct.cpp b/src/src/DataStructs/RTC_cache_handler_struct.cpp index 6d26ffbbe..e07bc9b16 100644 --- a/src/src/DataStructs/RTC_cache_handler_struct.cpp +++ b/src/src/DataStructs/RTC_cache_handler_struct.cpp @@ -249,12 +249,12 @@ bool RTC_cache_handler_struct::loadMetaData() // No need to load on ESP32, as the data is already allocated to the RTC memory by the compiler #ifdef ESP8266 - if (!system_rtc_mem_read(RTC_BASE_CACHE, (byte *)&RTC_cache, sizeof(RTC_cache))) { + if (!system_rtc_mem_read(RTC_BASE_CACHE, (uint8_t *)&RTC_cache, sizeof(RTC_cache))) { return false; } #endif - return RTC_cache.checksumMetadata == calc_CRC32((byte *)&RTC_cache, sizeof(RTC_cache) - sizeof(uint32_t)); + return RTC_cache.checksumMetadata == calc_CRC32((uint8_t *)&RTC_cache, sizeof(RTC_cache) - sizeof(uint32_t)); } bool RTC_cache_handler_struct::loadData() @@ -263,7 +263,7 @@ bool RTC_cache_handler_struct::loadData() // No need to load on ESP32, as the data is already allocated to the RTC memory by the compiler #ifdef ESP8266 - if (!system_rtc_mem_read(RTC_BASE_CACHE + (sizeof(RTC_cache) / 4), (byte *)&RTC_cache_data[0], RTC_CACHE_DATA_SIZE)) { + if (!system_rtc_mem_read(RTC_BASE_CACHE + (sizeof(RTC_cache) / 4), (uint8_t *)&RTC_cache_data[0], RTC_CACHE_DATA_SIZE)) { return false; } #endif @@ -284,13 +284,13 @@ bool RTC_cache_handler_struct::saveRTCcache() { bool RTC_cache_handler_struct::saveRTCcache(unsigned int startOffset, size_t nrBytes) { RTC_cache.checksumData = getDataChecksum(); - RTC_cache.checksumMetadata = calc_CRC32((byte *)&RTC_cache, sizeof(RTC_cache) - sizeof(uint32_t)); + RTC_cache.checksumMetadata = calc_CRC32((uint8_t *)&RTC_cache, sizeof(RTC_cache) - sizeof(uint32_t)); #ifdef ESP32 return true; #endif #ifdef ESP8266 - if (!system_rtc_mem_write(RTC_BASE_CACHE, (byte *)&RTC_cache, sizeof(RTC_cache)) || !loadMetaData()) + if (!system_rtc_mem_write(RTC_BASE_CACHE, (uint8_t *)&RTC_cache, sizeof(RTC_cache)) || !loadMetaData()) { # ifdef RTC_STRUCT_DEBUG addLog(LOG_LEVEL_ERROR, F("RTC : Error while writing cache metadata to RTC")); @@ -302,7 +302,7 @@ bool RTC_cache_handler_struct::saveRTCcache(unsigned int startOffset, size_t nrB if (nrBytes > 0) { // Check needed? const size_t address = RTC_BASE_CACHE + ((sizeof(RTC_cache) + startOffset) / 4); - if (!system_rtc_mem_write(address, (byte *)&RTC_cache_data[startOffset], nrBytes)) + if (!system_rtc_mem_write(address, (uint8_t *)&RTC_cache_data[startOffset], nrBytes)) { # ifdef RTC_STRUCT_DEBUG addLog(LOG_LEVEL_ERROR, F("RTC : Error while writing cache data to RTC")); @@ -329,7 +329,7 @@ uint32_t RTC_cache_handler_struct::getDataChecksum() { */ // Only compute the checksum over the number of samples stored. - return calc_CRC32((byte *)&RTC_cache_data[0], /*dataLength*/ RTC_CACHE_DATA_SIZE); + return calc_CRC32((uint8_t *)&RTC_cache_data[0], /*dataLength*/ RTC_CACHE_DATA_SIZE); } void RTC_cache_handler_struct::initRTCcache_data() { diff --git a/src/src/DataStructs/RTC_cache_handler_struct.h b/src/src/DataStructs/RTC_cache_handler_struct.h index 18d93a24b..42b68f531 100644 --- a/src/src/DataStructs/RTC_cache_handler_struct.h +++ b/src/src/DataStructs/RTC_cache_handler_struct.h @@ -91,7 +91,7 @@ private: size_t peekfilenr = 0; size_t peekreadpos = 0; - byte storageLocation = CACHE_STORAGE_SPIFFS; + uint8_t storageLocation = CACHE_STORAGE_SPIFFS; bool writeerror = false; }; diff --git a/src/src/DataStructs/SecurityStruct.h b/src/src/DataStructs/SecurityStruct.h index e4a347f0a..a279556b9 100644 --- a/src/src/DataStructs/SecurityStruct.h +++ b/src/src/DataStructs/SecurityStruct.h @@ -35,9 +35,9 @@ struct SecurityStruct char ControllerUser[CONTROLLER_MAX][26]; char ControllerPassword[CONTROLLER_MAX][64]; char Password[26]; - byte AllowedIPrangeLow[4] = {0}; // TD-er: Use these - byte AllowedIPrangeHigh[4] = {0}; - byte IPblockLevel = 0; + uint8_t AllowedIPrangeLow[4] = {0}; // TD-er: Use these + uint8_t AllowedIPrangeHigh[4] = {0}; + uint8_t IPblockLevel = 0; //its safe to extend this struct, up to 4096 bytes, default values in config are 0. Make sure crc is last uint8_t ProgmemMd5[16] = {0}; // crc of the binary that last saved the struct to file. diff --git a/src/src/DataStructs/SettingsStruct.cpp b/src/src/DataStructs/SettingsStruct.cpp index 2d54538d4..93e8710ac 100644 --- a/src/src/DataStructs/SettingsStruct.cpp +++ b/src/src/DataStructs/SettingsStruct.cpp @@ -261,7 +261,7 @@ bool SettingsStruct_tmpl::networkSettingsEmpty() const { template void SettingsStruct_tmpl::clearNetworkSettings() { - for (byte i = 0; i < 4; ++i) { + for (uint8_t i = 0; i < 4; ++i) { IP[i] = 0; Gateway[i] = 0; Subnet[i] = 0; @@ -287,7 +287,7 @@ void SettingsStruct_tmpl::clearTimeSettings() { template void SettingsStruct_tmpl::clearNotifications() { - for (byte i = 0; i < NOTIFICATION_MAX; ++i) { + for (uint8_t i = 0; i < NOTIFICATION_MAX; ++i) { Notification[i] = 0; NotificationEnabled[i] = false; } @@ -316,7 +316,7 @@ void SettingsStruct_tmpl::clearLogSettings() { SDLogLevel = 0; SyslogFacility = DEFAULT_SYSLOG_FACILITY; - for (byte i = 0; i < 4; ++i) { Syslog_IP[i] = 0; } + for (uint8_t i = 0; i < 4; ++i) { Syslog_IP[i] = 0; } } template @@ -357,13 +357,13 @@ void SettingsStruct_tmpl::clearMisc() { // Here we initialize all data to 0, so this is the ONLY reason why PinBootStates // can now be directly accessed. // In all other use cases, use the get and set functions for it. - constexpr byte maxStates = sizeof(PinBootStates) / sizeof(PinBootStates[0]); - for (byte i = 0; i < maxStates; ++i) { + constexpr uint8_t maxStates = sizeof(PinBootStates) / sizeof(PinBootStates[0]); + for (uint8_t i = 0; i < maxStates; ++i) { PinBootStates[i] = 0; } #ifdef ESP32 - constexpr byte maxStatesesp32 = sizeof(PinBootStates_ESP32) / sizeof(PinBootStates_ESP32[0]); - for (byte i = 0; i < maxStatesesp32; ++i) { + constexpr uint8_t maxStatesesp32 = sizeof(PinBootStates_ESP32) / sizeof(PinBootStates_ESP32[0]); + for (uint8_t i = 0; i < maxStatesesp32; ++i) { PinBootStates_ESP32[i] = 0; } #endif @@ -433,16 +433,16 @@ void SettingsStruct_tmpl::clearTask(taskIndex_t task) { TaskDevicePort[task] = 0; TaskDevicePin1PullUp[task] = false; - for (byte cv = 0; cv < PLUGIN_CONFIGVAR_MAX; ++cv) { + for (uint8_t cv = 0; cv < PLUGIN_CONFIGVAR_MAX; ++cv) { TaskDevicePluginConfig[task][cv] = 0; } TaskDevicePin1Inversed[task] = false; - for (byte cv = 0; cv < PLUGIN_CONFIGFLOATVAR_MAX; ++cv) { + for (uint8_t cv = 0; cv < PLUGIN_CONFIGFLOATVAR_MAX; ++cv) { TaskDevicePluginConfigFloat[task][cv] = 0.0f; } - for (byte cv = 0; cv < PLUGIN_CONFIGLONGVAR_MAX; ++cv) { + for (uint8_t cv = 0; cv < PLUGIN_CONFIGLONGVAR_MAX; ++cv) { TaskDevicePluginConfigLong[task][cv] = 0; } TaskDeviceSendDataFlags[task] = 0; @@ -472,12 +472,12 @@ String SettingsStruct_tmpl::getHostname(bool appendUnit) const { template PinBootState SettingsStruct_tmpl::getPinBootState(uint8_t gpio_pin) const { - constexpr byte maxStates = sizeof(PinBootStates) / sizeof(PinBootStates[0]); + constexpr uint8_t maxStates = sizeof(PinBootStates) / sizeof(PinBootStates[0]); if (gpio_pin < maxStates) { return static_cast(PinBootStates[gpio_pin]); } #ifdef ESP32 - constexpr byte maxStatesesp32 = sizeof(PinBootStates_ESP32) / sizeof(PinBootStates_ESP32[0]); + constexpr uint8_t maxStatesesp32 = sizeof(PinBootStates_ESP32) / sizeof(PinBootStates_ESP32[0]); const uint8_t addr = gpio_pin - maxStates; if (addr < maxStatesesp32) { return static_cast(PinBootStates_ESP32[addr]); @@ -488,12 +488,12 @@ PinBootState SettingsStruct_tmpl::getPinBootState(uint8_t gpio_pin) con template void SettingsStruct_tmpl::setPinBootState(uint8_t gpio_pin, PinBootState state) { - constexpr byte maxStates = sizeof(PinBootStates) / sizeof(PinBootStates[0]); + constexpr uint8_t maxStates = sizeof(PinBootStates) / sizeof(PinBootStates[0]); if (gpio_pin < maxStates) { PinBootStates[gpio_pin] = static_cast(state); } #ifdef ESP32 - constexpr byte maxStatesesp32 = sizeof(PinBootStates_ESP32) / sizeof(PinBootStates_ESP32[0]); + constexpr uint8_t maxStatesesp32 = sizeof(PinBootStates_ESP32) / sizeof(PinBootStates_ESP32[0]); const uint8_t addr = gpio_pin - maxStates; if (addr < maxStatesesp32) { PinBootStates_ESP32[addr] = static_cast(state); @@ -538,7 +538,7 @@ bool SettingsStruct_tmpl::isSPI_pin(int8_t pin) const { if (pin < 0) return false; int8_t spi_gpios[3]; if (getSPI_pins(spi_gpios)) { - for (byte i = 0; i < 3; ++i) { + for (uint8_t i = 0; i < 3; ++i) { if (spi_gpios[i] == pin) return true; } } @@ -582,7 +582,7 @@ bool SettingsStruct_tmpl::isEthernetPinOptional(int8_t pin) const { } template -int8_t SettingsStruct_tmpl::getTaskDevicePin(taskIndex_t taskIndex, byte pinnr) const { +int8_t SettingsStruct_tmpl::getTaskDevicePin(taskIndex_t taskIndex, uint8_t pinnr) const { if (validTaskIndex(taskIndex)) { switch(pinnr) { case 1: return TaskDevicePin1[taskIndex]; diff --git a/src/src/DataStructs/SettingsStruct.h b/src/src/DataStructs/SettingsStruct.h index 174052292..3b971c9c8 100644 --- a/src/src/DataStructs/SettingsStruct.h +++ b/src/src/DataStructs/SettingsStruct.h @@ -177,7 +177,7 @@ class SettingsStruct_tmpl // Access to TaskDevicePin1 ... TaskDevicePin3 // @param pinnr 1 = TaskDevicePin1, ..., 3 = TaskDevicePin3 - int8_t getTaskDevicePin(taskIndex_t taskIndex, byte pinnr) const; + int8_t getTaskDevicePin(taskIndex_t taskIndex, uint8_t pinnr) const; float getWiFi_TX_power() const; void setWiFi_TX_power(float dBm); @@ -186,12 +186,12 @@ class SettingsStruct_tmpl unsigned long PID; int Version; int16_t Build; - byte IP[4]; - byte Gateway[4]; - byte Subnet[4]; - byte DNS[4]; - byte IP_Octet; - byte Unit; + uint8_t IP[4]; + uint8_t Gateway[4]; + uint8_t Subnet[4]; + uint8_t DNS[4]; + uint8_t IP_Octet; + uint8_t Unit; char Name[26]; char NTPHost[64]; // FIXME TD-er: Issue #2690 @@ -201,18 +201,18 @@ class SettingsStruct_tmpl int8_t Pin_status_led; int8_t Pin_sd_cs; int8_t PinBootStates[17]; // Only use getPinBootState and setPinBootState as multiple pins are packed for ESP32 - byte Syslog_IP[4]; + uint8_t Syslog_IP[4]; unsigned int UDPPort; - byte SyslogLevel; - byte SerialLogLevel; - byte WebLogLevel; - byte SDLogLevel; + uint8_t SyslogLevel; + uint8_t SerialLogLevel; + uint8_t WebLogLevel; + uint8_t SDLogLevel; unsigned long BaudRate; unsigned long MessageDelay_unused; // MQTT settings now moved to the controller settings. - byte deepSleep_wakeTime; // 0 = Sleep Disabled, else time awake from sleep in seconds + uint8_t deepSleep_wakeTime; // 0 = Sleep Disabled, else time awake from sleep in seconds boolean CustomCSS; boolean DST; - byte WDI2CAddress; + uint8_t WDI2CAddress; boolean UseRules; boolean UseSerial; boolean UseSSDP; @@ -222,19 +222,19 @@ class SettingsStruct_tmpl unsigned long ConnectionFailuresThreshold; int16_t TimeZone; boolean MQTTRetainFlag_unused; - byte InitSPI; //0 = disabled, 1= enabled but for ESP32 there is option 2= SPI2 + uint8_t InitSPI; //0 = disabled, 1= enabled but for ESP32 there is option 2= SPI2 // FIXME TD-er: Must change to cpluginID_t, but then also another check must be added since changing the pluginID_t will also render settings incompatible - byte Protocol[CONTROLLER_MAX]; - byte Notification[NOTIFICATION_MAX]; //notifications, point to a NPLUGIN id + uint8_t Protocol[CONTROLLER_MAX]; + uint8_t Notification[NOTIFICATION_MAX]; //notifications, point to a NPLUGIN id // FIXME TD-er: Must change to pluginID_t, but then also another check must be added since changing the pluginID_t will also render settings incompatible - byte TaskDeviceNumber[N_TASKS]; // The "plugin number" set at as task (e.g. 4 for P004_dallas) + uint8_t TaskDeviceNumber[N_TASKS]; // The "plugin number" set at as task (e.g. 4 for P004_dallas) unsigned int OLD_TaskDeviceID[N_TASKS]; //UNUSED: this can be removed union { struct { int8_t TaskDevicePin1[N_TASKS]; int8_t TaskDevicePin2[N_TASKS]; int8_t TaskDevicePin3[N_TASKS]; - byte TaskDevicePort[N_TASKS]; + uint8_t TaskDevicePort[N_TASKS]; }; int8_t TaskDevicePin[4][N_TASKS]; }; @@ -243,9 +243,9 @@ class SettingsStruct_tmpl boolean TaskDevicePin1Inversed[N_TASKS]; float TaskDevicePluginConfigFloat[N_TASKS][PLUGIN_CONFIGFLOATVAR_MAX]; long TaskDevicePluginConfigLong[N_TASKS][PLUGIN_CONFIGLONGVAR_MAX]; - byte TaskDeviceSendDataFlags[N_TASKS]; - byte OLD_TaskDeviceGlobalSync[N_TASKS]; - byte TaskDeviceDataFeed[N_TASKS]; // When set to 0, only read local connected sensorsfeeds + uint8_t TaskDeviceSendDataFlags[N_TASKS]; + uint8_t OLD_TaskDeviceGlobalSync[N_TASKS]; + uint8_t TaskDeviceDataFeed[N_TASKS]; // When set to 0, only read local connected sensorsfeeds unsigned long TaskDeviceTimer[N_TASKS]; boolean TaskDeviceEnabled[N_TASKS]; boolean ControllerEnabled[CONTROLLER_MAX]; @@ -260,7 +260,7 @@ class SettingsStruct_tmpl uint16_t DST_End; boolean UseRTOSMultitasking; int8_t Pin_Reset; - byte SyslogFacility; + uint8_t SyslogFacility; uint32_t StructSize; // Forced to be 32 bit, to make sure alignment is clear. boolean MQTTUseUnitNameAsClientId_unused; @@ -277,7 +277,7 @@ class SettingsStruct_tmpl // FIXME @TD-er: As discussed in #1292, the CRC for the settings is now disabled. // make sure crc is the last value in the struct - // Try to extend settings to make the checksum 4-byte aligned. + // Try to extend settings to make the checksum 4-uint8_t aligned. // uint8_t ProgmemMd5[16]; // crc of the binary that last saved the struct to file. // uint8_t md5[16]; uint8_t ETH_Phy_Addr; @@ -286,10 +286,10 @@ class SettingsStruct_tmpl int8_t ETH_Pin_power; EthPhyType_t ETH_Phy_Type; EthClockMode_t ETH_Clock_Mode; - byte ETH_IP[4]; - byte ETH_Gateway[4]; - byte ETH_Subnet[4]; - byte ETH_DNS[4]; + uint8_t ETH_IP[4]; + uint8_t ETH_Gateway[4]; + uint8_t ETH_Subnet[4]; + uint8_t ETH_DNS[4]; NetworkMedium_t NetworkMedium; int8_t I2C_Multiplexer_Type; int8_t I2C_Multiplexer_Addr; diff --git a/src/src/DataStructs/UnitMessageCount.h b/src/src/DataStructs/UnitMessageCount.h index 734d6cbe3..de2550510 100644 --- a/src/src/DataStructs/UnitMessageCount.h +++ b/src/src/DataStructs/UnitMessageCount.h @@ -11,10 +11,10 @@ struct UnitMessageCount_t { UnitMessageCount_t() {} - UnitMessageCount_t(byte unitnr, byte messageCount) : unit(unitnr), count(messageCount) {} + UnitMessageCount_t(uint8_t unitnr, uint8_t messageCount) : unit(unitnr), count(messageCount) {} - byte unit = 0; // Initialize to "not set" - byte count = 0; + uint8_t unit = 0; // Initialize to "not set" + uint8_t count = 0; }; struct UnitLastMessageCount_map { @@ -24,7 +24,7 @@ struct UnitLastMessageCount_map { private: - std::map_map; + std::map_map; }; #endif // ifndef DATASTRUCTS_UNITMESSAGECOUNT_H diff --git a/src/src/DataStructs/UserVarStruct.cpp b/src/src/DataStructs/UserVarStruct.cpp index c7d014d39..00bb3651d 100644 --- a/src/src/DataStructs/UserVarStruct.cpp +++ b/src/src/DataStructs/UserVarStruct.cpp @@ -55,7 +55,7 @@ void UserVarStruct::setSensorTypeLong(taskIndex_t taskIndex, unsigned long value _data[baseVarIndex + 1] = (value >> 16) & 0xFFFF; } -uint32_t UserVarStruct::getUint32(taskIndex_t taskIndex, byte varNr) const +uint32_t UserVarStruct::getUint32(taskIndex_t taskIndex, uint8_t varNr) const { if (!validTaskIndex(taskIndex) || (varNr >= VARS_PER_TASK)) { addLog(LOG_LEVEL_ERROR, F("UserVar index out of range")); @@ -67,7 +67,7 @@ uint32_t UserVarStruct::getUint32(taskIndex_t taskIndex, byte varNr) const return res; } -void UserVarStruct::setUint32(taskIndex_t taskIndex, byte varNr, uint32_t value) +void UserVarStruct::setUint32(taskIndex_t taskIndex, uint8_t varNr, uint32_t value) { if (!validTaskIndex(taskIndex) || (varNr >= VARS_PER_TASK)) { addLog(LOG_LEVEL_ERROR, F("UserVar index out of range")); @@ -87,7 +87,7 @@ size_t UserVarStruct::getNrElements() const return _data.size(); } -byte * UserVarStruct::get() +uint8_t * UserVarStruct::get() { - return (byte *)(&_data[0]); + return (uint8_t *)(&_data[0]); } diff --git a/src/src/DataStructs/UserVarStruct.h b/src/src/DataStructs/UserVarStruct.h index 52272d39d..e97cf5dc2 100644 --- a/src/src/DataStructs/UserVarStruct.h +++ b/src/src/DataStructs/UserVarStruct.h @@ -18,15 +18,15 @@ struct UserVarStruct { // 32 bit unsigned int stored at the memory location of the float uint32_t getUint32(taskIndex_t taskIndex, - byte varNr) const; + uint8_t varNr) const; void setUint32(taskIndex_t taskIndex, - byte varNr, + uint8_t varNr, uint32_t value); size_t getNrElements() const; - byte * get(); + uint8_t * get(); private: diff --git a/src/src/DataStructs/WiFiEventData.cpp b/src/src/DataStructs/WiFiEventData.cpp index 6182afd41..0aafaf489 100644 --- a/src/src/DataStructs/WiFiEventData.cpp +++ b/src/src/DataStructs/WiFiEventData.cpp @@ -164,7 +164,7 @@ void WiFiEventData_t::markDisconnect(WiFiDisconnectReason reason) { wifiConnectInProgress = false; } -void WiFiEventData_t::markConnected(const String& ssid, const uint8_t bssid[6], byte channel) { +void WiFiEventData_t::markConnected(const String& ssid, const uint8_t bssid[6], uint8_t channel) { usedChannel = channel; lastConnectMoment.setNow(); processedConnect = false; @@ -174,7 +174,7 @@ void WiFiEventData_t::markConnected(const String& ssid, const uint8_t bssid[6], auth_mode = WiFi_AP_Candidates.getCurrent().enc_type; RTC.lastWiFiChannel = channel; - for (byte i = 0; i < 6; ++i) { + for (uint8_t i = 0; i < 6; ++i) { if (RTC.lastBSSID[i] != bssid[i]) { bssid_changed = true; RTC.lastBSSID[i] = bssid[i]; diff --git a/src/src/DataStructs/WiFiEventData.h b/src/src/DataStructs/WiFiEventData.h index deb735f5c..322a1bb04 100644 --- a/src/src/DataStructs/WiFiEventData.h +++ b/src/src/DataStructs/WiFiEventData.h @@ -49,7 +49,7 @@ struct WiFiEventData_t { void markDisconnect(WiFiDisconnectReason reason); void markConnected(const String& ssid, const uint8_t bssid[6], - byte channel); + uint8_t channel); void markConnectedAPmode(const uint8_t mac[6]); void markDisconnectedAPmode(const uint8_t mac[6]); diff --git a/src/src/DataStructs/WiFi_AP_Candidate.cpp b/src/src/DataStructs/WiFi_AP_Candidate.cpp index 3c7f6bf18..25cec631a 100644 --- a/src/src/DataStructs/WiFi_AP_Candidate.cpp +++ b/src/src/DataStructs/WiFi_AP_Candidate.cpp @@ -15,7 +15,7 @@ #define WIFI_AP_CANDIDATE_MAX_AGE 300000 // 5 minutes in msec -WiFi_AP_Candidate::WiFi_AP_Candidate(byte index_c, const String& ssid_c, const String& pass) : +WiFi_AP_Candidate::WiFi_AP_Candidate(uint8_t index_c, const String& ssid_c, const String& pass) : rssi(0), channel(0), index(index_c), isHidden(false) { const size_t ssid_length = ssid_c.length(); diff --git a/src/src/DataStructs/WiFi_AP_Candidate.h b/src/src/DataStructs/WiFi_AP_Candidate.h index b11bf962d..ad5543726 100644 --- a/src/src/DataStructs/WiFi_AP_Candidate.h +++ b/src/src/DataStructs/WiFi_AP_Candidate.h @@ -9,7 +9,7 @@ struct WiFi_AP_Candidate { // @param index The index of the stored credentials // @param ssid_c SSID of the credentials // @param pass Password/key of the credentials - WiFi_AP_Candidate(byte index, + WiFi_AP_Candidate(uint8_t index, const String& ssid_c, const String& pass); @@ -60,8 +60,8 @@ struct WiFi_AP_Candidate { int32_t rssi = 0; int32_t channel = 0; MAC_address bssid; - byte index = 0; // Index of the matching credentials - byte enc_type = 0; // Encryption used (e.g. WPA2) + uint8_t index = 0; // Index of the matching credentials + uint8_t enc_type = 0; // Encryption used (e.g. WPA2) bool isHidden = false; // Hidden SSID bool lowPriority = false; // Try as last attempt bool isEmergencyFallback = false; diff --git a/src/src/DataTypes/ControllerIndex.h b/src/src/DataTypes/ControllerIndex.h index 2b10bd114..75f7db59b 100644 --- a/src/src/DataTypes/ControllerIndex.h +++ b/src/src/DataTypes/ControllerIndex.h @@ -3,7 +3,7 @@ #include -typedef byte controllerIndex_t; +typedef uint8_t controllerIndex_t; extern controllerIndex_t INVALID_CONTROLLER_INDEX; diff --git a/src/src/DataTypes/EventValueSource.h b/src/src/DataTypes/EventValueSource.h index d8d147b01..394ae60b7 100644 --- a/src/src/DataTypes/EventValueSource.h +++ b/src/src/DataTypes/EventValueSource.h @@ -4,7 +4,7 @@ #include struct EventValueSourceGroup { - enum class Enum : byte { + enum class Enum : uint8_t { RESTRICTED, ALL }; @@ -13,7 +13,7 @@ struct EventValueSourceGroup { struct EventValueSource { // Keep the values as they can be used by other/older builds to communicate with ESPEasy - enum class Enum : byte { + enum class Enum : uint8_t { VALUE_SOURCE_NOT_SET = 0, VALUE_SOURCE_SYSTEM = 1, VALUE_SOURCE_SERIAL = 2, diff --git a/src/src/DataTypes/ProtocolIndex.h b/src/src/DataTypes/ProtocolIndex.h index 48e2feb92..9167f3546 100644 --- a/src/src/DataTypes/ProtocolIndex.h +++ b/src/src/DataTypes/ProtocolIndex.h @@ -3,7 +3,7 @@ #include -typedef byte protocolIndex_t; +typedef uint8_t protocolIndex_t; extern protocolIndex_t INVALID_PROTOCOL_INDEX; diff --git a/src/src/DataTypes/TaskIndex.h b/src/src/DataTypes/TaskIndex.h index e0f6283cb..610e94c6b 100644 --- a/src/src/DataTypes/TaskIndex.h +++ b/src/src/DataTypes/TaskIndex.h @@ -7,7 +7,7 @@ #define USERVAR_MAX_INDEX (VARS_PER_TASK * TASKS_MAX) -typedef byte taskIndex_t; +typedef uint8_t taskIndex_t; typedef uint16_t userVarIndex_t; typedef uint16_t taskVarIndex_t; diff --git a/src/src/ESPEasyCore/Controller.cpp b/src/src/ESPEasyCore/Controller.cpp index bc7c77e89..9066e8f70 100644 --- a/src/src/ESPEasyCore/Controller.cpp +++ b/src/src/ESPEasyCore/Controller.cpp @@ -97,7 +97,7 @@ bool validUserVar(struct EventStruct *event) { default: break; } - byte valueCount = getValueCountForTask(event->TaskIndex); + uint8_t valueCount = getValueCountForTask(event->TaskIndex); for (int i = 0; i < valueCount; ++i) { const float f(UserVar[event->BaseVarIndex + i]); @@ -114,7 +114,7 @@ bool validUserVar(struct EventStruct *event) { \*********************************************************************************************/ // handle MQTT messages -void incoming_mqtt_callback(char *c_topic, byte *b_payload, unsigned int length) { +void incoming_mqtt_callback(char *c_topic, uint8_t *b_payload, unsigned int length) { statusLED(true); controllerIndex_t enabledMqttController = firstEnabledMQTT_ControllerIndex(); @@ -236,7 +236,7 @@ bool MQTTConnect(controllerIndex_t controller_idx) delay(0); - byte controller_number = Settings.Protocol[controller_idx]; + uint8_t controller_number = Settings.Protocol[controller_idx]; count_connection_results(MQTTresult, F("MQTT : Broker "), controller_number); @@ -607,7 +607,7 @@ void SensorSendTask(taskIndex_t TaskIndex) float preValue[VARS_PER_TASK]; // store values before change, in case we need it in the formula - for (byte varNr = 0; varNr < VARS_PER_TASK; varNr++) { + for (uint8_t varNr = 0; varNr < VARS_PER_TASK; varNr++) { preValue[varNr] = UserVar[TempEvent.BaseVarIndex + varNr]; } @@ -625,7 +625,7 @@ void SensorSendTask(taskIndex_t TaskIndex) if (Device[DeviceIndex].FormulaOption) { START_TIMER; - for (byte varNr = 0; varNr < VARS_PER_TASK; varNr++) + for (uint8_t varNr = 0; varNr < VARS_PER_TASK; varNr++) { if (ExtraTaskSettings.TaskDeviceFormula[varNr][0] != 0) { diff --git a/src/src/ESPEasyCore/Controller.h b/src/src/ESPEasyCore/Controller.h index 54ac0cb3e..0a69b48a4 100644 --- a/src/src/ESPEasyCore/Controller.h +++ b/src/src/ESPEasyCore/Controller.h @@ -19,7 +19,7 @@ bool validUserVar(struct EventStruct *event); \*********************************************************************************************/ // handle MQTT messages -void incoming_mqtt_callback(char *c_topic, byte *b_payload, unsigned int length); +void incoming_mqtt_callback(char *c_topic, uint8_t *b_payload, unsigned int length); /*********************************************************************************************\ * Disconnect from MQTT message broker diff --git a/src/src/ESPEasyCore/ESPEasyGPIO.cpp b/src/src/ESPEasyCore/ESPEasyGPIO.cpp index fa34672cd..0801f9454 100644 --- a/src/src/ESPEasyCore/ESPEasyGPIO.cpp +++ b/src/src/ESPEasyCore/ESPEasyGPIO.cpp @@ -17,7 +17,7 @@ //******************************************************************************** // Internal GPIO write //******************************************************************************** -void GPIO_Internal_Write(int pin, byte value) +void GPIO_Internal_Write(int pin, uint8_t value) { if (checkValidPortRange(PLUGIN_GPIO, pin)) { const uint32_t key = createKey(PLUGIN_GPIO, pin); @@ -59,7 +59,7 @@ bool GPIO_Read_Switch_State(struct EventStruct *event) { return false; } -bool GPIO_Read_Switch_State(int pin, byte pinMode) { +bool GPIO_Read_Switch_State(int pin, uint8_t pinMode) { bool canRead = false; if (checkValidPortRange(PLUGIN_GPIO, pin)) { switch (pinMode) @@ -95,13 +95,13 @@ int8_t GPIO_MCP_Read(int Par1) { int8_t pinState = -1; if (checkValidPortRange(PLUGIN_MCP, Par1)) { - byte unit = (Par1 - 1) / 16; - byte port = Par1 - (unit * 16) - 1; + uint8_t unit = (Par1 - 1) / 16; + uint8_t port = Par1 - (unit * 16) - 1; uint8_t address = 0x20 + unit; - byte IOBankValueReg = (port<8)? MCP23017_GPIOA : MCP23017_GPIOB; + uint8_t IOBankValueReg = (port<8)? MCP23017_GPIOA : MCP23017_GPIOB; port = port % 8; - byte retValue; + uint8_t retValue; if (GPIO_MCP_ReadRegister(address,IOBankValueReg,&retValue)) { retValue = (retValue & (1 << port)) >> port; pinState = (retValue==0)?0:1; @@ -126,7 +126,7 @@ int8_t GPIO_MCP_Read(int Par1) // MCP23017 read register //******************************************************************************** -bool GPIO_MCP_ReadRegister(byte mcpAddr, uint8_t regAddr, uint8_t *retValue) { +bool GPIO_MCP_ReadRegister(uint8_t mcpAddr, uint8_t regAddr, uint8_t *retValue) { bool success = false; // Read the register Wire.beginTransmission(mcpAddr); @@ -145,7 +145,7 @@ bool GPIO_MCP_ReadRegister(byte mcpAddr, uint8_t regAddr, uint8_t *retValue) { // MCP23017 write register //******************************************************************************** -void GPIO_MCP_WriteRegister(byte mcpAddr, uint8_t regAddr, uint8_t regValue) { +void GPIO_MCP_WriteRegister(uint8_t mcpAddr, uint8_t regAddr, uint8_t regValue) { // Write the register Wire.beginTransmission(mcpAddr); Wire.write(regAddr); @@ -157,20 +157,20 @@ void GPIO_MCP_WriteRegister(byte mcpAddr, uint8_t regAddr, uint8_t regValue) { //******************************************************************************** // MCP23017 write pin //******************************************************************************** -bool GPIO_MCP_Write(int Par1, byte Par2) +bool GPIO_MCP_Write(int Par1, uint8_t Par2) { if (!checkValidPortRange(PLUGIN_MCP, Par1)) { return false; } bool success = false; - byte unit = (Par1 - 1) / 16; - byte port = Par1 - (unit * 16) - 1; + uint8_t unit = (Par1 - 1) / 16; + uint8_t port = Par1 - (unit * 16) - 1; uint8_t address = int((Par1-1) / 16) + 0x20; - byte IOBankConfigReg = (port<8)? MCP23017_IODIRA : MCP23017_IODIRB; - byte IOBankValueReg = (port<8)? MCP23017_GPIOA : MCP23017_GPIOB; + uint8_t IOBankConfigReg = (port<8)? MCP23017_IODIRA : MCP23017_IODIRB; + uint8_t IOBankValueReg = (port<8)? MCP23017_GPIOA : MCP23017_GPIOB; port = port % 8; - byte retValue; + uint8_t retValue; // turn this port into output, first read current config if (GPIO_MCP_ReadRegister(address,IOBankConfigReg,&retValue)) { @@ -190,7 +190,7 @@ bool GPIO_MCP_Write(int Par1, byte Par2) return(success); /* - byte portvalue = 0; + uint8_t portvalue = 0; // turn this port into output, first read current config Wire.beginTransmission(address); Wire.write(IOBankConfigReg); // IO config register @@ -243,14 +243,14 @@ bool setMCPInputAndPullupMode(uint8_t Par1, bool enablePullUp) } bool success = false; - byte unit = (Par1 - 1) / 16; - byte port = Par1 - (unit * 16) -1; + uint8_t unit = (Par1 - 1) / 16; + uint8_t port = Par1 - (unit * 16) -1; uint8_t address = 0x20 + unit; - byte IOBankPullUpReg = (port<8)? MCP23017_GPPUA : MCP23017_GPPUB; - byte IOBankIODirReg = (port<8)? MCP23017_IODIRA : MCP23017_IODIRB; + uint8_t IOBankPullUpReg = (port<8)? MCP23017_GPPUA : MCP23017_GPPUB; + uint8_t IOBankIODirReg = (port<8)? MCP23017_IODIRA : MCP23017_IODIRB; port = port % 8; - byte retValue; + uint8_t retValue; // set this port mode to INPUT (bit=1) if (GPIO_MCP_ReadRegister(address, IOBankIODirReg, &retValue)) { retValue |= (1 << port); @@ -274,11 +274,11 @@ bool setMCPOutputMode(uint8_t Par1) } bool success = false; - byte retValue; - byte unit = (Par1 - 1) / 16; - byte port = Par1 - (unit * 16) - 1; + uint8_t retValue; + uint8_t unit = (Par1 - 1) / 16; + uint8_t port = Par1 - (unit * 16) - 1; uint8_t address = 0x20 + unit; - byte IOBankIODirReg = (port<8)? MCP23017_IODIRA : MCP23017_IODIRB; + uint8_t IOBankIODirReg = (port<8)? MCP23017_IODIRA : MCP23017_IODIRB; port = port % 8; // set this port mode to OUTPUT (bit=0) @@ -298,8 +298,8 @@ int8_t GPIO_PCF_Read(int Par1) { int8_t state = -1; if (checkValidPortRange(PLUGIN_PCF, Par1)) { - byte unit = (Par1 - 1) / 8; - byte port = Par1 - (unit * 8) - 1; + uint8_t unit = (Par1 - 1) / 8; + uint8_t port = Par1 - (unit * 8) - 1; uint8_t address = 0x20 + unit; if (unit > 7) address += 0x10; @@ -337,7 +337,7 @@ void GPIO_PCF_WriteAllPins(uint8_t address, uint8_t value) Wire.endTransmission(); } -bool GPIO_PCF_Write(int Par1, byte Par2) +bool GPIO_PCF_Write(int Par1, uint8_t Par2) { if (!checkValidPortRange(PLUGIN_PCF, Par1)) { return false; @@ -513,7 +513,7 @@ void setInternalGPIOPullupMode(uint8_t port) } } -bool GPIO_Write(pluginID_t pluginID, int port, byte value, byte pinMode) +bool GPIO_Write(pluginID_t pluginID, int port, uint8_t value, uint8_t pinMode) { bool success=true; switch (pluginID) diff --git a/src/src/ESPEasyCore/ESPEasyGPIO.h b/src/src/ESPEasyCore/ESPEasyGPIO.h index 0a40bf7ea..540f89264 100644 --- a/src/src/ESPEasyCore/ESPEasyGPIO.h +++ b/src/src/ESPEasyCore/ESPEasyGPIO.h @@ -17,26 +17,26 @@ //******************************************************************************** // Internal GPIO write //******************************************************************************** -void GPIO_Internal_Write(int pin, byte value); +void GPIO_Internal_Write(int pin, uint8_t value); //******************************************************************************** // Internal GPIO read //******************************************************************************** bool GPIO_Internal_Read(int pin); bool GPIO_Read_Switch_State(struct EventStruct *event); -bool GPIO_Read_Switch_State(int pinNumber, byte pinMode); +bool GPIO_Read_Switch_State(int pinNumber, uint8_t pinMode); //******************************************************************************** // MCP23017 read //******************************************************************************** int8_t GPIO_MCP_Read(int Par1); -bool GPIO_MCP_ReadRegister(byte mcpAddr, uint8_t regAddr, uint8_t *retValue); +bool GPIO_MCP_ReadRegister(uint8_t mcpAddr, uint8_t regAddr, uint8_t *retValue); //******************************************************************************** // MCP23017 write //******************************************************************************** -bool GPIO_MCP_Write(int Par1, byte Par2); -void GPIO_MCP_WriteRegister(byte mcpAddr, uint8_t regAddr, uint8_t regValue); +bool GPIO_MCP_Write(int Par1, uint8_t Par2); +void GPIO_MCP_WriteRegister(uint8_t mcpAddr, uint8_t regAddr, uint8_t regValue); //******************************************************************************** // MCP23017 pullUP @@ -52,7 +52,7 @@ bool GPIO_PCF_ReadAllPins(uint8_t address, uint8_t *retValue); //******************************************************************************** // PCF8574 write //******************************************************************************** -bool GPIO_PCF_Write(int Par1, byte Par2); +bool GPIO_PCF_Write(int Par1, uint8_t Par2); void GPIO_PCF_WriteAllPins(uint8_t Par1, uint8_t Par2); //********************************************************* @@ -70,14 +70,14 @@ void GPIO_Monitor10xSec(); void sendMonitorEvent(const char* prefix, int port, int8_t state); bool checkValidPortRange(pluginID_t pluginID, int port); -bool checkValidPortAddress(pluginID_t pluginID, byte address); +bool checkValidPortAddress(pluginID_t pluginID, uint8_t address); void setInternalGPIOPullupMode(uint8_t port); bool setMCPInputAndPullupMode(uint8_t Par1, bool enablePullUp); bool setMCPOutputMode(uint8_t Par1); bool setPCFInputMode(uint8_t pin); -bool GPIO_Write(pluginID_t pluginID, int port, byte value, byte pinMode=PIN_MODE_OUTPUT); +bool GPIO_Write(pluginID_t pluginID, int port, uint8_t value, uint8_t pinMode=PIN_MODE_OUTPUT); bool GPIO_Read(pluginID_t pluginID, int port, int8_t &value); #endif \ No newline at end of file diff --git a/src/src/ESPEasyCore/ESPEasyRules.cpp b/src/src/ESPEasyCore/ESPEasyRules.cpp index 7246d4960..f88f464a1 100644 --- a/src/src/ESPEasyCore/ESPEasyRules.cpp +++ b/src/src/ESPEasyCore/ESPEasyRules.cpp @@ -59,7 +59,7 @@ String FileNameToEvent(const String& fileName) { } void checkRuleSets() { - for (byte x = 0; x < RULESETS_MAX; x++) { + for (uint8_t x = 0; x < RULESETS_MAX; x++) { #if defined(ESP8266) String fileName = F("rules"); #endif // if defined(ESP8266) @@ -128,7 +128,7 @@ void rulesProcessing(const String& event) { } if (Settings.OldRulesEngine()) { - for (byte x = 0; x < RULESETS_MAX; x++) { + for (uint8_t x = 0; x < RULESETS_MAX; x++) { if (activeRuleSets[x]) { rulesProcessingFile(getRulesFileName(x), event); } @@ -185,7 +185,7 @@ String rulesProcessingFile(const String& fileName, const String& event) { } #endif // ifndef BUILD_NO_DEBUG - static byte nestingLevel = 0; + static uint8_t nestingLevel = 0; nestingLevel++; @@ -207,10 +207,10 @@ String rulesProcessingFile(const String& fileName, const String& event) { bool isCommand = false; bool condition[RULES_IF_MAX_NESTING_LEVEL]; bool ifBranche[RULES_IF_MAX_NESTING_LEVEL]; - byte ifBlock = 0; - byte fakeIfBlock = 0; + uint8_t ifBlock = 0; + uint8_t fakeIfBlock = 0; - std::vector buf; + std::vector buf; buf.resize(RULES_BUFFER_SIZE); bool firstNonSpaceRead = false; @@ -589,7 +589,7 @@ void parse_string_commands(String& line) { } else if (cmd_s_lower.equals(F("div100ths"))) { // division and giving the 100ths as integer // 5 / 100 would yield 5 - // useful for fractions that use a full byte gaining a + // useful for fractions that use a full uint8_t gaining a // precision/granularity of 1/256 instead of only 1/100 // Syntax like XXX{div100ths:24:256}XXX if (validUInt64FromString(arg1, iarg1) @@ -698,7 +698,7 @@ void parseCompleteNonCommentLine(String& line, const String& event, String& action, bool& match, bool& codeBlock, bool& isCommand, bool condition[], bool ifBranche[], - byte& ifBlock, byte& fakeIfBlock) { + uint8_t& ifBlock, uint8_t& fakeIfBlock) { const bool lineStartsWith_on = line.substring(0, 3).equalsIgnoreCase(F("on ")); if (!codeBlock && !match) { @@ -804,7 +804,7 @@ void parseCompleteNonCommentLine(String& line, const String& event, void processMatchedRule(String& action, const String& event, bool& match, bool& codeBlock, bool& isCommand, bool condition[], bool ifBranche[], - byte& ifBlock, byte& fakeIfBlock) { + uint8_t& ifBlock, uint8_t& fakeIfBlock) { String lcAction = action; lcAction.toLowerCase(); @@ -1242,7 +1242,7 @@ bool timeStringToSeconds(const String& tBuf, int& time_seconds, String& timeStri // Should only try to match "7:07", not "7:07 and 10:11:12" // Or else it will find "7:07:11" bool done = false; - for (byte pos = 0; !done && timeString.length() < 8 && pos < tBuf.length(); ++pos) { + for (uint8_t pos = 0; !done && timeString.length() < 8 && pos < tBuf.length(); ++pos) { char c = tBuf[pos]; if (isdigit(c) || c == ':') { timeString += c; @@ -1429,7 +1429,7 @@ void createRuleEvents(struct EventStruct *event) { LoadTaskSettings(event->TaskIndex); - const byte valueCount = getValueCountForTask(event->TaskIndex); + const uint8_t valueCount = getValueCountForTask(event->TaskIndex); // Small optimization as sensor type string may result in large strings // These also only yield a single value, so no need to check for combining task values. @@ -1467,7 +1467,7 @@ void createRuleEvents(struct EventStruct *event) { eventString = getTaskDeviceName(event->TaskIndex); eventString += F("#All="); - for (byte varNr = 0; varNr < valueCount; varNr++) { + for (uint8_t varNr = 0; varNr < valueCount; varNr++) { if (varNr != 0) { eventString += ','; } @@ -1475,7 +1475,7 @@ void createRuleEvents(struct EventStruct *event) { } eventQueue.addMove(std::move(eventString)); } else { - for (byte varNr = 0; varNr < valueCount; varNr++) { + for (uint8_t varNr = 0; varNr < valueCount; varNr++) { String eventString; eventString.reserve(64); // Enough for most use cases, prevent lots of memory allocations. eventString = getTaskDeviceName(event->TaskIndex); diff --git a/src/src/ESPEasyCore/ESPEasyRules.h b/src/src/ESPEasyCore/ESPEasyRules.h index 8c562f48d..da7695098 100644 --- a/src/src/ESPEasyCore/ESPEasyRules.h +++ b/src/src/ESPEasyCore/ESPEasyRules.h @@ -100,8 +100,8 @@ void parseCompleteNonCommentLine(String& line, bool & isCommand, bool condition[], bool ifBranche[], - byte & ifBlock, - byte & fakeIfBlock); + uint8_t & ifBlock, + uint8_t & fakeIfBlock); void processMatchedRule(String& action, const String& event, @@ -110,8 +110,8 @@ void processMatchedRule(String& action, bool & isCommand, bool condition[], bool ifBranche[], - byte & ifBlock, - byte & fakeIfBlock); + uint8_t & ifBlock, + uint8_t & fakeIfBlock); /********************************************************************************************\ Check if an event matches to a given rule diff --git a/src/src/ESPEasyCore/ESPEasy_Log.cpp b/src/src/ESPEasyCore/ESPEasy_Log.cpp index eaa3d0372..b41261b97 100644 --- a/src/src/ESPEasyCore/ESPEasy_Log.cpp +++ b/src/src/ESPEasyCore/ESPEasy_Log.cpp @@ -47,7 +47,7 @@ const __FlashStringHelper * getLogLevelDisplayString(int logLevel) { return F(""); } -const __FlashStringHelper * getLogLevelDisplayStringFromIndex(byte index, int& logLevel) { +const __FlashStringHelper * getLogLevelDisplayStringFromIndex(uint8_t index, int& logLevel) { switch (index) { case 0: logLevel = LOG_LEVEL_ERROR; break; case 1: logLevel = LOG_LEVEL_INFO; break; @@ -65,7 +65,7 @@ void disableSerialLog() { setLogLevelFor(LOG_TO_SERIAL, 0); } -void setLogLevelFor(byte destination, byte logLevel) { +void setLogLevelFor(uint8_t destination, uint8_t logLevel) { switch (destination) { case LOG_TO_SERIAL: if (!log_to_serial_disabled || logLevel == 0) { @@ -82,7 +82,7 @@ void setLogLevelFor(byte destination, byte logLevel) { } void updateLogLevelCache() { - byte max_lvl = 0; + uint8_t max_lvl = 0; const bool useSerial = Settings.UseSerial && !activeTaskUseSerial0(); if (log_to_serial_disabled) { if (useSerial) { @@ -106,11 +106,11 @@ void updateLogLevelCache() { highest_active_log_level = max_lvl; } -bool loglevelActiveFor(byte logLevel) { +bool loglevelActiveFor(uint8_t logLevel) { return loglevelActive(logLevel, highest_active_log_level); } -byte getSerialLogLevel() { +uint8_t getSerialLogLevel() { if (log_to_serial_disabled || !Settings.UseSerial || activeTaskUseSerial0()) return 0; if (!(WiFiEventData.WiFiServicesInitialized())){ if (Settings.SerialLogLevel < LOG_LEVEL_INFO) { @@ -120,8 +120,8 @@ byte getSerialLogLevel() { return Settings.SerialLogLevel; } -byte getWebLogLevel() { - byte logLevelSettings = 0; +uint8_t getWebLogLevel() { + uint8_t logLevelSettings = 0; if (Logging.logActiveRead()) { logLevelSettings = Settings.WebLogLevel; } else { @@ -132,8 +132,8 @@ byte getWebLogLevel() { return logLevelSettings; } -bool loglevelActiveFor(byte destination, byte logLevel) { - byte logLevelSettings = 0; +bool loglevelActiveFor(uint8_t destination, uint8_t logLevel) { + uint8_t logLevelSettings = 0; switch (destination) { case LOG_TO_SERIAL: { logLevelSettings = getSerialLogLevel(); @@ -160,29 +160,29 @@ bool loglevelActiveFor(byte destination, byte logLevel) { } -bool loglevelActive(byte logLevel, byte logLevelSettings) { +bool loglevelActive(uint8_t logLevel, uint8_t logLevelSettings) { return (logLevel <= logLevelSettings); } //#ifdef LIMIT_BUILD_SIZE -void addLog(byte loglevel, const __FlashStringHelper *str) +void addLog(uint8_t loglevel, const __FlashStringHelper *str) { addToLog(loglevel, str); } -void addLog(byte logLevel, const char *line) +void addLog(uint8_t logLevel, const char *line) { addToLog(logLevel, line); } -void addLog(byte loglevel, const String& string) +void addLog(uint8_t loglevel, const String& string) { addToLog(loglevel, string); } //#endif -void addToLog(byte loglevel, const __FlashStringHelper *str) +void addToLog(uint8_t loglevel, const __FlashStringHelper *str) { if (loglevelActiveFor(loglevel)) { String copy; @@ -193,14 +193,14 @@ void addToLog(byte loglevel, const __FlashStringHelper *str) } } -void addToLog(byte loglevel, const String& string) +void addToLog(uint8_t loglevel, const String& string) { if (loglevelActiveFor(loglevel)) { addToLog(loglevel, string.c_str()); } } -void addToLog(byte logLevel, const char *line) +void addToLog(uint8_t logLevel, const char *line) { // Please note all functions called from here handling line must be PROGMEM aware. if (loglevelActiveFor(LOG_TO_SERIAL, logLevel)) { diff --git a/src/src/ESPEasyCore/ESPEasy_Log.h b/src/src/ESPEasyCore/ESPEasy_Log.h index b4f1dd100..601f9758c 100644 --- a/src/src/ESPEasyCore/ESPEasy_Log.h +++ b/src/src/ESPEasyCore/ESPEasy_Log.h @@ -25,40 +25,40 @@ void initLog(); const __FlashStringHelper * getLogLevelDisplayString(int logLevel); -const __FlashStringHelper * getLogLevelDisplayStringFromIndex(byte index, int& logLevel); +const __FlashStringHelper * getLogLevelDisplayStringFromIndex(uint8_t index, int& logLevel); void disableSerialLog(); -void setLogLevelFor(byte destination, byte logLevel); +void setLogLevelFor(uint8_t destination, uint8_t logLevel); void updateLogLevelCache(); -bool loglevelActiveFor(byte logLevel); +bool loglevelActiveFor(uint8_t logLevel); -byte getSerialLogLevel(); +uint8_t getSerialLogLevel(); -byte getWebLogLevel(); +uint8_t getWebLogLevel(); -bool loglevelActiveFor(byte destination, byte logLevel); +bool loglevelActiveFor(uint8_t destination, uint8_t logLevel); -bool loglevelActive(byte logLevel, byte logLevelSettings); +bool loglevelActive(uint8_t logLevel, uint8_t logLevelSettings); //#ifdef LIMIT_BUILD_SIZE // Macro does add to the build size, but does take more resources as the string may need resources to create -void addLog(byte loglevel, const __FlashStringHelper *str); -void addLog(byte logLevel, const char *line); -void addLog(byte loglevel, const String& string); +void addLog(uint8_t loglevel, const __FlashStringHelper *str); +void addLog(uint8_t logLevel, const char *line); +void addLog(uint8_t loglevel, const String& string); //#else // Do this in a template to prevent casting to String when not needed. //#define addLog(L,S) if (loglevelActiveFor(L)) { addToLog(L,S); } //#endif -void addToLog(byte loglevel, const __FlashStringHelper *str); +void addToLog(uint8_t loglevel, const __FlashStringHelper *str); -void addToLog(byte loglevel, const String& string); +void addToLog(uint8_t loglevel, const String& string); -void addToLog(byte logLevel, const char *line); +void addToLog(uint8_t logLevel, const char *line); #endif \ No newline at end of file diff --git a/src/src/ESPEasyCore/ESPEasy_setup.cpp b/src/src/ESPEasyCore/ESPEasy_setup.cpp index 058f562d9..77fd0564f 100644 --- a/src/src/ESPEasyCore/ESPEasy_setup.cpp +++ b/src/src/ESPEasyCore/ESPEasy_setup.cpp @@ -223,7 +223,7 @@ void ESPEasy_setup() Settings.UseRTOSMultitasking = false; // For now, disable it, we experience heap corruption. if ((RTC.bootFailedCount > 10) && (RTC.bootCounter > 10)) { - byte toDisable = RTC.bootFailedCount - 10; + uint8_t toDisable = RTC.bootFailedCount - 10; toDisable = disablePlugin(toDisable); if (toDisable != 0) { diff --git a/src/src/ESPEasyCore/Serial.cpp b/src/src/ESPEasyCore/Serial.cpp index 552760a66..911a3001b 100644 --- a/src/src/ESPEasyCore/Serial.cpp +++ b/src/src/ESPEasyCore/Serial.cpp @@ -14,7 +14,7 @@ * Get data from Serial Interface \*********************************************************************************************/ -byte SerialInByte; +uint8_t SerialInByte; int SerialInByteCounter = 0; char InputBuffer_Serial[INPUT_BUFFER_SIZE + 2]; diff --git a/src/src/ESPEasyCore/Serial.h b/src/src/ESPEasyCore/Serial.h index ea9abab1d..56f97c2eb 100644 --- a/src/src/ESPEasyCore/Serial.h +++ b/src/src/ESPEasyCore/Serial.h @@ -5,7 +5,7 @@ #define INPUT_BUFFER_SIZE 128 -extern byte SerialInByte; +extern uint8_t SerialInByte; extern int SerialInByteCounter; extern char InputBuffer_Serial[INPUT_BUFFER_SIZE + 2]; diff --git a/src/src/Globals/C016_ControllerCache.cpp b/src/src/Globals/C016_ControllerCache.cpp index 381210584..f28750b30 100644 --- a/src/src/Globals/C016_ControllerCache.cpp +++ b/src/src/Globals/C016_ControllerCache.cpp @@ -22,10 +22,10 @@ bool C016_deleteOldestCacheBlock() { bool C016_getCSVline( unsigned long& timestamp, - byte& controller_idx, - byte& TaskIndex, + uint8_t& controller_idx, + uint8_t& TaskIndex, Sensor_VType& sensorType, - byte& valueCount, + uint8_t& valueCount, float& val1, float& val2, float& val3, diff --git a/src/src/Globals/C016_ControllerCache.h b/src/src/Globals/C016_ControllerCache.h index 08c13446a..edcd613ed 100644 --- a/src/src/Globals/C016_ControllerCache.h +++ b/src/src/Globals/C016_ControllerCache.h @@ -22,10 +22,10 @@ bool C016_deleteOldestCacheBlock(); bool C016_getCSVline( unsigned long& timestamp, - byte& controller_idx, - byte& TaskIndex, + uint8_t& controller_idx, + uint8_t& TaskIndex, Sensor_VType& sensorType, - byte& valueCount, + uint8_t& valueCount, float& val1, float& val2, float& val3, diff --git a/src/src/Globals/MainLoopCommand.cpp b/src/src/Globals/MainLoopCommand.cpp index 9a5bb2e1a..8f5fc427d 100644 --- a/src/src/Globals/MainLoopCommand.cpp +++ b/src/src/Globals/MainLoopCommand.cpp @@ -1,3 +1,3 @@ #include "MainLoopCommand.h" -byte cmd_within_mainloop = 0; \ No newline at end of file +uint8_t cmd_within_mainloop = 0; \ No newline at end of file diff --git a/src/src/Globals/MainLoopCommand.h b/src/src/Globals/MainLoopCommand.h index 055446114..1d2caa715 100644 --- a/src/src/Globals/MainLoopCommand.h +++ b/src/src/Globals/MainLoopCommand.h @@ -3,7 +3,7 @@ #include -extern byte cmd_within_mainloop; +extern uint8_t cmd_within_mainloop; // ******************************************************************************** // DO NOT CHANGE ANYTHING BELOW THIS LINE diff --git a/src/src/Globals/NPlugins.cpp b/src/src/Globals/NPlugins.cpp index f9fbe5b6c..975091bcb 100644 --- a/src/src/Globals/NPlugins.cpp +++ b/src/src/Globals/NPlugins.cpp @@ -52,7 +52,7 @@ String getNPluginNameFromNotifierIndex(notifierIndex_t NotifierIndex) { \*********************************************************************************************/ nprotocolIndex_t getNProtocolIndex(npluginID_t Number) { - for (byte x = 0; x <= notificationCount; x++) { + for (uint8_t x = 0; x <= notificationCount; x++) { if (Notification[x].Number == Number) { return x; } diff --git a/src/src/Globals/NPlugins.h b/src/src/Globals/NPlugins.h index 2875a8679..38f4e659e 100644 --- a/src/src/Globals/NPlugins.h +++ b/src/src/Globals/NPlugins.h @@ -9,8 +9,8 @@ #include "../DataTypes/ESPEasy_plugin_functions.h" -typedef byte nprotocolIndex_t; -typedef byte notifierIndex_t; +typedef uint8_t nprotocolIndex_t; +typedef uint8_t notifierIndex_t; typedef uint8_t npluginID_t; extern nprotocolIndex_t INVALID_NPROTOCOL_INDEX; @@ -28,7 +28,7 @@ extern NotificationStruct Notification[NPLUGIN_MAX]; extern int notificationCount; -byte NPluginCall(NPlugin::Function Function, +uint8_t NPluginCall(NPlugin::Function Function, struct EventStruct *event); bool validNProtocolIndex(nprotocolIndex_t index); diff --git a/src/src/Globals/NetworkState.cpp b/src/src/Globals/NetworkState.cpp index 4d8582b12..3f42e91b4 100644 --- a/src/src/Globals/NetworkState.cpp +++ b/src/src/Globals/NetworkState.cpp @@ -16,7 +16,7 @@ bool statusNTPInitialized = false; // Setup DNS, only used if the ESP has no valid WiFi config -const byte DNS_PORT = 53; +const uint8_t DNS_PORT = 53; IPAddress apIP(DEFAULT_AP_IP); diff --git a/src/src/Globals/NetworkState.h b/src/src/Globals/NetworkState.h index f229ec2ff..ec8aa2174 100644 --- a/src/src/Globals/NetworkState.h +++ b/src/src/Globals/NetworkState.h @@ -22,7 +22,7 @@ extern bool statusNTPInitialized; // Setup DNS, only used if the ESP has no valid WiFi config -extern const byte DNS_PORT; +extern const uint8_t DNS_PORT; extern IPAddress apIP; // udp protocol stuff (syslog, global sync, node info list, ntp time) diff --git a/src/src/Globals/Plugins.cpp b/src/src/Globals/Plugins.cpp index bd4a15f29..62424cf59 100644 --- a/src/src/Globals/Plugins.cpp +++ b/src/src/Globals/Plugins.cpp @@ -32,7 +32,7 @@ int deviceCount = -1; -boolean (*Plugin_ptr[PLUGIN_MAX])(byte, +boolean (*Plugin_ptr[PLUGIN_MAX])(uint8_t, struct EventStruct *, String&); @@ -255,7 +255,7 @@ void queueTaskEvent(const String& eventName, taskIndex_t taskIndex, int value1) /** * Call the plugin of 1 task for 1 function, with standard EventStruct and optional command string */ -bool PluginCallForTask(taskIndex_t taskIndex, byte Function, EventStruct *TempEvent, String& command, EventStruct *event = nullptr) { +bool PluginCallForTask(taskIndex_t taskIndex, uint8_t Function, EventStruct *TempEvent, String& command, EventStruct *event = nullptr) { bool retval = false; if (Settings.TaskDeviceEnabled[taskIndex] && validPluginID_fullcheck(Settings.TaskDeviceNumber[taskIndex])) { @@ -308,7 +308,7 @@ bool PluginCallForTask(taskIndex_t taskIndex, byte Function, EventStruct *TempEv /*********************************************************************************************\ * Function call to all or specific plugins \*********************************************************************************************/ -bool PluginCall(byte Function, struct EventStruct *event, String& str) +bool PluginCall(uint8_t Function, struct EventStruct *event, String& str) { struct EventStruct TempEvent; diff --git a/src/src/Globals/Plugins.h b/src/src/Globals/Plugins.h index e190de0bb..dfedcc3e3 100644 --- a/src/src/Globals/Plugins.h +++ b/src/src/Globals/Plugins.h @@ -46,7 +46,7 @@ extern int deviceCount; // Array of function pointers to call plugins. -extern boolean (*Plugin_ptr[PLUGIN_MAX])(byte, +extern boolean (*Plugin_ptr[PLUGIN_MAX])(uint8_t, struct EventStruct *, String&); @@ -93,7 +93,7 @@ void post_I2C_by_taskIndex(taskIndex_t taskIndex, deviceIndex_t DeviceIndex); /*********************************************************************************************\ * Function call to all or specific plugins \*********************************************************************************************/ -bool PluginCall(byte Function, struct EventStruct *event, String& str); +bool PluginCall(uint8_t Function, struct EventStruct *event, String& str); /*********************************************************************************************\ diff --git a/src/src/Helpers/Audio.cpp b/src/src/Helpers/Audio.cpp index 1c769338b..c29fdc5fb 100644 --- a/src/src/Helpers/Audio.cpp +++ b/src/src/Helpers/Audio.cpp @@ -38,14 +38,14 @@ bool play_rtttl(uint8_t _pin, const char *p) }; - byte default_dur = 4; - byte default_oct = 6; + uint8_t default_dur = 4; + uint8_t default_oct = 6; int bpm = 63; int num; long wholenote; long duration; - byte note; - byte scale; + uint8_t note; + uint8_t scale; // format: d=N,o=N,b=NNN: // find the start (skip name, etc) diff --git a/src/src/Helpers/Convert.cpp b/src/src/Helpers/Convert.cpp index b8c00a669..b178371df 100644 --- a/src/src/Helpers/Convert.cpp +++ b/src/src/Helpers/Convert.cpp @@ -234,7 +234,7 @@ float ul2float(unsigned long ul) /*********************************************************************************************\ Workaround for removing trailing white space when String() converts a float with 0 decimals \*********************************************************************************************/ -String toString(const float& value, byte decimals) +String toString(const float& value, uint8_t decimals) { String sValue = String(value, decimals); diff --git a/src/src/Helpers/Convert.h b/src/src/Helpers/Convert.h index 669d5ed47..e5c1bf8a8 100644 --- a/src/src/Helpers/Convert.h +++ b/src/src/Helpers/Convert.h @@ -65,7 +65,7 @@ float ul2float(unsigned long ul); /*********************************************************************************************\ Workaround for removing trailing white space when String() converts a float with 0 decimals \*********************************************************************************************/ -String toString(const float& value, byte decimals); +String toString(const float& value, uint8_t decimals); String doubleToString(const double& value, int decimals = 2, bool trimTrailingZeros = false); diff --git a/src/src/Helpers/Dallas1WireHelper.cpp b/src/src/Helpers/Dallas1WireHelper.cpp index 48b20d048..d59fc2944 100644 --- a/src/src/Helpers/Dallas1WireHelper.cpp +++ b/src/src/Helpers/Dallas1WireHelper.cpp @@ -46,7 +46,7 @@ String Dallas_format_address(const uint8_t addr[]) { result.reserve(40); - for (byte j = 0; j < 8; j++) + for (uint8_t j = 0; j < 8; j++) { if (addr[j] < 0x10) { result += '0'; @@ -65,7 +65,7 @@ String Dallas_format_address(const uint8_t addr[]) { uint64_t Dallas_addr_to_uint64(const uint8_t addr[]) { uint64_t tmpAddr_64 = 0; - for (byte i = 0; i < 8; ++i) { + for (uint8_t i = 0; i < 8; ++i) { tmpAddr_64 *= 256; tmpAddr_64 += addr[i]; } @@ -160,7 +160,7 @@ void Dallas_addr_selector_webform_load(taskIndex_t TaskIndex, int8_t gpio_pin_rx // get currently saved address uint8_t savedAddress[8]; - for (byte index = 0; index < scan_res.size(); ++index) { + for (uint8_t index = 0; index < scan_res.size(); ++index) { Dallas_plugin_get_addr(savedAddress, TaskIndex, var_index); Dallas_uint64_to_addr(scan_res[index], tmpAddress); String option = Dallas_format_address(tmpAddress); @@ -248,7 +248,7 @@ void Dallas_plugin_get_addr(uint8_t addr[], taskIndex_t TaskIndex, uint8_t var_i // Load ROM address from tasksettings LoadTaskSettings(TaskIndex); - for (byte x = 0; x < 8; x++) { + for (uint8_t x = 0; x < 8; x++) { uint32_t value = (uint32_t)ExtraTaskSettings.TaskDevicePluginConfigLong[x]; addr[x] = static_cast((value >> (var_index * 8)) & 0xFF); } @@ -262,7 +262,7 @@ void Dallas_plugin_set_addr(uint8_t addr[], taskIndex_t TaskIndex, uint8_t var_i LoadTaskSettings(TaskIndex); const uint32_t mask = ~(0xFF << (var_index * 8)); - for (byte x = 0; x < 8; x++) { + for (uint8_t x = 0; x < 8; x++) { uint32_t value = (uint32_t)ExtraTaskSettings.TaskDevicePluginConfigLong[x]; value &= mask; value += (static_cast(addr[x]) << (var_index * 8)); @@ -273,10 +273,10 @@ void Dallas_plugin_set_addr(uint8_t addr[], taskIndex_t TaskIndex, uint8_t var_i /*********************************************************************************************\ Dallas Scan bus \*********************************************************************************************/ -byte Dallas_scan(byte getDeviceROM, uint8_t *ROM, int8_t gpio_pin_rx, int8_t gpio_pin_tx) +uint8_t Dallas_scan(uint8_t getDeviceROM, uint8_t *ROM, int8_t gpio_pin_rx, int8_t gpio_pin_tx) { - byte tmpaddr[8]; - byte devCount = 0; + uint8_t tmpaddr[8]; + uint8_t devCount = 0; Dallas_reset(gpio_pin_rx, gpio_pin_tx); @@ -285,7 +285,7 @@ byte Dallas_scan(byte getDeviceROM, uint8_t *ROM, int8_t gpio_pin_rx, int8_t gpi while (Dallas_search(tmpaddr, gpio_pin_rx, gpio_pin_tx)) { if (getDeviceROM == devCount) { - for (byte i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { ROM[i] = tmpaddr[i]; } } @@ -309,7 +309,7 @@ void Dallas_startConversion(const uint8_t ROM[8], int8_t gpio_pin_rx, int8_t gpi Dallas_reset(gpio_pin_rx, gpio_pin_tx); Dallas_write(0x55, gpio_pin_rx, gpio_pin_tx); // Choose ROM - for (byte i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { Dallas_write(ROM[i], gpio_pin_rx, gpio_pin_tx); } Dallas_write(0x44, gpio_pin_rx, gpio_pin_tx); @@ -321,14 +321,14 @@ void Dallas_startConversion(const uint8_t ROM[8], int8_t gpio_pin_rx, int8_t gpi bool Dallas_readTemp(const uint8_t ROM[8], float *value, int8_t gpio_pin_rx, int8_t gpio_pin_tx) { int16_t DSTemp; - byte ScratchPad[12]; + uint8_t ScratchPad[12]; if (!Dallas_address_ROM(ROM, gpio_pin_rx, gpio_pin_tx)) { return false; } Dallas_write(0xBE, gpio_pin_rx, gpio_pin_tx); // Read scratchpad - for (byte i = 0; i < 9; i++) { // read 9 bytes + for (uint8_t i = 0; i < 9; i++) { // read 9 bytes ScratchPad[i] = Dallas_read(gpio_pin_rx, gpio_pin_tx); } @@ -337,7 +337,7 @@ bool Dallas_readTemp(const uint8_t ROM[8], float *value, int8_t gpio_pin_rx, int if (loglevelActiveFor(LOG_LEVEL_DEBUG)) { String log = F("DS: SP: "); - for (byte x = 0; x < 9; x++) + for (uint8_t x = 0; x < 9; x++) { if (x != 0) { log += ','; @@ -389,25 +389,25 @@ bool Dallas_readTemp(const uint8_t ROM[8], float *value, int8_t gpio_pin_rx, int return true; } -bool Dallas_readiButton(const byte addr[8], int8_t gpio_pin_rx, int8_t gpio_pin_tx) +bool Dallas_readiButton(const uint8_t addr[8], int8_t gpio_pin_rx, int8_t gpio_pin_tx) { // maybe this is needed to trigger the reading - // byte ScratchPad[12]; + // uint8_t ScratchPad[12]; Dallas_reset(gpio_pin_rx, gpio_pin_tx); Dallas_write(0x55, gpio_pin_rx, gpio_pin_tx); // Choose ROM - for (byte i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { Dallas_write(addr[i], gpio_pin_rx, gpio_pin_tx); } Dallas_write(0xBE, gpio_pin_rx, gpio_pin_tx); // Read scratchpad - // for (byte i = 0; i < 9; i++) // read 9 bytes + // for (uint8_t i = 0; i < 9; i++) // read 9 bytes // ScratchPad[i] = Dallas_read(); // end maybe this is needed to trigger the reading - byte tmpaddr[8]; + uint8_t tmpaddr[8]; bool found = false; Dallas_reset(gpio_pin_rx, gpio_pin_tx); @@ -496,19 +496,19 @@ bool Dallas_readCounter(const uint8_t ROM[8], float *value, int8_t gpio_pin_rx, /*********************************************************************************************\ * Dallas Get Resolution \*********************************************************************************************/ -byte Dallas_getResolution(const uint8_t ROM[8], int8_t gpio_pin_rx, int8_t gpio_pin_tx) +uint8_t Dallas_getResolution(const uint8_t ROM[8], int8_t gpio_pin_rx, int8_t gpio_pin_tx) { // DS1820 and DS18S20 have no resolution configuration register if (ROM[0] == 0x10) { return 12; } - byte ScratchPad[12]; + uint8_t ScratchPad[12]; if (!Dallas_address_ROM(ROM, gpio_pin_rx, gpio_pin_tx)) { return 0; } Dallas_write(0xBE, gpio_pin_rx, gpio_pin_tx); // Read scratchpad - for (byte i = 0; i < 9; i++) { // read 9 bytes + for (uint8_t i = 0; i < 9; i++) { // read 9 bytes ScratchPad[i] = Dallas_read(gpio_pin_rx, gpio_pin_tx); } @@ -539,19 +539,19 @@ byte Dallas_getResolution(const uint8_t ROM[8], int8_t gpio_pin_rx, int8_t gpio_ /*********************************************************************************************\ * Dallas Get Resolution \*********************************************************************************************/ -bool Dallas_setResolution(const uint8_t ROM[8], byte res, int8_t gpio_pin_rx, int8_t gpio_pin_tx) +bool Dallas_setResolution(const uint8_t ROM[8], uint8_t res, int8_t gpio_pin_rx, int8_t gpio_pin_tx) { // DS1820 and DS18S20 have no resolution configuration register if (ROM[0] == 0x10) { return true; } - byte ScratchPad[12]; + uint8_t ScratchPad[12]; if (!Dallas_address_ROM(ROM, gpio_pin_rx, gpio_pin_tx)) { return false; } Dallas_write(0xBE, gpio_pin_rx, gpio_pin_tx); // Read scratchpad - for (byte i = 0; i < 9; i++) { // read 9 bytes + for (uint8_t i = 0; i < 9; i++) { // read 9 bytes ScratchPad[i] = Dallas_read(gpio_pin_rx, gpio_pin_tx); } @@ -561,7 +561,7 @@ bool Dallas_setResolution(const uint8_t ROM[8], byte res, int8_t gpio_pin_rx, in } else { - byte old_configuration = ScratchPad[4]; + uint8_t old_configuration = ScratchPad[4]; switch (res) { @@ -706,7 +706,7 @@ void Dallas_reset_search() LastDeviceFlag = FALSE; LastFamilyDiscrepancy = 0; - for (byte i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { ROM_NO[i] = 0; } } @@ -985,7 +985,7 @@ bool Dallas_address_ROM(const uint8_t ROM[8], int8_t gpio_pin_rx, int8_t gpio_pi if (!Dallas_reset(gpio_pin_rx, gpio_pin_tx)) { return false; } Dallas_write(0x55, gpio_pin_rx, gpio_pin_tx); // Choose ROM - for (byte i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { Dallas_write(ROM[i], gpio_pin_rx, gpio_pin_tx); } return true; diff --git a/src/src/Helpers/Dallas1WireHelper.h b/src/src/Helpers/Dallas1WireHelper.h index 209e6cd12..5e64305e8 100644 --- a/src/src/Helpers/Dallas1WireHelper.h +++ b/src/src/Helpers/Dallas1WireHelper.h @@ -86,7 +86,7 @@ void Dallas_plugin_set_addr(uint8_t addr[], taskIndex_t TaskIndex, uint8_t var_i /*********************************************************************************************\ Dallas Scan bus \*********************************************************************************************/ -byte Dallas_scan(byte getDeviceROM, +uint8_t Dallas_scan(uint8_t getDeviceROM, uint8_t *ROM, int8_t gpio_pin_rx, int8_t gpio_pin_tx); @@ -108,7 +108,7 @@ bool Dallas_readTemp(const uint8_t ROM[8], int8_t gpio_pin_rx, int8_t gpio_pin_tx); -bool Dallas_readiButton(const byte addr[8], +bool Dallas_readiButton(const uint8_t addr[8], int8_t gpio_pin_rx, int8_t gpio_pin_tx); @@ -121,7 +121,7 @@ bool Dallas_readCounter(const uint8_t ROM[8], /*********************************************************************************************\ * Dallas Get Resolution \*********************************************************************************************/ -byte Dallas_getResolution(const uint8_t ROM[8], +uint8_t Dallas_getResolution(const uint8_t ROM[8], int8_t gpio_pin_rx, int8_t gpio_pin_tx); @@ -129,7 +129,7 @@ byte Dallas_getResolution(const uint8_t ROM[8], * Dallas Set Resolution \*********************************************************************************************/ bool Dallas_setResolution(const uint8_t ROM[8], - byte res, + uint8_t res, int8_t gpio_pin_rx, int8_t gpio_pin_tx); diff --git a/src/src/Helpers/ESPEasyRTC.cpp b/src/src/Helpers/ESPEasyRTC.cpp index b4841fd32..1e93990c6 100644 --- a/src/src/Helpers/ESPEasyRTC.cpp +++ b/src/src/Helpers/ESPEasyRTC.cpp @@ -36,7 +36,7 @@ So, if we want to access some data at the beginning of user data area, address: 256/4 = 64 data : data pointer - size : data length, byte + size : data length, uint8_t Prototype: bool system_rtc_mem_read ( @@ -114,7 +114,7 @@ bool saveToRTC() #else // if defined(ESP32) START_TIMER - if (!system_rtc_mem_write(RTC_BASE_STRUCT, (byte *)&RTC, sizeof(RTC)) || !readFromRTC()) + if (!system_rtc_mem_write(RTC_BASE_STRUCT, (uint8_t *)&RTC, sizeof(RTC)) || !readFromRTC()) { # ifdef RTC_STRUCT_DEBUG addLog(LOG_LEVEL_ERROR, F("RTC : Error while writing to RTC")); @@ -154,7 +154,7 @@ bool readFromRTC() RTC = RTC_tmp; #endif #ifdef ESP8266 - if (!system_rtc_mem_read(RTC_BASE_STRUCT, (byte *)&RTC, sizeof(RTC))) { + if (!system_rtc_mem_read(RTC_BASE_STRUCT, (uint8_t *)&RTC, sizeof(RTC))) { return false; } #endif @@ -172,17 +172,17 @@ bool saveUserVarToRTC() for (size_t i = 0; i < UserVar_nrelements; ++i) { UserVar_RTC[i] = UserVar[i]; } - UserVar_checksum = calc_CRC32((byte *)(&UserVar[0]), UserVar_nrelements * sizeof(float)); + UserVar_checksum = calc_CRC32((uint8_t *)(&UserVar[0]), UserVar_nrelements * sizeof(float)); return true; #endif #ifdef ESP8266 // addLog(LOG_LEVEL_DEBUG, F("RTCMEM: saveUserVarToRTC")); - byte *buffer = UserVar.get(); + uint8_t *buffer = UserVar.get(); size_t size = UserVar.getNrElements() * sizeof(float); uint32_t sum = calc_CRC32(buffer, size); bool ret = system_rtc_mem_write(RTC_BASE_USERVAR, buffer, size); - ret &= system_rtc_mem_write(RTC_BASE_USERVAR + (size >> 2), (byte *)&sum, 4); + ret &= system_rtc_mem_write(RTC_BASE_USERVAR + (size >> 2), (uint8_t *)&sum, 4); return ret; #endif } @@ -195,7 +195,7 @@ bool readUserVarFromRTC() // ESP8266 has the RTC struct stored in memory which we must actively fetch // ESP32 Uses a temp structure which is mapped to the RTC address range. #if defined(ESP32) - if (calc_CRC32((byte *)(&UserVar_RTC[0]), UserVar_nrelements * sizeof(float)) == UserVar_checksum) { + if (calc_CRC32((uint8_t *)(&UserVar_RTC[0]), UserVar_nrelements * sizeof(float)) == UserVar_checksum) { for (size_t i = 0; i < UserVar_nrelements; ++i) { UserVar[i] = UserVar_RTC[i]; } @@ -206,12 +206,12 @@ bool readUserVarFromRTC() #ifdef ESP8266 // addLog(LOG_LEVEL_DEBUG, F("RTCMEM: readUserVarFromRTC")); - byte *buffer = UserVar.get(); + uint8_t *buffer = UserVar.get(); size_t size = UserVar.getNrElements() * sizeof(float); bool ret = system_rtc_mem_read(RTC_BASE_USERVAR, buffer, size); uint32_t sumRAM = calc_CRC32(buffer, size); uint32_t sumRTC = 0; - ret &= system_rtc_mem_read(RTC_BASE_USERVAR + (size >> 2), (byte *)&sumRTC, 4); + ret &= system_rtc_mem_read(RTC_BASE_USERVAR + (size >> 2), (uint8_t *)&sumRTC, 4); if (!ret || (sumRTC != sumRAM)) { diff --git a/src/src/Helpers/ESPEasyStatistics.cpp b/src/src/Helpers/ESPEasyStatistics.cpp index 8a09a68b5..2fd85f161 100644 --- a/src/src/Helpers/ESPEasyStatistics.cpp +++ b/src/src/Helpers/ESPEasyStatistics.cpp @@ -8,7 +8,7 @@ #include "../Globals/Protocol.h" /* - void logStatistics(byte loglevel, bool clearStats) { + void logStatistics(uint8_t loglevel, bool clearStats) { if (loglevelActiveFor(loglevel)) { String log; log.reserve(80); diff --git a/src/src/Helpers/ESPEasyStatistics.h b/src/src/Helpers/ESPEasyStatistics.h index e806afb92..20a3bdd6c 100644 --- a/src/src/Helpers/ESPEasyStatistics.h +++ b/src/src/Helpers/ESPEasyStatistics.h @@ -9,7 +9,7 @@ #include "../DataStructs/TimingStats.h" -//void logStatistics(byte loglevel, bool clearStats); +//void logStatistics(uint8_t loglevel, bool clearStats); void stream_json_timing_stats(const TimingStats& stats, long timeSinceLastReset); diff --git a/src/src/Helpers/ESPEasy_Storage.cpp b/src/src/Helpers/ESPEasy_Storage.cpp index d967f4354..27e523e89 100644 --- a/src/src/Helpers/ESPEasy_Storage.cpp +++ b/src/src/Helpers/ESPEasy_Storage.cpp @@ -266,8 +266,8 @@ String BuildFixes() } if (Settings.Build < 20111) { #ifdef ESP32 - constexpr byte maxStatesesp32 = sizeof(Settings.PinBootStates_ESP32) / sizeof(Settings.PinBootStates_ESP32[0]); - for (byte i = 0; i < maxStatesesp32; ++i) { + constexpr uint8_t maxStatesesp32 = sizeof(Settings.PinBootStates_ESP32) / sizeof(Settings.PinBootStates_ESP32[0]); + for (uint8_t i = 0; i < maxStatesesp32; ++i) { Settings.PinBootStates_ESP32[i] = 0; } #endif @@ -395,7 +395,7 @@ String SaveSettings() memcpy(Settings.md5, tmp_md5, 16); */ Settings.validate(); - err = SaveToFile(SettingsType::getSettingsFileName(SettingsType::Enum::BasicSettings_Type).c_str(), 0, (byte *)&Settings, sizeof(Settings)); + err = SaveToFile(SettingsType::getSettingsFileName(SettingsType::Enum::BasicSettings_Type).c_str(), 0, (uint8_t *)&Settings, sizeof(Settings)); } if (err.length()) { @@ -427,7 +427,7 @@ String SaveSecuritySettings() { if (memcmp(tmp_md5, SecuritySettings.md5, 16) != 0) { // Settings have changed, save to file. memcpy(SecuritySettings.md5, tmp_md5, 16); - err = SaveToFile((char *)FILE_SECURITY, 0, (byte *)&SecuritySettings, sizeof(SecuritySettings)); + err = SaveToFile((char *)FILE_SECURITY, 0, (uint8_t *)&SecuritySettings, sizeof(SecuritySettings)); if (WifiIsAP(WiFi.getMode())) { // Security settings are saved, may be update of WiFi settings or hostname. @@ -471,7 +471,7 @@ String LoadSettings() uint8_t calculatedMd5[16]; MD5Builder md5; - err = LoadFromFile(SettingsType::getSettingsFileName(SettingsType::Enum::BasicSettings_Type).c_str(), 0, (byte *)&Settings, sizeof(SettingsStruct)); + err = LoadFromFile(SettingsType::getSettingsFileName(SettingsType::Enum::BasicSettings_Type).c_str(), 0, (uint8_t *)&Settings, sizeof(SettingsStruct)); if (err.length()) { return err; @@ -497,7 +497,7 @@ String LoadSettings() } */ - err = LoadFromFile((char *)FILE_SECURITY, 0, (byte *)&SecuritySettings, sizeof(SecurityStruct)); + err = LoadFromFile((char *)FILE_SECURITY, 0, (uint8_t *)&SecuritySettings, sizeof(SecurityStruct)); md5.begin(); md5.add((uint8_t *)&SecuritySettings, sizeof(SecuritySettings) - 16); md5.calculate(); @@ -526,7 +526,7 @@ String LoadSettings() /********************************************************************************************\ Disable Plugin, based on bootFailedCount \*********************************************************************************************/ -byte disablePlugin(byte bootFailedCount) { +uint8_t disablePlugin(uint8_t bootFailedCount) { for (taskIndex_t i = 0; i < TASKS_MAX && bootFailedCount > 0; ++i) { if (Settings.TaskDeviceEnabled[i]) { --bootFailedCount; @@ -542,7 +542,7 @@ byte disablePlugin(byte bootFailedCount) { /********************************************************************************************\ Disable Controller, based on bootFailedCount \*********************************************************************************************/ -byte disableController(byte bootFailedCount) { +uint8_t disableController(uint8_t bootFailedCount) { for (controllerIndex_t i = 0; i < CONTROLLER_MAX && bootFailedCount > 0; ++i) { if (Settings.ControllerEnabled[i]) { --bootFailedCount; @@ -558,8 +558,8 @@ byte disableController(byte bootFailedCount) { /********************************************************************************************\ Disable Notification, based on bootFailedCount \*********************************************************************************************/ -byte disableNotification(byte bootFailedCount) { - for (byte i = 0; i < NOTIFICATION_MAX && bootFailedCount > 0; ++i) { +uint8_t disableNotification(uint8_t bootFailedCount) { + for (uint8_t i = 0; i < NOTIFICATION_MAX && bootFailedCount > 0; ++i) { if (Settings.NotificationEnabled[i]) { --bootFailedCount; @@ -676,7 +676,7 @@ String SaveStringArray(SettingsType::Enum settingsType, int index, const String const uint16_t bufferSize = 128; // FIXME TD-er: For now stack allocated, may need to be heap allocated? - byte buffer[bufferSize]; + uint8_t buffer[bufferSize]; String result; int writePos = 0; @@ -764,7 +764,7 @@ String SaveTaskSettings(taskIndex_t TaskIndex) } String err = SaveToFile(SettingsType::Enum::TaskSettings_Type, TaskIndex, - (byte *)&ExtraTaskSettings, + (uint8_t *)&ExtraTaskSettings, sizeof(struct ExtraTaskSettingsStruct)); if (err.isEmpty()) { @@ -791,7 +791,7 @@ String LoadTaskSettings(taskIndex_t TaskIndex) START_TIMER ExtraTaskSettings.clear(); - const String result = LoadFromFile(SettingsType::Enum::TaskSettings_Type, TaskIndex, (byte *)&ExtraTaskSettings, sizeof(struct ExtraTaskSettingsStruct)); + const String result = LoadFromFile(SettingsType::Enum::TaskSettings_Type, TaskIndex, (uint8_t *)&ExtraTaskSettings, sizeof(struct ExtraTaskSettingsStruct)); // After loading, some settings may need patching. ExtraTaskSettings.TaskIndex = TaskIndex; // Needed when an empty task was requested @@ -800,7 +800,7 @@ String LoadTaskSettings(taskIndex_t TaskIndex) if (validDeviceIndex(DeviceIndex)) { if (!Device[DeviceIndex].configurableDecimals()) { // Nr of decimals cannot be configured, so set them to 0 just to be sure. - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { ExtraTaskSettings.TaskDeviceValueDecimals[i] = 0; } } @@ -823,7 +823,7 @@ String LoadTaskSettings(taskIndex_t TaskIndex) /********************************************************************************************\ Save Custom Task settings to file system \*********************************************************************************************/ -String SaveCustomTaskSettings(taskIndex_t TaskIndex, byte *memAddress, int datasize) +String SaveCustomTaskSettings(taskIndex_t TaskIndex, uint8_t *memAddress, int datasize) { #ifndef BUILD_NO_RAM_TRACKER checkRAM(F("SaveCustomTaskSettings")); @@ -845,7 +845,7 @@ String SaveCustomTaskSettings(taskIndex_t TaskIndex, String strings[], uint16_t strings, nrStrings, maxStringLength); } -String getCustomTaskSettingsError(byte varNr) { +String getCustomTaskSettingsError(uint8_t varNr) { String error = F("Error: Text too long for line "); error += varNr + 1; @@ -865,7 +865,7 @@ String ClearCustomTaskSettings(taskIndex_t TaskIndex) /********************************************************************************************\ Load Custom Task settings from file system \*********************************************************************************************/ -String LoadCustomTaskSettings(taskIndex_t TaskIndex, byte *memAddress, int datasize) +String LoadCustomTaskSettings(taskIndex_t TaskIndex, uint8_t *memAddress, int datasize) { START_TIMER; #ifndef BUILD_NO_RAM_TRACKER @@ -903,7 +903,7 @@ String SaveControllerSettings(controllerIndex_t ControllerIndex, ControllerSetti #endif controller_settings.validate(); // Make sure the saved controller settings have proper values. return SaveToFile(SettingsType::Enum::ControllerSettings_Type, ControllerIndex, - (byte *)&controller_settings, sizeof(controller_settings)); + (uint8_t *)&controller_settings, sizeof(controller_settings)); } /********************************************************************************************\ @@ -915,7 +915,7 @@ String LoadControllerSettings(controllerIndex_t ControllerIndex, ControllerSetti #endif String result = LoadFromFile(SettingsType::Enum::ControllerSettings_Type, ControllerIndex, - (byte *)&controller_settings, sizeof(controller_settings)); + (uint8_t *)&controller_settings, sizeof(controller_settings)); controller_settings.validate(); // Make sure the loaded controller settings have proper values. return result; } @@ -936,7 +936,7 @@ String ClearCustomControllerSettings(controllerIndex_t ControllerIndex) /********************************************************************************************\ Save Custom Controller settings to file system \*********************************************************************************************/ -String SaveCustomControllerSettings(controllerIndex_t ControllerIndex, byte *memAddress, int datasize) +String SaveCustomControllerSettings(controllerIndex_t ControllerIndex, uint8_t *memAddress, int datasize) { #ifndef BUILD_NO_RAM_TRACKER checkRAM(F("SaveCustomControllerSettings")); @@ -947,7 +947,7 @@ String SaveCustomControllerSettings(controllerIndex_t ControllerIndex, byte *mem /********************************************************************************************\ Load Custom Controller settings to file system \*********************************************************************************************/ -String LoadCustomControllerSettings(controllerIndex_t ControllerIndex, byte *memAddress, int datasize) +String LoadCustomControllerSettings(controllerIndex_t ControllerIndex, uint8_t *memAddress, int datasize) { #ifndef BUILD_NO_RAM_TRACKER checkRAM(F("LoadCustomControllerSettings")); @@ -958,7 +958,7 @@ String LoadCustomControllerSettings(controllerIndex_t ControllerIndex, byte *mem /********************************************************************************************\ Save Controller settings to file system \*********************************************************************************************/ -String SaveNotificationSettings(int NotificationIndex, byte *memAddress, int datasize) +String SaveNotificationSettings(int NotificationIndex, uint8_t *memAddress, int datasize) { #ifndef BUILD_NO_RAM_TRACKER checkRAM(F("SaveNotificationSettings")); @@ -969,7 +969,7 @@ String SaveNotificationSettings(int NotificationIndex, byte *memAddress, int dat /********************************************************************************************\ Load Controller settings to file system \*********************************************************************************************/ -String LoadNotificationSettings(int NotificationIndex, byte *memAddress, int datasize) +String LoadNotificationSettings(int NotificationIndex, uint8_t *memAddress, int datasize) { #ifndef BUILD_NO_RAM_TRACKER checkRAM(F("LoadNotificationSettings")); @@ -1017,13 +1017,13 @@ String InitFile(SettingsType::SettingsFileEnum file_type) /********************************************************************************************\ Save data into config file on file system \*********************************************************************************************/ -String SaveToFile(const char *fname, int index, const byte *memAddress, int datasize) +String SaveToFile(const char *fname, int index, const uint8_t *memAddress, int datasize) { return doSaveToFile(fname, index, memAddress, datasize, "r+"); } // See for mode description: https://github.com/esp8266/Arduino/blob/master/doc/filesystem.rst -String doSaveToFile(const char *fname, int index, const byte *memAddress, int datasize, const char *mode) +String doSaveToFile(const char *fname, int index, const uint8_t *memAddress, int datasize, const char *mode) { #ifndef BUILD_NO_DEBUG #ifndef ESP32 @@ -1071,7 +1071,7 @@ String doSaveToFile(const char *fname, int index, const byte *memAddress, int da clearAllCaches(); SPIFFS_CHECK(f, fname); SPIFFS_CHECK(f.seek(index, fs::SeekSet), fname); - const byte *pointerToByteToSave = memAddress; + const uint8_t *pointerToByteToSave = memAddress; for (int x = 0; x < datasize; x++) { @@ -1184,7 +1184,7 @@ String ClearInFile(const char *fname, int index, int datasize) /********************************************************************************************\ Load data from config file on file system \*********************************************************************************************/ -String LoadFromFile(const char *fname, int offset, byte *memAddress, int datasize) +String LoadFromFile(const char *fname, int offset, uint8_t *memAddress, int datasize) { if (offset < 0) { #ifndef BUILD_NO_DEBUG @@ -1252,7 +1252,7 @@ String getSettingsFileDatasizeError(bool read, SettingsType::Enum settingsType, return error; } -String LoadFromFile(SettingsType::Enum settingsType, int index, byte *memAddress, int datasize, int offset_in_block) { +String LoadFromFile(SettingsType::Enum settingsType, int index, uint8_t *memAddress, int datasize, int offset_in_block) { bool read = true; int offset, max_size; @@ -1267,15 +1267,15 @@ String LoadFromFile(SettingsType::Enum settingsType, int index, byte *memAddress return LoadFromFile(fname.c_str(), (offset + offset_in_block), memAddress, datasize); } -String LoadFromFile(SettingsType::Enum settingsType, int index, byte *memAddress, int datasize) { +String LoadFromFile(SettingsType::Enum settingsType, int index, uint8_t *memAddress, int datasize) { return LoadFromFile(settingsType, index, memAddress, datasize, 0); } -String SaveToFile(SettingsType::Enum settingsType, int index, byte *memAddress, int datasize) { +String SaveToFile(SettingsType::Enum settingsType, int index, uint8_t *memAddress, int datasize) { return SaveToFile(settingsType, index, memAddress, datasize, 0); } -String SaveToFile(SettingsType::Enum settingsType, int index, byte *memAddress, int datasize, int posInBlock) { +String SaveToFile(SettingsType::Enum settingsType, int index, uint8_t *memAddress, int datasize, int posInBlock) { bool read = false; int offset, max_size; @@ -1499,7 +1499,7 @@ bool getCacheFileCounters(uint16_t& lowest, uint16_t& highest, size_t& filesizeH Get partition table information \*********************************************************************************************/ #ifdef ESP32 -String getPartitionType(byte pType, byte pSubType) { +String getPartitionType(uint8_t pType, uint8_t pSubType) { esp_partition_type_t partitionType = static_cast(pType); esp_partition_subtype_t partitionSubType = static_cast(pSubType); @@ -1552,7 +1552,7 @@ String getPartitionTableHeader(const String& itemSep, const String& lineEnd) { return result; } -String getPartitionTable(byte pType, const String& itemSep, const String& lineEnd) { +String getPartitionTable(uint8_t pType, const String& itemSep, const String& lineEnd) { esp_partition_type_t partitionType = static_cast(pType); String result; esp_partition_iterator_t _mypartiterator = esp_partition_find(partitionType, ESP_PARTITION_SUBTYPE_ANY, NULL); diff --git a/src/src/Helpers/ESPEasy_Storage.h b/src/src/Helpers/ESPEasy_Storage.h index c9d32af4b..c592aa92b 100644 --- a/src/src/Helpers/ESPEasy_Storage.h +++ b/src/src/Helpers/ESPEasy_Storage.h @@ -67,17 +67,17 @@ String LoadSettings(); /********************************************************************************************\ Disable Plugin, based on bootFailedCount \*********************************************************************************************/ -byte disablePlugin(byte bootFailedCount); +uint8_t disablePlugin(uint8_t bootFailedCount); /********************************************************************************************\ Disable Controller, based on bootFailedCount \*********************************************************************************************/ -byte disableController(byte bootFailedCount); +uint8_t disableController(uint8_t bootFailedCount); /********************************************************************************************\ Disable Notification, based on bootFailedCount \*********************************************************************************************/ -byte disableNotification(byte bootFailedCount); +uint8_t disableNotification(uint8_t bootFailedCount); bool getAndLogSettingsParameters(bool read, SettingsType::Enum settingsType, int index, int& offset, int& max_size); @@ -108,7 +108,7 @@ String LoadTaskSettings(taskIndex_t TaskIndex); /********************************************************************************************\ Save Custom Task settings to file system \*********************************************************************************************/ -String SaveCustomTaskSettings(taskIndex_t TaskIndex, byte *memAddress, int datasize); +String SaveCustomTaskSettings(taskIndex_t TaskIndex, uint8_t *memAddress, int datasize); /********************************************************************************************\ Save array of Strings to Custom Task settings @@ -116,7 +116,7 @@ String SaveCustomTaskSettings(taskIndex_t TaskIndex, byte *memAddress, int datas \*********************************************************************************************/ String SaveCustomTaskSettings(taskIndex_t TaskIndex, String strings[], uint16_t nrStrings, uint16_t maxStringLength); -String getCustomTaskSettingsError(byte varNr); +String getCustomTaskSettingsError(uint8_t varNr); /********************************************************************************************\ Clear custom task settings @@ -126,7 +126,7 @@ String ClearCustomTaskSettings(taskIndex_t TaskIndex); /********************************************************************************************\ Load Custom Task settings from file system \*********************************************************************************************/ -String LoadCustomTaskSettings(taskIndex_t TaskIndex, byte *memAddress, int datasize); +String LoadCustomTaskSettings(taskIndex_t TaskIndex, uint8_t *memAddress, int datasize); /********************************************************************************************\ Load array of Strings from Custom Task settings @@ -152,23 +152,23 @@ String ClearCustomControllerSettings(controllerIndex_t ControllerIndex); /********************************************************************************************\ Save Custom Controller settings to file system \*********************************************************************************************/ -String SaveCustomControllerSettings(controllerIndex_t ControllerIndex, byte *memAddress, int datasize); +String SaveCustomControllerSettings(controllerIndex_t ControllerIndex, uint8_t *memAddress, int datasize); /********************************************************************************************\ Load Custom Controller settings to file system \*********************************************************************************************/ -String LoadCustomControllerSettings(controllerIndex_t ControllerIndex, byte *memAddress, int datasize); +String LoadCustomControllerSettings(controllerIndex_t ControllerIndex, uint8_t *memAddress, int datasize); /********************************************************************************************\ Save Controller settings to file system \*********************************************************************************************/ -String SaveNotificationSettings(int NotificationIndex, byte *memAddress, int datasize); +String SaveNotificationSettings(int NotificationIndex, uint8_t *memAddress, int datasize); /********************************************************************************************\ Load Controller settings to file system \*********************************************************************************************/ -String LoadNotificationSettings(int NotificationIndex, byte *memAddress, int datasize); +String LoadNotificationSettings(int NotificationIndex, uint8_t *memAddress, int datasize); /********************************************************************************************\ @@ -182,10 +182,10 @@ String InitFile(SettingsType::SettingsFileEnum file_type); /********************************************************************************************\ Save data into config file on file system \*********************************************************************************************/ -String SaveToFile(const char *fname, int index, const byte *memAddress, int datasize); +String SaveToFile(const char *fname, int index, const uint8_t *memAddress, int datasize); // See for mode description: https://github.com/esp8266/Arduino/blob/master/doc/filesystem.rst -String doSaveToFile(const char *fname, int index, const byte *memAddress, int datasize, const char *mode); +String doSaveToFile(const char *fname, int index, const uint8_t *memAddress, int datasize, const char *mode); /********************************************************************************************\ @@ -196,7 +196,7 @@ String ClearInFile(const char *fname, int index, int datasize); /********************************************************************************************\ Load data from config file on file system \*********************************************************************************************/ -String LoadFromFile(const char *fname, int offset, byte *memAddress, int datasize); +String LoadFromFile(const char *fname, int offset, uint8_t *memAddress, int datasize); /********************************************************************************************\ Wrapper functions to handle errors in accessing settings @@ -205,13 +205,13 @@ String getSettingsFileIndexRangeError(bool read, SettingsType::Enum settingsType String getSettingsFileDatasizeError(bool read, SettingsType::Enum settingsType, int index, int datasize, int max_size); -String LoadFromFile(SettingsType::Enum settingsType, int index, byte *memAddress, int datasize, int offset_in_block); +String LoadFromFile(SettingsType::Enum settingsType, int index, uint8_t *memAddress, int datasize, int offset_in_block); -String LoadFromFile(SettingsType::Enum settingsType, int index, byte *memAddress, int datasize); +String LoadFromFile(SettingsType::Enum settingsType, int index, uint8_t *memAddress, int datasize); -String SaveToFile(SettingsType::Enum settingsType, int index, byte *memAddress, int datasize); +String SaveToFile(SettingsType::Enum settingsType, int index, uint8_t *memAddress, int datasize); -String SaveToFile(SettingsType::Enum settingsType, int index, byte *memAddress, int datasize, int posInBlock); +String SaveToFile(SettingsType::Enum settingsType, int index, uint8_t *memAddress, int datasize, int posInBlock); String ClearInFile(SettingsType::Enum settingsType, int index); @@ -249,11 +249,11 @@ bool getCacheFileCounters(uint16_t& lowest, uint16_t& highest, size_t& filesizeH \*********************************************************************************************/ #ifdef ESP32 -String getPartitionType(byte pType, byte pSubType); +String getPartitionType(uint8_t pType, uint8_t pSubType); String getPartitionTableHeader(const String& itemSep, const String& lineEnd); -String getPartitionTable(byte pType, const String& itemSep, const String& lineEnd); +String getPartitionTable(uint8_t pType, const String& itemSep, const String& lineEnd); #endif // ifdef ESP32 diff --git a/src/src/Helpers/ESPEasy_time.cpp b/src/src/Helpers/ESPEasy_time.cpp index 415b326b8..8aa227ce9 100644 --- a/src/src/Helpers/ESPEasy_time.cpp +++ b/src/src/Helpers/ESPEasy_time.cpp @@ -74,7 +74,7 @@ void ESPEasy_time::breakTime(unsigned long timeInput, struct tm& tm) { } -void ESPEasy_time::restoreLastKnownUnixTime(unsigned long lastSysTime, byte deepSleepState) +void ESPEasy_time::restoreLastKnownUnixTime(unsigned long lastSysTime, uint8_t deepSleepState) { static bool firstCall = true; if (firstCall && lastSysTime != 0 && deepSleepState != 1) { @@ -252,7 +252,7 @@ bool ESPEasy_time::getNtpTime(double& unixTime_d) } const int NTP_PACKET_SIZE = 48; // NTP time is in the first 48 bytes of message - byte packetBuffer[NTP_PACKET_SIZE]; // buffer to hold incoming & outgoing packets + uint8_t packetBuffer[NTP_PACKET_SIZE]; // buffer to hold incoming & outgoing packets log += F(" queried"); #ifndef BUILD_NO_DEBUG diff --git a/src/src/Helpers/ESPEasy_time.h b/src/src/Helpers/ESPEasy_time.h index 5b2d4972f..6d4c452ee 100644 --- a/src/src/Helpers/ESPEasy_time.h +++ b/src/src/Helpers/ESPEasy_time.h @@ -21,7 +21,7 @@ static void breakTime(unsigned long timeInput, struct tm& tm); // This way the unit can do things based on local time even when NTP servers may not respond. // Do not use this when booting from deep sleep. // Only call this once during boot. -void restoreLastKnownUnixTime(unsigned long lastSysTime, byte deepSleepState); +void restoreLastKnownUnixTime(unsigned long lastSysTime, uint8_t deepSleepState); void setExternalTimeSource(double time, timeSource_t source); @@ -98,31 +98,31 @@ int year() const } // Get current month -byte month() const +uint8_t month() const { return tm.tm_mon + 1; // tm_mon starts at 0 } // Get current day of the month -byte day() const +uint8_t day() const { return tm.tm_mday; } // Get current hour -byte hour() const +uint8_t hour() const { return tm.tm_hour; } // Get current minute -byte minute() const +uint8_t minute() const { return tm.tm_min; } // Get current second -byte second() const +uint8_t second() const { return tm.tm_sec; } @@ -184,7 +184,7 @@ struct tm sunRise; struct tm sunSet; timeSource_t timeSource = No_time_source; -byte PrevMinutes = 0; +uint8_t PrevMinutes = 0; diff --git a/src/src/Helpers/ESPEasy_time_calc.cpp b/src/src/Helpers/ESPEasy_time_calc.cpp index 3e6fe2e49..e5d0833c5 100644 --- a/src/src/Helpers/ESPEasy_time_calc.cpp +++ b/src/src/Helpers/ESPEasy_time_calc.cpp @@ -209,7 +209,7 @@ bool matchClockEvent(unsigned long clockEvent, unsigned long clockSet) { unsigned long Mask; - for (byte y = 0; y < 8; y++) + for (uint8_t y = 0; y < 8; y++) { if (((clockSet >> (y * 4)) & 0xf) == 0xf) // if nibble y has the wildcard value 0xf { diff --git a/src/src/Helpers/Hardware.cpp b/src/src/Helpers/Hardware.cpp index 240f9b045..44ca52af7 100644 --- a/src/src/Helpers/Hardware.cpp +++ b/src/src/Helpers/Hardware.cpp @@ -198,14 +198,14 @@ void initI2C() { delay(500); Wire.beginTransmission(Settings.WDI2CAddress); Wire.write(0x83); // command to set pointer - Wire.write(17); // pointer value to status byte + Wire.write(17); // pointer value to status uint8_t Wire.endTransmission(); Wire.requestFrom(Settings.WDI2CAddress, (uint8_t)1); if (Wire.available()) { - byte status = Wire.read(); + uint8_t status = Wire.read(); if (status & 0x1) { @@ -245,8 +245,8 @@ void I2CMultiplexerReset() { } // Shift the bit in the right position when selecting a single channel -byte I2CMultiplexerShiftBit(uint8_t i) { - byte toWrite = 0; +uint8_t I2CMultiplexerShiftBit(uint8_t i) { + uint8_t toWrite = 0; switch (Settings.I2C_Multiplexer_Type) { case I2C_MULTIPLEXER_TCA9543A: // TCA9543/6/8 addressing @@ -272,7 +272,7 @@ void I2CMultiplexerSelectByTaskIndex(taskIndex_t taskIndex) { if (!validTaskIndex(taskIndex)) { return; } if (!I2CMultiplexerPortSelectedForTask(taskIndex)) { return; } - byte toWrite = 0; + uint8_t toWrite = 0; if (!bitRead(Settings.I2C_Flags[taskIndex], I2C_FLAGS_MUX_MULTICHANNEL)) { uint8_t i = Settings.I2C_Multiplexer_Channel[taskIndex]; @@ -289,7 +289,7 @@ void I2CMultiplexerSelectByTaskIndex(taskIndex_t taskIndex) { void I2CMultiplexerSelect(uint8_t i) { if (i > 7) { return; } - byte toWrite = I2CMultiplexerShiftBit(i); + uint8_t toWrite = I2CMultiplexerShiftBit(i); SetI2CMultiplexer(toWrite); } @@ -297,7 +297,7 @@ void I2CMultiplexerOff() { SetI2CMultiplexer(0); // no channel selected } -void SetI2CMultiplexer(byte toWrite) { +void SetI2CMultiplexer(uint8_t toWrite) { if (isI2CMultiplexerEnabled()) { // FIXME TD-er: Must check to see if we can cache the value so only change it when needed. Wire.beginTransmission(Settings.I2C_Multiplexer_Addr); @@ -307,7 +307,7 @@ void SetI2CMultiplexer(byte toWrite) { } } -byte I2CMultiplexerMaxChannels() { +uint8_t I2CMultiplexerMaxChannels() { uint channels = 0; switch (Settings.I2C_Multiplexer_Type) { @@ -331,7 +331,7 @@ bool I2CMultiplexerPortSelectedForTask(taskIndex_t taskIndex) { #endif // ifdef FEATURE_I2CMULTIPLEXER void checkResetFactoryPin() { - static byte factoryResetCounter = 0; + static uint8_t factoryResetCounter = 0; if (Settings.Pin_Reset == -1) { return; @@ -780,7 +780,7 @@ void addPredefinedPlugins(const GpioFactorySettingsStruct& gpio_settings) { } } -void addButtonRelayRule(byte buttonNumber, int relay_gpio) { +void addButtonRelayRule(uint8_t buttonNumber, int relay_gpio) { Settings.UseRules = true; String fileName; @@ -1060,7 +1060,7 @@ int touchPinToGpio(int touch_pin) void initAnalogWrite() { #if defined(ESP32) - for(byte x = 0; x < 16; x++) { + for(uint8_t x = 0; x < 16; x++) { ledcSetup(x, 0, 10); // Clear the channel ledChannelPin[x] = -1; ledChannelFreq[x] = 0; @@ -1082,7 +1082,7 @@ int8_t attachLedChannel(int pin, uint32_t frequency) // find existing channel if this pin has been used before int8_t ledChannel = -1; bool mustSetup = false; - for (byte x = 0; x < 16; x++) { + for (uint8_t x = 0; x < 16; x++) { if (ledChannelPin[x] == pin) { ledChannel = x; } @@ -1090,7 +1090,7 @@ int8_t attachLedChannel(int pin, uint32_t frequency) if (ledChannel == -1) // no channel set for this pin { - for (byte x = 0; x < 16; x++) { // find free channel + for (uint8_t x = 0; x < 16; x++) { // find free channel if (ledChannelPin[x] == -1) { if (!ledcRead(x)) { @@ -1130,7 +1130,7 @@ void detachLedChannel(int pin) { int8_t ledChannel = -1; - for (byte x = 0; x < 16; x++) { + for (uint8_t x = 0; x < 16; x++) { if (ledChannelPin[x] == pin) { ledChannel = x; } @@ -1177,7 +1177,7 @@ bool set_Gpio_PWM(int gpio, uint32_t dutyCycle, uint32_t frequency) { bool set_Gpio_PWM(int gpio, uint32_t dutyCycle, uint32_t fadeDuration_ms, uint32_t& frequency, uint32_t& key) { // For now, we only support the internal GPIO pins. - byte pluginID = PLUGIN_GPIO; + uint8_t pluginID = PLUGIN_GPIO; if (!checkValidPortRange(pluginID, gpio)) { return false; } @@ -1203,7 +1203,7 @@ bool set_Gpio_PWM(int gpio, uint32_t dutyCycle, uint32_t fadeDuration_ms, uint32 if (fadeDuration_ms != 0) { const int32_t resolution_factor = (1 << 12); - const byte prev_mode = tempStatus.mode; + const uint8_t prev_mode = tempStatus.mode; int32_t prev_value = tempStatus.getDutyCycle(); // getPinState(pluginID, gpio, &prev_mode, &prev_value); diff --git a/src/src/Helpers/Hardware.h b/src/src/Helpers/Hardware.h index d5a688ff6..340aa5561 100644 --- a/src/src/Helpers/Hardware.h +++ b/src/src/Helpers/Hardware.h @@ -34,9 +34,9 @@ void I2CMultiplexerSelect(uint8_t i); void I2CMultiplexerOff(); -void SetI2CMultiplexer(byte toWrite); +void SetI2CMultiplexer(uint8_t toWrite); -byte I2CMultiplexerMaxChannels(); +uint8_t I2CMultiplexerMaxChannels(); void I2CMultiplexerReset(); @@ -101,7 +101,7 @@ void addSwitchPlugin(taskIndex_t taskIndex, int gpio, const String& name, bool a void addPredefinedPlugins(const GpioFactorySettingsStruct& gpio_settings); -void addButtonRelayRule(byte buttonNumber, int relay_gpio); +void addButtonRelayRule(uint8_t buttonNumber, int relay_gpio); void addPredefinedRules(const GpioFactorySettingsStruct& gpio_settings); diff --git a/src/src/Helpers/I2C_access.cpp b/src/src/Helpers/I2C_access.cpp index 890679a40..a6f2d128d 100644 --- a/src/src/Helpers/I2C_access.cpp +++ b/src/src/Helpers/I2C_access.cpp @@ -37,7 +37,7 @@ void I2C_wakeup(uint8_t i2caddr) { // **************************************************************************/ // Writes an 8 bit value over I2C // **************************************************************************/ -bool I2C_write8(uint8_t i2caddr, byte value) { +bool I2C_write8(uint8_t i2caddr, uint8_t value) { Wire.beginTransmission(i2caddr); Wire.write((uint8_t)value); return Wire.endTransmission() == 0; @@ -46,7 +46,7 @@ bool I2C_write8(uint8_t i2caddr, byte value) { // **************************************************************************/ // Writes an 8 bit value over I2C to a register // **************************************************************************/ -bool I2C_write8_reg(uint8_t i2caddr, byte reg, byte value) { +bool I2C_write8_reg(uint8_t i2caddr, uint8_t reg, uint8_t value) { Wire.beginTransmission(i2caddr); Wire.write((uint8_t)reg); Wire.write((uint8_t)value); @@ -56,7 +56,7 @@ bool I2C_write8_reg(uint8_t i2caddr, byte reg, byte value) { // **************************************************************************/ // Writes an 16 bit value over I2C to a register // **************************************************************************/ -bool I2C_write16_reg(uint8_t i2caddr, byte reg, uint16_t value) { +bool I2C_write16_reg(uint8_t i2caddr, uint8_t reg, uint16_t value) { Wire.beginTransmission(i2caddr); Wire.write((uint8_t)reg); Wire.write((uint8_t)(value >> 8)); @@ -67,7 +67,7 @@ bool I2C_write16_reg(uint8_t i2caddr, byte reg, uint16_t value) { // **************************************************************************/ // Writes an 16 bit value over I2C to a register // **************************************************************************/ -bool I2C_write16_LE_reg(uint8_t i2caddr, byte reg, uint16_t value) { +bool I2C_write16_LE_reg(uint8_t i2caddr, uint8_t reg, uint16_t value) { return I2C_write16_reg(i2caddr, reg, (value << 8) | (value >> 8)); } @@ -77,7 +77,7 @@ bool I2C_write16_LE_reg(uint8_t i2caddr, byte reg, uint16_t value) { uint8_t I2C_read8(uint8_t i2caddr, bool *is_ok) { uint8_t value; - byte count = Wire.requestFrom(i2caddr, (byte)1); + uint8_t count = Wire.requestFrom(i2caddr, (uint8_t)1); if (is_ok != NULL) { *is_ok = (count == 1); @@ -92,7 +92,7 @@ uint8_t I2C_read8(uint8_t i2caddr, bool *is_ok) { // **************************************************************************/ // Reads an 8 bit value from a register over I2C // **************************************************************************/ -uint8_t I2C_read8_reg(uint8_t i2caddr, byte reg, bool *is_ok) { +uint8_t I2C_read8_reg(uint8_t i2caddr, uint8_t reg, bool *is_ok) { uint8_t value; Wire.beginTransmission(i2caddr); @@ -111,7 +111,7 @@ uint8_t I2C_read8_reg(uint8_t i2caddr, byte reg, bool *is_ok) { *is_ok = false; } } - byte count = Wire.requestFrom(i2caddr, (byte)1); + uint8_t count = Wire.requestFrom(i2caddr, (uint8_t)1); if (is_ok != NULL) { *is_ok = (count == 1); @@ -124,13 +124,13 @@ uint8_t I2C_read8_reg(uint8_t i2caddr, byte reg, bool *is_ok) { // **************************************************************************/ // Reads a 16 bit value starting at a given register over I2C // **************************************************************************/ -uint16_t I2C_read16_reg(uint8_t i2caddr, byte reg) { +uint16_t I2C_read16_reg(uint8_t i2caddr, uint8_t reg) { uint16_t value(0); Wire.beginTransmission(i2caddr); Wire.write((uint8_t)reg); Wire.endTransmission(END_TRANSMISSION_FLAG); - Wire.requestFrom(i2caddr, (byte)2); + Wire.requestFrom(i2caddr, (uint8_t)2); value = (Wire.read() << 8) | Wire.read(); return value; @@ -139,13 +139,13 @@ uint16_t I2C_read16_reg(uint8_t i2caddr, byte reg) { // **************************************************************************/ // Reads a 24 bit value starting at a given register over I2C // **************************************************************************/ -int32_t I2C_read24_reg(uint8_t i2caddr, byte reg) { +int32_t I2C_read24_reg(uint8_t i2caddr, uint8_t reg) { int32_t value; Wire.beginTransmission(i2caddr); Wire.write((uint8_t)reg); Wire.endTransmission(END_TRANSMISSION_FLAG); - Wire.requestFrom(i2caddr, (byte)3); + Wire.requestFrom(i2caddr, (uint8_t)3); value = (((int32_t)Wire.read()) << 16) | (Wire.read() << 8) | Wire.read(); return value; @@ -154,13 +154,13 @@ int32_t I2C_read24_reg(uint8_t i2caddr, byte reg) { // **************************************************************************/ // Reads a 32 bit value starting at a given register over I2C // **************************************************************************/ -int32_t I2C_read32_reg(uint8_t i2caddr, byte reg) { +int32_t I2C_read32_reg(uint8_t i2caddr, uint8_t reg) { int32_t value; Wire.beginTransmission(i2caddr); Wire.write((uint8_t)reg); Wire.endTransmission(END_TRANSMISSION_FLAG); - Wire.requestFrom(i2caddr, (byte)4); + Wire.requestFrom(i2caddr, (uint8_t)4); value = (((int32_t)Wire.read()) << 24) | (((uint32_t)Wire.read()) << 16) | (Wire.read() << 8) | Wire.read(); return value; @@ -169,7 +169,7 @@ int32_t I2C_read32_reg(uint8_t i2caddr, byte reg) { // **************************************************************************/ // Reads a 16 bit value starting at a given register over I2C // **************************************************************************/ -uint16_t I2C_read16_LE_reg(uint8_t i2caddr, byte reg) { +uint16_t I2C_read16_LE_reg(uint8_t i2caddr, uint8_t reg) { uint16_t temp = I2C_read16_reg(i2caddr, reg); return (temp >> 8) | (temp << 8); @@ -178,11 +178,11 @@ uint16_t I2C_read16_LE_reg(uint8_t i2caddr, byte reg) { // **************************************************************************/ // Reads a signed 16 bit value starting at a given register over I2C // **************************************************************************/ -int16_t I2C_readS16_reg(uint8_t i2caddr, byte reg) { +int16_t I2C_readS16_reg(uint8_t i2caddr, uint8_t reg) { return (int16_t)I2C_read16_reg(i2caddr, reg); } -int16_t I2C_readS16_LE_reg(uint8_t i2caddr, byte reg) { +int16_t I2C_readS16_LE_reg(uint8_t i2caddr, uint8_t reg) { return (int16_t)I2C_read16_LE_reg(i2caddr, reg); } diff --git a/src/src/Helpers/I2C_access.h b/src/src/Helpers/I2C_access.h index 85478043b..e1cf3b030 100644 --- a/src/src/Helpers/I2C_access.h +++ b/src/src/Helpers/I2C_access.h @@ -21,27 +21,27 @@ void I2C_wakeup(uint8_t i2caddr); // Writes an 8 bit value over I2C // **************************************************************************/ bool I2C_write8(uint8_t i2caddr, - byte value); + uint8_t value); // **************************************************************************/ // Writes an 8 bit value over I2C to a register // **************************************************************************/ bool I2C_write8_reg(uint8_t i2caddr, - byte reg, - byte value); + uint8_t reg, + uint8_t value); // **************************************************************************/ // Writes an 16 bit value over I2C to a register // **************************************************************************/ bool I2C_write16_reg(uint8_t i2caddr, - byte reg, + uint8_t reg, uint16_t value); // **************************************************************************/ // Writes an 16 bit value over I2C to a register // **************************************************************************/ bool I2C_write16_LE_reg(uint8_t i2caddr, - byte reg, + uint8_t reg, uint16_t value); // **************************************************************************/ @@ -54,41 +54,41 @@ uint8_t I2C_read8(uint8_t i2caddr, // Reads an 8 bit value from a register over I2C // **************************************************************************/ uint8_t I2C_read8_reg(uint8_t i2caddr, - byte reg, + uint8_t reg, bool *is_ok = nullptr); // **************************************************************************/ // Reads a 16 bit value starting at a given register over I2C // **************************************************************************/ uint16_t I2C_read16_reg(uint8_t i2caddr, - byte reg); + uint8_t reg); // **************************************************************************/ // Reads a 24 bit value starting at a given register over I2C // **************************************************************************/ int32_t I2C_read24_reg(uint8_t i2caddr, - byte reg); + uint8_t reg); // **************************************************************************/ // Reads a 32 bit value starting at a given register over I2C // **************************************************************************/ int32_t I2C_read32_reg(uint8_t i2caddr, - byte reg); + uint8_t reg); // **************************************************************************/ // Reads a 16 bit value starting at a given register over I2C // **************************************************************************/ uint16_t I2C_read16_LE_reg(uint8_t i2caddr, - byte reg); + uint8_t reg); // **************************************************************************/ // Reads a signed 16 bit value starting at a given register over I2C // **************************************************************************/ int16_t I2C_readS16_reg(uint8_t i2caddr, - byte reg); + uint8_t reg); int16_t I2C_readS16_LE_reg(uint8_t i2caddr, - byte reg); + uint8_t reg); #endif // HELPERS_I2C_ACCESS_H diff --git a/src/src/Helpers/Misc.cpp b/src/src/Helpers/Misc.cpp index 1b3e04410..11bc348f1 100644 --- a/src/src/Helpers/Misc.cpp +++ b/src/src/Helpers/Misc.cpp @@ -292,9 +292,9 @@ void SendValueLogger(taskIndex_t TaskIndex) if (validDeviceIndex(DeviceIndex)) { LoadTaskSettings(TaskIndex); - const byte valueCount = getValueCountForTask(TaskIndex); + const uint8_t valueCount = getValueCountForTask(TaskIndex); - for (byte varNr = 0; varNr < valueCount; varNr++) + for (uint8_t varNr = 0; varNr < valueCount; varNr++) { logger += node_time.getDateString('-'); logger += ' '; @@ -409,22 +409,22 @@ void HSV2RGBW(float H, float S, float I, int rgbw[4]) { // Simple bitwise get/set functions -uint8_t get8BitFromUL(uint32_t number, byte bitnr) { +uint8_t get8BitFromUL(uint32_t number, uint8_t bitnr) { return (number >> bitnr) & 0xFF; } -void set8BitToUL(uint32_t& number, byte bitnr, uint8_t value) { +void set8BitToUL(uint32_t& number, uint8_t bitnr, uint8_t value) { uint32_t mask = (0xFFUL << bitnr); uint32_t newvalue = ((value << bitnr) & mask); number = (number & ~mask) | newvalue; } -uint8_t get4BitFromUL(uint32_t number, byte bitnr) { +uint8_t get4BitFromUL(uint32_t number, uint8_t bitnr) { return (number >> bitnr) & 0x0F; } -void set4BitToUL(uint32_t& number, byte bitnr, uint8_t value) { +void set4BitToUL(uint32_t& number, uint8_t bitnr, uint8_t value) { uint32_t mask = (0x0FUL << bitnr); uint32_t newvalue = ((value << bitnr) & mask); diff --git a/src/src/Helpers/Misc.h b/src/src/Helpers/Misc.h index 6bbe96134..4dd8e7aab 100644 --- a/src/src/Helpers/Misc.h +++ b/src/src/Helpers/Misc.h @@ -157,17 +157,17 @@ void HSV2RGBW(float H, // Simple bitwise get/set functions uint8_t get8BitFromUL(uint32_t number, - byte bitnr); + uint8_t bitnr); void set8BitToUL(uint32_t& number, - byte bitnr, + uint8_t bitnr, uint8_t value); uint8_t get4BitFromUL(uint32_t number, - byte bitnr); + uint8_t bitnr); void set4BitToUL(uint32_t& number, - byte bitnr, + uint8_t bitnr, uint8_t value); diff --git a/src/src/Helpers/Modbus_RTU.cpp b/src/src/Helpers/Modbus_RTU.cpp index dbbdc72b0..a4bee6173 100644 --- a/src/src/Helpers/Modbus_RTU.cpp +++ b/src/src/Helpers/Modbus_RTU.cpp @@ -36,11 +36,11 @@ void ModbusRTU_struct::reset() { _reads_nodata = 0; } -bool ModbusRTU_struct::init(const ESPEasySerialPort port, const int16_t serial_rx, const int16_t serial_tx, int16_t baudrate, byte address) { +bool ModbusRTU_struct::init(const ESPEasySerialPort port, const int16_t serial_rx, const int16_t serial_tx, int16_t baudrate, uint8_t address) { return init(port, serial_rx, serial_tx, baudrate, address, -1); } -bool ModbusRTU_struct::init(const ESPEasySerialPort port, const int16_t serial_rx, const int16_t serial_tx, int16_t baudrate, byte address, int8_t dere_pin) { +bool ModbusRTU_struct::init(const ESPEasySerialPort port, const int16_t serial_rx, const int16_t serial_tx, int16_t baudrate, uint8_t address, int8_t dere_pin) { if ((serial_rx < 0) || (serial_tx < 0)) { return false; } @@ -86,15 +86,15 @@ uint16_t ModbusRTU_struct::getModbusTimeout() const { return _modbus_timeout; } -String ModbusRTU_struct::getDevice_description(byte slaveAddress) { +String ModbusRTU_struct::getDevice_description(uint8_t slaveAddress) { bool more_follows = true; - byte next_object_id = 0; - byte conformity_level = 0; + uint8_t next_object_id = 0; + uint8_t conformity_level = 0; unsigned int object_value_int; String description; String obj_text; - for (byte object_id = 0; object_id < 0x84; ++object_id) { + for (uint8_t object_id = 0; object_id < 0x84; ++object_id) { if (object_id == 6) { object_id = 0x82; // Skip to the serialnr/sensor type } @@ -155,18 +155,18 @@ String ModbusRTU_struct::getDevice_description(byte slaveAddress) { } // Read from RAM or EEPROM -void ModbusRTU_struct::buildRead_RAM_EEPROM(byte slaveAddress, byte functionCode, - short startAddress, byte number_bytes) { +void ModbusRTU_struct::buildRead_RAM_EEPROM(uint8_t slaveAddress, uint8_t functionCode, + short startAddress, uint8_t number_bytes) { _sendframe[0] = slaveAddress; _sendframe[1] = functionCode; - _sendframe[2] = (byte)(startAddress >> 8); - _sendframe[3] = (byte)(startAddress & 0xFF); + _sendframe[2] = (uint8_t)(startAddress >> 8); + _sendframe[3] = (uint8_t)(startAddress & 0xFF); _sendframe[4] = number_bytes; _sendframe_used = 5; } // Write to the Special Control Register (SCR) -void ModbusRTU_struct::buildWriteCommandRegister(byte slaveAddress, byte value) { +void ModbusRTU_struct::buildWriteCommandRegister(uint8_t slaveAddress, uint8_t value) { _sendframe[0] = slaveAddress; _sendframe[1] = MODBUS_CMD_WRITE_RAM; _sendframe[2] = 0; // Address-Hi SCR (0x0060) @@ -176,32 +176,32 @@ void ModbusRTU_struct::buildWriteCommandRegister(byte slaveAddress, byte value) _sendframe_used = 6; } -void ModbusRTU_struct::buildWriteMult16bRegister(byte slaveAddress, uint16_t startAddress, uint16_t value) { +void ModbusRTU_struct::buildWriteMult16bRegister(uint8_t slaveAddress, uint16_t startAddress, uint16_t value) { _sendframe[0] = slaveAddress; _sendframe[1] = MODBUS_WRITE_MULTIPLE_REGISTERS; - _sendframe[2] = (byte)(startAddress >> 8); - _sendframe[3] = (byte)(startAddress & 0xFF); + _sendframe[2] = (uint8_t)(startAddress >> 8); + _sendframe[3] = (uint8_t)(startAddress & 0xFF); _sendframe[4] = 0; // nr reg hi _sendframe[5] = 1; // nr reg lo _sendframe[6] = 2; // nr bytes to follow (2 bytes per register) - _sendframe[7] = (byte)(value >> 8); - _sendframe[8] = (byte)(value & 0xFF); + _sendframe[7] = (uint8_t)(value >> 8); + _sendframe[8] = (uint8_t)(value & 0xFF); _sendframe_used = 9; } -void ModbusRTU_struct::buildFrame(byte slaveAddress, byte functionCode, +void ModbusRTU_struct::buildFrame(uint8_t slaveAddress, uint8_t functionCode, short startAddress, short parameter) { _sendframe[0] = slaveAddress; _sendframe[1] = functionCode; - _sendframe[2] = (byte)(startAddress >> 8); - _sendframe[3] = (byte)(startAddress & 0xFF); - _sendframe[4] = (byte)(parameter >> 8); - _sendframe[5] = (byte)(parameter & 0xFF); + _sendframe[2] = (uint8_t)(startAddress >> 8); + _sendframe[3] = (uint8_t)(startAddress & 0xFF); + _sendframe[4] = (uint8_t)(parameter >> 8); + _sendframe[5] = (uint8_t)(parameter & 0xFF); _sendframe_used = 6; } -void ModbusRTU_struct::build_modbus_MEI_frame(byte slaveAddress, byte device_id, - byte object_id) { +void ModbusRTU_struct::build_modbus_MEI_frame(uint8_t slaveAddress, uint8_t device_id, + uint8_t object_id) { _sendframe[0] = slaveAddress; _sendframe[1] = 0x2B; _sendframe[2] = 0x0E; @@ -216,7 +216,7 @@ void ModbusRTU_struct::build_modbus_MEI_frame(byte slaveAddress, byte device_id, _sendframe_used = 5; } -String ModbusRTU_struct::MEI_objectid_to_name(byte object_id) { +String ModbusRTU_struct::MEI_objectid_to_name(uint8_t object_id) { String result; switch (object_id) { @@ -239,9 +239,9 @@ String ModbusRTU_struct::MEI_objectid_to_name(byte object_id) { } String ModbusRTU_struct::parse_modbus_MEI_response(unsigned int& object_value_int, - byte & next_object_id, + uint8_t & next_object_id, bool & more_follows, - byte & conformity_level) { + uint8_t & conformity_level) { String result; if (_recv_buf_used < 8) { @@ -258,13 +258,13 @@ String ModbusRTU_struct::parse_modbus_MEI_response(unsigned int& object_value_in conformity_level = _recv_buf[pos++]; more_follows = _recv_buf[pos++] != 0; next_object_id = _recv_buf[pos++]; - const byte number_objects = _recv_buf[pos++]; - byte object_id = 0; + const uint8_t number_objects = _recv_buf[pos++]; + uint8_t object_id = 0; for (int i = 0; i < number_objects; ++i) { if ((pos + 3) < _recv_buf_used) { object_id = _recv_buf[pos++]; - const byte object_length = _recv_buf[pos++]; + const uint8_t object_length = _recv_buf[pos++]; if ((pos + object_length) < _recv_buf_used) { String object_value; @@ -299,7 +299,7 @@ String ModbusRTU_struct::parse_modbus_MEI_response(unsigned int& object_value_in return result; } -void ModbusRTU_struct::logModbusException(byte value) { +void ModbusRTU_struct::logModbusException(uint8_t value) { if (value == 0) { return; } @@ -397,7 +397,7 @@ void ModbusRTU_struct::logModbusException(byte value) { } /* - String log_buffer(byte *buffer, int length) { + String log_buffer(uint8_t *buffer, int length) { String log; log.reserve(3 * length + 5); for (int i = 0; i < length; ++i) { @@ -412,26 +412,26 @@ void ModbusRTU_struct::logModbusException(byte value) { return log; } */ -byte ModbusRTU_struct::processCommand() { +uint8_t ModbusRTU_struct::processCommand() { // CRC-calculation unsigned int crc = ModRTU_CRC(_sendframe, _sendframe_used); // Note, this number has low and high bytes swapped, so use it accordingly (or // swap bytes) - byte checksumHi = (byte)((crc >> 8) & 0xFF); - byte checksumLo = (byte)(crc & 0xFF); + uint8_t checksumHi = (uint8_t)((crc >> 8) & 0xFF); + uint8_t checksumLo = (uint8_t)(crc & 0xFF); _sendframe[_sendframe_used++] = checksumLo; _sendframe[_sendframe_used++] = checksumHi; int nrRetriesLeft = 2; - byte return_value = 0; + uint8_t return_value = 0; while (nrRetriesLeft > 0) { return_value = 0; - // Send the byte array + // Send the uint8_t array startWrite(); easySerial->write(_sendframe, _sendframe_used); @@ -484,7 +484,7 @@ byte ModbusRTU_struct::processCommand() { ++_reads_crc_failed; return_value = MODBUS_BADCRC; } else { - const byte received_functionCode = _recv_buf[1]; + const uint8_t received_functionCode = _recv_buf[1]; if ((received_functionCode & 0x80) != 0) { return_value = _recv_buf[2]; @@ -513,7 +513,7 @@ byte ModbusRTU_struct::processCommand() { uint32_t ModbusRTU_struct::read_32b_InputRegister(short address) { uint32_t result = 0; - byte errorcode; + uint8_t errorcode; int idHigh = readInputRegister(address, errorcode); if (errorcode != 0) { return result; } @@ -548,12 +548,12 @@ float ModbusRTU_struct::read_float_HoldingRegister(short address) { // return fval; } -int ModbusRTU_struct::readInputRegister(short address, byte& errorcode) { +int ModbusRTU_struct::readInputRegister(short address, uint8_t& errorcode) { // Only read 1 register return process_16b_register(_modbus_address, MODBUS_READ_INPUT_REGISTERS, address, 1, errorcode); } -int ModbusRTU_struct::readHoldingRegister(short address, byte& errorcode) { +int ModbusRTU_struct::readHoldingRegister(short address, uint8_t& errorcode) { // Only read 1 register return process_16b_register( _modbus_address, MODBUS_READ_HOLDING_REGISTERS, address, 1, errorcode); @@ -562,12 +562,12 @@ int ModbusRTU_struct::readHoldingRegister(short address, byte& errorcode) { // Write to holding register. int ModbusRTU_struct::writeSingleRegister(short address, short value) { // No check for the specific error code. - byte errorcode = 0; + uint8_t errorcode = 0; return writeSingleRegister(address, value, errorcode); } -int ModbusRTU_struct::writeSingleRegister(short address, short value, byte& errorcode) { +int ModbusRTU_struct::writeSingleRegister(short address, short value, uint8_t& errorcode) { // GN: Untested, will probably not work return process_16b_register( _modbus_address, MODBUS_WRITE_SINGLE_REGISTER, address, value, errorcode); @@ -579,13 +579,13 @@ int ModbusRTU_struct::writeMultipleRegisters(short address, short value) { _modbus_address, address, value); } -byte ModbusRTU_struct::modbus_get_MEI(byte slaveAddress, byte object_id, +uint8_t ModbusRTU_struct::modbus_get_MEI(uint8_t slaveAddress, uint8_t object_id, String& result, unsigned int& object_value_int, - byte& next_object_id, bool& more_follows, - byte& conformity_level) { + uint8_t& next_object_id, bool& more_follows, + uint8_t& conformity_level) { // Force device_id to 4 = individual access (reading one ID object per call) build_modbus_MEI_frame(slaveAddress, 4, object_id); - const byte process_result = processCommand(); + const uint8_t process_result = processCommand(); if (process_result == 0) { result = parse_modbus_MEI_response(object_value_int, @@ -597,19 +597,19 @@ byte ModbusRTU_struct::modbus_get_MEI(byte slaveAddress, byte object_id, return process_result; } -void ModbusRTU_struct::modbus_log_MEI(byte slaveAddress) { +void ModbusRTU_struct::modbus_log_MEI(uint8_t slaveAddress) { // Iterate over all Device identification items, using // Modbus command (0x2B / 0x0E) Read Device Identification // And add to log. bool more_follows = true; - byte conformity_level = 0; - byte object_id = 0; - byte next_object_id = 0; + uint8_t conformity_level = 0; + uint8_t object_id = 0; + uint8_t next_object_id = 0; while (more_follows) { String result; unsigned int object_value_int; - const byte process_result = modbus_get_MEI( + const uint8_t process_result = modbus_get_MEI( slaveAddress, object_id, result, object_value_int, next_object_id, more_follows, conformity_level); @@ -650,9 +650,9 @@ void ModbusRTU_struct::modbus_log_MEI(byte slaveAddress) { } } -int ModbusRTU_struct::process_16b_register(byte slaveAddress, byte functionCode, +int ModbusRTU_struct::process_16b_register(uint8_t slaveAddress, uint8_t functionCode, short startAddress, short parameter, - byte& errorcode) { + uint8_t& errorcode) { buildFrame(slaveAddress, functionCode, startAddress, parameter); errorcode = processCommand(); @@ -664,9 +664,9 @@ int ModbusRTU_struct::process_16b_register(byte slaveAddress, byte functionCode, } // Still writing single register, but calling it using "Preset Multiple Registers" function (FC=16) -int ModbusRTU_struct::preset_mult16b_register(byte slaveAddress, uint16_t startAddress, uint16_t value) { +int ModbusRTU_struct::preset_mult16b_register(uint8_t slaveAddress, uint16_t startAddress, uint16_t value) { buildWriteMult16bRegister(slaveAddress, startAddress, value); - const byte process_result = processCommand(); + const uint8_t process_result = processCommand(); if (process_result == 0) { return (_recv_buf[4] << 8) | (_recv_buf[5]); @@ -675,15 +675,15 @@ int ModbusRTU_struct::preset_mult16b_register(byte slaveAddress, uint16_t startA return -1 * process_result; } -bool ModbusRTU_struct::process_32b_register(byte slaveAddress, byte functionCode, +bool ModbusRTU_struct::process_32b_register(uint8_t slaveAddress, uint8_t functionCode, short startAddress, uint32_t& result) { buildFrame(slaveAddress, functionCode, startAddress, 2); - const byte process_result = processCommand(); + const uint8_t process_result = processCommand(); if (process_result == 0) { result = 0; - for (byte i = 0; i < 4; ++i) { + for (uint8_t i = 0; i < 4; ++i) { result = result << 8; result += _recv_buf[i + 3]; } @@ -693,9 +693,9 @@ bool ModbusRTU_struct::process_32b_register(byte slaveAddress, byte functionCode return false; } -int ModbusRTU_struct::writeSpecialCommandRegister(byte command) { +int ModbusRTU_struct::writeSpecialCommandRegister(uint8_t command) { buildWriteCommandRegister(_modbus_address, command); - const byte process_result = processCommand(); + const uint8_t process_result = processCommand(); if (process_result == 0) { return 0; @@ -704,9 +704,9 @@ int ModbusRTU_struct::writeSpecialCommandRegister(byte command) { return -1 * process_result; } -unsigned int ModbusRTU_struct::read_RAM_EEPROM(byte command, byte startAddress, - byte nrBytes, - byte& errorcode) { +unsigned int ModbusRTU_struct::read_RAM_EEPROM(uint8_t command, uint8_t startAddress, + uint8_t nrBytes, + uint8_t& errorcode) { buildRead_RAM_EEPROM(_modbus_address, command, startAddress, nrBytes); errorcode = processCommand(); @@ -715,7 +715,7 @@ unsigned int ModbusRTU_struct::read_RAM_EEPROM(byte command, byte startAddress, unsigned int result = 0; for (int i = 0; i < _recv_buf[2]; ++i) { - // Most significant byte at lower address + // Most significant uint8_t at lower address result = (result << 8) | _recv_buf[i + 3]; } return result; @@ -725,11 +725,11 @@ unsigned int ModbusRTU_struct::read_RAM_EEPROM(byte command, byte startAddress, } // Compute the MODBUS RTU CRC -unsigned int ModbusRTU_struct::ModRTU_CRC(byte *buf, int len) { +unsigned int ModbusRTU_struct::ModRTU_CRC(uint8_t *buf, int len) { unsigned int crc = 0xFFFF; for (int pos = 0; pos < len; pos++) { - crc ^= (unsigned int)buf[pos]; // XOR byte into least sig. byte of crc + crc ^= (unsigned int)buf[pos]; // XOR uint8_t into least sig. uint8_t of crc for (int i = 8; i != 0; i--) { // Loop over each bit if ((crc & 0x0001) != 0) { // If the LSB is set diff --git a/src/src/Helpers/Modbus_RTU.h b/src/src/Helpers/Modbus_RTU.h index ab04cc10f..da135e917 100644 --- a/src/src/Helpers/Modbus_RTU.h +++ b/src/src/Helpers/Modbus_RTU.h @@ -54,13 +54,13 @@ struct ModbusRTU_struct { const int16_t serial_rx, const int16_t serial_tx, int16_t baudrate, - byte address); + uint8_t address); bool init(const ESPEasySerialPort port, const int16_t serial_rx, const int16_t serial_tx, int16_t baudrate, - byte address, + uint8_t address, int8_t dere_pin); bool isInitialized() const; @@ -73,42 +73,42 @@ struct ModbusRTU_struct { uint16_t getModbusTimeout() const; - String getDevice_description(byte slaveAddress); + String getDevice_description(uint8_t slaveAddress); // Read from RAM or EEPROM - void buildRead_RAM_EEPROM(byte slaveAddress, - byte functionCode, + void buildRead_RAM_EEPROM(uint8_t slaveAddress, + uint8_t functionCode, short startAddress, - byte number_bytes); + uint8_t number_bytes); // Write to the Special Control Register (SCR) - void buildWriteCommandRegister(byte slaveAddress, - byte value); + void buildWriteCommandRegister(uint8_t slaveAddress, + uint8_t value); - void buildWriteMult16bRegister(byte slaveAddress, + void buildWriteMult16bRegister(uint8_t slaveAddress, uint16_t startAddress, uint16_t value); - void buildFrame(byte slaveAddress, - byte functionCode, + void buildFrame(uint8_t slaveAddress, + uint8_t functionCode, short startAddress, short parameter); - void build_modbus_MEI_frame(byte slaveAddress, - byte device_id, - byte object_id); + void build_modbus_MEI_frame(uint8_t slaveAddress, + uint8_t device_id, + uint8_t object_id); - String MEI_objectid_to_name(byte object_id); + String MEI_objectid_to_name(uint8_t object_id); String parse_modbus_MEI_response(unsigned int& object_value_int, - byte & next_object_id, + uint8_t & next_object_id, bool & more_follows, - byte & conformity_level); + uint8_t & conformity_level); - void logModbusException(byte value); + void logModbusException(uint8_t value); /* - String log_buffer(byte *buffer, int length) { + String log_buffer(uint8_t *buffer, int length) { String log; log.reserve(3 * length + 5); for (int i = 0; i < length; ++i) { @@ -123,7 +123,7 @@ struct ModbusRTU_struct { return log; } */ - byte processCommand(); + uint8_t processCommand(); uint32_t read_32b_InputRegister(short address); @@ -132,10 +132,10 @@ struct ModbusRTU_struct { float read_float_HoldingRegister(short address); int readInputRegister(short address, - byte& errorcode); + uint8_t& errorcode); int readHoldingRegister(short address, - byte& errorcode); + uint8_t& errorcode); // Write to holding register. int writeSingleRegister(short address, @@ -143,47 +143,47 @@ struct ModbusRTU_struct { int writeSingleRegister(short address, short value, - byte& errorcode); + uint8_t& errorcode); // Function 16 (0x10) "Write Multiple Registers" to write to a single holding register int writeMultipleRegisters(short address, short value); - byte modbus_get_MEI(byte slaveAddress, - byte object_id, + uint8_t modbus_get_MEI(uint8_t slaveAddress, + uint8_t object_id, String & result, unsigned int& object_value_int, - byte & next_object_id, + uint8_t & next_object_id, bool & more_follows, - byte & conformity_level); + uint8_t & conformity_level); - void modbus_log_MEI(byte slaveAddress); + void modbus_log_MEI(uint8_t slaveAddress); - int process_16b_register(byte slaveAddress, - byte functionCode, + int process_16b_register(uint8_t slaveAddress, + uint8_t functionCode, short startAddress, short parameter, - byte& errorcode); + uint8_t& errorcode); // Still writing single register, but calling it using "Preset Multiple Registers" function (FC=16) - int preset_mult16b_register(byte slaveAddress, + int preset_mult16b_register(uint8_t slaveAddress, uint16_t startAddress, uint16_t value); - bool process_32b_register(byte slaveAddress, - byte functionCode, + bool process_32b_register(uint8_t slaveAddress, + uint8_t functionCode, short startAddress, uint32_t& result); - int writeSpecialCommandRegister(byte command); + int writeSpecialCommandRegister(uint8_t command); - unsigned int read_RAM_EEPROM(byte command, - byte startAddress, - byte nrBytes, - byte& errorcode); + unsigned int read_RAM_EEPROM(uint8_t command, + uint8_t startAddress, + uint8_t nrBytes, + uint8_t& errorcode); // Compute the MODBUS RTU CRC - static unsigned int ModRTU_CRC(byte *buf, + static unsigned int ModRTU_CRC(uint8_t *buf, int len); uint32_t readTypeId(); @@ -202,11 +202,11 @@ private: void startRead(); - byte _sendframe[12] = { 0 }; - byte _sendframe_used = 0; - byte _recv_buf[MODBUS_RECEIVE_BUFFER] = { 0 }; - byte _recv_buf_used = 0; - byte _modbus_address = MODBUS_BROADCAST_ADDRESS; + uint8_t _sendframe[12] = { 0 }; + uint8_t _sendframe_used = 0; + uint8_t _recv_buf[MODBUS_RECEIVE_BUFFER] = { 0 }; + uint8_t _recv_buf_used = 0; + uint8_t _modbus_address = MODBUS_BROADCAST_ADDRESS; int8_t _dere_pin = -1; uint32_t _reads_pass = 0; uint32_t _reads_crc_failed = 0; diff --git a/src/src/Helpers/Networking.cpp b/src/src/Helpers/Networking.cpp index 33779955d..f353f5188 100644 --- a/src/src/Helpers/Networking.cpp +++ b/src/src/Helpers/Networking.cpp @@ -68,7 +68,7 @@ void etharp_gratuitous_r(struct netif *netif) { /*********************************************************************************************\ Syslog client \*********************************************************************************************/ -void syslog(byte logLevel, const char *message) +void syslog(uint8_t logLevel, const char *message) { if ((Settings.Syslog_IP[0] != 0) && NetworkConnected()) { @@ -79,7 +79,7 @@ void syslog(byte logLevel, const char *message) // problem resolving the hostname or port return; } - byte prio = Settings.SyslogFacility * 8; + uint8_t prio = Settings.SyslogFacility * 8; if (logLevel == LOG_LEVEL_ERROR) { prio += 3; // syslog error @@ -237,16 +237,16 @@ void checkUDP() if (len < 13) { break; } - byte unit = packetBuffer[12]; + uint8_t unit = packetBuffer[12]; #ifndef BUILD_NO_DEBUG MAC_address mac; - byte ip[4]; + uint8_t ip[4]; - for (byte x = 0; x < 6; x++) { + for (uint8_t x = 0; x < 6; x++) { mac.mac[x] = packetBuffer[x + 2]; } - for (byte x = 0; x < 4; x++) { + for (uint8_t x = 0; x < 4; x++) { ip[x] = packetBuffer[x + 8]; } #endif // ifndef BUILD_NO_DEBUG @@ -254,7 +254,7 @@ void checkUDP() NodesMap::iterator it = Nodes.find(unit); if (it != Nodes.end()) { - for (byte x = 0; x < 4; x++) { + for (uint8_t x = 0; x < 4; x++) { it->second.ip[x] = packetBuffer[x + 8]; } it->second.age = 0; // reset 'age counter' @@ -263,7 +263,7 @@ void checkUDP() { it->second.build = makeWord(packetBuffer[14], packetBuffer[13]); char tmpNodeName[26] = { 0 }; - memcpy(&tmpNodeName[0], reinterpret_cast(&packetBuffer[15]), 25); + memcpy(&tmpNodeName[0], reinterpret_cast(&packetBuffer[15]), 25); tmpNodeName[25] = 0; it->second.nodeName = tmpNodeName; it->second.nodeName.trim(); @@ -295,7 +295,7 @@ void checkUDP() default: { struct EventStruct TempEvent; - TempEvent.Data = reinterpret_cast(&packetBuffer[0]); + TempEvent.Data = reinterpret_cast(&packetBuffer[0]); TempEvent.Par1 = remoteIP[3]; TempEvent.Par2 = len; String dummy; @@ -321,7 +321,7 @@ void checkUDP() /*********************************************************************************************\ Send event using UDP message \*********************************************************************************************/ -void SendUDPCommand(byte destUnit, const char *data, byte dataLength) +void SendUDPCommand(uint8_t destUnit, const char *data, uint8_t dataLength) { if (!NetworkConnected(10)) { return; @@ -329,12 +329,12 @@ void SendUDPCommand(byte destUnit, const char *data, byte dataLength) if (destUnit != 0) { - sendUDP(destUnit, (const byte *)data, dataLength); + sendUDP(destUnit, (const uint8_t *)data, dataLength); delay(10); } else { for (NodesMap::iterator it = Nodes.begin(); it != Nodes.end(); ++it) { if (it->first != Settings.Unit) { - sendUDP(it->first, (const byte *)data, dataLength); + sendUDP(it->first, (const uint8_t *)data, dataLength); delay(10); } } @@ -346,7 +346,7 @@ void SendUDPCommand(byte destUnit, const char *data, byte dataLength) Get formatted IP address for unit formatcodes: 0 = default toString(), 1 = empty string when invalid, 2 = 0 when invalid \*********************************************************************************************/ -String formatUnitToIPAddress(byte unit, byte formatCode) { +String formatUnitToIPAddress(uint8_t unit, uint8_t formatCode) { IPAddress unitIPAddress = getIPAddressForUnit(unit); if (unitIPAddress[0] == 0) { // Invalid? @@ -367,7 +367,7 @@ String formatUnitToIPAddress(byte unit, byte formatCode) { /*********************************************************************************************\ Get IP address for unit \*********************************************************************************************/ -IPAddress getIPAddressForUnit(byte unit) { +IPAddress getIPAddressForUnit(uint8_t unit) { IPAddress remoteNodeIP; if (unit == 255) { @@ -391,7 +391,7 @@ IPAddress getIPAddressForUnit(byte unit) { /*********************************************************************************************\ Send UDP message (unit 255=broadcast) \*********************************************************************************************/ -void sendUDP(byte unit, const byte *data, byte size) +void sendUDP(uint8_t unit, const uint8_t *data, uint8_t size) { if (!NetworkConnected(10)) { return; @@ -457,50 +457,50 @@ void refreshNodeList() /*********************************************************************************************\ Broadcast system info to other nodes. (to update node lists) \*********************************************************************************************/ -void sendSysInfoUDP(byte repeats) +void sendSysInfoUDP(uint8_t repeats) { if ((Settings.UDPPort == 0) || !NetworkConnected(10)) { return; } // TODO: make a nice struct of it and clean up - // 1 byte 'binary token 255' - // 1 byte id '1' - // 6 byte mac - // 4 byte ip - // 1 byte unit - // 2 byte build + // 1 uint8_t 'binary token 255' + // 1 uint8_t id '1' + // 6 uint8_t mac + // 4 uint8_t ip + // 1 uint8_t unit + // 2 uint8_t build // 25 char name - // 1 byte node type id + // 1 uint8_t node type id // send my info to the world... #ifndef BUILD_NO_DEBUG addLog(LOG_LEVEL_DEBUG_MORE, F("UDP : Send Sysinfo message")); #endif // ifndef BUILD_NO_DEBUG - for (byte counter = 0; counter < repeats; counter++) + for (uint8_t counter = 0; counter < repeats; counter++) { - byte data[80] = { 0 }; + uint8_t data[80] = { 0 }; data[0] = 255; data[1] = 1; { const MAC_address macread = NetworkMacAddress(); - for (byte x = 0; x < 6; x++) { + for (uint8_t x = 0; x < 6; x++) { data[x + 2] = macread.mac[x]; } } { const IPAddress ip = NetworkLocalIP(); - for (byte x = 0; x < 4; x++) { + for (uint8_t x = 0; x < 4; x++) { data[x + 8] = ip[x]; } } data[12] = Settings.Unit; data[13] = lowByte(Settings.Build); data[14] = highByte(Settings.Build); - memcpy((byte *)data + 15, Settings.Name, 25); + memcpy((uint8_t *)data + 15, Settings.Name, 25); data[40] = NODE_TYPE_ID; data[41] = lowByte(Settings.WebserverPort); data[42] = highByte(Settings.WebserverPort); @@ -526,7 +526,7 @@ void sendSysInfoUDP(byte repeats) { IPAddress ip = NetworkLocalIP(); - for (byte x = 0; x < 4; x++) { + for (uint8_t x = 0; x < 4; x++) { it->second.ip[x] = ip[x]; } it->second.age = 0; @@ -684,7 +684,7 @@ bool SSDP_begin() { /********************************************************************************************\ Send SSDP messages (notify & responses) \*********************************************************************************************/ -void SSDP_send(byte method) { +void SSDP_send(uint8_t method) { uint32_t ip = NetworkLocalIP(); // FIXME TD-er: Why create String objects of these flashstrings? @@ -904,7 +904,7 @@ bool getSubnetRange(IPAddress& low, IPAddress& high) high = ip; // Compute subnet range. - for (byte i = 0; i < 4; ++i) { + for (uint8_t i = 0; i < 4; ++i) { if (subnet[i] != 255) { low[i] = low[i] & subnet[i]; high[i] = high[i] | ~subnet[i]; @@ -973,7 +973,7 @@ bool hostReachable(const IPAddress& ip) { /* // Only do 1 ping at a time to return early - byte retry = 3; + uint8_t retry = 3; while (retry > 0) { #if defined(ESP8266) if (Ping.ping(ip, 1)) return true; @@ -1246,7 +1246,7 @@ bool downloadFile(const String& url, String file_save, const String& user, const // read all data from server while (http.connected() && (len > 0 || len == -1)) { - // read up to 128 byte + // read up to 128 uint8_t size_t c = stream->readBytes(buff, std::min((size_t)len, sizeof(buff))); if (c > 0) { diff --git a/src/src/Helpers/Networking.h b/src/src/Helpers/Networking.h index 69de5c3be..1bd629147 100644 --- a/src/src/Helpers/Networking.h +++ b/src/src/Helpers/Networking.h @@ -10,7 +10,7 @@ /*********************************************************************************************\ Syslog client \*********************************************************************************************/ -void syslog(byte logLevel, const char *message); +void syslog(uint8_t logLevel, const char *message); /*********************************************************************************************\ @@ -28,23 +28,23 @@ void checkUDP(); /*********************************************************************************************\ Send event using UDP message \*********************************************************************************************/ -void SendUDPCommand(byte destUnit, const char *data, byte dataLength); +void SendUDPCommand(uint8_t destUnit, const char *data, uint8_t dataLength); /*********************************************************************************************\ Get formatted IP address for unit formatcodes: 0 = default toString(), 1 = empty string when invalid, 2 = 0 when invalid \*********************************************************************************************/ -String formatUnitToIPAddress(byte unit, byte formatCode); +String formatUnitToIPAddress(uint8_t unit, uint8_t formatCode); /*********************************************************************************************\ Get IP address for unit \*********************************************************************************************/ -IPAddress getIPAddressForUnit(byte unit); +IPAddress getIPAddressForUnit(uint8_t unit); /*********************************************************************************************\ Send UDP message (unit 255=broadcast) \*********************************************************************************************/ -void sendUDP(byte unit, const byte *data, byte size); +void sendUDP(uint8_t unit, const uint8_t *data, uint8_t size); /*********************************************************************************************\ Refresh aging for remote units, drop if too old... @@ -54,7 +54,7 @@ void refreshNodeList(); /*********************************************************************************************\ Broadcast system info to other nodes. (to update node lists) \*********************************************************************************************/ -void sendSysInfoUDP(byte repeats); +void sendSysInfoUDP(uint8_t repeats); #if defined(ESP8266) @@ -101,7 +101,7 @@ bool SSDP_begin(); /********************************************************************************************\ Send SSDP messages (notify & responses) \*********************************************************************************************/ -void SSDP_send(byte method); +void SSDP_send(uint8_t method); /********************************************************************************************\ SSDP message processing diff --git a/src/src/Helpers/PeriodicalActions.cpp b/src/src/Helpers/PeriodicalActions.cpp index c92f52cab..892169bc1 100644 --- a/src/src/Helpers/PeriodicalActions.cpp +++ b/src/src/Helpers/PeriodicalActions.cpp @@ -404,7 +404,7 @@ controllerIndex_t firstEnabledMQTT_ControllerIndex() { void logTimerStatistics() { - byte loglevel = LOG_LEVEL_DEBUG; + uint8_t loglevel = LOG_LEVEL_DEBUG; updateLoopStats_30sec(loglevel); #ifndef BUILD_NO_DEBUG // logStatistics(loglevel, true); @@ -416,7 +416,7 @@ void logTimerStatistics() { #endif } -void updateLoopStats_30sec(byte loglevel) { +void updateLoopStats_30sec(uint8_t loglevel) { loopCounterLast = loopCounter; loopCounter = 0; if (loopCounterLast > loopCounterMax) diff --git a/src/src/Helpers/PeriodicalActions.h b/src/src/Helpers/PeriodicalActions.h index 90188d8d4..27aa51598 100644 --- a/src/src/Helpers/PeriodicalActions.h +++ b/src/src/Helpers/PeriodicalActions.h @@ -48,7 +48,7 @@ controllerIndex_t firstEnabledMQTT_ControllerIndex(); void logTimerStatistics(); -void updateLoopStats_30sec(byte loglevel); +void updateLoopStats_30sec(uint8_t loglevel); /********************************************************************************************\ Clean up all before going to sleep or reboot. diff --git a/src/src/Helpers/PortStatus.cpp b/src/src/Helpers/PortStatus.cpp index a5fd8110a..7c8d46a80 100644 --- a/src/src/Helpers/PortStatus.cpp +++ b/src/src/Helpers/PortStatus.cpp @@ -118,12 +118,12 @@ uint16_t getPortFromKey(uint32_t key) { set pin mode & state (info table) \*********************************************************************************************/ /* - void setPinState(byte plugin, byte index, byte mode, uint16_t value) + void setPinState(uint8_t plugin, uint8_t index, uint8_t mode, uint16_t value) { // plugin number and index form a unique key // first check if this pin is already known bool reUse = false; - for (byte x = 0; x < PINSTATE_TABLE_MAX; x++) + for (uint8_t x = 0; x < PINSTATE_TABLE_MAX; x++) if ((pinStates[x].plugin == plugin) && (pinStates[x].index == index)) { pinStates[x].mode = mode; @@ -134,7 +134,7 @@ uint16_t getPortFromKey(uint32_t key) { if (!reUse) { - for (byte x = 0; x < PINSTATE_TABLE_MAX; x++) + for (uint8_t x = 0; x < PINSTATE_TABLE_MAX; x++) if (pinStates[x].plugin == 0) { pinStates[x].plugin = plugin; @@ -152,9 +152,9 @@ uint16_t getPortFromKey(uint32_t key) { \*********************************************************************************************/ /* - bool getPinState(byte plugin, byte index, byte *mode, uint16_t *value) + bool getPinState(uint8_t plugin, uint8_t index, uint8_t *mode, uint16_t *value) { - for (byte x = 0; x < PINSTATE_TABLE_MAX; x++) + for (uint8_t x = 0; x < PINSTATE_TABLE_MAX; x++) if ((pinStates[x].plugin == plugin) && (pinStates[x].index == index)) { * mode = pinStates[x].mode; @@ -169,9 +169,9 @@ uint16_t getPortFromKey(uint32_t key) { check if pin mode & state is known (info table) \*********************************************************************************************/ /* - bool hasPinState(byte plugin, byte index) + bool hasPinState(uint8_t plugin, uint8_t index) { - for (byte x = 0; x < PINSTATE_TABLE_MAX; x++) + for (uint8_t x = 0; x < PINSTATE_TABLE_MAX; x++) if ((pinStates[x].plugin == plugin) && (pinStates[x].index == index)) { return true; @@ -191,7 +191,7 @@ String getPinStateJSON(bool search, uint32_t key, const String& log, int16_t noS checkRAM(F("getPinStateJSON")); #endif printToWebJSON = true; - byte mode = PIN_MODE_INPUT; + uint8_t mode = PIN_MODE_INPUT; int16_t value = noSearchValue; bool found = false; @@ -233,7 +233,7 @@ String getPinStateJSON(bool search, uint32_t key, const String& log, int16_t noS return ""; } -const __FlashStringHelper * getPinModeString(byte mode) { +const __FlashStringHelper * getPinModeString(uint8_t mode) { switch (mode) { case PIN_MODE_UNDEFINED: return F("undefined"); diff --git a/src/src/Helpers/PortStatus.h b/src/src/Helpers/PortStatus.h index 7b3ff2b9c..eeba29743 100644 --- a/src/src/Helpers/PortStatus.h +++ b/src/src/Helpers/PortStatus.h @@ -39,7 +39,7 @@ uint16_t getPortFromKey(uint32_t key); set pin mode & state (info table) \*********************************************************************************************/ /* - void setPinState(byte plugin, byte index, byte mode, uint16_t value); + void setPinState(uint8_t plugin, uint8_t index, uint8_t mode, uint16_t value); */ /*********************************************************************************************\ @@ -47,14 +47,14 @@ uint16_t getPortFromKey(uint32_t key); \*********************************************************************************************/ /* - bool getPinState(byte plugin, byte index, byte *mode, uint16_t *value); + bool getPinState(uint8_t plugin, uint8_t index, uint8_t *mode, uint16_t *value); */ /*********************************************************************************************\ check if pin mode & state is known (info table) \*********************************************************************************************/ /* - bool hasPinState(byte plugin, byte index); + bool hasPinState(uint8_t plugin, uint8_t index); */ @@ -67,6 +67,6 @@ String getPinStateJSON(bool search, const String& log, int16_t noSearchValue); -const __FlashStringHelper * getPinModeString(byte mode); +const __FlashStringHelper * getPinModeString(uint8_t mode); #endif \ No newline at end of file diff --git a/src/src/Helpers/Scheduler.cpp b/src/src/Helpers/Scheduler.cpp index c853db5a9..d29a83228 100644 --- a/src/src/Helpers/Scheduler.cpp +++ b/src/src/Helpers/Scheduler.cpp @@ -167,9 +167,9 @@ String ESPEasy_Scheduler::decodeSchedulerId(unsigned long mixed_id) { case GPIO_TIMER: { result = F("GPIO: "); - byte GPIOType = static_cast((id) & 0xFF); - byte pinNumber = static_cast((id >> 8) & 0xFF); - byte pinStateValue = static_cast((id >> 16) & 0xFF); + uint8_t GPIOType = static_cast((id) & 0xFF); + uint8_t pinNumber = static_cast((id >> 8) & 0xFF); + uint8_t pinStateValue = static_cast((id >> 16) & 0xFF); switch (GPIOType) { @@ -835,7 +835,7 @@ void ESPEasy_Scheduler::process_plugin_timer(unsigned long id) { * GPIO Timer * Special timer to handle timed GPIO actions \*********************************************************************************************/ -unsigned long ESPEasy_Scheduler::createGPIOTimerId(byte GPIOType, byte pinNumber, int Par1) { +unsigned long ESPEasy_Scheduler::createGPIOTimerId(uint8_t GPIOType, uint8_t pinNumber, int Par1) { const unsigned long mask = (1 << TIMER_ID_SHIFT) - 1; // const unsigned long mixed = (Par1 << 8) + pinNumber; @@ -846,7 +846,7 @@ unsigned long ESPEasy_Scheduler::createGPIOTimerId(byte GPIOType, byte pinNumber void ESPEasy_Scheduler::setGPIOTimer(unsigned long msecFromNow, pluginID_t pluginID, int Par1, int Par2, int Par3, int Par4, int Par5) { - byte GPIOType = GPIO_TYPE_INVALID; + uint8_t GPIOType = GPIO_TYPE_INVALID; switch (pluginID) { case PLUGIN_GPIO: @@ -869,13 +869,13 @@ void ESPEasy_Scheduler::setGPIOTimer(unsigned long msecFromNow, pluginID_t plugi void ESPEasy_Scheduler::process_gpio_timer(unsigned long id) { - byte GPIOType = static_cast((id) & 0xFF); - byte pinNumber = static_cast((id >> 8) & 0xFF); - byte pinStateValue = static_cast((id >> 16) & 0xFF); + uint8_t GPIOType = static_cast((id) & 0xFF); + uint8_t pinNumber = static_cast((id >> 8) & 0xFF); + uint8_t pinStateValue = static_cast((id >> 16) & 0xFF); bool success = true; - byte pluginID; + uint8_t pluginID; switch (GPIOType) { @@ -998,7 +998,7 @@ void ESPEasy_Scheduler::process_task_device_timer(unsigned long task_index, unsi * Thus only use these when the result is not needed immediately. * Proper use case is calling from a callback function, since those cannot use yield() or delay() \*********************************************************************************************/ -void ESPEasy_Scheduler::schedule_plugin_task_event_timer(deviceIndex_t DeviceIndex, byte Function, struct EventStruct &&event) { +void ESPEasy_Scheduler::schedule_plugin_task_event_timer(deviceIndex_t DeviceIndex, uint8_t Function, struct EventStruct &&event) { if (validDeviceIndex(DeviceIndex)) { schedule_event_timer(PluginPtrType::TaskPlugin, DeviceIndex, Function, std::move(event)); } @@ -1006,12 +1006,12 @@ void ESPEasy_Scheduler::schedule_plugin_task_event_timer(deviceIndex_t DeviceInd void ESPEasy_Scheduler::schedule_mqtt_plugin_import_event_timer(deviceIndex_t DeviceIndex, taskIndex_t TaskIndex, - byte Function, + uint8_t Function, char *c_topic, - byte *b_payload, + uint8_t *b_payload, unsigned int length) { if (validDeviceIndex(DeviceIndex)) { - const unsigned long mixedId = createSystemEventMixedId(PluginPtrType::TaskPlugin, DeviceIndex, static_cast(Function)); + const unsigned long mixedId = createSystemEventMixedId(PluginPtrType::TaskPlugin, DeviceIndex, static_cast(Function)); EventStruct event(TaskIndex); const size_t topic_length = strlen_P(c_topic); if (!(event.String1.reserve(topic_length) && event.String2.reserve(length))) { @@ -1031,7 +1031,7 @@ void ESPEasy_Scheduler::schedule_mqtt_plugin_import_event_timer(deviceIndex_t } } -void ESPEasy_Scheduler::schedule_controller_event_timer(protocolIndex_t ProtocolIndex, byte Function, struct EventStruct &&event) { +void ESPEasy_Scheduler::schedule_controller_event_timer(protocolIndex_t ProtocolIndex, uint8_t Function, struct EventStruct &&event) { if (validProtocolIndex(ProtocolIndex)) { schedule_event_timer(PluginPtrType::ControllerPlugin, ProtocolIndex, Function, std::move(event)); } @@ -1044,7 +1044,7 @@ unsigned long ESPEasy_Scheduler::createSystemEventMixedId(PluginPtrType ptr_type return getMixedId(SYSTEM_EVENT_QUEUE, subId); } -unsigned long ESPEasy_Scheduler::createSystemEventMixedId(PluginPtrType ptr_type, byte Index, byte Function) { +unsigned long ESPEasy_Scheduler::createSystemEventMixedId(PluginPtrType ptr_type, uint8_t Index, uint8_t Function) { unsigned long subId = static_cast(ptr_type); subId = (subId << 8) + Index; @@ -1055,12 +1055,12 @@ unsigned long ESPEasy_Scheduler::createSystemEventMixedId(PluginPtrType ptr_type void ESPEasy_Scheduler::schedule_mqtt_controller_event_timer(protocolIndex_t ProtocolIndex, CPlugin::Function Function, char *c_topic, - byte *b_payload, + uint8_t *b_payload, unsigned int length) { if (validProtocolIndex(ProtocolIndex)) { // Emplace empty event in the queue first and the fill it. // This makes sure the relatively large event will not be in memory twice. - const unsigned long mixedId = createSystemEventMixedId(PluginPtrType::ControllerPlugin, ProtocolIndex, static_cast(Function)); + const unsigned long mixedId = createSystemEventMixedId(PluginPtrType::ControllerPlugin, ProtocolIndex, static_cast(Function)); ScheduledEventQueue.emplace_back(mixedId, EventStruct()); ScheduledEventQueue.back().event.String1 = c_topic; @@ -1076,11 +1076,11 @@ void ESPEasy_Scheduler::schedule_mqtt_controller_event_timer(protocolIndex_t Pro } } -void ESPEasy_Scheduler::schedule_notification_event_timer(byte NotificationProtocolIndex, NPlugin::Function Function, struct EventStruct &&event) { - schedule_event_timer(PluginPtrType::NotificationPlugin, NotificationProtocolIndex, static_cast(Function), std::move(event)); +void ESPEasy_Scheduler::schedule_notification_event_timer(uint8_t NotificationProtocolIndex, NPlugin::Function Function, struct EventStruct &&event) { + schedule_event_timer(PluginPtrType::NotificationPlugin, NotificationProtocolIndex, static_cast(Function), std::move(event)); } -void ESPEasy_Scheduler::schedule_event_timer(PluginPtrType ptr_type, byte Index, byte Function, struct EventStruct &&event) { +void ESPEasy_Scheduler::schedule_event_timer(PluginPtrType ptr_type, uint8_t Index, uint8_t Function, struct EventStruct &&event) { const unsigned long mixedId = createSystemEventMixedId(ptr_type, Index, Function); // EventStructCommandWrapper eventWrapper(mixedId, *event); @@ -1091,8 +1091,8 @@ void ESPEasy_Scheduler::schedule_event_timer(PluginPtrType ptr_type, byte Index, void ESPEasy_Scheduler::process_system_event_queue() { if (ScheduledEventQueue.size() == 0) { return; } unsigned long id = ScheduledEventQueue.front().id; - byte Function = id & 0xFF; - byte Index = (id >> 8) & 0xFF; + uint8_t Function = id & 0xFF; + uint8_t Index = (id >> 8) & 0xFF; PluginPtrType ptr_type = static_cast((id >> 16) & 0xFF); // At this moment, the String is not being used in the plugin calls, so just supply a dummy String. diff --git a/src/src/Helpers/Scheduler.h b/src/src/Helpers/Scheduler.h index f28b624d3..e070113bf 100644 --- a/src/src/Helpers/Scheduler.h +++ b/src/src/Helpers/Scheduler.h @@ -186,8 +186,8 @@ public: * GPIO Timer * Special timer to handle timed GPIO actions \*********************************************************************************************/ - static unsigned long createGPIOTimerId(byte GPIOType, - byte pinNumber, + static unsigned long createGPIOTimerId(uint8_t GPIOType, + uint8_t pinNumber, int Par1); @@ -233,30 +233,30 @@ public: // Note: event will be moved void schedule_plugin_task_event_timer(deviceIndex_t DeviceIndex, - byte Function, + uint8_t Function, struct EventStruct &&event); void schedule_mqtt_plugin_import_event_timer(deviceIndex_t DeviceIndex, taskIndex_t TaskIndex, - byte Function, + uint8_t Function, char *c_topic, - byte *b_payload, + uint8_t *b_payload, unsigned int length); // Note: the event will be moved void schedule_controller_event_timer(protocolIndex_t ProtocolIndex, - byte Function, + uint8_t Function, struct EventStruct &&event); void schedule_mqtt_controller_event_timer(protocolIndex_t ProtocolIndex, CPlugin::Function Function, char *c_topic, - byte *b_payload, + uint8_t *b_payload, unsigned int length); // Note: The event will be moved - void schedule_notification_event_timer(byte NotificationProtocolIndex, + void schedule_notification_event_timer(uint8_t NotificationProtocolIndex, NPlugin::Function Function, struct EventStruct &&event); @@ -265,13 +265,13 @@ public: uint16_t crc16); static unsigned long createSystemEventMixedId(PluginPtrType ptr_type, - byte Index, - byte Function); + uint8_t Index, + uint8_t Function); // Note, the event will be moved void schedule_event_timer(PluginPtrType ptr_type, - byte Index, - byte Function, + uint8_t Index, + uint8_t Function, struct EventStruct &&event); void process_system_event_queue(); diff --git a/src/src/Helpers/StringConverter.cpp b/src/src/Helpers/StringConverter.cpp index 8264cae22..4ec15bcd8 100644 --- a/src/src/Helpers/StringConverter.cpp +++ b/src/src/Helpers/StringConverter.cpp @@ -76,24 +76,24 @@ bool string2float(const String& string, float& floatvalue) { } /********************************************************************************************\ - Convert a char string to IP byte array + Convert a char string to IP uint8_t array \*********************************************************************************************/ bool isIP(const String& string) { IPAddress tmpip; return (tmpip.fromString(string)); } -bool str2ip(const String& string, byte *IP) { +bool str2ip(const String& string, uint8_t *IP) { return str2ip(string.c_str(), IP); } -bool str2ip(const char *string, byte *IP) +bool str2ip(const char *string, uint8_t *IP) { IPAddress tmpip; // Default constructor => set to 0.0.0.0 if ((*string == 0) || tmpip.fromString(string)) { // Eiher empty string or a valid IP addres, so copy value. - for (byte i = 0; i < 4; ++i) { + for (uint8_t i = 0; i < 4; ++i) { IP[i] = tmpip[i]; } return true; @@ -162,7 +162,7 @@ String formatHumanReadable(unsigned long value, unsigned long factor) { String formatHumanReadable(unsigned long value, unsigned long factor, int NrDecimals) { float floatValue(value); - byte steps = 0; + uint8_t steps = 0; while (value >= factor) { value /= factor; @@ -225,7 +225,7 @@ void addNewLine(String& line) { /*********************************************************************************************\ Format a value to the set number of decimals \*********************************************************************************************/ -String doFormatUserVar(struct EventStruct *event, byte rel_index, bool mustCheck, bool& isvalid) { +String doFormatUserVar(struct EventStruct *event, uint8_t rel_index, bool mustCheck, bool& isvalid) { if (event == nullptr) return EMPTY_STRING; isvalid = true; @@ -249,7 +249,7 @@ String doFormatUserVar(struct EventStruct *event, byte rel_index, bool mustCheck } - const byte valueCount = getValueCountForTask(event->TaskIndex); + const uint8_t valueCount = getValueCountForTask(event->TaskIndex); Sensor_VType sensorType = event->getSensorType(); if (valueCount <= rel_index) { @@ -298,7 +298,7 @@ String doFormatUserVar(struct EventStruct *event, byte rel_index, bool mustCheck } LoadTaskSettings(event->TaskIndex); - byte nrDecimals = ExtraTaskSettings.TaskDeviceValueDecimals[rel_index]; + uint8_t nrDecimals = ExtraTaskSettings.TaskDeviceValueDecimals[rel_index]; if (!Device[DeviceIndex].configurableDecimals()) { nrDecimals = 0; @@ -309,7 +309,7 @@ String doFormatUserVar(struct EventStruct *event, byte rel_index, bool mustCheck return result; } -String formatUserVarNoCheck(taskIndex_t TaskIndex, byte rel_index) { +String formatUserVarNoCheck(taskIndex_t TaskIndex, uint8_t rel_index) { bool isvalid; // FIXME TD-er: calls to this function cannot handle Sensor_VType::SENSOR_TYPE_STRING @@ -318,21 +318,21 @@ String formatUserVarNoCheck(taskIndex_t TaskIndex, byte rel_index) { return doFormatUserVar(&TempEvent, rel_index, false, isvalid); } -String formatUserVar(taskIndex_t TaskIndex, byte rel_index, bool& isvalid) { +String formatUserVar(taskIndex_t TaskIndex, uint8_t rel_index, bool& isvalid) { // FIXME TD-er: calls to this function cannot handle Sensor_VType::SENSOR_TYPE_STRING struct EventStruct TempEvent(TaskIndex); return doFormatUserVar(&TempEvent, rel_index, true, isvalid); } -String formatUserVarNoCheck(struct EventStruct *event, byte rel_index) +String formatUserVarNoCheck(struct EventStruct *event, uint8_t rel_index) { bool isvalid; return doFormatUserVar(event, rel_index, false, isvalid); } -String formatUserVar(struct EventStruct *event, byte rel_index, bool& isvalid) +String formatUserVar(struct EventStruct *event, uint8_t rel_index, bool& isvalid) { return doFormatUserVar(event, rel_index, true, isvalid); } @@ -514,14 +514,14 @@ String to_internal_string(const String& input, char replaceSpace) { IndexFind = 1 => command. // FIXME TD-er: parseString* should use index starting at 0. \*********************************************************************************************/ -String parseString(const String& string, byte indexFind, char separator) { +String parseString(const String& string, uint8_t indexFind, char separator) { String result = parseStringKeepCase(string, indexFind, separator); result.toLowerCase(); return result; } -String parseStringKeepCase(const String& string, byte indexFind, char separator) { +String parseStringKeepCase(const String& string, uint8_t indexFind, char separator) { String result; if (!GetArgv(string.c_str(), result, indexFind, separator)) { @@ -531,19 +531,19 @@ String parseStringKeepCase(const String& string, byte indexFind, char separator) return stripQuotes(result); } -String parseStringToEnd(const String& string, byte indexFind, char separator) { +String parseStringToEnd(const String& string, uint8_t indexFind, char separator) { String result = parseStringToEndKeepCase(string, indexFind, separator); result.toLowerCase(); return result; } -String parseStringToEndKeepCase(const String& string, byte indexFind, char separator) { +String parseStringToEndKeepCase(const String& string, uint8_t indexFind, char separator) { // Loop over the arguments to find the first and last pos of the arguments. int pos_begin = string.length(); int pos_end = pos_begin; int tmppos_begin, tmppos_end = -1; - byte nextArgument = indexFind; + uint8_t nextArgument = indexFind; bool hasArgument = false; while (GetArgvBeginEnd(string.c_str(), nextArgument, tmppos_begin, tmppos_end, separator)) @@ -569,7 +569,7 @@ String parseStringToEndKeepCase(const String& string, byte indexFind, char separ return stripQuotes(result); } -String tolerantParseStringKeepCase(const String& string, byte indexFind, char separator) +String tolerantParseStringKeepCase(const String& string, uint8_t indexFind, char separator) { if (Settings.TolerantLastArgParse()) { return parseStringToEndKeepCase(string, indexFind, separator); @@ -787,7 +787,7 @@ void parseControllerVariables(String& s, struct EventStruct *event, bool useURLe void parseSingleControllerVariable(String & s, struct EventStruct *event, - byte taskValueIndex, + uint8_t taskValueIndex, bool useURLencode) { if (validTaskIndex(event->TaskIndex)) { LoadTaskSettings(event->TaskIndex); @@ -819,7 +819,7 @@ void parseEventVariables(String& s, struct EventStruct *event, bool useURLencode if (event->getSensorType() == Sensor_VType::SENSOR_TYPE_LONG) { SMART_REPL(F("%val1%"), String(UserVar.getSensorTypeLong(event->TaskIndex))) } else { - for (byte i = 0; i < getValueCountForTask(event->TaskIndex); ++i) { + for (uint8_t i = 0; i < getValueCountForTask(event->TaskIndex); ++i) { String valstr = F("%val"); valstr += (i + 1); valstr += '%'; @@ -840,7 +840,7 @@ void parseEventVariables(String& s, struct EventStruct *event, bool useURLencode const bool vname_found = s.indexOf(F("%vname")) != -1; if (vname_found) { - for (byte i = 0; i < 4; ++i) { + for (uint8_t i = 0; i < 4; ++i) { String vname = F("%vname"); vname += (i + 1); vname += '%'; diff --git a/src/src/Helpers/StringConverter.h b/src/src/Helpers/StringConverter.h index 013849120..eb40a935b 100644 --- a/src/src/Helpers/StringConverter.h +++ b/src/src/Helpers/StringConverter.h @@ -30,15 +30,15 @@ bool string2float(const String& string, /********************************************************************************************\ - Convert a char string to IP byte array + Convert a char string to IP uint8_t array \*********************************************************************************************/ bool isIP(const String& string); bool str2ip(const String& string, - byte *IP); + uint8_t *IP); bool str2ip(const char *string, - byte *IP); + uint8_t *IP); String formatIP(const IPAddress& ip); @@ -87,22 +87,22 @@ void addNewLine(String& line); Format a value to the set number of decimals \*********************************************************************************************/ String doFormatUserVar(struct EventStruct *event, - byte rel_index, + uint8_t rel_index, bool mustCheck, bool & isvalid); String formatUserVarNoCheck(taskIndex_t TaskIndex, - byte rel_index); + uint8_t rel_index); String formatUserVar(taskIndex_t TaskIndex, - byte rel_index, + uint8_t rel_index, bool & isvalid); String formatUserVarNoCheck(struct EventStruct *event, - byte rel_index); + uint8_t rel_index); String formatUserVar(struct EventStruct *event, - byte rel_index, + uint8_t rel_index, bool & isvalid); @@ -171,23 +171,23 @@ String to_internal_string(const String& input, // FIXME TD-er: parseString* should use index starting at 0. \*********************************************************************************************/ String parseString(const String& string, - byte indexFind, + uint8_t indexFind, char separator = ','); String parseStringKeepCase(const String& string, - byte indexFind, + uint8_t indexFind, char separator = ','); String parseStringToEnd(const String& string, - byte indexFind, + uint8_t indexFind, char separator = ','); String parseStringToEndKeepCase(const String& string, - byte indexFind, + uint8_t indexFind, char separator = ','); String tolerantParseStringKeepCase(const String& string, - byte indexFind, + uint8_t indexFind, char separator = ','); // escapes special characters in strings for use in html-forms @@ -232,7 +232,7 @@ void parseControllerVariables(String & s, void parseSingleControllerVariable(String & s, struct EventStruct *event, - byte taskValueIndex, + uint8_t taskValueIndex, bool useURLencode); void parseSystemVariables(String& s, diff --git a/src/src/Helpers/StringGenerator_System.cpp b/src/src/Helpers/StringGenerator_System.cpp index 9d75c8b5d..ce4e18a88 100644 --- a/src/src/Helpers/StringGenerator_System.cpp +++ b/src/src/Helpers/StringGenerator_System.cpp @@ -56,7 +56,7 @@ const __FlashStringHelper * getLastBootCauseString() { #include // See https://github.com/espressif/esp-idf/blob/master/components/esp32/include/rom/rtc.h -String getResetReasonString(byte icore) { +String getResetReasonString(uint8_t icore) { bool isDEEPSLEEP_RESET(false); switch (rtc_get_reset_reason((RESET_REASON)icore)) { diff --git a/src/src/Helpers/StringGenerator_System.h b/src/src/Helpers/StringGenerator_System.h index 4d7baa4ee..e4a5e7763 100644 --- a/src/src/Helpers/StringGenerator_System.h +++ b/src/src/Helpers/StringGenerator_System.h @@ -23,7 +23,7 @@ const __FlashStringHelper * getLastBootCauseString(); #ifdef ESP32 // See https://github.com/espressif/esp-idf/blob/master/components/esp32/include/rom/rtc.h -String getResetReasonString(byte icore); +String getResetReasonString(uint8_t icore); #endif // ifdef ESP32 String getResetReasonString(); diff --git a/src/src/Helpers/StringGenerator_WiFi.cpp b/src/src/Helpers/StringGenerator_WiFi.cpp index e158282c9..f90d855b6 100644 --- a/src/src/Helpers/StringGenerator_WiFi.cpp +++ b/src/src/Helpers/StringGenerator_WiFi.cpp @@ -2,7 +2,7 @@ #include "../Globals/ESPEasyWiFiEvent.h" -const __FlashStringHelper * WiFi_encryptionType(byte encryptionType) { +const __FlashStringHelper * WiFi_encryptionType(uint8_t encryptionType) { switch (encryptionType) { #ifdef ESP32 case WIFI_AUTH_OPEN: return F("open"); diff --git a/src/src/Helpers/StringGenerator_WiFi.h b/src/src/Helpers/StringGenerator_WiFi.h index 9d74f964a..d08e57b98 100644 --- a/src/src/Helpers/StringGenerator_WiFi.h +++ b/src/src/Helpers/StringGenerator_WiFi.h @@ -3,7 +3,7 @@ #include "../../ESPEasy_common.h" -const __FlashStringHelper * WiFi_encryptionType(byte encryptionType); +const __FlashStringHelper * WiFi_encryptionType(uint8_t encryptionType); #ifdef ESP8266 #ifdef LIMIT_BUILD_SIZE diff --git a/src/src/Helpers/StringParser.cpp b/src/src/Helpers/StringParser.cpp index b442a8dd8..b4fc80011 100644 --- a/src/src/Helpers/StringParser.cpp +++ b/src/src/Helpers/StringParser.cpp @@ -36,12 +36,12 @@ String parseTemplate(String& tmpString, bool useURLencode) return parseTemplate_padded(tmpString, 0, useURLencode); } -String parseTemplate_padded(String& tmpString, byte minimal_lineSize) +String parseTemplate_padded(String& tmpString, uint8_t minimal_lineSize) { return parseTemplate_padded(tmpString, minimal_lineSize, false); } -String parseTemplate_padded(String& tmpString, byte minimal_lineSize, bool useURLencode) +String parseTemplate_padded(String& tmpString, uint8_t minimal_lineSize, bool useURLencode) { #ifndef BUILD_NO_RAM_TRACKER checkRAM(F("parseTemplate_padded")); @@ -49,7 +49,7 @@ String parseTemplate_padded(String& tmpString, byte minimal_lineSize, bool useUR START_TIMER; // Keep current loaded taskSettings to restore at the end. - byte currentTaskIndex = ExtraTaskSettings.TaskIndex; + uint8_t currentTaskIndex = ExtraTaskSettings.TaskIndex; String newString; newString.reserve(minimal_lineSize); // Our best guess of the new size. @@ -126,7 +126,7 @@ String parseTemplate_padded(String& tmpString, byte minimal_lineSize, bool useUR taskIndex_t taskIndex = findTaskIndexByName(deviceName); if (validTaskIndex(taskIndex) && Settings.TaskDeviceEnabled[taskIndex]) { - byte valueNr = findDeviceValueIndexByName(valueName, taskIndex); + uint8_t valueNr = findDeviceValueIndexByName(valueName, taskIndex); if (valueNr != VARS_PER_TASK) { // here we know the task and value, so find the uservar @@ -197,7 +197,7 @@ String parseTemplate_padded(String& tmpString, byte minimal_lineSize, bool useUR // valueFormat="transformation#justification" void transformValue( String & newString, - byte lineSize, + uint8_t lineSize, String value, String & valueFormat, const String& tmpString) @@ -377,7 +377,7 @@ void transformValue( indexDot = value.length(); } - for (byte f = 0; f < (x - indexDot); f++) { + for (uint8_t f = 0; f < (x - indexDot); f++) { value = (tempValueFormat[0] == 'd' ? ' ' : '0') + value; } break; @@ -410,7 +410,7 @@ void transformValue( { int filler = valueJust[1] - value.length() - '0'; // char '0' = 48; char '9' = 58 - for (byte f = 0; f < filler; f++) { + for (uint8_t f = 0; f < filler; f++) { newString += ' '; } } @@ -424,7 +424,7 @@ void transformValue( { int filler = valueJust[1] - value.length() - '0'; // 48 - for (byte f = 0; f < filler; f++) { + for (uint8_t f = 0; f < filler; f++) { value += ' '; } } @@ -496,7 +496,7 @@ void transformValue( { int filler = lineSize - newString.length() - value.length() - tmpString.length(); - for (byte f = 0; f < filler; f++) { + for (uint8_t f = 0; f < filler; f++) { newString += ' '; } } @@ -566,7 +566,7 @@ taskIndex_t findTaskIndexByName(const String& deviceName) // Find the first device value index of a taskIndex. // Return VARS_PER_TASK if none found. -byte findDeviceValueIndexByName(const String& valueName, taskIndex_t taskIndex) +uint8_t findDeviceValueIndexByName(const String& valueName, taskIndex_t taskIndex) { const deviceIndex_t deviceIndex = getDeviceIndex_from_TaskIndex(taskIndex); @@ -590,9 +590,9 @@ byte findDeviceValueIndexByName(const String& valueName, taskIndex_t taskIndex) } LoadTaskSettings(taskIndex); // Probably already loaded, but just to be sure - const byte valCount = getValueCountForTask(taskIndex); + const uint8_t valCount = getValueCountForTask(taskIndex); - for (byte valueNr = 0; valueNr < valCount; valueNr++) + for (uint8_t valueNr = 0; valueNr < valCount; valueNr++) { // Check case insensitive, since the user entered value name can have any case. if (valueName.equalsIgnoreCase(ExtraTaskSettings.TaskDeviceValueNames[valueNr])) diff --git a/src/src/Helpers/StringParser.h b/src/src/Helpers/StringParser.h index 075f40cd8..9dd7a6bbd 100644 --- a/src/src/Helpers/StringParser.h +++ b/src/src/Helpers/StringParser.h @@ -14,10 +14,10 @@ String parseTemplate(String& tmpString, bool useURLencode); String parseTemplate_padded(String& tmpString, - byte minimal_lineSize); + uint8_t minimal_lineSize); String parseTemplate_padded(String& tmpString, - byte minimal_lineSize, + uint8_t minimal_lineSize, bool useURLencode); @@ -29,7 +29,7 @@ String parseTemplate_padded(String& tmpString, // valueFormat="transformation#justification" void transformValue( String & newString, - byte lineSize, + uint8_t lineSize, String value, String & valueFormat, const String& tmpString); @@ -42,7 +42,7 @@ taskIndex_t findTaskIndexByName(const String& deviceName); // Find the first device value index of a taskIndex. // Return VARS_PER_TASK if none found. -byte findDeviceValueIndexByName(const String& valueName, +uint8_t findDeviceValueIndexByName(const String& valueName, taskIndex_t taskIndex); // Find positions of [...#...] in the given string. diff --git a/src/src/Helpers/WiFi_AP_CandidatesList.cpp b/src/src/Helpers/WiFi_AP_CandidatesList.cpp index 0cd7441fa..209f876d2 100644 --- a/src/src/Helpers/WiFi_AP_CandidatesList.cpp +++ b/src/src/Helpers/WiFi_AP_CandidatesList.cpp @@ -29,7 +29,7 @@ void WiFi_AP_CandidatesList::load_knownCredentials() { { // Add the known SSIDs String ssid, key; - byte index = 1; // Index 0 is the "unset" value + uint8_t index = 1; // Index 0 is the "unset" value bool done = false; @@ -413,7 +413,7 @@ void WiFi_AP_CandidatesList::purge_unusable() { candidates.unique(); } -bool WiFi_AP_CandidatesList::get_SSID_key(byte index, String& ssid, String& key) const { +bool WiFi_AP_CandidatesList::get_SSID_key(uint8_t index, String& ssid, String& key) const { switch (index) { case 1: ssid = SecuritySettings.WifiSSID; diff --git a/src/src/Helpers/WiFi_AP_CandidatesList.h b/src/src/Helpers/WiFi_AP_CandidatesList.h index a12431ec5..93e2c1b02 100644 --- a/src/src/Helpers/WiFi_AP_CandidatesList.h +++ b/src/src/Helpers/WiFi_AP_CandidatesList.h @@ -68,7 +68,7 @@ private: void purge_unusable(); // Load SSID and pass/key from the settings. - bool get_SSID_key(byte index, + bool get_SSID_key(uint8_t index, String& ssid, String& key) const; diff --git a/src/src/Helpers/_CPlugin_DomoticzHelper.cpp b/src/src/Helpers/_CPlugin_DomoticzHelper.cpp index 075a417f8..bcc7a01c3 100644 --- a/src/src/Helpers/_CPlugin_DomoticzHelper.cpp +++ b/src/src/Helpers/_CPlugin_DomoticzHelper.cpp @@ -25,7 +25,7 @@ // 1=Comfortable // 2=Dry // 3=Wet -String humStatDomoticz(struct EventStruct *event, byte rel_index) { +String humStatDomoticz(struct EventStruct *event, uint8_t rel_index) { userVarIndex_t userVarIndex = event->BaseVarIndex + rel_index; if (validTaskVarIndex(rel_index) && validUserVarIndex(userVarIndex)) { @@ -62,7 +62,7 @@ int mapVccToDomoticz() { } // Format including trailing semi colon -String formatUserVarDomoticz(struct EventStruct *event, byte rel_index) { +String formatUserVarDomoticz(struct EventStruct *event, uint8_t rel_index) { String text = formatUserVarNoCheck(event, rel_index); text += ';'; @@ -169,7 +169,7 @@ String formatDomoticzSensorType(struct EventStruct *event) { if (loglevelActiveFor(LOG_LEVEL_ERROR)) { String log = F("Domoticz Controller: Not yet implemented sensor type: "); - log += static_cast(event->sensorType); + log += static_cast(event->sensorType); log += F(" idx: "); log += event->idx; addLog(LOG_LEVEL_ERROR, log); @@ -191,7 +191,7 @@ String formatDomoticzSensorType(struct EventStruct *event) { if (loglevelActiveFor(LOG_LEVEL_INFO)) { String log = F(" Domoticz: Sensortype: "); - log += static_cast(event->sensorType); + log += static_cast(event->sensorType); log += F(" idx: "); log += event->idx; log += F(" values: "); diff --git a/src/src/Helpers/_CPlugin_DomoticzHelper.h b/src/src/Helpers/_CPlugin_DomoticzHelper.h index 5dd91e22f..a3b4adc8a 100644 --- a/src/src/Helpers/_CPlugin_DomoticzHelper.h +++ b/src/src/Helpers/_CPlugin_DomoticzHelper.h @@ -14,7 +14,7 @@ // 2=Dry // 3=Wet String humStatDomoticz(struct EventStruct *event, - byte rel_index); + uint8_t rel_index); int mapRSSItoDomoticz(); @@ -22,7 +22,7 @@ int mapVccToDomoticz(); // Format including trailing semi colon String formatUserVarDomoticz(struct EventStruct *event, - byte rel_index); + uint8_t rel_index); String formatUserVarDomoticz(int value); diff --git a/src/src/Helpers/_CPlugin_Helper.cpp b/src/src/Helpers/_CPlugin_Helper.cpp index 4ff8c5daf..903ae9954 100644 --- a/src/src/Helpers/_CPlugin_Helper.cpp +++ b/src/src/Helpers/_CPlugin_Helper.cpp @@ -336,7 +336,7 @@ bool send_via_http(const String& logIdentifier, WiFiClient& client, const String bool success = !must_check_reply; // This will send the request to the server - byte written = client.print(postStr); + uint8_t written = client.print(postStr); // as of 2018/11/01 the print function only returns one byte (upd to 256 chars sent). However if the string sent can be longer than this // therefore we calculate modulo 256. @@ -552,7 +552,7 @@ String send_via_http(const String& logIdentifier, if (httpCode > 0) { response = http.getString(); - byte loglevel = LOG_LEVEL_ERROR; + uint8_t loglevel = LOG_LEVEL_ERROR; // HTTP codes: // 1xx Informational response // 2xx Success diff --git a/src/src/Helpers/_CPlugin_Helper_webform.cpp b/src/src/Helpers/_CPlugin_Helper_webform.cpp index bfef0ed48..617c328f7 100644 --- a/src/src/Helpers/_CPlugin_Helper_webform.cpp +++ b/src/src/Helpers/_CPlugin_Helper_webform.cpp @@ -129,7 +129,7 @@ void addControllerParameterForm(const ControllerSettingsStruct& ControllerSettin switch (varType) { case ControllerSettingsStruct::CONTROLLER_USE_DNS: { - byte choice = ControllerSettings.UseDNS; + uint8_t choice = ControllerSettings.UseDNS; const __FlashStringHelper * options[2]; options[0] = F("Use IP address"); options[1] = F("Use Hostname"); @@ -286,7 +286,7 @@ void saveControllerParameterForm(ControllerSettingsStruct & ControllerSet IPAddress IP; resolveHostByName(ControllerSettings.HostName, IP, ControllerSettings.ClientTimeout); - for (byte x = 0; x < 4; x++) { + for (uint8_t x = 0; x < 4; x++) { ControllerSettings.IP[x] = IP[x]; } } diff --git a/src/src/Helpers/_CPlugin_LoRa_TTN_helper.cpp b/src/src/Helpers/_CPlugin_LoRa_TTN_helper.cpp index d7ea9709f..034955aad 100644 --- a/src/src/Helpers/_CPlugin_LoRa_TTN_helper.cpp +++ b/src/src/Helpers/_CPlugin_LoRa_TTN_helper.cpp @@ -15,7 +15,7 @@ String getPackedFromPlugin(struct EventStruct *event, uint8_t sampleSetCount) { - byte value_count = getValueCountForTask(event->TaskIndex); + uint8_t value_count = getValueCountForTask(event->TaskIndex); String raw_packed; if (PluginCall(PLUGIN_GET_PACKED_RAW_DATA, event, raw_packed)) { @@ -51,7 +51,7 @@ String getPackedFromPlugin(struct EventStruct *event, uint8_t sampleSetCount) default: - for (byte i = 0; i < value_count && i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < value_count && i < VARS_PER_TASK; ++i) { // For now, just store the floats as an int32 by multiplying the value with 10000. packed += LoRa_addFloat(UserVar[event->BaseVarIndex + i], PackedData_int32_1e4); } diff --git a/src/src/Helpers/_Internal_GPIO_pulseHelper.cpp b/src/src/Helpers/_Internal_GPIO_pulseHelper.cpp index ce6f3072a..7afd532ef 100644 --- a/src/src/Helpers/_Internal_GPIO_pulseHelper.cpp +++ b/src/src/Helpers/_Internal_GPIO_pulseHelper.cpp @@ -408,7 +408,7 @@ void Internal_GPIO_pulseHelper::updateStatisticalCounters(int par1) { pulseModeData.Step3OKcounter -= ISRdata.pulseTotalCounter - par1; } -void Internal_GPIO_pulseHelper::setStatsLogLevel(byte logLevel) { +void Internal_GPIO_pulseHelper::setStatsLogLevel(uint8_t logLevel) { pulseModeData.StatsLogLevel = logLevel; } @@ -430,7 +430,7 @@ void Internal_GPIO_pulseHelper::resetStatsErrorVars() { /*********************************************************************************************\ * write statistic counters to logfile \*********************************************************************************************/ -void Internal_GPIO_pulseHelper::doStatisticLogging(byte logLevel) +void Internal_GPIO_pulseHelper::doStatisticLogging(uint8_t logLevel) { if (loglevelActiveFor(logLevel)) { // Statistic to logfile. E.g: ... [123/1|111|100/5|80/3/4|40] [12243|3244] @@ -455,7 +455,7 @@ void Internal_GPIO_pulseHelper::doStatisticLogging(byte logLevel) /*********************************************************************************************\ * write collected timing values to logfile \*********************************************************************************************/ -void Internal_GPIO_pulseHelper::doTimingLogging(byte logLevel) +void Internal_GPIO_pulseHelper::doTimingLogging(uint8_t logLevel) { if (loglevelActiveFor(logLevel)) { // Timer to logfile. E.g: ... [4|12000|13444|12243|3244] diff --git a/src/src/Helpers/_Internal_GPIO_pulseHelper.h b/src/src/Helpers/_Internal_GPIO_pulseHelper.h index 075598c78..de5b5f690 100644 --- a/src/src/Helpers/_Internal_GPIO_pulseHelper.h +++ b/src/src/Helpers/_Internal_GPIO_pulseHelper.h @@ -74,7 +74,7 @@ struct pulseModeData_t { unsigned int Step3IGNcounter = 0; // counts how often step 3 detected the wrong pin state (2nd verification failed) unsigned int Step0ODcounter = 0; // counts how often the debounce time timed out before step 0 was reached long StepOverdueMax[P003_PSTEP_MAX + 1] = { 0 }; // longest recognised overdue time per step in ms - byte StatsLogLevel = PULSE_STATS_ADHOC_LOG_LEVEL; // log level for regular statistics logging + uint8_t StatsLogLevel = PULSE_STATS_ADHOC_LOG_LEVEL; // log level for regular statistics logging #endif }; @@ -109,8 +109,8 @@ struct Internal_GPIO_pulseHelper { uint64_t debounceTime_micros = 0; // 64 bit version of debounceTime in micoseconds uint16_t debounceTime = 0; taskIndex_t taskIndex = INVALID_TASK_INDEX; - byte gpio = -1; - byte pullupPinMode = INPUT_PULLUP; + uint8_t gpio = -1; + uint8_t pullupPinMode = INPUT_PULLUP; GPIOtriggerMode interruptPinMode = GPIOtriggerMode::Change; }; @@ -167,7 +167,7 @@ public: // adjust the statistical step counters relative to TotalCounter, in order to keep statistic correct void updateStatisticalCounters(int par1); - void setStatsLogLevel(byte logLevel); + void setStatsLogLevel(uint8_t logLevel); /*********************************************************************************************\ * reset statistical error cunters and overview variables @@ -177,12 +177,12 @@ public: /*********************************************************************************************\ * write statistic counters to logfile \*********************************************************************************************/ - void doStatisticLogging(byte logLevel); + void doStatisticLogging(uint8_t logLevel); /*********************************************************************************************\ * write collected timing values to logfile \*********************************************************************************************/ - void doTimingLogging(byte logLevel); + void doTimingLogging(uint8_t logLevel); #endif // ifdef PULSE_STATISTIC }; diff --git a/src/src/Helpers/_Plugin_Helper_serial.cpp b/src/src/Helpers/_Plugin_Helper_serial.cpp index c72f0f0c5..7af28d57a 100644 --- a/src/src/Helpers/_Plugin_Helper_serial.cpp +++ b/src/src/Helpers/_Plugin_Helper_serial.cpp @@ -251,7 +251,7 @@ void serialHelper_webformLoad(ESPEasySerialPort port, int rxPinDef, int txPinDef #endif } -void serialHelper_webformSave(byte& port, int8_t& rxPin, int8_t& txPin) { +void serialHelper_webformSave(uint8_t& port, int8_t& rxPin, int8_t& txPin) { int serialPortSelected = getFormItemInt(F("serPort"), -1); if (serialPortSelected < 0) { return; } @@ -295,14 +295,14 @@ void serialHelper_webformSave(struct EventStruct *event) { serialHelper_webformSave(CONFIG_PORT, CONFIG_PIN1, CONFIG_PIN2); } -bool serialHelper_isValid_serialconfig(byte serialconfig) { +bool serialHelper_isValid_serialconfig(uint8_t serialconfig) { if ((serialconfig >= 0x10) && (serialconfig <= 0x3f)) { return true; } return false; } -void serialHelper_serialconfig_webformLoad(struct EventStruct *event, byte currentSelection) { +void serialHelper_serialconfig_webformLoad(struct EventStruct *event, uint8_t currentSelection) { // nrOptions = 4 * 3 * 2 = 24 (bits 5..8 , parity N/E/O , stopbits 1/2) String id = F("serConf"); @@ -310,13 +310,13 @@ void serialHelper_serialconfig_webformLoad(struct EventStruct *event, byte curre do_addSelector_Head(id, EMPTY_STRING, EMPTY_STRING, false); if (currentSelection == 0) { - // Must truncate it to 1 byte, since ESP32 uses a 32-bit value. We add these high bits later for ESP32. - currentSelection = static_cast(SERIAL_8N1 & 0xFF); // Some default + // Must truncate it to 1 uint8_t, since ESP32 uses a 32-bit value. We add these high bits later for ESP32. + currentSelection = static_cast(SERIAL_8N1 & 0xFF); // Some default } - for (byte parity = 0; parity < 3; ++parity) { - for (byte stopBits = 1; stopBits <= 2; ++stopBits) { - for (byte bits = 5; bits <= 8; ++bits) { + for (uint8_t parity = 0; parity < 3; ++parity) { + for (uint8_t stopBits = 1; stopBits <= 2; ++stopBits) { + for (uint8_t bits = 5; bits <= 8; ++bits) { String label; label.reserve(36); label = String(bits); @@ -343,23 +343,23 @@ void serialHelper_serialconfig_webformLoad(struct EventStruct *event, byte curre addSelector_Foot(); } -byte serialHelper_serialconfig_webformSave() { +uint8_t serialHelper_serialconfig_webformSave() { int serialConfSelected = getFormItemInt(F("serConf"), 0); if (serialHelper_isValid_serialconfig(serialConfSelected)) { return serialConfSelected; } - // Must truncate it to 1 byte, since ESP32 uses a 32-bit value. We add these high bits later for ESP32. - return static_cast(SERIAL_8N1 & 0xFF); // Some default + // Must truncate it to 1 uint8_t, since ESP32 uses a 32-bit value. We add these high bits later for ESP32. + return static_cast(SERIAL_8N1 & 0xFF); // Some default } // Used by some plugins, which used several TaskDevicePluginConfigLong -byte serialHelper_convertOldSerialConfig(byte newLocationConfig) { +uint8_t serialHelper_convertOldSerialConfig(uint8_t newLocationConfig) { if (serialHelper_isValid_serialconfig(newLocationConfig)) { return newLocationConfig; } - byte serialconfig = 0x10; // Default stopbits = 1 + uint8_t serialconfig = 0x10; // Default stopbits = 1 serialconfig += ExtraTaskSettings.TaskDevicePluginConfigLong[3]; // Parity serialconfig += (ExtraTaskSettings.TaskDevicePluginConfigLong[2] - 5) << 2; // databits @@ -372,6 +372,6 @@ byte serialHelper_convertOldSerialConfig(byte newLocationConfig) { return serialconfig; } - // Must truncate it to 1 byte, since ESP32 uses a 32-bit value. We add these high bits later for ESP32. - return static_cast(SERIAL_8N1 & 0xFF); // Some default + // Must truncate it to 1 uint8_t, since ESP32 uses a 32-bit value. We add these high bits later for ESP32. + return static_cast(SERIAL_8N1 & 0xFF); // Some default } diff --git a/src/src/Helpers/_Plugin_Helper_serial.h b/src/src/Helpers/_Plugin_Helper_serial.h index 9401b9707..3151aef89 100644 --- a/src/src/Helpers/_Plugin_Helper_serial.h +++ b/src/src/Helpers/_Plugin_Helper_serial.h @@ -37,18 +37,18 @@ void serialHelper_webformLoad(struct EventStruct *event, bool allowSoftwareSeria void serialHelper_webformLoad(ESPEasySerialPort port, int rxPinDef, int txPinDef, bool allowSoftwareSerial); -void serialHelper_webformSave(byte& port, int8_t &rxPin, int8_t &txPin); +void serialHelper_webformSave(uint8_t& port, int8_t &rxPin, int8_t &txPin); void serialHelper_webformSave(struct EventStruct *event); -bool serialHelper_isValid_serialconfig(byte serialconfig); +bool serialHelper_isValid_serialconfig(uint8_t serialconfig); -void serialHelper_serialconfig_webformLoad(struct EventStruct *event, byte currentSelection); +void serialHelper_serialconfig_webformLoad(struct EventStruct *event, uint8_t currentSelection); -byte serialHelper_serialconfig_webformSave(); +uint8_t serialHelper_serialconfig_webformSave(); // Used by some plugins, which used several TaskDevicePluginConfigLong -byte serialHelper_convertOldSerialConfig(byte newLocationConfig); +uint8_t serialHelper_convertOldSerialConfig(uint8_t newLocationConfig); diff --git a/src/src/Helpers/_Plugin_SensorTypeHelper.cpp b/src/src/Helpers/_Plugin_SensorTypeHelper.cpp index eebae55bc..637101367 100644 --- a/src/src/Helpers/_Plugin_SensorTypeHelper.cpp +++ b/src/src/Helpers/_Plugin_SensorTypeHelper.cpp @@ -14,7 +14,7 @@ Only use this function to determine nr of output values when changing output type of a task To get the actual output values for a task, use getValueCountForTask \*********************************************************************************************/ -byte getValueCountFromSensorType(Sensor_VType sensorType) +uint8_t getValueCountFromSensorType(Sensor_VType sensorType) { switch (sensorType) { @@ -66,22 +66,22 @@ const __FlashStringHelper * getSensorTypeLabel(Sensor_VType sensorType) { return F(""); } -void sensorTypeHelper_webformLoad_allTypes(struct EventStruct *event, byte pconfigIndex) +void sensorTypeHelper_webformLoad_allTypes(struct EventStruct *event, uint8_t pconfigIndex) { - byte optionValues[12]; + uint8_t optionValues[12]; - optionValues[0] = static_cast(Sensor_VType::SENSOR_TYPE_SINGLE); - optionValues[1] = static_cast(Sensor_VType::SENSOR_TYPE_TEMP_HUM); - optionValues[2] = static_cast(Sensor_VType::SENSOR_TYPE_TEMP_BARO); - optionValues[3] = static_cast(Sensor_VType::SENSOR_TYPE_TEMP_HUM_BARO); - optionValues[4] = static_cast(Sensor_VType::SENSOR_TYPE_DUAL); - optionValues[5] = static_cast(Sensor_VType::SENSOR_TYPE_TRIPLE); - optionValues[6] = static_cast(Sensor_VType::SENSOR_TYPE_QUAD); - optionValues[7] = static_cast(Sensor_VType::SENSOR_TYPE_SWITCH); - optionValues[8] = static_cast(Sensor_VType::SENSOR_TYPE_DIMMER); - optionValues[9] = static_cast(Sensor_VType::SENSOR_TYPE_LONG); - optionValues[10] = static_cast(Sensor_VType::SENSOR_TYPE_WIND); - optionValues[11] = static_cast(Sensor_VType::SENSOR_TYPE_STRING); + optionValues[0] = static_cast(Sensor_VType::SENSOR_TYPE_SINGLE); + optionValues[1] = static_cast(Sensor_VType::SENSOR_TYPE_TEMP_HUM); + optionValues[2] = static_cast(Sensor_VType::SENSOR_TYPE_TEMP_BARO); + optionValues[3] = static_cast(Sensor_VType::SENSOR_TYPE_TEMP_HUM_BARO); + optionValues[4] = static_cast(Sensor_VType::SENSOR_TYPE_DUAL); + optionValues[5] = static_cast(Sensor_VType::SENSOR_TYPE_TRIPLE); + optionValues[6] = static_cast(Sensor_VType::SENSOR_TYPE_QUAD); + optionValues[7] = static_cast(Sensor_VType::SENSOR_TYPE_SWITCH); + optionValues[8] = static_cast(Sensor_VType::SENSOR_TYPE_DIMMER); + optionValues[9] = static_cast(Sensor_VType::SENSOR_TYPE_LONG); + optionValues[10] = static_cast(Sensor_VType::SENSOR_TYPE_WIND); + optionValues[11] = static_cast(Sensor_VType::SENSOR_TYPE_STRING); sensorTypeHelper_webformLoad(event, pconfigIndex, 11, optionValues); } @@ -90,19 +90,19 @@ void sensorTypeHelper_webformLoad_header() addFormSubHeader(F("Output Configuration")); } -void sensorTypeHelper_webformLoad_simple(struct EventStruct *event, byte pconfigIndex) +void sensorTypeHelper_webformLoad_simple(struct EventStruct *event, uint8_t pconfigIndex) { sensorTypeHelper_webformLoad_header(); - byte optionValues[4]; - optionValues[0] = static_cast(Sensor_VType::SENSOR_TYPE_SINGLE); - optionValues[1] = static_cast(Sensor_VType::SENSOR_TYPE_DUAL); - optionValues[2] = static_cast(Sensor_VType::SENSOR_TYPE_TRIPLE); - optionValues[3] = static_cast(Sensor_VType::SENSOR_TYPE_QUAD); + uint8_t optionValues[4]; + optionValues[0] = static_cast(Sensor_VType::SENSOR_TYPE_SINGLE); + optionValues[1] = static_cast(Sensor_VType::SENSOR_TYPE_DUAL); + optionValues[2] = static_cast(Sensor_VType::SENSOR_TYPE_TRIPLE); + optionValues[3] = static_cast(Sensor_VType::SENSOR_TYPE_QUAD); sensorTypeHelper_webformLoad(event, pconfigIndex, 4, optionValues); } -void sensorTypeHelper_webformLoad(struct EventStruct *event, byte pconfigIndex, int optionCount, const byte options[]) +void sensorTypeHelper_webformLoad(struct EventStruct *event, uint8_t pconfigIndex, int optionCount, const uint8_t options[]) { if (pconfigIndex >= PLUGIN_CONFIGVAR_MAX) { return; @@ -111,12 +111,12 @@ void sensorTypeHelper_webformLoad(struct EventStruct *event, byte pconfigIndex, const deviceIndex_t DeviceIndex = getDeviceIndex_from_TaskIndex(event->TaskIndex); if (!validDeviceIndex(DeviceIndex)) { choice = Sensor_VType::SENSOR_TYPE_NONE; - PCONFIG(pconfigIndex) = static_cast(choice); + PCONFIG(pconfigIndex) = static_cast(choice); } else if (getValueCountFromSensorType(choice) != getValueCountForTask(event->TaskIndex)) { // Invalid value checkDeviceVTypeForTask(event); choice = event->sensorType; - PCONFIG(pconfigIndex) = static_cast(choice); + PCONFIG(pconfigIndex) = static_cast(choice); } String outputTypeLabel = F("Output Data Type"); if (Device[DeviceIndex].OutputDataType == Output_Data_type_t::Simple) { @@ -130,7 +130,7 @@ void sensorTypeHelper_webformLoad(struct EventStruct *event, byte pconfigIndex, default: { choice = Device[DeviceIndex].VType; - PCONFIG(pconfigIndex) = static_cast(choice); + PCONFIG(pconfigIndex) = static_cast(choice); break; } } @@ -139,7 +139,7 @@ void sensorTypeHelper_webformLoad(struct EventStruct *event, byte pconfigIndex, addRowLabel(outputTypeLabel); addSelector_Head(PCONFIG_LABEL(pconfigIndex)); - for (byte x = 0; x < optionCount; x++) + for (uint8_t x = 0; x < optionCount; x++) { String name = getSensorTypeLabel(static_cast(options[x])); addSelector_Item(name, @@ -156,7 +156,7 @@ void sensorTypeHelper_webformLoad(struct EventStruct *event, byte pconfigIndex, } } -void sensorTypeHelper_saveOutputSelector(struct EventStruct *event, byte pconfigIndex, byte valueIndex, const String& defaultValueName) +void sensorTypeHelper_saveOutputSelector(struct EventStruct *event, uint8_t pconfigIndex, uint8_t valueIndex, const String& defaultValueName) { if (defaultValueName.equals(ExtraTaskSettings.TaskDeviceValueNames[valueIndex])) { ZERO_FILL(ExtraTaskSettings.TaskDeviceValueNames[valueIndex]); @@ -164,16 +164,16 @@ void sensorTypeHelper_saveOutputSelector(struct EventStruct *event, byte pconfig pconfig_webformSave(event, pconfigIndex); } -void pconfig_webformSave(struct EventStruct *event, byte pconfigIndex) +void pconfig_webformSave(struct EventStruct *event, uint8_t pconfigIndex) { PCONFIG(pconfigIndex) = getFormItemInt(PCONFIG_LABEL(pconfigIndex), 0); } void sensorTypeHelper_loadOutputSelector( - struct EventStruct *event, byte pconfigIndex, byte valuenr, + struct EventStruct *event, uint8_t pconfigIndex, uint8_t valuenr, int optionCount, const __FlashStringHelper * options[], const int indices[]) { - byte choice = PCONFIG(pconfigIndex); + uint8_t choice = PCONFIG(pconfigIndex); String label = F("Value "); label += (valuenr + 1); @@ -182,10 +182,10 @@ void sensorTypeHelper_loadOutputSelector( void sensorTypeHelper_loadOutputSelector( - struct EventStruct *event, byte pconfigIndex, byte valuenr, + struct EventStruct *event, uint8_t pconfigIndex, uint8_t valuenr, int optionCount, const String options[], const int indices[]) { - byte choice = PCONFIG(pconfigIndex); + uint8_t choice = PCONFIG(pconfigIndex); String label = F("Value "); label += (valuenr + 1); diff --git a/src/src/Helpers/_Plugin_SensorTypeHelper.h b/src/src/Helpers/_Plugin_SensorTypeHelper.h index d9e3c1ebd..83d2a3ee9 100644 --- a/src/src/Helpers/_Plugin_SensorTypeHelper.h +++ b/src/src/Helpers/_Plugin_SensorTypeHelper.h @@ -11,28 +11,28 @@ Only use this function to determine nr of output values when changing output type of a task To get the actual output values for a task, use getValueCountForTask \*********************************************************************************************/ -byte getValueCountFromSensorType(Sensor_VType sensorType); +uint8_t getValueCountFromSensorType(Sensor_VType sensorType); const __FlashStringHelper * getSensorTypeLabel(Sensor_VType sensorType); -void sensorTypeHelper_webformLoad_allTypes(struct EventStruct *event, byte pconfigIndex); +void sensorTypeHelper_webformLoad_allTypes(struct EventStruct *event, uint8_t pconfigIndex); void sensorTypeHelper_webformLoad_header(); -void sensorTypeHelper_webformLoad_simple(struct EventStruct *event, byte pconfigIndex); +void sensorTypeHelper_webformLoad_simple(struct EventStruct *event, uint8_t pconfigIndex); -void sensorTypeHelper_webformLoad(struct EventStruct *event, byte pconfigIndex, int optionCount, const byte options[]); +void sensorTypeHelper_webformLoad(struct EventStruct *event, uint8_t pconfigIndex, int optionCount, const uint8_t options[]); -void sensorTypeHelper_saveOutputSelector(struct EventStruct *event, byte pconfigIndex, byte valueIndex, const String& defaultValueName); +void sensorTypeHelper_saveOutputSelector(struct EventStruct *event, uint8_t pconfigIndex, uint8_t valueIndex, const String& defaultValueName); -void pconfig_webformSave(struct EventStruct *event, byte pconfigIndex); +void pconfig_webformSave(struct EventStruct *event, uint8_t pconfigIndex); void sensorTypeHelper_loadOutputSelector( - struct EventStruct *event, byte pconfigIndex, byte valuenr, + struct EventStruct *event, uint8_t pconfigIndex, uint8_t valuenr, int optionCount, const __FlashStringHelper * options[], const int indices[] = NULL); void sensorTypeHelper_loadOutputSelector( - struct EventStruct *event, byte pconfigIndex, byte valuenr, + struct EventStruct *event, uint8_t pconfigIndex, uint8_t valuenr, int optionCount, const String options[], const int indices[] = NULL); diff --git a/src/src/PluginStructs/P004_data_struct.cpp b/src/src/PluginStructs/P004_data_struct.cpp index ea84c1a28..a847acab7 100644 --- a/src/src/PluginStructs/P004_data_struct.cpp +++ b/src/src/PluginStructs/P004_data_struct.cpp @@ -30,7 +30,7 @@ void P004_data_struct::add_addr(const uint8_t addr[], uint8_t index) { bool P004_data_struct::initiate_read() { _measurementStart = millis(); - for (byte i = 0; i < 4; ++i) { + for (uint8_t i = 0; i < 4; ++i) { if (_sensors[i].initiate_read(_gpio_rx, _gpio_tx, _res)) { if (!measurement_active()) { // Set the timer right after initiating the first sensor @@ -58,7 +58,7 @@ bool P004_data_struct::initiate_read() { bool P004_data_struct::collect_values() { bool success = false; - for (byte i = 0; i < 4; ++i) { + for (uint8_t i = 0; i < 4; ++i) { if (_sensors[i].collect_value(_gpio_rx, _gpio_tx)) { success = true; } diff --git a/src/src/PluginStructs/P012_data_struct.cpp b/src/src/PluginStructs/P012_data_struct.cpp index 804c9b086..d5e7db1ab 100644 --- a/src/src/PluginStructs/P012_data_struct.cpp +++ b/src/src/PluginStructs/P012_data_struct.cpp @@ -9,7 +9,7 @@ P012_data_struct::P012_data_struct(uint8_t addr, uint8_t lcd_size, uint8_t mode, - byte timer) : + uint8_t timer) : lcd(addr, 20, 4), Plugin_012_mode(mode), displayTimer(timer) { @@ -38,7 +38,7 @@ P012_data_struct::P012_data_struct(uint8_t addr, createCustomChars(); } -void P012_data_struct::setBacklightTimer(byte timer) { +void P012_data_struct::setBacklightTimer(uint8_t timer) { displayTimer = timer; lcd.backlight(); } @@ -54,12 +54,12 @@ void P012_data_struct::checkTimer() { } } -void P012_data_struct::lcdWrite(const String& text, byte col, byte row) { +void P012_data_struct::lcdWrite(const String& text, uint8_t col, uint8_t row) { // clear line before writing new string if (Plugin_012_mode == 2) { lcd.setCursor(col, row); - for (byte i = col; i < Plugin_012_cols; i++) { + for (uint8_t i = col; i < Plugin_012_cols; i++) { lcd.print(" "); } } @@ -69,7 +69,7 @@ void P012_data_struct::lcdWrite(const String& text, byte col, byte row) { if ((Plugin_012_mode == 1) || (Plugin_012_mode == 2)) { lcd.setCursor(col, row); - for (byte i = 0; i < Plugin_012_cols - col; i++) { + for (uint8_t i = 0; i < Plugin_012_cols - col; i++) { if (text[i]) { lcd.print(text[i]); } @@ -80,7 +80,7 @@ void P012_data_struct::lcdWrite(const String& text, byte col, byte row) { else { // Fix Weird (native) lcd display behaviour that split long string into row 1,3,2,4, instead of 1,2,3,4 bool stillProcessing = 1; - byte charCount = 1; + uint8_t charCount = 1; while (stillProcessing) { if (++col > Plugin_012_cols) { // have we printed 20 characters yet (+1 for the logic) @@ -107,7 +107,7 @@ void P012_data_struct::lcdWrite(const String& text, byte col, byte row) { // Perform some specific changes for LCD display // https://www.letscontrolit.com/forum/viewtopic.php?t=2368 -String P012_data_struct::P012_parseTemplate(String& tmpString, byte lineSize) { +String P012_data_struct::P012_parseTemplate(String& tmpString, uint8_t lineSize) { String result = parseTemplate_padded(tmpString, lineSize); const char degree[3] = { 0xc2, 0xb0, 0 }; // Unicode degree symbol const char degree_lcd[2] = { 0xdf, 0 }; // P012_LCD degree symbol diff --git a/src/src/PluginStructs/P012_data_struct.h b/src/src/PluginStructs/P012_data_struct.h index 95fb5d6c1..658e46df2 100644 --- a/src/src/PluginStructs/P012_data_struct.h +++ b/src/src/PluginStructs/P012_data_struct.h @@ -11,17 +11,17 @@ struct P012_data_struct : public PluginTaskData_base { P012_data_struct(uint8_t addr, uint8_t lcd_size, uint8_t mode, - byte timer); + uint8_t timer); - void setBacklightTimer(byte timer); + void setBacklightTimer(uint8_t timer); void checkTimer(); void lcdWrite(const String& text, - byte col, - byte row); + uint8_t col, + uint8_t row); - String P012_parseTemplate(String& tmpString, byte lineSize); + String P012_parseTemplate(String& tmpString, uint8_t lineSize); void createCustomChars(); @@ -30,7 +30,7 @@ struct P012_data_struct : public PluginTaskData_base { int Plugin_012_cols = 16; int Plugin_012_rows = 2; int Plugin_012_mode = 1; - byte displayTimer = 0; + uint8_t displayTimer = 0; }; #endif // ifdef USES_P012 diff --git a/src/src/PluginStructs/P015_data_struct.cpp b/src/src/PluginStructs/P015_data_struct.cpp index 461f23cd2..dc3d4c0bd 100644 --- a/src/src/PluginStructs/P015_data_struct.cpp +++ b/src/src/PluginStructs/P015_data_struct.cpp @@ -12,7 +12,7 @@ # define TSL2561_REG_DATA_1 0x0E -P015_data_struct::P015_data_struct(byte i2caddr, unsigned int gain, byte integration) : +P015_data_struct::P015_data_struct(uint8_t i2caddr, unsigned int gain, uint8_t integration) : _gain(gain), _i2cAddr(i2caddr), _integration(integration) @@ -138,7 +138,7 @@ bool P015_data_struct::readByte(unsigned char address, unsigned char& value) // Read requested byte if (_error == 0) { - Wire.requestFrom(_i2cAddr, (byte)1); + Wire.requestFrom(_i2cAddr, (uint8_t)1); if (Wire.available() == 1) { @@ -188,7 +188,7 @@ bool P015_data_struct::readUInt(unsigned char address, unsigned int& value) // Read two bytes (low and high) if (_error == 0) { - Wire.requestFrom(_i2cAddr, (byte)2); + Wire.requestFrom(_i2cAddr, (uint8_t)2); if (Wire.available() == 2) { diff --git a/src/src/PluginStructs/P015_data_struct.h b/src/src/PluginStructs/P015_data_struct.h index 5c31836cf..9c1b1493e 100644 --- a/src/src/PluginStructs/P015_data_struct.h +++ b/src/src/PluginStructs/P015_data_struct.h @@ -16,9 +16,9 @@ # define P015_EXT_AUTO_GAIN 3 struct P015_data_struct : public PluginTaskData_base { - P015_data_struct(byte i2caddr, + P015_data_struct(uint8_t i2caddr, unsigned int gain, - byte integration); + uint8_t integration); bool begin(); @@ -125,9 +125,9 @@ struct P015_data_struct : public PluginTaskData_base { unsigned int _gain; // Gain setting, 0 = X1, 1 = X16, 2 = auto, 3 = extended auto; - byte _i2cAddr = 0; - byte _integration = 0; - byte _error = 0; + uint8_t _i2cAddr = 0; + uint8_t _integration = 0; + uint8_t _error = 0; bool _gain16xActive = false; }; diff --git a/src/src/PluginStructs/P020_data_struct.cpp b/src/src/PluginStructs/P020_data_struct.cpp index b8fada952..e88481dc2 100644 --- a/src/src/PluginStructs/P020_data_struct.cpp +++ b/src/src/PluginStructs/P020_data_struct.cpp @@ -111,7 +111,7 @@ void P020_Task::clearBuffer() { serial_buffer.reserve(P020_DATAGRAM_MAX_SIZE); } -void P020_Task::serialBegin(const ESPEasySerialPort port, int16_t rxPin, int16_t txPin, unsigned long baud, byte config) { +void P020_Task::serialBegin(const ESPEasySerialPort port, int16_t rxPin, int16_t txPin, unsigned long baud, uint8_t config) { serialEnd(); if (rxPin >= 0) { diff --git a/src/src/PluginStructs/P020_data_struct.h b/src/src/PluginStructs/P020_data_struct.h index f687ae284..3b9bcd716 100644 --- a/src/src/PluginStructs/P020_data_struct.h +++ b/src/src/PluginStructs/P020_data_struct.h @@ -36,7 +36,7 @@ struct P020_Task : public PluginTaskData_base { int16_t rxPin, int16_t txPin, unsigned long baud, - byte config); + uint8_t config); void serialEnd(); @@ -58,7 +58,7 @@ struct P020_Task : public PluginTaskData_base { String net_buffer; int checkI = 0; ESPeasySerial *ser2netSerial = nullptr; - byte serial_processing = 0; + uint8_t serial_processing = 0; taskIndex_t _taskIndex = INVALID_TASK_INDEX; }; diff --git a/src/src/PluginStructs/P022_data_struct.cpp b/src/src/PluginStructs/P022_data_struct.cpp index b36636457..3e59d26b3 100644 --- a/src/src/PluginStructs/P022_data_struct.cpp +++ b/src/src/PluginStructs/P022_data_struct.cpp @@ -41,7 +41,7 @@ bool P022_data_struct::p022_clear_init(uint8_t address) { // ******************************************************************************** // PCA9685 config // ******************************************************************************** -void P022_data_struct::Plugin_022_writeRegister(int i2cAddress, int regAddress, byte data) { +void P022_data_struct::Plugin_022_writeRegister(int i2cAddress, int regAddress, uint8_t data) { Wire.beginTransmission(i2cAddress); Wire.write(regAddress); Wire.write(data); @@ -96,7 +96,7 @@ void P022_data_struct::Plugin_022_Frequency(int address, uint16_t freq) { int i2cAddress = address; - Plugin_022_writeRegister(i2cAddress, PLUGIN_022_PCA9685_MODE1, (byte)0x0); + Plugin_022_writeRegister(i2cAddress, PLUGIN_022_PCA9685_MODE1, (uint8_t)0x0); freq *= 0.9; // prescale = 25000000 / 4096; @@ -107,11 +107,11 @@ void P022_data_struct::Plugin_022_Frequency(int address, uint16_t freq) uint8_t oldmode = Plugin_022_readRegister(i2cAddress, 0); uint8_t newmode = (oldmode & 0x7f) | 0x10; - Plugin_022_writeRegister(i2cAddress, PLUGIN_022_PCA9685_MODE1, (byte)newmode); - Plugin_022_writeRegister(i2cAddress, 0xfe, (byte)prescale); // prescale register - Plugin_022_writeRegister(i2cAddress, PLUGIN_022_PCA9685_MODE1, (byte)oldmode); + Plugin_022_writeRegister(i2cAddress, PLUGIN_022_PCA9685_MODE1, (uint8_t)newmode); + Plugin_022_writeRegister(i2cAddress, 0xfe, (uint8_t)prescale); // prescale register + Plugin_022_writeRegister(i2cAddress, PLUGIN_022_PCA9685_MODE1, (uint8_t)oldmode); delayMicroseconds(5000); - Plugin_022_writeRegister(i2cAddress, PLUGIN_022_PCA9685_MODE1, (byte)oldmode | 0xa1); + Plugin_022_writeRegister(i2cAddress, PLUGIN_022_PCA9685_MODE1, (uint8_t)oldmode | 0xa1); } void P022_data_struct::Plugin_022_initialize(int address) @@ -119,10 +119,10 @@ void P022_data_struct::Plugin_022_initialize(int address) int i2cAddress = address; // default mode is open drain output, drive leds connected to VCC - Plugin_022_writeRegister(i2cAddress, PLUGIN_022_PCA9685_MODE1, (byte)0x01); // reset the device + Plugin_022_writeRegister(i2cAddress, PLUGIN_022_PCA9685_MODE1, (uint8_t)0x01); // reset the device delay(1); - Plugin_022_writeRegister(i2cAddress, PLUGIN_022_PCA9685_MODE1, (byte)B10100000); // set up for auto increment - // Plugin_022_writeRegister(i2cAddress, PCA9685_MODE2, (byte)0x10); // set to output + Plugin_022_writeRegister(i2cAddress, PLUGIN_022_PCA9685_MODE1, (uint8_t)B10100000); // set up for auto increment + // Plugin_022_writeRegister(i2cAddress, PCA9685_MODE2, (uint8_t)0x10); // set to output p022_set_init(address); } diff --git a/src/src/PluginStructs/P022_data_struct.h b/src/src/PluginStructs/P022_data_struct.h index e76c8476c..3778d124a 100644 --- a/src/src/PluginStructs/P022_data_struct.h +++ b/src/src/PluginStructs/P022_data_struct.h @@ -16,7 +16,7 @@ # define PCA9685_MAX_PWM 4095 # define PCA9685_MIN_FREQUENCY 23.0 // Min possible PWM cycle frequency # define PCA9685_MAX_FREQUENCY 1500.0 // Max possible PWM cycle frequency -# define PCA9685_ALLLED_REG (byte)0xFA +# define PCA9685_ALLLED_REG (uint8_t)0xFA // FIXME TD-er: This still uses a bitmask to keep track of what address was initialized. // That's no longer needed as it is now a data struct object per task instead of per address. @@ -31,7 +31,7 @@ struct P022_data_struct : public PluginTaskData_base { void Plugin_022_writeRegister(int i2cAddress, int regAddress, - byte data); + uint8_t data); uint8_t Plugin_022_readRegister(int i2cAddress, int regAddress); diff --git a/src/src/PluginStructs/P023_data_struct.cpp b/src/src/PluginStructs/P023_data_struct.cpp index 596628743..6dd95e99b 100644 --- a/src/src/PluginStructs/P023_data_struct.cpp +++ b/src/src/PluginStructs/P023_data_struct.cpp @@ -205,11 +205,11 @@ const char Plugin_023_myFont[][8] PROGMEM = { }; -P023_data_struct::P023_data_struct(byte _address, byte _type, P023_data_struct::Spacing _font_spacing, byte _displayTimer,byte _use_sh1106) +P023_data_struct::P023_data_struct(uint8_t _address, uint8_t _type, P023_data_struct::Spacing _font_spacing, uint8_t _displayTimer,uint8_t _use_sh1106) : address(_address), type(_type), font_spacing(_font_spacing), displayTimer(_displayTimer), use_sh1106(_use_sh1106) {} -void P023_data_struct::setDisplayTimer(byte _displayTimer) { +void P023_data_struct::setDisplayTimer(uint8_t _displayTimer) { displayOn(); displayTimer = _displayTimer; } @@ -226,7 +226,7 @@ void P023_data_struct::checkDisplayTimer() { } // Perform some specific changes for OLED display -String P023_data_struct::parseTemplate(String& tmpString, byte lineSize) { +String P023_data_struct::parseTemplate(String& tmpString, uint8_t lineSize) { String result = parseTemplate_padded(tmpString, lineSize); const char degree[3] = { 0xc2, 0xb0, 0 }; // Unicode degree symbol const char degree_oled[2] = { 0x7F, 0 }; // P023_OLED degree symbol diff --git a/src/src/PluginStructs/P023_data_struct.h b/src/src/PluginStructs/P023_data_struct.h index 5d1b50678..e05eef006 100644 --- a/src/src/PluginStructs/P023_data_struct.h +++ b/src/src/PluginStructs/P023_data_struct.h @@ -23,17 +23,17 @@ struct P023_data_struct : public PluginTaskData_base { optimized = 0x02 }; - P023_data_struct(byte _address, - byte _type, + P023_data_struct(uint8_t _address, + uint8_t _type, Spacing _font_spacing, - byte _displayTimer, - byte _use_sh1106); + uint8_t _displayTimer, + uint8_t _use_sh1106); - void setDisplayTimer(byte _displayTimer); + void setDisplayTimer(uint8_t _displayTimer); void checkDisplayTimer(); String parseTemplate(String& tmpString, - byte lineSize); + uint8_t lineSize); void resetDisplay(); @@ -72,11 +72,11 @@ struct P023_data_struct : public PluginTaskData_base { void init_OLED(); - byte address = 0; - byte type = 0; + uint8_t address = 0; + uint8_t type = 0; Spacing font_spacing = Spacing::normal; - byte displayTimer = 0; - byte use_sh1106 = 0; + uint8_t displayTimer = 0; + uint8_t use_sh1106 = 0; }; diff --git a/src/src/PluginStructs/P028_data_struct.cpp b/src/src/PluginStructs/P028_data_struct.cpp index d59dc9aa5..f564fa5ee 100644 --- a/src/src/PluginStructs/P028_data_struct.cpp +++ b/src/src/PluginStructs/P028_data_struct.cpp @@ -16,7 +16,7 @@ P028_data_struct::P028_data_struct(uint8_t addr) : state(BMx_Uninitialized) {} -byte P028_data_struct::get_config_settings() const { +uint8_t P028_data_struct::get_config_settings() const { switch (sensorID) { case BMP280_DEVICE_SAMPLE1: case BMP280_DEVICE_SAMPLE2: @@ -26,7 +26,7 @@ byte P028_data_struct::get_config_settings() const { } } -byte P028_data_struct::get_control_settings() const { +uint8_t P028_data_struct::get_control_settings() const { switch (sensorID) { case BMP280_DEVICE_SAMPLE1: case BMP280_DEVICE_SAMPLE2: diff --git a/src/src/PluginStructs/P028_data_struct.h b/src/src/PluginStructs/P028_data_struct.h index c1c275a78..bed32b746 100644 --- a/src/src/PluginStructs/P028_data_struct.h +++ b/src/src/PluginStructs/P028_data_struct.h @@ -106,9 +106,9 @@ enum BMx_state { struct P028_data_struct : public PluginTaskData_base { P028_data_struct(uint8_t addr); - byte get_config_settings() const; + uint8_t get_config_settings() const; - byte get_control_settings() const; + uint8_t get_control_settings() const; String getFullDeviceName() const; diff --git a/src/src/PluginStructs/P044_data_struct.cpp b/src/src/PluginStructs/P044_data_struct.cpp index 1e9d6d130..b16fe7b59 100644 --- a/src/src/PluginStructs/P044_data_struct.cpp +++ b/src/src/PluginStructs/P044_data_struct.cpp @@ -214,7 +214,7 @@ bool P044_Task::validP1char(char ch) { } void P044_Task::serialBegin(const ESPEasySerialPort port, int16_t rxPin, int16_t txPin, - unsigned long baud, byte config) { + unsigned long baud, uint8_t config) { serialEnd(); if (rxPin >= 0) { diff --git a/src/src/PluginStructs/P044_data_struct.h b/src/src/PluginStructs/P044_data_struct.h index 009d2dec2..62469d5c8 100644 --- a/src/src/PluginStructs/P044_data_struct.h +++ b/src/src/PluginStructs/P044_data_struct.h @@ -17,7 +17,7 @@ struct P044_Task : public PluginTaskData_base { - enum class ParserState : byte { + enum class ParserState : uint8_t { WAITING, READING, CHECKSUM @@ -73,7 +73,7 @@ struct P044_Task : public PluginTaskData_base { int16_t rxPin, int16_t txPin, unsigned long baud, - byte config); + uint8_t config); void serialEnd(); diff --git a/src/src/PluginStructs/P062_data_struct.cpp b/src/src/PluginStructs/P062_data_struct.cpp index 407c9c67c..52b47f3e0 100644 --- a/src/src/PluginStructs/P062_data_struct.cpp +++ b/src/src/PluginStructs/P062_data_struct.cpp @@ -58,7 +58,7 @@ bool P062_data_struct::readKey(uint16_t& key) { { uint16_t colMask = 0x01; - for (byte col = 1; col <= 12; col++) + for (uint8_t col = 1; col <= 12; col++) { if (key & colMask) // this key pressed? { diff --git a/src/src/PluginStructs/P079_data_struct.cpp b/src/src/PluginStructs/P079_data_struct.cpp index 3aa89e897..3cfb84efd 100644 --- a/src/src/PluginStructs/P079_data_struct.cpp +++ b/src/src/PluginStructs/P079_data_struct.cpp @@ -49,10 +49,10 @@ WemosMotor::WemosMotor(uint8_t address, uint8_t motor, uint32_t freq, uint8_t ST void WemosMotor::setfreq(uint32_t freq) { Wire.beginTransmission(_address); - Wire.write(((byte)(freq >> 24)) & (byte)0x0f); - Wire.write((byte)(freq >> 16)); - Wire.write((byte)(freq >> 8)); - Wire.write((byte)freq); + Wire.write(((uint8_t)(freq >> 24)) & (uint8_t)0x0f); + Wire.write((uint8_t)(freq >> 16)); + Wire.write((uint8_t)(freq >> 8)); + Wire.write((uint8_t)freq); Wire.endTransmission(); // stop transmitting delay(0); } @@ -92,7 +92,7 @@ void WemosMotor::setmotor(uint8_t dir, float pwm_val) } Wire.beginTransmission(_address); - Wire.write(_motor | (byte)0x10); // CMD either 0x10 or 0x11 + Wire.write(_motor | (uint8_t)0x10); // CMD either 0x10 or 0x11 Wire.write(dir); // PWM in % @@ -102,8 +102,8 @@ void WemosMotor::setmotor(uint8_t dir, float pwm_val) _pwm_val = 10000; } - Wire.write((byte)(_pwm_val >> 8)); - Wire.write((byte)_pwm_val); + Wire.write((uint8_t)(_pwm_val >> 8)); + Wire.write((uint8_t)_pwm_val); Wire.endTransmission(); // stop transmitting delay(0); diff --git a/src/src/PluginStructs/P082_data_struct.h b/src/src/PluginStructs/P082_data_struct.h index 44945a576..7c814f3bc 100644 --- a/src/src/PluginStructs/P082_data_struct.h +++ b/src/src/PluginStructs/P082_data_struct.h @@ -15,7 +15,7 @@ # define P082_DEFAULT_FIX_TIMEOUT 2500 // TTL of fix status in ms since last update -enum class P082_query : byte { +enum class P082_query : uint8_t { P082_QUERY_LONG = 0, P082_QUERY_LAT = 1, P082_QUERY_ALT = 2, @@ -83,7 +83,7 @@ struct P082_data_struct : public PluginTaskData_base { String _currentSentence; # endif // ifdef P082_SEND_GPS_TO_LOG - float _cache[static_cast(P082_query::P082_NR_OUTPUT_OPTIONS)] = { 0 }; + float _cache[static_cast(P082_query::P082_NR_OUTPUT_OPTIONS)] = { 0 }; }; #endif // ifdef USES_P082 diff --git a/src/src/PluginStructs/P087_data_struct.cpp b/src/src/PluginStructs/P087_data_struct.cpp index d68301a02..7ca2fb353 100644 --- a/src/src/PluginStructs/P087_data_struct.cpp +++ b/src/src/PluginStructs/P087_data_struct.cpp @@ -160,7 +160,7 @@ void P087_data_struct::setMaxLength(uint16_t maxlenght) { max_length = maxlenght; } -void P087_data_struct::setLine(byte varNr, const String& line) { +void P087_data_struct::setLine(uint8_t varNr, const String& line) { if (varNr < P87_Nlines) { _lines[varNr] = line; } @@ -247,7 +247,7 @@ static std::vector capture_vector; // called for each match void P087_data_struct::match_callback(const char *match, const unsigned int length, const MatchState& ms) { - for (byte i = 0; i < ms.level; i++) + for (uint8_t i = 0; i < ms.level; i++) { capture_tuple tuple; tuple.first = i; diff --git a/src/src/PluginStructs/P087_data_struct.h b/src/src/PluginStructs/P087_data_struct.h index d450d8f52..e069da493 100644 --- a/src/src/PluginStructs/P087_data_struct.h +++ b/src/src/PluginStructs/P087_data_struct.h @@ -71,7 +71,7 @@ public: void setMaxLength(uint16_t maxlenght); - void setLine(byte varNr, + void setLine(uint8_t varNr, const String& line); String getRegEx() const; diff --git a/src/src/PluginStructs/P090_data_struct.cpp b/src/src/PluginStructs/P090_data_struct.cpp index ab70a7a55..90d704557 100644 --- a/src/src/PluginStructs/P090_data_struct.cpp +++ b/src/src/PluginStructs/P090_data_struct.cpp @@ -153,7 +153,7 @@ CCS811Core::status CCS811Core::multiWriteRegister(uint8_t offset, uint8_t *input while (i < length) // send data bytes { - Wire.write(*inputPointer); // receive a byte as character + Wire.write(*inputPointer); // receive a uint8_t as character inputPointer++; i++; } @@ -416,7 +416,7 @@ CCS811Core::status CCS811::setEnvironmentalData(float relativeHumidity, float te uint32_t rH = relativeHumidity * 1000; // 42.348 becomes 42348 uint32_t temp = temperature * 1000; // 23.2 becomes 23200 - byte envData[4]; + uint8_t envData[4]; //Split value into 7-bit integer and 9-bit fractional diff --git a/src/src/PluginStructs/P094_data_struct.cpp b/src/src/PluginStructs/P094_data_struct.cpp index c37378104..80e8c0e44 100644 --- a/src/src/PluginStructs/P094_data_struct.cpp +++ b/src/src/PluginStructs/P094_data_struct.cpp @@ -172,7 +172,7 @@ void P094_data_struct::setMaxLength(uint16_t maxlenght) { max_length = maxlenght; } -void P094_data_struct::setLine(byte varNr, const String& line) { +void P094_data_struct::setLine(uint8_t varNr, const String& line) { if (varNr < P94_Nlines) { _lines[varNr] = line; } diff --git a/src/src/PluginStructs/P094_data_struct.h b/src/src/PluginStructs/P094_data_struct.h index c3ea2de3e..d5d22fc69 100644 --- a/src/src/PluginStructs/P094_data_struct.h +++ b/src/src/PluginStructs/P094_data_struct.h @@ -85,7 +85,7 @@ public: void setMaxLength(uint16_t maxlenght); - void setLine(byte varNr, + void setLine(uint8_t varNr, const String& line); diff --git a/src/src/PluginStructs/P099_data_struct.h b/src/src/PluginStructs/P099_data_struct.h index e8aa4c21b..769432f73 100644 --- a/src/src/PluginStructs/P099_data_struct.h +++ b/src/src/PluginStructs/P099_data_struct.h @@ -82,7 +82,7 @@ struct P099_data_struct : public PluginTaskData_base struct tP099_Touchobjects { char objectname[P099_MaxObjectNameLength] = { 0 }; - byte flags = 0; + uint8_t flags = 0; tP099_Point top_left; tP099_Point bottom_right; }; diff --git a/src/src/PluginStructs/P111_data_struct.cpp b/src/src/PluginStructs/P111_data_struct.cpp index d214535bf..913f4a77f 100644 --- a/src/src/PluginStructs/P111_data_struct.cpp +++ b/src/src/PluginStructs/P111_data_struct.cpp @@ -8,7 +8,7 @@ #include -P111_data_struct::P111_data_struct(byte csPin, byte rstPin) : mfrc522(nullptr), _csPin(csPin), _rstPin(rstPin) +P111_data_struct::P111_data_struct(uint8_t csPin, uint8_t rstPin) : mfrc522(nullptr), _csPin(csPin), _rstPin(rstPin) {} void P111_data_struct::init() { @@ -21,9 +21,9 @@ void P111_data_struct::init() { /** * read status and tag */ -byte P111_data_struct::readCardStatus(unsigned long *key, bool *removedTag) { +uint8_t P111_data_struct::readCardStatus(unsigned long *key, bool *removedTag) { - byte error = 0; + uint8_t error = 0; uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; uint8_t uidLength; @@ -103,7 +103,7 @@ bool P111_data_struct::reset(int8_t csPin, int8_t resetPin) { if (result) { //String log = F("RC522: Found"); // Get the MFRC522 software version - byte v = mfrc522->PCD_ReadRegister(mfrc522->VersionReg); + uint8_t v = mfrc522->PCD_ReadRegister(mfrc522->VersionReg); // When 0x00 or 0xFF is returned, communication probably failed if ((v == 0x00) || (v == 0xFF)) { @@ -129,7 +129,7 @@ bool P111_data_struct::reset(int8_t csPin, int8_t resetPin) { /*********************************************************************************************\ * RC522 read tag ID \*********************************************************************************************/ -byte P111_data_struct::readPassiveTargetID(uint8_t *uid, uint8_t *uidLength) { //needed ? see above (not PN532) +uint8_t P111_data_struct::readPassiveTargetID(uint8_t *uid, uint8_t *uidLength) { //needed ? see above (not PN532) // Getting ready for Reading PICCs if ( ! mfrc522->PICC_IsNewCardPresent()) { //If a new PICC placed to RFID reader continue return 2; @@ -139,9 +139,9 @@ byte P111_data_struct::readPassiveTargetID(uint8_t *uid, uint8_t *uidLength) { / return 1; } - // There are Mifare PICCs which have 4 byte or 7 byte UID care if you use 7 byte PICC - // I think we should assume every PICC as they have 4 byte UID - // Until we support 7 byte PICCs + // There are Mifare PICCs which have 4 uint8_t or 7 uint8_t UID care if you use 7 uint8_t PICC + // I think we should assume every PICC as they have 4 uint8_t UID + // Until we support 7 uint8_t PICCs addLog(LOG_LEVEL_INFO, F("MFRC522: Scanned PICC's UID")); for (uint8_t i = 0; i < 4; i++) { // uid[i] = mfrc522->uid.uidByte[i]; diff --git a/src/src/PluginStructs/P111_data_struct.h b/src/src/PluginStructs/P111_data_struct.h index 1f3387a68..45f6ed66a 100644 --- a/src/src/PluginStructs/P111_data_struct.h +++ b/src/src/PluginStructs/P111_data_struct.h @@ -8,23 +8,23 @@ struct P111_data_struct : public PluginTaskData_base { - P111_data_struct(byte csPin, byte rstPin); + P111_data_struct(uint8_t csPin, uint8_t rstPin); void init(); - byte readCardStatus(unsigned long *key, bool *removedTag); + uint8_t readCardStatus(unsigned long *key, bool *removedTag); String getCardName(); MFRC522 *mfrc522; - byte counter = 0; + uint8_t counter = 0; private: bool reset(int8_t csPin, int8_t resetPin); - byte readPassiveTargetID(uint8_t *uid, uint8_t *uidLength); + uint8_t readPassiveTargetID(uint8_t *uid, uint8_t *uidLength); - byte _csPin; - byte _rstPin; + uint8_t _csPin; + uint8_t _rstPin; - byte errorCount = 0; + uint8_t errorCount = 0; bool removedState = true; // On startup, there will usually not be a tag nearby }; diff --git a/src/src/PluginStructs/P112_data_struct.h b/src/src/PluginStructs/P112_data_struct.h index f98c2d8a8..e1a71a606 100644 --- a/src/src/PluginStructs/P112_data_struct.h +++ b/src/src/PluginStructs/P112_data_struct.h @@ -26,7 +26,7 @@ struct P112_data_struct : public PluginTaskData_base { // MeasurementStatus: // 0 : Not running // 1 - 18 : Running - byte MeasurementStatus = 0; + uint8_t MeasurementStatus = 0; }; #endif // ifdef USES_P112 diff --git a/src/src/WebServer/AdvancedConfigPage.cpp b/src/src/WebServer/AdvancedConfigPage.cpp index 1d4a19c7b..db21c0772 100644 --- a/src/src/WebServer/AdvancedConfigPage.cpp +++ b/src/src/WebServer/AdvancedConfigPage.cpp @@ -18,7 +18,7 @@ #ifdef WEBSERVER_ADVANCED -void setLogLevelFor(byte destination, LabelType::Enum label) { +void setLogLevelFor(uint8_t destination, LabelType::Enum label) { setLogLevelFor(destination, getFormItemInt(getInternalLabel(label))); } diff --git a/src/src/WebServer/CacheControllerPages.cpp b/src/src/WebServer/CacheControllerPages.cpp index d4e123612..cbf4a200f 100644 --- a/src/src/WebServer/CacheControllerPages.cpp +++ b/src/src/WebServer/CacheControllerPages.cpp @@ -24,10 +24,10 @@ void handle_dumpcache() { C016_startCSVdump(); unsigned long timestamp; - byte controller_idx; - byte TaskIndex; + uint8_t controller_idx; + uint8_t TaskIndex; Sensor_VType sensorType; - byte valueCount; + uint8_t valueCount; float val1; float val2; float val3; @@ -62,7 +62,7 @@ void handle_dumpcache() { html += ';'; html += controller_idx; html += ';'; - html += static_cast(sensorType); + html += static_cast(sensorType); html += ';'; html += TaskIndex; html += ';'; diff --git a/src/src/WebServer/ConfigPage.cpp b/src/src/WebServer/ConfigPage.cpp index c05da53cd..fbce37616 100644 --- a/src/src/WebServer/ConfigPage.cpp +++ b/src/src/WebServer/ConfigPage.cpp @@ -95,7 +95,7 @@ void handle_config() { IPAddress low, high; getSubnetRange(low, high); - for (byte i = 0; i < 4; ++i) { + for (uint8_t i = 0; i < 4; ++i) { SecuritySettings.AllowedIPrangeLow[i] = low[i]; SecuritySettings.AllowedIPrangeHigh[i] = high[i]; } @@ -164,10 +164,10 @@ void handle_config() { { IPAddress low, high; getIPallowedRange(low, high); - byte iplow[4]; - byte iphigh[4]; + uint8_t iplow[4]; + uint8_t iphigh[4]; - for (byte i = 0; i < 4; ++i) { + for (uint8_t i = 0; i < 4; ++i) { iplow[i] = low[i]; iphigh[i] = high[i]; } diff --git a/src/src/WebServer/ControllerPage.cpp b/src/src/WebServer/ControllerPage.cpp index e24342cf9..5d5a4ef5f 100644 --- a/src/src/WebServer/ControllerPage.cpp +++ b/src/src/WebServer/ControllerPage.cpp @@ -37,7 +37,7 @@ void handle_controllers() { TXBuffer.startStream(); sendHeadandTail_stdtemplate(_HEAD); - byte controllerindex = getFormItemInt(F("index"), 0); + uint8_t controllerindex = getFormItemInt(F("index"), 0); boolean controllerNotSet = controllerindex == 0; --controllerindex; // Index in URL is starting from 1, but starting from 0 in the array. @@ -123,7 +123,7 @@ void handle_controllers() { // Selected controller has changed. // Clear all Controller settings and load some defaults // ******************************************************************************** -void handle_controllers_clearLoadDefaults(byte controllerindex, ControllerSettingsStruct& ControllerSettings) +void handle_controllers_clearLoadDefaults(uint8_t controllerindex, ControllerSettingsStruct& ControllerSettings) { // Protocol has changed and it was not an empty one. // reset (some) default-settings @@ -162,7 +162,7 @@ void handle_controllers_clearLoadDefaults(byte controllerindex, ControllerSettin // ******************************************************************************** // Collect all submitted form data and store in the ControllerSettings // ******************************************************************************** -void handle_controllers_CopySubmittedSettings(byte controllerindex, ControllerSettingsStruct& ControllerSettings) +void handle_controllers_CopySubmittedSettings(uint8_t controllerindex, ControllerSettingsStruct& ControllerSettings) { // copy all settings to controller settings struct for (int parameterIdx = 0; parameterIdx <= ControllerSettingsStruct::CONTROLLER_ENABLED; ++parameterIdx) { @@ -171,7 +171,7 @@ void handle_controllers_CopySubmittedSettings(byte controllerindex, ControllerSe } } -void handle_controllers_CopySubmittedSettings_CPluginCall(byte controllerindex) { +void handle_controllers_CopySubmittedSettings_CPluginCall(uint8_t controllerindex) { protocolIndex_t ProtocolIndex = getProtocolIndex_from_ControllerIndex(controllerindex); if (validProtocolIndex(ProtocolIndex)) { @@ -275,11 +275,11 @@ void handle_controllers_ControllerSettingsPage(controllerIndex_t controllerindex html_table_class_normal(); addFormHeader(F("Controller Settings")); addRowLabel(F("Protocol")); - byte choice = Settings.Protocol[controllerindex]; + uint8_t choice = Settings.Protocol[controllerindex]; addSelector_Head_reloadOnChange(F("protocol")); addSelector_Item(F("- Standalone -"), 0, false, false, EMPTY_STRING); - for (byte x = 0; x <= protocolCount; x++) + for (uint8_t x = 0; x <= protocolCount; x++) { boolean disabled = false; // !((controllerindex == 0) || !Protocol[x].usesMQTT); addSelector_Item(getCPluginNameFromProtocolIndex(x), diff --git a/src/src/WebServer/ControllerPage.h b/src/src/WebServer/ControllerPage.h index c9834ac9f..7c9e495b0 100644 --- a/src/src/WebServer/ControllerPage.h +++ b/src/src/WebServer/ControllerPage.h @@ -20,14 +20,14 @@ void handle_controllers(); // Selected controller has changed. // Clear all Controller settings and load some defaults // ******************************************************************************** -void handle_controllers_clearLoadDefaults(byte controllerindex, ControllerSettingsStruct& ControllerSettings); +void handle_controllers_clearLoadDefaults(uint8_t controllerindex, ControllerSettingsStruct& ControllerSettings); // ******************************************************************************** // Collect all submitted form data and store in the ControllerSettings // ******************************************************************************** -void handle_controllers_CopySubmittedSettings(byte controllerindex, ControllerSettingsStruct& ControllerSettings); +void handle_controllers_CopySubmittedSettings(uint8_t controllerindex, ControllerSettingsStruct& ControllerSettings); -void handle_controllers_CopySubmittedSettings_CPluginCall(byte controllerindex); +void handle_controllers_CopySubmittedSettings_CPluginCall(uint8_t controllerindex); // ******************************************************************************** // Show table with all selected controllers diff --git a/src/src/WebServer/CustomPage.cpp b/src/src/WebServer/CustomPage.cpp index 50b4bc33a..b7d7518a3 100644 --- a/src/src/WebServer/CustomPage.cpp +++ b/src/src/WebServer/CustomPage.cpp @@ -54,8 +54,8 @@ boolean handle_custom(String path) { if (dashboardPage) // for the dashboard page, create a default unit dropdown selector { // handle page redirects to other unit's as requested by the unit dropdown selector - byte unit = getFormItemInt(F("unit")); - byte btnunit = getFormItemInt(F("btnunit")); + uint8_t unit = getFormItemInt(F("unit")); + uint8_t btnunit = getFormItemInt(F("btnunit")); if (!unit) { unit = btnunit; // unit element prevails, if not used then set to btnunit } @@ -83,7 +83,7 @@ boolean handle_custom(String path) { // create unit selector dropdown addSelector_Head_reloadOnChange(F("unit")); - byte choice = Settings.Unit; + uint8_t choice = Settings.Unit; for (NodesMap::iterator it = Nodes.begin(); it != Nodes.end(); ++it) { @@ -103,11 +103,11 @@ boolean handle_custom(String path) { addSelector_Foot(); // create <> navigation buttons - byte prev = Settings.Unit; - byte next = Settings.Unit; + uint8_t prev = Settings.Unit; + uint8_t next = Settings.Unit; NodesMap::iterator it; - for (byte x = Settings.Unit - 1; x > 0; x--) { + for (uint8_t x = Settings.Unit - 1; x > 0; x--) { it = Nodes.find(x); if (it != Nodes.end()) { @@ -115,7 +115,7 @@ boolean handle_custom(String path) { } } - for (byte x = Settings.Unit + 1; x < UNIT_NUMBER_MAX; x++) { + for (uint8_t x = Settings.Unit + 1; x < UNIT_NUMBER_MAX; x++) { it = Nodes.find(x); if (it != Nodes.end()) { @@ -179,9 +179,9 @@ boolean handle_custom(String path) { html_TR_TD(); addHtml(ExtraTaskSettings.TaskDeviceName); - const byte valueCount = getValueCountForTask(x); + const uint8_t valueCount = getValueCountForTask(x); - for (byte varNr = 0; varNr < VARS_PER_TASK; varNr++) + for (uint8_t varNr = 0; varNr < VARS_PER_TASK; varNr++) { if ((varNr < valueCount) && (ExtraTaskSettings.TaskDeviceValueNames[varNr][0] != 0)) diff --git a/src/src/WebServer/DevicesPage.cpp b/src/src/WebServer/DevicesPage.cpp index f33d70072..226340c16 100644 --- a/src/src/WebServer/DevicesPage.cpp +++ b/src/src/WebServer/DevicesPage.cpp @@ -71,7 +71,7 @@ void handle_devices() { // String taskdeviceglobalsync = webArg(F("TDGS")); // String taskdeviceenabled = webArg(F("TDE")); - // for (byte varNr = 0; varNr < VARS_PER_TASK; varNr++) + // for (uint8_t varNr = 0; varNr < VARS_PER_TASK; varNr++) // { // char argc[25]; // String arg = F("TDF"); @@ -104,12 +104,12 @@ void handle_devices() { // taskdevicesenddata[controllerNr] = webArg(argc); // } - byte page = getFormItemInt(F("page"), 0); + uint8_t page = getFormItemInt(F("page"), 0); if (page == 0) { page = 1; } - byte setpage = getFormItemInt(F("setpage"), 0); + uint8_t setpage = getFormItemInt(F("setpage"), 0); if (setpage > 0) { @@ -201,7 +201,7 @@ void addDeviceSelect(const __FlashStringHelper * name, int choice) addSelector_Head_reloadOnChange(name); addSelector_Item(F("- None -"), 0, false); - for (byte x = 0; x <= deviceCount; x++) + for (uint8_t x = 0; x <= deviceCount; x++) { const deviceIndex_t deviceIndex = DeviceIndex_sorted[x]; @@ -302,9 +302,9 @@ void handle_devices_CopySubmittedSettings(taskIndex_t taskIndex, pluginID_t task // nr output values has changed, generate new variable names String oldNames[VARS_PER_TASK]; - byte oldNrDec[VARS_PER_TASK]; + uint8_t oldNrDec[VARS_PER_TASK]; - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { oldNames[i] = ExtraTaskSettings.TaskDeviceValueNames[i]; oldNrDec[i] = ExtraTaskSettings.TaskDeviceValueDecimals[i]; } @@ -313,7 +313,7 @@ void handle_devices_CopySubmittedSettings(taskIndex_t taskIndex, pluginID_t task PluginCall(PLUGIN_GET_DEVICEVALUENAMES, &TempEvent, dummy); // Restore the settings that were already set by the user - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { if (!oldNames[i].isEmpty()) { safe_strncpy(ExtraTaskSettings.TaskDeviceValueNames[i], oldNames[i], sizeof(ExtraTaskSettings.TaskDeviceValueNames[i])); ExtraTaskSettings.TaskDeviceValueDecimals[i] = oldNrDec[i]; @@ -361,9 +361,9 @@ void handle_devices_CopySubmittedSettings(taskIndex_t taskIndex, pluginID_t task # endif // ifdef PLUGIN_USES_SERIAL } - const byte valueCount = getValueCountForTask(taskIndex); + const uint8_t valueCount = getValueCountForTask(taskIndex); - for (byte varNr = 0; varNr < valueCount; varNr++) + for (uint8_t varNr = 0; varNr < valueCount; varNr++) { strncpy_webserver_arg(ExtraTaskSettings.TaskDeviceFormula[varNr], String(F("TDF")) + (varNr + 1)); update_whenset_FormItemInt(String(F("TDVD")) + (varNr + 1), ExtraTaskSettings.TaskDeviceValueDecimals[varNr]); @@ -413,7 +413,7 @@ void Label_Gpio_toHtml(const __FlashStringHelper * label, const String& gpio_pin // ******************************************************************************** // Show table with all selected Tasks/Devices // ******************************************************************************** -void handle_devicess_ShowAllTasksTable(byte page) +void handle_devicess_ShowAllTasksTable(uint8_t page) { serve_JS(JSfiles_e::UpdateSensorValuesDevicePage); html_table_class_multirow(); @@ -521,7 +521,7 @@ void handle_devicess_ShowAllTasksTable(byte page) if (validDeviceIndex(DeviceIndex)) { if (Settings.TaskDeviceDataFeed[x] != 0) { // Show originating node number - const byte remoteUnit = Settings.TaskDeviceDataFeed[x]; + const uint8_t remoteUnit = Settings.TaskDeviceDataFeed[x]; format_originating_node(remoteUnit); } else { String portDescr; @@ -715,9 +715,9 @@ void handle_devicess_ShowAllTasksTable(byte page) if (!customValues) { - const byte valueCount = getValueCountForTask(x); + const uint8_t valueCount = getValueCountForTask(x); - for (byte varNr = 0; varNr < valueCount; varNr++) + for (uint8_t varNr = 0; varNr < valueCount; varNr++) { if (validPluginID_fullcheck(Settings.TaskDeviceNumber[x])) { @@ -735,7 +735,7 @@ void handle_devicess_ShowAllTasksTable(byte page) html_end_form(); } -void format_originating_node(byte remoteUnit) { +void format_originating_node(uint8_t remoteUnit) { addHtml(F("Unit ")); addHtmlInt(remoteUnit); @@ -831,7 +831,7 @@ void format_SPI_pin_description(int8_t spi_gpios[3], taskIndex_t x) // ******************************************************************************** // Show the task settings page // ******************************************************************************** -void handle_devices_TaskSettingsPage(taskIndex_t taskIndex, byte page) +void handle_devices_TaskSettingsPage(taskIndex_t taskIndex, uint8_t page) { if (!validTaskIndex(taskIndex)) { return; } const deviceIndex_t DeviceIndex = getDeviceIndex_from_TaskIndex(taskIndex); @@ -932,7 +932,7 @@ void handle_devices_TaskSettingsPage(taskIndex_t taskIndex, byte page) else { // Show remote feed information. addFormSubHeader(F("Data Source")); - byte remoteUnit = Settings.TaskDeviceDataFeed[taskIndex]; + uint8_t remoteUnit = Settings.TaskDeviceDataFeed[taskIndex]; addFormNumericBox(F("Remote Unit"), F("RemoteUnit"), remoteUnit, 0, 255); if (remoteUnit != 255) { @@ -1224,7 +1224,7 @@ void devicePage_show_interval_config(taskIndex_t taskIndex, deviceIndex_t Device void devicePage_show_task_values(taskIndex_t taskIndex, deviceIndex_t DeviceIndex) { // section: Values - const byte valueCount = getValueCountForTask(taskIndex); + const uint8_t valueCount = getValueCountForTask(taskIndex); if (!Device[DeviceIndex].Custom && (valueCount > 0)) { @@ -1247,7 +1247,7 @@ void devicePage_show_task_values(taskIndex_t taskIndex, deviceIndex_t DeviceInde } // table body - for (byte varNr = 0; varNr < valueCount; varNr++) + for (uint8_t varNr = 0; varNr < valueCount; varNr++) { html_TR_TD(); addHtmlInt(varNr + 1); diff --git a/src/src/WebServer/DevicesPage.h b/src/src/WebServer/DevicesPage.h index 1a67d02e8..79c96b503 100644 --- a/src/src/WebServer/DevicesPage.h +++ b/src/src/WebServer/DevicesPage.h @@ -34,9 +34,9 @@ void handle_devices_CopySubmittedSettings(taskIndex_t taskIndex, pluginID_t task // ******************************************************************************** // Show table with all selected Tasks/Devices // ******************************************************************************** -void handle_devicess_ShowAllTasksTable(byte page); +void handle_devicess_ShowAllTasksTable(uint8_t page); -void format_originating_node(byte remoteUnit); +void format_originating_node(uint8_t remoteUnit); void format_I2C_port_description(taskIndex_t x); @@ -51,7 +51,7 @@ void format_SPI_pin_description(int8_t spi_gpios[3], taskIndex_t x); // ******************************************************************************** // Show the task settings page // ******************************************************************************** -void handle_devices_TaskSettingsPage(taskIndex_t taskIndex, byte page); +void handle_devices_TaskSettingsPage(taskIndex_t taskIndex, uint8_t page); void devicePage_show_pin_config(taskIndex_t taskIndex, deviceIndex_t DeviceIndex); diff --git a/src/src/WebServer/I2C_Scanner.cpp b/src/src/WebServer/I2C_Scanner.cpp index 0ffb27cbc..b6aa9f6b5 100644 --- a/src/src/WebServer/I2C_Scanner.cpp +++ b/src/src/WebServer/I2C_Scanner.cpp @@ -26,7 +26,7 @@ int scanI2CbusForDevices_json( // Utility function for scanning the I2C bus for , i2c_addresses_t &excludeDevices #endif ) { - byte error, address; + uint8_t error, address; for (address = 1; address <= 127; address++) { @@ -143,7 +143,7 @@ void handle_i2cscanner_json() { #endif // WEBSERVER_NEW_UI -String getKnownI2Cdevice(byte address) { +String getKnownI2Cdevice(uint8_t address) { String result; #ifndef LIMIT_BUILD_SIZE @@ -266,7 +266,7 @@ int scanI2CbusForDevices( // Utility function for scanning the I2C bus for valid , i2c_addresses_t &excludeDevices #endif ) { - byte error, address; + uint8_t error, address; for (address = 1; address <= 127; address++) { diff --git a/src/src/WebServer/I2C_Scanner.h b/src/src/WebServer/I2C_Scanner.h index 4819bb198..fff7e273e 100644 --- a/src/src/WebServer/I2C_Scanner.h +++ b/src/src/WebServer/I2C_Scanner.h @@ -30,7 +30,7 @@ void handle_i2cscanner_json(); #endif // WEBSERVER_NEW_UI -String getKnownI2Cdevice(byte address); +String getKnownI2Cdevice(uint8_t address); int scanI2CbusForDevices( // Utility function for scanning the I2C bus for valid devices, with HTML table output int8_t muxAddr diff --git a/src/src/WebServer/JSON.cpp b/src/src/WebServer/JSON.cpp index 7c0a165a7..8723f872f 100644 --- a/src/src/WebServer/JSON.cpp +++ b/src/src/WebServer/JSON.cpp @@ -59,13 +59,13 @@ void handle_csvval() if (validDeviceIndex(DeviceIndex)) { LoadTaskSettings(taskNr); - const byte taskValCount = getValueCountForTask(taskNr); + const uint8_t taskValCount = getValueCountForTask(taskNr); uint16_t stringReserveSize = (valNr == INVALID_VALUE_NUM ? 1 : taskValCount) * 24; htmlData.reserve(stringReserveSize); if (printHeader) { - for (byte x = 0; x < taskValCount; x++) + for (uint8_t x = 0; x < taskValCount; x++) { if (valNr == INVALID_VALUE_NUM || valNr == x) { @@ -81,7 +81,7 @@ void handle_csvval() htmlData = ""; } - for (byte x = 0; x < taskValCount; x++) + for (uint8_t x = 0; x < taskValCount; x++) { if ((valNr == INVALID_VALUE_NUM) || (valNr == x)) { @@ -336,7 +336,7 @@ void handle_json() unsigned long ttl_json = 60; // Default value // For simplicity, do the optional values first. - const byte valueCount = getValueCountForTask(TaskIndex); + const uint8_t valueCount = getValueCountForTask(TaskIndex); if (valueCount != 0) { if ((taskInterval > 0) && Settings.TaskDeviceEnabled[TaskIndex]) { @@ -348,11 +348,11 @@ void handle_json() } addHtml(F("\"TaskValues\": [\n")); - for (byte x = 0; x < valueCount; x++) + for (uint8_t x = 0; x < valueCount; x++) { addHtml('{'); const String value = formatUserVarNoCheck(TaskIndex, x); - byte nrDecimals = ExtraTaskSettings.TaskDeviceValueDecimals[x]; + uint8_t nrDecimals = ExtraTaskSettings.TaskDeviceValueDecimals[x]; if (mustConsiderAsString(value)) { // Flag as not to treat as a float @@ -527,7 +527,7 @@ void handle_buildinfo() { { json_open(true, F("notifications")); - for (byte x = 0; x < NPLUGIN_MAX; x++) { + for (uint8_t x = 0; x < NPLUGIN_MAX; x++) { if (validNPluginID(NPlugin_id[x])) { json_open(); json_number(F("id"), String(x + 1)); diff --git a/src/src/WebServer/Log.cpp b/src/src/WebServer/Log.cpp index ae0973841..52115c080 100644 --- a/src/src/WebServer/Log.cpp +++ b/src/src/WebServer/Log.cpp @@ -55,7 +55,7 @@ void handle_log_JSON() { if (webrequest == F("legend")) { addHtml(F("\"Legend\": [")); - for (byte i = 0; i < LOG_LEVEL_NRELEMENTS; ++i) { + for (uint8_t i = 0; i < LOG_LEVEL_NRELEMENTS; ++i) { if (i != 0) { addHtml(','); } @@ -74,7 +74,7 @@ void handle_log_JSON() { while (logLinesAvailable) { String message; - byte loglevel; + uint8_t loglevel; if (Logging.getNext(logLinesAvailable, lastTimeStamp, message, loglevel)) { addHtml('{'); stream_next_json_object_value(F("timestamp"), String(lastTimeStamp)); diff --git a/src/src/WebServer/Markup.cpp b/src/src/WebServer/Markup.cpp index 459b85297..16c0a6e7e 100644 --- a/src/src/WebServer/Markup.cpp +++ b/src/src/WebServer/Markup.cpp @@ -103,7 +103,7 @@ void addSelector_options(int optionCount, const __FlashStringHelper *options[], { int index; - for (byte x = 0; x < optionCount; x++) + for (uint8_t x = 0; x < optionCount; x++) { if (indices) { index = indices[x]; @@ -125,7 +125,7 @@ void addSelector_options(int optionCount, const String options[], const int indi { int index; - for (byte x = 0; x < optionCount; x++) + for (uint8_t x = 0; x < optionCount; x++) { if (indices) { index = indices[x]; @@ -549,7 +549,7 @@ void addNumericBox(const String& id, int value, int min, int max) addHtml('>'); } -void addFloatNumberBox(const String& id, float value, float min, float max, byte nrDecimals, float stepsize) +void addFloatNumberBox(const String& id, float value, float min, float max, uint8_t nrDecimals, float stepsize) { String html; @@ -567,7 +567,7 @@ void addFloatNumberBox(const String& id, float value, float min, float max, byte if (stepsize <= 0.0f) { html += F("0."); - for (byte i = 1; i < nrDecimals; ++i) { + for (uint8_t i = 1; i < nrDecimals; ++i) { html += '0'; } html += '1'; diff --git a/src/src/WebServer/Markup.h b/src/src/WebServer/Markup.h index 07eab7906..f5aab4860 100644 --- a/src/src/WebServer/Markup.h +++ b/src/src/WebServer/Markup.h @@ -131,7 +131,7 @@ void addCheckBox(const String& id, boolean checked, bool disabled = false); void addNumericBox(const __FlashStringHelper * id, int value, int min, int max); void addNumericBox(const String& id, int value, int min, int max); -void addFloatNumberBox(const String& id, float value, float min, float max, byte nrDecimals = 6, float stepsize = 0.0f); +void addFloatNumberBox(const String& id, float value, float min, float max, uint8_t nrDecimals = 6, float stepsize = 0.0f); // ******************************************************************************** // Add Textbox diff --git a/src/src/WebServer/Markup_Forms.cpp b/src/src/WebServer/Markup_Forms.cpp index 17d899b50..855ea5141 100644 --- a/src/src/WebServer/Markup_Forms.cpp +++ b/src/src/WebServer/Markup_Forms.cpp @@ -104,11 +104,11 @@ void addFormNumericBox(const String& label, const String& id, int value, int min addNumericBox(id, value, min, max); } -void addFormFloatNumberBox(LabelType::Enum label, float value, float min, float max, byte nrDecimals, float stepsize) { +void addFormFloatNumberBox(LabelType::Enum label, float value, float min, float max, uint8_t nrDecimals, float stepsize) { addFormFloatNumberBox(getLabel(label), getInternalLabel(label), value, min, max, nrDecimals, stepsize); } -void addFormFloatNumberBox(const String& label, const String& id, float value, float min, float max, byte nrDecimals, float stepsize) +void addFormFloatNumberBox(const String& label, const String& id, float value, float min, float max, uint8_t nrDecimals, float stepsize) { addRowLabel_tr_id(label, id); addFloatNumberBox(id, value, min, max, nrDecimals, stepsize); @@ -190,7 +190,7 @@ bool getFormPassword(const String& id, String& password) // Add a IP Box form // ******************************************************************************** -void addFormIPBox(const String& label, const String& id, const byte ip[4]) +void addFormIPBox(const String& label, const String& id, const uint8_t ip[4]) { bool empty_IP = (ip[0] == 0 && ip[1] == 0 && ip[2] == 0 && ip[3] == 0); @@ -240,7 +240,7 @@ void addFormSelectorI2C(const String& id, int addressCount, const int addresses[ addRowLabel_tr_id(F("I2C Address"), id); do_addSelector_Head(id, EMPTY_STRING, EMPTY_STRING, false); - for (byte x = 0; x < addressCount; x++) + for (uint8_t x = 0; x < addressCount; x++) { String option = formatToHex_decimal(addresses[x]); @@ -442,7 +442,7 @@ bool update_whenset_FormItemInt(const String& key, int& value) { return false; } -bool update_whenset_FormItemInt(const String& key, byte& value) { +bool update_whenset_FormItemInt(const String& key, uint8_t& value) { int tmpVal; if (getCheckWebserverArg_int(key, tmpVal)) { diff --git a/src/src/WebServer/Markup_Forms.h b/src/src/WebServer/Markup_Forms.h index becd65d73..c2ec65599 100644 --- a/src/src/WebServer/Markup_Forms.h +++ b/src/src/WebServer/Markup_Forms.h @@ -41,8 +41,8 @@ void addFormNumericBox(LabelType::Enum label, int value, int min = INT_MIN, int void addFormNumericBox(const __FlashStringHelper * label, const __FlashStringHelper * id, int value, int min = INT_MIN, int max = INT_MAX); void addFormNumericBox(const String& label, const String& id, int value, int min = INT_MIN, int max = INT_MAX); -void addFormFloatNumberBox(LabelType::Enum label, float value, float min, float max, byte nrDecimals = 6, float stepsize = 0.0f); -void addFormFloatNumberBox(const String& label, const String& id, float value, float min, float max, byte nrDecimals = 6, float stepsize = 0.0f); +void addFormFloatNumberBox(LabelType::Enum label, float value, float min, float max, uint8_t nrDecimals = 6, float stepsize = 0.0f); +void addFormFloatNumberBox(const String& label, const String& id, float value, float min, float max, uint8_t nrDecimals = 6, float stepsize = 0.0f); // ******************************************************************************** // Add a task selector form @@ -90,7 +90,7 @@ bool getFormPassword(const String& id, String& password); // Add a IP Box form // ******************************************************************************** -void addFormIPBox(const String& label, const String& id, const byte ip[4]); +void addFormIPBox(const String& label, const String& id, const uint8_t ip[4]); // ******************************************************************************** // Add a IP Access Control select dropdown list @@ -184,7 +184,7 @@ bool getCheckWebserverArg_int(const String& key, int& value); bool update_whenset_FormItemInt(const String& key, int& value); -bool update_whenset_FormItemInt(const String& key, byte& value); +bool update_whenset_FormItemInt(const String& key, uint8_t& value); // Note: Checkbox values will not appear in POST Form data if unchecked. // So if webserver does not have an argument for a checkbox form, it means it should be considered unchecked. diff --git a/src/src/WebServer/NotificationPage.cpp b/src/src/WebServer/NotificationPage.cpp index 84067875c..fef28387f 100644 --- a/src/src/WebServer/NotificationPage.cpp +++ b/src/src/WebServer/NotificationPage.cpp @@ -41,7 +41,7 @@ void handle_notifications() { // char tmpString[64]; - byte notificationindex = getFormItemInt(F("index"), 0); + uint8_t notificationindex = getFormItemInt(F("index"), 0); boolean notificationindexNotSet = notificationindex == 0; --notificationindex; @@ -81,7 +81,7 @@ void handle_notifications() { } // Save the settings. - addHtmlError(SaveNotificationSettings(notificationindex, (byte *)&NotificationSettings, sizeof(NotificationSettingsStruct))); + addHtmlError(SaveNotificationSettings(notificationindex, (uint8_t *)&NotificationSettings, sizeof(NotificationSettingsStruct))); addHtmlError(SaveSettings()); if (web_server.hasArg(F("test"))) { @@ -112,9 +112,9 @@ void handle_notifications() { MakeNotificationSettings(NotificationSettings); - for (byte x = 0; x < NOTIFICATION_MAX; x++) + for (uint8_t x = 0; x < NOTIFICATION_MAX; x++) { - LoadNotificationSettings(x, (byte *)&NotificationSettings, sizeof(NotificationSettingsStruct)); + LoadNotificationSettings(x, (uint8_t *)&NotificationSettings, sizeof(NotificationSettingsStruct)); NotificationSettings.validate(); html_TR_TD(); html_add_button_prefix(); @@ -130,7 +130,7 @@ void handle_notifications() { addEnabled(Settings.NotificationEnabled[x]); html_TD(); - byte NotificationProtocolIndex = getNProtocolIndex(Settings.Notification[x]); + uint8_t NotificationProtocolIndex = getNProtocolIndex(Settings.Notification[x]); String NotificationName = F("(plugin not found?)"); if (validNProtocolIndex(NotificationProtocolIndex)) @@ -155,11 +155,11 @@ void handle_notifications() { html_table_class_normal(); addFormHeader(F("Notification Settings")); addRowLabel(F("Notification")); - byte choice = Settings.Notification[notificationindex]; + uint8_t choice = Settings.Notification[notificationindex]; addSelector_Head_reloadOnChange(F("notification")); addSelector_Item(F("- None -"), 0, false); - for (byte x = 0; x <= notificationCount; x++) + for (uint8_t x = 0; x <= notificationCount; x++) { String NotificationName; NPlugin_ptr[x](NPlugin::Function::NPLUGIN_GET_DEVICENAME, 0, NotificationName); @@ -174,7 +174,7 @@ void handle_notifications() { if (Settings.Notification[notificationindex]) { MakeNotificationSettings(NotificationSettings); - LoadNotificationSettings(notificationindex, (byte *)&NotificationSettings, sizeof(NotificationSettingsStruct)); + LoadNotificationSettings(notificationindex, (uint8_t *)&NotificationSettings, sizeof(NotificationSettingsStruct)); NotificationSettings.validate(); nprotocolIndex_t NotificationProtocolIndex = getNProtocolIndex_from_NotifierIndex(notificationindex); diff --git a/src/src/WebServer/Rules.cpp b/src/src/WebServer/Rules.cpp index 201bcfa3d..df38755da 100644 --- a/src/src/WebServer/Rules.cpp +++ b/src/src/WebServer/Rules.cpp @@ -31,7 +31,7 @@ void handle_rules() { if (!isLoggedIn() || !Settings.UseRules) { return; } navMenuIndex = MENU_INDEX_RULES; - const byte rulesSet = getFormItemInt(F("set"), 1); + const uint8_t rulesSet = getFormItemInt(F("set"), 1); # if defined(ESP8266) String fileName = F("rules"); @@ -69,11 +69,11 @@ void handle_rules() { addHtml(F("
")); { // Place combo box in its own scope to release these arrays as soon as possible - byte choice = rulesSet; + uint8_t choice = rulesSet; String options[RULESETS_MAX]; int optionValues[RULESETS_MAX]; - for (byte x = 0; x < RULESETS_MAX; x++) + for (uint8_t x = 0; x < RULESETS_MAX; x++) { options[x] = F("Rules Set "); options[x] += x + 1; diff --git a/src/src/WebServer/SetupPage.cpp b/src/src/WebServer/SetupPage.cpp index 585688e7b..7918f0b45 100644 --- a/src/src/WebServer/SetupPage.cpp +++ b/src/src/WebServer/SetupPage.cpp @@ -76,8 +76,8 @@ void handle_setup() { } else { // if (active_network_medium == NetworkMedium_t::WIFI) // { - static byte status = HANDLE_SETUP_SCAN_STAGE; - static byte refreshCount = 0; + static uint8_t status = HANDLE_SETUP_SCAN_STAGE; + static uint8_t refreshCount = 0; String ssid = webArg(F("ssid")); String other = webArg(F("other")); @@ -364,7 +364,7 @@ void handle_setup_scan_and_show(const String& ssid, const String& other, const S html_end_table(); } -bool handle_setup_connectingStage(byte refreshCount) { +bool handle_setup_connectingStage(uint8_t refreshCount) { if (refreshCount > 0) { // safe_strncpy(SecuritySettings.WifiSSID, "ssid", sizeof(SecuritySettings.WifiSSID)); diff --git a/src/src/WebServer/SetupPage.h b/src/src/WebServer/SetupPage.h index 52359534f..8c82cfef6 100644 --- a/src/src/WebServer/SetupPage.h +++ b/src/src/WebServer/SetupPage.h @@ -14,7 +14,7 @@ void handle_setup(); void handle_setup_scan_and_show(const String& ssid, const String& other, const String& password); -bool handle_setup_connectingStage(byte refreshCount); +bool handle_setup_connectingStage(uint8_t refreshCount); #endif // ifdef WEBSERVER_SETUP diff --git a/src/src/WebServer/UploadPage.cpp b/src/src/WebServer/UploadPage.cpp index ad03c577c..845d8aaa8 100644 --- a/src/src/WebServer/UploadPage.cpp +++ b/src/src/WebServer/UploadPage.cpp @@ -132,8 +132,8 @@ void handleFileUpload() { for (unsigned int x = 0; x < sizeof(struct TempStruct); x++) { - byte b = upload.buf[x]; - memcpy((byte *)&Temp + x, &b, 1); + uint8_t b = upload.buf[x]; + memcpy((uint8_t *)&Temp + x, &b, 1); } if ((Temp.Version == VERSION) && (Temp.PID == ESP_PROJECT_PID)) { diff --git a/src/src/WebServer/WebServer.cpp b/src/src/WebServer/WebServer.cpp index 23aef9387..7d589c675 100644 --- a/src/src/WebServer/WebServer.cpp +++ b/src/src/WebServer/WebServer.cpp @@ -603,10 +603,10 @@ void getErrorNotifications() { // Check checksum of stored settings. } -byte navMenuIndex = MENU_INDEX_MAIN; +uint8_t navMenuIndex = MENU_INDEX_MAIN; // See https://github.com/letscontrolit/ESPEasy/issues/1650 -const __FlashStringHelper * getGpMenuIcon(byte index) { +const __FlashStringHelper * getGpMenuIcon(uint8_t index) { switch (index) { case MENU_INDEX_MAIN: return F("⌂"); case MENU_INDEX_CONFIG: return F("⚙"); @@ -620,7 +620,7 @@ const __FlashStringHelper * getGpMenuIcon(byte index) { return F(""); } -const __FlashStringHelper * getGpMenuLabel(byte index) { +const __FlashStringHelper * getGpMenuLabel(uint8_t index) { switch (index) { case MENU_INDEX_MAIN: return F("Main"); case MENU_INDEX_CONFIG: return F("Config"); @@ -634,7 +634,7 @@ const __FlashStringHelper * getGpMenuLabel(byte index) { return F(""); } -const __FlashStringHelper * getGpMenuURL(byte index) { +const __FlashStringHelper * getGpMenuURL(uint8_t index) { switch (index) { case MENU_INDEX_MAIN: return F("/"); case MENU_INDEX_CONFIG: return F("/config"); @@ -649,7 +649,7 @@ const __FlashStringHelper * getGpMenuURL(byte index) { } -bool GpMenuVisible(byte index) { +bool GpMenuVisible(uint8_t index) { switch (index) { case MENU_INDEX_MAIN: return MENU_INDEX_MAIN_VISIBLE; case MENU_INDEX_CONFIG: return MENU_INDEX_CONFIG_VISIBLE; @@ -683,7 +683,7 @@ void getWebPageTemplateVar(const String& varName) { addHtml(F("