Removed as many warnings as I could ... after enabling the all warning compiler flag

This commit is contained in:
Th3maz1ng 2022-03-29 23:25:27 +02:00
parent d2f620597c
commit 460db55496
25 changed files with 80 additions and 87 deletions

View File

@ -18,7 +18,7 @@ _I2C_scl(I2C_scl == DEFAULT_PIN ? GPIO_5_SCL : I2C_scl),
_SPI_mosi(SPI_mosi == DEFAULT_PIN ? GPIO_13_MOSI : SPI_mosi),
_SPI_miso(SPI_miso == DEFAULT_PIN ? GPIO_12_MISO : SPI_miso),
_SPI_clk(SPI_clk == DEFAULT_PIN ? GPIO_14_CLK : SPI_clk),
_SPI_SDCard_cs(_SPI_SDCard_cs == DEFAULT_PIN ? GPIO_2 : SPI_SDCard_cs),
_SPI_SDCard_cs(SPI_SDCard_cs == DEFAULT_PIN ? GPIO_2 : SPI_SDCard_cs),
_I2C_screenAddress(I2C_screenAddress),
_I2C_IOExpanderAddress(I2C_IOExpanderAddress),
_I2C_RTCFlashAddress(_I2C_RTCFlashAddress),

View File

@ -22,7 +22,7 @@ class BoardConfig
const Pin SPI_mosi = GPIO_13_MOSI,
const Pin SPI_miso = GPIO_12_MISO,
const Pin SPI_clk = GPIO_14_CLK,
const uint32_t spiSpeed = SPI_FULL_SPEED
const uint32_t spiSpeed = 0//SPI_FULL_SPEED
);
Pin getI2C_sda() const;

View File

@ -142,6 +142,8 @@ void *CFGFileParser::parseFile()
parsedParameter = NULL;
return NULL;
break;
default:
break;
}
}
@ -194,6 +196,8 @@ boolean CFGFileParser::save(void *data)
_state = COMMENT_SECTION;
else if(readChar == '\n') _state = DONE;
break;
default:
break;
}
}
@ -204,7 +208,7 @@ boolean CFGFileParser::save(void *data)
}
//Let's write the settings
for(int i = 0; i < ref->count(); i++)
for(unsigned int i = 0; i < ref->count(); i++)
{
CFGParameterValue *cfgPV = ref->getAt(i);

View File

@ -27,8 +27,8 @@ public:
return strcmp(_value,"true") == 0 || strcmp(_value,"TRUE") == 0 ? true : false;
}
const char *getParameter() const{return _parameter == NULL ? "" : _parameter;}
const bool isQuotedParameter()const{return _quotedParameter;}
const bool isQuotedValue()const{return _quotedValue;}
bool isQuotedParameter()const{return _quotedParameter;}
bool isQuotedValue()const{return _quotedValue;}
virtual const char *toString()
{
return _value;

View File

@ -46,8 +46,8 @@ boolean ConnectivityManager::connectToSTA()
}
else
toBeReturned = false;
return toBeReturned;
return toBeReturned;
}
boolean ConnectivityManager::startAP()

View File

@ -11,7 +11,7 @@ protected:
}
DictionaryInterface(const DictionaryInterface &Object)
{
(void)Object;
}
virtual ~DictionaryInterface(){}
virtual const char *toString() = 0;

View File

@ -1,21 +1,6 @@
#include "FTPClient.h"
FTPClient::FTPClient(WiFiClient client, uint8_t id, uint16_t clientCommandDataBufferSize) : TCPClient(client, id, clientCommandDataBufferSize),
_ftpCommand({'\0'}),
_cmdParameters(NULL),
_loggedIn(false),
_username(NULL),
_currentDirectory(NULL),
_currentFile(NULL),
_fileSentBytes(0),
_fileRecvBytes(0),
_waitingForDataConnection(false),
_fileIsBeeingReceived(false),
_actionTimeout(0),
_dataClientConnected(false),
_ftpClientState(FTPServer<FTPClient>::FTPClientState::INIT),
_binaryFlag(FTPServer<FTPClient>::BinaryFlag::OFF),
_dataTransferPending(FTPServer<FTPClient>::FTPClientDataTransfer::NONE)
FTPClient::FTPClient(WiFiClient client, uint8_t id, uint16_t clientCommandDataBufferSize) : TCPClient(client, id, clientCommandDataBufferSize)
{
}

View File

@ -23,22 +23,22 @@ class FTPClient : public TCPClient
void startTimeout();
void closeDataConnection();
char _ftpCommand[5];
Dictionary<DictionaryHelper::StringEntity> *_cmdParameters;
boolean _loggedIn;
char *_username;
char *_currentDirectory;
char *_currentFile;
uint64_t _fileSentBytes;
uint64_t _fileRecvBytes;
boolean _waitingForDataConnection;
boolean _fileIsBeeingReceived;
uint64_t _actionTimeout;
boolean _dataClientConnected;
char _ftpCommand[5] = {'\0'};
Dictionary<DictionaryHelper::StringEntity> *_cmdParameters = NULL;
boolean _loggedIn = false;
char *_username = NULL;
char *_currentDirectory = NULL;
char *_currentFile = NULL;
uint64_t _fileSentBytes = 0;
uint64_t _fileRecvBytes = 0;
boolean _waitingForDataConnection = false;
boolean _fileIsBeeingReceived = false;
uint64_t _actionTimeout = 0;
boolean _dataClientConnected = false;
FTPServer<FTPClient>::FTPClientState _ftpClientState;
FTPServer<FTPClient>::BinaryFlag _binaryFlag;
FTPServer<FTPClient>::FTPClientDataTransfer _dataTransferPending;
FTPServer<FTPClient>::FTPClientState _ftpClientState = FTPServer<FTPClient>::FTPClientState::INIT;
FTPServer<FTPClient>::BinaryFlag _binaryFlag = FTPServer<FTPClient>::BinaryFlag::OFF;
FTPServer<FTPClient>::FTPClientDataTransfer _dataTransferPending = FTPServer<FTPClient>::FTPClientDataTransfer::NONE;
WiFiClient _dataClient; //data socket
};

View File

@ -83,7 +83,7 @@ class FTPServer : public TCPServer<T>
client->_clientState = TCPClient::HANDLED;
}
ICACHE_RAM_ATTR virtual void processClientData(T *client)
IRAM_ATTR virtual void processClientData(T *client)
{
/*if (client->_waitingForDataConnection)
{
@ -263,6 +263,8 @@ class FTPServer : public TCPServer<T>
client->_fileRecvBytes = 0;
}
break;
default:
break;
}
#ifdef DEBUG_FTPS
@ -790,7 +792,7 @@ class FTPServer : public TCPServer<T>
}
//Here we write the received file to the sd card
ICACHE_RAM_ATTR inline boolean writeToSdCard(T *client, FileTransferStatus *fts, boolean append = false)
IRAM_ATTR inline boolean writeToSdCard(T *client, FileTransferStatus *fts, boolean append = false)
{
if (client->_currentFile != NULL)
{
@ -828,7 +830,7 @@ class FTPServer : public TCPServer<T>
}
//Here we send the fs tree to the ftp client
ICACHE_RAM_ATTR inline boolean sendFSTree(T *client)
IRAM_ATTR inline boolean sendFSTree(T *client)
{
if (client->_currentDirectory != NULL)
{
@ -886,7 +888,7 @@ class FTPServer : public TCPServer<T>
}
//The binary flag needs to be taken into consideration
ICACHE_RAM_ATTR inline boolean sendFile(T *client, FileTransferStatus *fts)
IRAM_ATTR inline boolean sendFile(T *client, FileTransferStatus *fts)
{
if (client->_currentFile != NULL)
{
@ -992,6 +994,8 @@ class FTPServer : public TCPServer<T>
case _550:
client->_client.printf_P(PSTR("550 Requested action not taken. %s\r\n"), msg);
break;
default:
client->_client.printf_P(PSTR("XXX Unhandled error code. %s\r\n"), msg);
}
}

View File

@ -178,7 +178,6 @@ public:
T* removeLastRef()
{
unsigned int position(0);
if(_head->_next == NULL) return NULL;
List *cursor = _head, *toRemove(NULL);
@ -211,7 +210,7 @@ public:
int contains(T *value)
{
unsigned int position(-1);
if(_head->_next == NULL) return NULL;
if(_head->_next == NULL) return 0;
List *cursor = _head;

View File

@ -48,7 +48,7 @@ void SAB::initCommonConfig()
initGPIO();
Serial.begin(115200, SERIAL_8N1, SERIAL_TX_ONLY);
Serial.println();
delay(200);
delay(1000);
//We initialize the pins for the I2C communication
Wire.begin(_boardConfig.getI2C_sda(), _boardConfig.getI2C_scl());
@ -57,7 +57,7 @@ void SAB::initCommonConfig()
{
SAB::_rtcManagerP = &_rtcManager;
}
if(!_display.begin(SSD1306_SWITCHCAPVCC, _boardConfig.getI2C_screenAddress())){ _error |= DISP_BEGIN_ERR; }
if(!_display.begin(SSD1306_SWITCHCAPVCC, _boardConfig.getI2C_screenAddress())){ _error |= DISP_BEGIN_ERR;}
if(!_sdCardManager.mountSD()){ _error |= SDCARD_INIT_ERR; Serial.print("Failed to init SDCard : SPI_SPEED : "); Serial.print(8000000); Serial.print(" CS PIN : "); Serial.println(_boardConfig.getSPI_SDCard_cs());}
else
{

View File

@ -50,15 +50,14 @@ class SAB
void initGPIO();
static time_t myTimeCallback();
void initCommonConfig();
const BoardConfig _boardConfig;
SDCardManager _sdCardManager;
Adafruit_SSD1306 _display;
ScreenManager _screenManager;
RTC_DS3231 _rtc;
RtcManager _rtcManager;
static RtcManager *_rtcManagerP;
SDCardManager _sdCardManager;
ConnectivityManager *_connectivityManager;
//WEBServerManager _webServerManager;
WEBServer<WEBClient> _webServer;
@ -68,7 +67,6 @@ class SAB
IOManager _ioManager;
TaskSchedulerManager _taskSchedulerManager;
PowerManager _powerManager;
DateTime _powerUpTime;
uint8_t _error;
};

View File

@ -5,35 +5,35 @@ SDCardManager::SDCardManager(const Pin csPin, uint32_t cfg) : _csPin(csPin), _sp
}
double SDCardManager::getSize(const SizeUnit sizeUnit)
float SDCardManager::getSize(const SizeUnit sizeUnit)
{
uint64_t numberOf512BytesChunks = blocksPerCluster() * totalClusters();//cardSize();
double result = 0;
float result = 0;
if(!isMounted()) return 0.0;
switch(sizeUnit)
{
case KBIT:
result = (double)numberOf512BytesChunks/2.0*8;
result = (float)numberOf512BytesChunks/2.0*8;
break;
case KBYTE:
result = (double)numberOf512BytesChunks/2.0;
result = (float)numberOf512BytesChunks/2.0;
break;
case MBIT:
result = (double)numberOf512BytesChunks/2.0/1024.0*8;
result = (float)numberOf512BytesChunks/2.0/1024.0*8;
break;
case MBYTE:
result = (double)numberOf512BytesChunks/2.0/1024.0;
result = (float)numberOf512BytesChunks/2.0/1024.0;
break;
case GBIT:
result = (double)numberOf512BytesChunks/2.0/1024.0/1024.0*8;
result = (float)numberOf512BytesChunks/2.0/1024.0/1024.0*8;
break;
case GBYTE:
result = (double)numberOf512BytesChunks/2.0/1024.0/1024.0;
result = (float)numberOf512BytesChunks/2.0/1024.0/1024.0;
break;
default:
result = (double)numberOf512BytesChunks/2.0/1024.0/1024.0;
result = (float)numberOf512BytesChunks/2.0/1024.0/1024.0;
}
return result;
}

View File

@ -11,7 +11,7 @@ class SDCardManager : public SDClass
friend class SAB;
public:
SDCardManager(const Pin csPin, uint32_t cfg);
double getSize(const SizeUnit sizeUnit = GBYTE);
float getSize(const SizeUnit sizeUnit = GBYTE);
boolean mountSD();
void unMountSD();
boolean isMounted();

View File

@ -18,7 +18,7 @@ ScreenManager::ScreenManager(Adafruit_SSD1306 &display, SDCardManager *sdCardMan
boolean ScreenManager::init()
{
applyCfgFromSD();
return applyCfgFromSD();
}
boolean ScreenManager::applyCfgFromSD()
@ -60,7 +60,7 @@ boolean ScreenManager::applyCfgFromSD()
else //Default value applied
{
setDefault();
return false;
return true;
}
}

View File

@ -20,6 +20,8 @@ class ScreenManager
const int UID;
struct viewLink *next, *previous;
} ViewLink, *ViewLinkedList;
ScreenManager(Adafruit_SSD1306 &display, SDCardManager *sdCardManager = NULL);
boolean addView(boolean (*viewLogicFunction)(Adafruit_SSD1306&, void*), void *pData, const unsigned char UID);
boolean removeView(const unsigned char UID);
@ -52,7 +54,6 @@ class ScreenManager
void iterateThroughList();
protected:
ScreenManager(Adafruit_SSD1306 &display, SDCardManager *sdCardManager = NULL);
private:
void *createEmptyList();
boolean addNewLinkAtTheEnd(ViewLinkedList *viewLinkedList, ViewLink viewLink);

View File

@ -59,7 +59,7 @@ bool TCPClient::operator==(TCPClient& Object)
return this->_client == Object._client;
}
bool TCPClient::closeConnection()
void TCPClient::closeConnection()
{
_client.stop();
}

View File

@ -15,7 +15,7 @@ class TCPClient
TCPClient(const TCPClient &Object);
virtual ~TCPClient();
bool operator==(TCPClient& Object);
bool closeConnection();
void closeConnection();
protected:
enum ClientState {NEW, HANDLED, DISCARDED} _clientState;
enum Error {OK = 0, MALLOC_ERR = 1} _error;

View File

@ -13,7 +13,7 @@ template <typename T>
class TCPServer
{
public:
TCPServer(uint16_t port = 80, uint8_t maxClient = MAX_CLIENT, uint16_t clientDataBufferSize = 255) : _wifiServer(port), _serverStarted(true), _maxClient(maxClient), _clientDataBufferSize(clientDataBufferSize), _currentClient(NULL)
TCPServer(uint16_t port = 80, uint8_t maxClient = MAX_CLIENT, uint16_t clientDataBufferSize = 255) : _serverStarted(true), _maxClient(maxClient), _clientDataBufferSize(clientDataBufferSize), _wifiServer(port), _currentClient(NULL)
{
_wifiServer.begin();
}
@ -92,7 +92,7 @@ class TCPServer
if(wc && wc.connected())
{
T *clientPointer = createNewClient(wc);
Serial.printf("Addr : %lu\n", clientPointer);
//Serial.printf("Addr : %lu\n", clientPointer);
//We activate the TKA : (The check is internally done in the
//ClientContext.h class : ie if one of the provided parameters is 0, then TKA is disabled)
(clientPointer->_client).keepAlive(_TKAIdleSec, _TKAIntvSec, _TKACount);

View File

@ -159,22 +159,22 @@ boolean TaskSchedulerManager::removeTask(uint16_t id)
return _taskDataDictio.remove(id);
}
boolean TaskSchedulerManager::enableTask(const char *name)
void TaskSchedulerManager::enableTask(const char *name)
{
getTask(name)->setEnabled(true);
}
boolean TaskSchedulerManager::enableTask(uint16_t id)
void TaskSchedulerManager::enableTask(uint16_t id)
{
getTask(id)->setEnabled(true);
}
boolean TaskSchedulerManager::disableTask(const char *name)
void TaskSchedulerManager::disableTask(const char *name)
{
getTask(name)->setEnabled(false);
}
boolean TaskSchedulerManager::disableTask(uint16_t id)
void TaskSchedulerManager::disableTask(uint16_t id)
{
getTask(id)->setEnabled(false);
}
@ -191,7 +191,7 @@ TaskSchedulerManagerHelper::Schedule *TaskSchedulerManager::getTask(uint16_t id)
return &(_taskDataDictio(indiceToStr)->schedule);
}
boolean TaskSchedulerManager::clearTask()
void TaskSchedulerManager::clearTask()
{
_taskDataDictio.clear();
}
@ -239,7 +239,7 @@ void TaskSchedulerManager::run()
}
}
const unsigned int TaskSchedulerManager::taskCount()
unsigned int TaskSchedulerManager::taskCount()
{
return _taskDataDictio.count();
}

View File

@ -67,15 +67,15 @@ class TaskSchedulerManager
boolean addTask(uint16_t id, TaskSchedulerManagerHelper::Schedule *schedule, boolean (*taskRoutine)(void*), void *pData = NULL);
boolean removeTask(const char *name);
boolean removeTask(uint16_t id);
boolean enableTask(const char *name);
boolean enableTask(uint16_t id);
boolean disableTask(const char *name);
boolean disableTask(uint16_t id);
boolean clearTask();
void enableTask(const char *name);
void enableTask(uint16_t id);
void disableTask(const char *name);
void disableTask(uint16_t id);
void clearTask();
TaskSchedulerManagerHelper::Schedule *getTask(const char *name);
TaskSchedulerManagerHelper::Schedule *getTask(uint16_t id);
void run();
const unsigned int taskCount();
unsigned int taskCount();
uint16_t findFreeTaskId();
protected:
TaskSchedulerManager();

View File

@ -48,7 +48,7 @@ class WEBServer : public TCPServer<T>, public HttpConstants
}
//Helper function used for the webApi
static void injectApiHeader(char *header, const char *contentType, char *content)
static void injectApiHeader(char *header, const char *contentType, const char *content)
{
char *buffer = (char *)malloc(sizeof(char) * strlen(content) + 1);
if(buffer != NULL)
@ -72,7 +72,7 @@ class WEBServer : public TCPServer<T>, public HttpConstants
virtual void greetClient(T *client)
{
(void)client;
}
virtual void processClientData(T *client)
@ -706,7 +706,7 @@ class WEBServer : public TCPServer<T>, public HttpConstants
static void injectHeaderLayout(char *header, const char *contentType, size_t size)
{
sprintf(header,"HTTP/1.1 200 OK\r\nContent-Type: %s\r\nContent-Length: %lu\r\nCache-Control: max-age=31536000\r\n\r\n",contentType,size);
sprintf(header,"HTTP/1.1 200 OK\r\nContent-Type: %s\r\nContent-Length: %u\r\nCache-Control: max-age=31536000\r\n\r\n",contentType,size);
}
static char *getFileExtension(char *name)

View File

@ -24,7 +24,7 @@ void WEBServerManager::clearApiRoutine()
boolean WEBServerManager::removeApiRoutine(const char *uri)
{
_apiDictionary.remove(uri);
return _apiDictionary.remove(uri);
}
boolean WEBServerManager::runServer()

View File

@ -19,8 +19,9 @@ boolean task_batt_sensing(void *pData)
boolean task_esp_reset_restart(void * pData)
{
(void)pData;
ESP.restart();
return true;
}

View File

@ -88,6 +88,7 @@ boolean staInfo(Adafruit_SSD1306 &display, void *pData)
boolean memInfo(Adafruit_SSD1306 &display, void *pData)
{
(void)pData;
char dispBuffer[300];
uint32_t freeMem;
uint16_t biggestContigMemBlock;
@ -103,6 +104,8 @@ boolean memInfo(Adafruit_SSD1306 &display, void *pData)
boolean dummy(Adafruit_SSD1306 &display, void *pData)
{
(void)display;
(void)pData;
return false;
}
@ -143,8 +146,6 @@ boolean sysErrorInfo(Adafruit_SSD1306 &display, void *pData)
{
SAB *p = (SAB *)pData;
char error_str[300];
display.print(FPSTR("Rst reason : ")); display.println(ESP.getResetReason());
display.print(FPSTR("RTC : "));display.println((p->getError() & SAB::RTC_BEGIN_ERR) != 0 ? "ERROR":"OK");
display.print(FPSTR("DISPLAY : "));display.println((p->getError() & SAB::DISP_BEGIN_ERR) != 0 ? "ERROR":"OK");