Replace platform dependent variable types by platform independent

This commit is contained in:
Thomas Basler 2023-09-03 23:27:53 +02:00
parent 55afa81cf1
commit abf95634db
8 changed files with 32 additions and 30 deletions

View File

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#pragma once #pragma once
#include <Arduino.h> #include <cstdint>
#define CONFIG_FILENAME "/config.json" #define CONFIG_FILENAME "/config.json"
#define CONFIG_VERSION 0x00011900 // 0.1.24 // make sure to clean all after change #define CONFIG_VERSION 0x00011900 // 0.1.24 // make sure to clean all after change
@ -52,18 +52,18 @@ struct INVERTER_CONFIG_T {
struct CONFIG_T { struct CONFIG_T {
uint32_t Cfg_Version; uint32_t Cfg_Version;
uint Cfg_SaveCount; uint32_t Cfg_SaveCount;
char WiFi_Ssid[WIFI_MAX_SSID_STRLEN + 1]; char WiFi_Ssid[WIFI_MAX_SSID_STRLEN + 1];
char WiFi_Password[WIFI_MAX_PASSWORD_STRLEN + 1]; char WiFi_Password[WIFI_MAX_PASSWORD_STRLEN + 1];
byte WiFi_Ip[4]; uint8_t WiFi_Ip[4];
byte WiFi_Netmask[4]; uint8_t WiFi_Netmask[4];
byte WiFi_Gateway[4]; uint8_t WiFi_Gateway[4];
byte WiFi_Dns1[4]; uint8_t WiFi_Dns1[4];
byte WiFi_Dns2[4]; uint8_t WiFi_Dns2[4];
bool WiFi_Dhcp; bool WiFi_Dhcp;
char WiFi_Hostname[WIFI_MAX_HOSTNAME_STRLEN + 1]; char WiFi_Hostname[WIFI_MAX_HOSTNAME_STRLEN + 1];
uint WiFi_ApTimeout; uint32_t WiFi_ApTimeout;
char Ntp_Server[NTP_MAX_SERVER_STRLEN + 1]; char Ntp_Server[NTP_MAX_SERVER_STRLEN + 1];
char Ntp_Timezone[NTP_MAX_TIMEZONE_STRLEN + 1]; char Ntp_Timezone[NTP_MAX_TIMEZONE_STRLEN + 1];
@ -74,7 +74,7 @@ struct CONFIG_T {
bool Mqtt_Enabled; bool Mqtt_Enabled;
char Mqtt_Hostname[MQTT_MAX_HOSTNAME_STRLEN + 1]; char Mqtt_Hostname[MQTT_MAX_HOSTNAME_STRLEN + 1];
uint Mqtt_Port; uint32_t Mqtt_Port;
char Mqtt_Username[MQTT_MAX_USERNAME_STRLEN + 1]; char Mqtt_Username[MQTT_MAX_USERNAME_STRLEN + 1];
char Mqtt_Password[MQTT_MAX_PASSWORD_STRLEN + 1]; char Mqtt_Password[MQTT_MAX_PASSWORD_STRLEN + 1];
char Mqtt_Topic[MQTT_MAX_TOPIC_STRLEN + 1]; char Mqtt_Topic[MQTT_MAX_TOPIC_STRLEN + 1];

View File

@ -31,16 +31,16 @@ public:
float getTotalDcIrradiation(); float getTotalDcIrradiation();
// Amount of relevant digits for yield total // Amount of relevant digits for yield total
unsigned int getTotalAcYieldTotalDigits(); uint32_t getTotalAcYieldTotalDigits();
// Amount of relevant digits for yield total // Amount of relevant digits for yield total
unsigned int getTotalAcYieldDayDigits(); uint32_t getTotalAcYieldDayDigits();
// Amount of relevant digits for AC power // Amount of relevant digits for AC power
unsigned int getTotalAcPowerDigits(); uint32_t getTotalAcPowerDigits();
// Amount of relevant digits for DC power // Amount of relevant digits for DC power
unsigned int getTotalDcPowerDigits(); uint32_t getTotalDcPowerDigits();
// True, if at least one inverter is reachable // True, if at least one inverter is reachable
bool getIsAtLeastOneReachable(); bool getIsAtLeastOneReachable();
@ -68,10 +68,10 @@ private:
float _totalDcPowerIrradiation = 0; float _totalDcPowerIrradiation = 0;
float _totalDcIrradiationInstalled = 0; float _totalDcIrradiationInstalled = 0;
float _totalDcIrradiation = 0; float _totalDcIrradiation = 0;
unsigned int _totalAcYieldTotalDigits = 0; uint32_t _totalAcYieldTotalDigits = 0;
unsigned int _totalAcYieldDayDigits = 0; uint32_t _totalAcYieldDayDigits = 0;
unsigned int _totalAcPowerDigits = 0; uint32_t _totalAcPowerDigits = 0;
unsigned int _totalDcPowerDigits = 0; uint32_t _totalDcPowerDigits = 0;
bool _isAtLeastOneReachable = false; bool _isAtLeastOneReachable = false;
bool _isAtLeastOneProducing = false; bool _isAtLeastOneProducing = false;
bool _isAllEnabledProducing = false; bool _isAllEnabledProducing = false;

View File

@ -63,10 +63,10 @@ private:
void NetworkEvent(WiFiEvent_t event); void NetworkEvent(WiFiEvent_t event);
bool adminEnabled = true; bool adminEnabled = true;
bool forceDisconnection = false; bool forceDisconnection = false;
int adminTimeoutCounter = 0; uint32_t adminTimeoutCounter = 0;
int adminTimeoutCounterMax = 0; uint32_t adminTimeoutCounterMax = 0;
int connectTimeoutTimer = 0; uint32_t connectTimeoutTimer = 0;
int connectRedoTimer = 0; uint32_t connectRedoTimer = 0;
uint32_t lastTimerCall = 0; uint32_t lastTimerCall = 0;
const byte DNS_PORT = 53; const byte DNS_PORT = 53;
IPAddress apIp; IPAddress apIp;

View File

@ -22,8 +22,8 @@ private:
SunSet _sun; SunSet _sun;
bool _isDayPeriod = true; bool _isDayPeriod = true;
bool _isSunsetAvailable = true; bool _isSunsetAvailable = true;
uint _sunriseMinutes = 0; uint32_t _sunriseMinutes = 0;
uint _sunsetMinutes = 0; uint32_t _sunsetMinutes = 0;
uint32_t _lastUpdate = 0; uint32_t _lastUpdate = 0;
bool _isValidInfo = false; bool _isValidInfo = false;

View File

@ -151,25 +151,25 @@ float DatastoreClass::getTotalDcIrradiation()
return _totalDcIrradiation; return _totalDcIrradiation;
} }
unsigned int DatastoreClass::getTotalAcYieldTotalDigits() uint32_t DatastoreClass::getTotalAcYieldTotalDigits()
{ {
std::lock_guard<std::mutex> lock(_mutex); std::lock_guard<std::mutex> lock(_mutex);
return _totalAcYieldTotalDigits; return _totalAcYieldTotalDigits;
} }
unsigned int DatastoreClass::getTotalAcYieldDayDigits() uint32_t DatastoreClass::getTotalAcYieldDayDigits()
{ {
std::lock_guard<std::mutex> lock(_mutex); std::lock_guard<std::mutex> lock(_mutex);
return _totalAcYieldDayDigits; return _totalAcYieldDayDigits;
} }
unsigned int DatastoreClass::getTotalAcPowerDigits() uint32_t DatastoreClass::getTotalAcPowerDigits()
{ {
std::lock_guard<std::mutex> lock(_mutex); std::lock_guard<std::mutex> lock(_mutex);
return _totalAcPowerDigits; return _totalAcPowerDigits;
} }
unsigned int DatastoreClass::getTotalDcPowerDigits() uint32_t DatastoreClass::getTotalDcPowerDigits()
{ {
std::lock_guard<std::mutex> lock(_mutex); std::lock_guard<std::mutex> lock(_mutex);
return _totalDcPowerDigits; return _totalDcPowerDigits;

View File

@ -1,9 +1,10 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
/* /*
* Copyright (C) 2022 Thomas Basler and others * Copyright (C) 2022 - 2023 Thomas Basler and others
*/ */
#include "NtpSettings.h" #include "NtpSettings.h"
#include "Configuration.h" #include "Configuration.h"
#include <Arduino.h>
#include <time.h> #include <time.h>
NtpSettingsClass::NtpSettingsClass() NtpSettingsClass::NtpSettingsClass()

View File

@ -5,6 +5,7 @@
#include "SunPosition.h" #include "SunPosition.h"
#include "Configuration.h" #include "Configuration.h"
#include "Utils.h" #include "Utils.h"
#include <Arduino.h>
SunPositionClass SunPosition; SunPositionClass SunPosition;
@ -83,7 +84,7 @@ void SunPositionClass::updateSunData()
_sunriseMinutes = static_cast<int>(sunriseRaw); _sunriseMinutes = static_cast<int>(sunriseRaw);
_sunsetMinutes = static_cast<int>(sunsetRaw); _sunsetMinutes = static_cast<int>(sunsetRaw);
uint minutesPastMidnight = timeinfo.tm_hour * 60 + timeinfo.tm_min; uint32_t minutesPastMidnight = timeinfo.tm_hour * 60 + timeinfo.tm_min;
_isDayPeriod = (minutesPastMidnight >= _sunriseMinutes) && (minutesPastMidnight < _sunsetMinutes); _isDayPeriod = (minutesPastMidnight >= _sunriseMinutes) && (minutesPastMidnight < _sunsetMinutes);
_isSunsetAvailable = true; _isSunsetAvailable = true;

View File

@ -10,7 +10,7 @@
uint32_t Utils::getChipId() uint32_t Utils::getChipId()
{ {
uint32_t chipId = 0; uint32_t chipId = 0;
for (int i = 0; i < 17; i += 8) { for (uint8_t i = 0; i < 17; i += 8) {
chipId |= ((ESP.getEfuseMac() >> (40 - i)) & 0xff) << i; chipId |= ((ESP.getEfuseMac() >> (40 - i)) & 0xff) << i;
} }
return chipId; return chipId;