Skip to content

Commit

Permalink
Replace platform dependent variable types by platform independent
Browse files Browse the repository at this point in the history
  • Loading branch information
tbnobody committed Sep 3, 2023
1 parent 55afa81 commit abf9563
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 30 deletions.
18 changes: 9 additions & 9 deletions include/Configuration.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once

#include <Arduino.h>
#include <cstdint>

#define CONFIG_FILENAME "/config.json"
#define CONFIG_VERSION 0x00011900 // 0.1.24 // make sure to clean all after change
Expand Down Expand Up @@ -52,18 +52,18 @@ struct INVERTER_CONFIG_T {

struct CONFIG_T {
uint32_t Cfg_Version;
uint Cfg_SaveCount;
uint32_t Cfg_SaveCount;

char WiFi_Ssid[WIFI_MAX_SSID_STRLEN + 1];
char WiFi_Password[WIFI_MAX_PASSWORD_STRLEN + 1];
byte WiFi_Ip[4];
byte WiFi_Netmask[4];
byte WiFi_Gateway[4];
byte WiFi_Dns1[4];
byte WiFi_Dns2[4];
uint8_t WiFi_Ip[4];
uint8_t WiFi_Netmask[4];
uint8_t WiFi_Gateway[4];
uint8_t WiFi_Dns1[4];
uint8_t WiFi_Dns2[4];
bool WiFi_Dhcp;
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_Timezone[NTP_MAX_TIMEZONE_STRLEN + 1];
Expand All @@ -74,7 +74,7 @@ struct CONFIG_T {

bool Mqtt_Enabled;
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_Password[MQTT_MAX_PASSWORD_STRLEN + 1];
char Mqtt_Topic[MQTT_MAX_TOPIC_STRLEN + 1];
Expand Down
16 changes: 8 additions & 8 deletions include/Datastore.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ class DatastoreClass {
float getTotalDcIrradiation();

// Amount of relevant digits for yield total
unsigned int getTotalAcYieldTotalDigits();
uint32_t getTotalAcYieldTotalDigits();

// Amount of relevant digits for yield total
unsigned int getTotalAcYieldDayDigits();
uint32_t getTotalAcYieldDayDigits();

// Amount of relevant digits for AC power
unsigned int getTotalAcPowerDigits();
uint32_t getTotalAcPowerDigits();

// Amount of relevant digits for DC power
unsigned int getTotalDcPowerDigits();
uint32_t getTotalDcPowerDigits();

// True, if at least one inverter is reachable
bool getIsAtLeastOneReachable();
Expand Down Expand Up @@ -68,10 +68,10 @@ class DatastoreClass {
float _totalDcPowerIrradiation = 0;
float _totalDcIrradiationInstalled = 0;
float _totalDcIrradiation = 0;
unsigned int _totalAcYieldTotalDigits = 0;
unsigned int _totalAcYieldDayDigits = 0;
unsigned int _totalAcPowerDigits = 0;
unsigned int _totalDcPowerDigits = 0;
uint32_t _totalAcYieldTotalDigits = 0;
uint32_t _totalAcYieldDayDigits = 0;
uint32_t _totalAcPowerDigits = 0;
uint32_t _totalDcPowerDigits = 0;
bool _isAtLeastOneReachable = false;
bool _isAtLeastOneProducing = false;
bool _isAllEnabledProducing = false;
Expand Down
8 changes: 4 additions & 4 deletions include/NetworkSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ class NetworkSettingsClass {
void NetworkEvent(WiFiEvent_t event);
bool adminEnabled = true;
bool forceDisconnection = false;
int adminTimeoutCounter = 0;
int adminTimeoutCounterMax = 0;
int connectTimeoutTimer = 0;
int connectRedoTimer = 0;
uint32_t adminTimeoutCounter = 0;
uint32_t adminTimeoutCounterMax = 0;
uint32_t connectTimeoutTimer = 0;
uint32_t connectRedoTimer = 0;
uint32_t lastTimerCall = 0;
const byte DNS_PORT = 53;
IPAddress apIp;
Expand Down
4 changes: 2 additions & 2 deletions include/SunPosition.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class SunPositionClass {
SunSet _sun;
bool _isDayPeriod = true;
bool _isSunsetAvailable = true;
uint _sunriseMinutes = 0;
uint _sunsetMinutes = 0;
uint32_t _sunriseMinutes = 0;
uint32_t _sunsetMinutes = 0;

uint32_t _lastUpdate = 0;
bool _isValidInfo = false;
Expand Down
8 changes: 4 additions & 4 deletions src/Datastore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,25 +151,25 @@ float DatastoreClass::getTotalDcIrradiation()
return _totalDcIrradiation;
}

unsigned int DatastoreClass::getTotalAcYieldTotalDigits()
uint32_t DatastoreClass::getTotalAcYieldTotalDigits()
{
std::lock_guard<std::mutex> lock(_mutex);
return _totalAcYieldTotalDigits;
}

unsigned int DatastoreClass::getTotalAcYieldDayDigits()
uint32_t DatastoreClass::getTotalAcYieldDayDigits()
{
std::lock_guard<std::mutex> lock(_mutex);
return _totalAcYieldDayDigits;
}

unsigned int DatastoreClass::getTotalAcPowerDigits()
uint32_t DatastoreClass::getTotalAcPowerDigits()
{
std::lock_guard<std::mutex> lock(_mutex);
return _totalAcPowerDigits;
}

unsigned int DatastoreClass::getTotalDcPowerDigits()
uint32_t DatastoreClass::getTotalDcPowerDigits()
{
std::lock_guard<std::mutex> lock(_mutex);
return _totalDcPowerDigits;
Expand Down
3 changes: 2 additions & 1 deletion src/NtpSettings.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// 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 "Configuration.h"
#include <Arduino.h>
#include <time.h>

NtpSettingsClass::NtpSettingsClass()
Expand Down
3 changes: 2 additions & 1 deletion src/SunPosition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "SunPosition.h"
#include "Configuration.h"
#include "Utils.h"
#include <Arduino.h>

SunPositionClass SunPosition;

Expand Down Expand Up @@ -83,7 +84,7 @@ void SunPositionClass::updateSunData()

_sunriseMinutes = static_cast<int>(sunriseRaw);
_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);
_isSunsetAvailable = true;
Expand Down
2 changes: 1 addition & 1 deletion src/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
uint32_t Utils::getChipId()
{
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;
}
return chipId;
Expand Down

0 comments on commit abf9563

Please sign in to comment.