Compare commits
	
		
			6 Commits
		
	
	
		
			47f289f3fe
			...
			05f7794679
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 05f7794679 | |||
| 460db55496 | |||
| d2f620597c | |||
| 4dca5a0f1a | |||
| 6b1a06f1f7 | |||
| fb1d592dd1 | 
							
								
								
									
										42
									
								
								.vscode/tasks.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								.vscode/tasks.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,42 @@ | ||||
| { | ||||
|     // See https://go.microsoft.com/fwlink/?LinkId=733558 | ||||
|     // for the documentation about the tasks.json format | ||||
|     "version": "2.0.0", | ||||
|     "tasks": [ | ||||
|         { | ||||
|             "label": "Build", | ||||
|             "type": "shell", | ||||
|             "command": "arduino-cli compile -v --warnings all -b esp8266:esp8266:nodemcuv2:xtal=80,vt=flash,exception=disabled,stacksmash=enabled,ssl=basic,mmu=3232,non32xfer=fast,eesz=4M,led=2,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=921600 ((pwd).path + '/src/app')", | ||||
|             "group": "build", | ||||
|             "presentation": { | ||||
|                 "echo": true, | ||||
|                 "reveal": "always", | ||||
|                 "focus": false, | ||||
|                 "panel": "shared", | ||||
|                 "showReuseMessage": true, | ||||
|                 "clear": true | ||||
|             } | ||||
|         }, | ||||
|         { | ||||
|             "label": "Flash", | ||||
|             "type": "shell", | ||||
|             "command": "arduino-cli upload -v -b esp8266:esp8266:nodemcuv2:xtal=80,vt=flash,exception=disabled,stacksmash=enabled,ssl=basic,mmu=3232,non32xfer=fast,eesz=4M,led=2,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=921600 ((pwd).path + '/src/app') -p COM27", | ||||
|             "group": "build", | ||||
|             "presentation": { | ||||
|                 "echo": true, | ||||
|                 "reveal": "always", | ||||
|                 "focus": false, | ||||
|                 "panel": "shared", | ||||
|                 "showReuseMessage": true, | ||||
|                 "clear": true | ||||
|             } | ||||
|         }, | ||||
|         { | ||||
|             "label": "Build & Flash", | ||||
|             "type": "shell", | ||||
|             "group": "build", | ||||
|             "dependsOrder": "sequence", | ||||
|             "dependsOn":["Build", "Flash"] | ||||
|         } | ||||
|     ] | ||||
| } | ||||
| @ -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), | ||||
|  | ||||
| @ -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; | ||||
|  | ||||
| @ -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); | ||||
|   	 | ||||
|  | ||||
| @ -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; | ||||
|  | ||||
| @ -46,8 +46,8 @@ boolean ConnectivityManager::connectToSTA() | ||||
|   } | ||||
|   else | ||||
|     toBeReturned = false; | ||||
|      | ||||
|     return toBeReturned; | ||||
|    | ||||
|   return toBeReturned; | ||||
| } | ||||
| 
 | ||||
| boolean ConnectivityManager::startAP() | ||||
|  | ||||
| @ -11,7 +11,7 @@ protected: | ||||
|     } | ||||
|     DictionaryInterface(const DictionaryInterface &Object) | ||||
|     { | ||||
| 
 | ||||
|         (void)Object; | ||||
|     } | ||||
|     virtual ~DictionaryInterface(){} | ||||
|     virtual const char *toString() = 0; | ||||
|  | ||||
| @ -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) | ||||
| { | ||||
|    | ||||
| } | ||||
|  | ||||
| @ -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
 | ||||
| }; | ||||
| 
 | ||||
|  | ||||
| @ -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); | ||||
|       } | ||||
|     } | ||||
|      | ||||
|  | ||||
| @ -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; | ||||
| 
 | ||||
|  | ||||
| @ -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 | ||||
|   { | ||||
|  | ||||
| @ -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; | ||||
| }; | ||||
|  | ||||
| @ -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; | ||||
| } | ||||
|  | ||||
| @ -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(); | ||||
|  | ||||
| @ -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; | ||||
|   } | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -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); | ||||
|  | ||||
| @ -59,7 +59,7 @@ bool TCPClient::operator==(TCPClient& Object) | ||||
| 	return this->_client == Object._client; | ||||
| } | ||||
| 
 | ||||
| bool TCPClient::closeConnection() | ||||
| void TCPClient::closeConnection() | ||||
| { | ||||
|   _client.stop(); | ||||
| } | ||||
|  | ||||
| @ -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; | ||||
|  | ||||
| @ -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); | ||||
|  | ||||
| @ -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(); | ||||
| } | ||||
|  | ||||
| @ -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(); | ||||
|  | ||||
| @ -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) | ||||
|  | ||||
| @ -24,7 +24,7 @@ void WEBServerManager::clearApiRoutine() | ||||
| 
 | ||||
| boolean WEBServerManager::removeApiRoutine(const char *uri) | ||||
| { | ||||
|   _apiDictionary.remove(uri); | ||||
|   return _apiDictionary.remove(uri); | ||||
| } | ||||
| 
 | ||||
| boolean WEBServerManager::runServer() | ||||
|  | ||||
| @ -33,12 +33,14 @@ void setup() | ||||
|   { | ||||
|     Serial.print("AP PASSWORD : ");if((*cfgDictionary)("PASSWORD") != NULL)Serial.println((*cfgDictionary)("PASSWORD")->stringValue()); | ||||
|   } | ||||
|    | ||||
|   /*CFGFileParser cfgFileParsert1(sab.getSdCardManager(), "/CONFIG/TEST1.CFG");
 | ||||
| 
 | ||||
|   #if 0 | ||||
|   CFGFileParser cfgFileParsert1(sab.getSdCardManager(), "/CONFIG/TEST1.CFG"); | ||||
|   CFGFileParser cfgFileParsert2(sab.getSdCardManager(), "/CONFIG/TEST2.CFG"); | ||||
|    | ||||
|   Serial.print("TEST1 : ");Serial.println(cfgFileParsert1.save(cfgDictionary)); | ||||
|   Serial.print("TEST2 : ");Serial.println(cfgFileParsert2.save(cfgDictionary));*/ | ||||
|   Serial.print("TEST2 : ");Serial.println(cfgFileParsert2.save(cfgDictionary)); | ||||
|   #endif | ||||
|    | ||||
|   delete cfgDictionary; | ||||
|    | ||||
| @ -132,6 +134,8 @@ void loop() | ||||
|       Serial.printf("Changing view\nSelected view is : %d\n",sab.getScreenManager().getCurrentViewUID()); | ||||
|       #endif | ||||
|       break; | ||||
|     default: //NO_EVENT
 | ||||
|       break; | ||||
|   } | ||||
|    | ||||
|   //Run the different services
 | ||||
| @ -139,7 +143,7 @@ void loop() | ||||
|   evHan.run(); | ||||
| } | ||||
| 
 | ||||
| ICACHE_RAM_ATTR void ioISR() | ||||
| IRAM_ATTR void ioISR() | ||||
| { | ||||
|   ioStateChange = true; | ||||
| } | ||||
|  | ||||
| @ -19,8 +19,9 @@ boolean task_batt_sensing(void *pData) | ||||
| 
 | ||||
| boolean task_esp_reset_restart(void * pData) | ||||
| { | ||||
|   (void)pData; | ||||
|   ESP.restart(); | ||||
| 
 | ||||
|    | ||||
|   return true; | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -7,36 +7,37 @@ | ||||
|  * Versioning scheme MAJOR.MINOR.PATCH | ||||
|  */ | ||||
| 
 | ||||
| #define SOFT_VERSION "1.0.0" //First version tracking
 | ||||
| #define SOFT_VERSION "1.1.0" //Added trailing zeros to the date and time
 | ||||
| #define SOFT_VERSION "1.1.1" //Added delayed esp restart/reset api call
 | ||||
| #define SOFT_VERSION "1.1.2" //Fixed a big memory leak :( shame on me...
 | ||||
| #define SOFT_VERSION "1.1.3" //TaskSchedulerManager added millis rollover
 | ||||
| #define SOFT_VERSION "1.1.4" //Cleaned AP and STA wifi start
 | ||||
| #define SOFT_VERSION "1.2.0" //Added new PowerManager class
 | ||||
| #define SOFT_VERSION "1.2.1" //Corrected a bug in the TaskSchedulerManager class
 | ||||
| #define SOFT_VERSION "1.3.0" //Implemented multi-client non blocking webserver
 | ||||
| #define SOFT_VERSION "1.3.1" //Fixed sdCardUnmount api call
 | ||||
| #define SOFT_VERSION "1.3.2" //Modified TCPServer and WEBServer core logic
 | ||||
| #define SOFT_VERSION "1.4.0" //Added the new FTPServer
 | ||||
| #define SOFT_VERSION "1.4.1" //Updated FTP server to use the new SD library for the ESP8266
 | ||||
| #define SOFT_VERSION "1.4.2" //Added new functionalities to the FTP server as well as login check
 | ||||
| #define SOFT_VERSION "1.4.3" //Added ICACHE_RAM_ATTR because of a strange performance hit
 | ||||
| #define SOFT_VERSION "1.5.0" //Added new rtcInfo view + DS3231 internal temperature
 | ||||
| #define SOFT_VERSION "1.5.1" //Corrected a mistake in the sendPageToClientFromSdCard method (WEBServer class)
 | ||||
| #define SOFT_VERSION "1.5.2" //Started to put every string in the flash memory instead of the ram
 | ||||
| #define SOFT_VERSION "1.5.3" //Minor changes and fixes to the ConnectivityManager class
 | ||||
| #define SOFT_VERSION "1.5.4" //Updated TCPClient (using memmove instead of strcpy)
 | ||||
| #define SOFT_VERSION "1.5.5" //WEBServer now parsing form parameters in the post data section
 | ||||
| #define SOFT_VERSION "1.5.6" //Added new SAB method to set te cpu frequency at run time
 | ||||
| #define SOFT_VERSION "1.6.0" //Added the new HttpClient class along with tests in a new task
 | ||||
| #define SOFT_VERSION "1.6.1" //Reworked the ScreenManager in order to display previous views and did some code optimization
 | ||||
| #define SOFT_VERSION "1.6.2" //Added a run method to the screen manager and reworked the error system
 | ||||
| #define SOFT_VERSION "1.6.3" //Added a new api call to get nearby wifi access points
 | ||||
| #define SOFT_VERSION "1.6.4" //Added the forceRefresh() method to the ScreenManager Object
 | ||||
| #define SOFT_VERSION "1.6.5" //Removed the sd card mount and unmount api calls, replaced with the sdCardAction api call which takes a parameter (does the same thing)
 | ||||
| #define SOFT_VERSION "1.6.6" //Removed useless INIT state that was like the LINE_BREAK state and added '-' as an allowed PARAM and VALUE character
 | ||||
| #define SOFT_VERSION "1.6.7" //Changed the way we store and return the 3 letter month abbreviation
 | ||||
| #define SOFT_VERSION "1.6.8" //Finally fixed the random crash issue concerning the servers :)
 | ||||
| //#define SOFT_VERSION "1.0.0" //First version tracking
 | ||||
| //#define SOFT_VERSION "1.1.0" //Added trailing zeros to the date and time
 | ||||
| //#define SOFT_VERSION "1.1.1" //Added delayed esp restart/reset api call
 | ||||
| //#define SOFT_VERSION "1.1.2" //Fixed a big memory leak :( shame on me...
 | ||||
| //#define SOFT_VERSION "1.1.3" //TaskSchedulerManager added millis rollover
 | ||||
| //#define SOFT_VERSION "1.1.4" //Cleaned AP and STA wifi start
 | ||||
| //#define SOFT_VERSION "1.2.0" //Added new PowerManager class
 | ||||
| //#define SOFT_VERSION "1.2.1" //Corrected a bug in the TaskSchedulerManager class
 | ||||
| //#define SOFT_VERSION "1.3.0" //Implemented multi-client non blocking webserver
 | ||||
| //#define SOFT_VERSION "1.3.1" //Fixed sdCardUnmount api call
 | ||||
| //#define SOFT_VERSION "1.3.2" //Modified TCPServer and WEBServer core logic
 | ||||
| //#define SOFT_VERSION "1.4.0" //Added the new FTPServer
 | ||||
| //#define SOFT_VERSION "1.4.1" //Updated FTP server to use the new SD library for the ESP8266
 | ||||
| //#define SOFT_VERSION "1.4.2" //Added new functionalities to the FTP server as well as login check
 | ||||
| //#define SOFT_VERSION "1.4.3" //Added ICACHE_RAM_ATTR because of a strange performance hit
 | ||||
| //#define SOFT_VERSION "1.5.0" //Added new rtcInfo view + DS3231 internal temperature
 | ||||
| //#define SOFT_VERSION "1.5.1" //Corrected a mistake in the sendPageToClientFromSdCard method (WEBServer class)
 | ||||
| //#define SOFT_VERSION "1.5.2" //Started to put every string in the flash memory instead of the ram
 | ||||
| //#define SOFT_VERSION "1.5.3" //Minor changes and fixes to the ConnectivityManager class
 | ||||
| //#define SOFT_VERSION "1.5.4" //Updated TCPClient (using memmove instead of strcpy)
 | ||||
| //#define SOFT_VERSION "1.5.5" //WEBServer now parsing form parameters in the post data section
 | ||||
| //#define SOFT_VERSION "1.5.6" //Added new SAB method to set te cpu frequency at run time
 | ||||
| //#define SOFT_VERSION "1.6.0" //Added the new HttpClient class along with tests in a new task
 | ||||
| //#define SOFT_VERSION "1.6.1" //Reworked the ScreenManager in order to display previous views and did some code optimization
 | ||||
| //#define SOFT_VERSION "1.6.2" //Added a run method to the screen manager and reworked the error system
 | ||||
| //#define SOFT_VERSION "1.6.3" //Added a new api call to get nearby wifi access points
 | ||||
| //#define SOFT_VERSION "1.6.4" //Added the forceRefresh() method to the ScreenManager Object
 | ||||
| //#define SOFT_VERSION "1.6.5" //Removed the sd card mount and unmount api calls, replaced with the sdCardAction api call which takes a parameter (does the same thing)
 | ||||
| //#define SOFT_VERSION "1.6.6" //Removed useless INIT state that was like the LINE_BREAK state and added '-' as an allowed PARAM and VALUE character
 | ||||
| //#define SOFT_VERSION "1.6.7" //Changed the way we store and return the 3 letter month abbreviation
 | ||||
| //#define SOFT_VERSION "1.6.8" //Finally fixed the random crash issue concerning the servers :)
 | ||||
| #define SOFT_VERSION "1.6.9" //Updated the whole app the work with the esp8266 core 3.0.2 version, removed a bunch of warnings, corrected an array index overflow in apiTesterApi function
 | ||||
| 
 | ||||
| #endif //VERSIONS_H
 | ||||
|  | ||||
| @ -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"); | ||||
|  | ||||
| @ -4,7 +4,9 @@ | ||||
| 
 | ||||
| boolean apiTesterApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient* wc, void* pData) | ||||
| { | ||||
|   char buffer[100]; | ||||
|   (void)HRD; | ||||
|   (void)pData; | ||||
|   char buffer[200]; | ||||
|    | ||||
|   WEBServer<WEBClient>::injectApiHeader(buffer, "application/json", "{\"status\":\"ok\",\"API\":\"available\"}"); | ||||
|   wc->print(buffer); | ||||
| @ -36,12 +38,13 @@ boolean viewByUIDApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc, | ||||
| 
 | ||||
| boolean nextViewApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc, void *pData) | ||||
| { | ||||
|   (void)HRD; | ||||
|   SAB *p = (SAB *)pData; | ||||
|   char buffer[200]; | ||||
|    | ||||
|   p->getScreenManager().displayNextView(); | ||||
|    | ||||
|   if(p->getScreenManager().getError() == OK) | ||||
|   if(p->getScreenManager().getError() == ScreenManager::OK) | ||||
|     sprintf(buffer, "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{\"status\":\"ok\",\"ViewUID\":\"%d\"}", p->getScreenManager().getCurrentViewUID()); | ||||
|   else | ||||
|     sprintf(buffer, "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{\"status\":\"failed\",\"message\":\"%s\"}", p->getScreenManager().getErrorMessage()); | ||||
| @ -51,6 +54,7 @@ boolean nextViewApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc, | ||||
| 
 | ||||
| boolean reloadViewApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc, void *pData) | ||||
| { | ||||
|   (void)HRD; | ||||
|   SAB *p = (SAB *)pData; | ||||
|   char buffer[200]; | ||||
| 
 | ||||
| @ -65,6 +69,7 @@ boolean reloadViewApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc | ||||
| 
 | ||||
| boolean rtcGetTimeApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc, void *pData) | ||||
| { | ||||
|   (void)HRD; | ||||
|   SAB *p = (SAB *)pData; | ||||
|   char buffer[200]; | ||||
|   DateTime d = p->getRtcManager().getDateTime(); | ||||
| @ -195,6 +200,7 @@ boolean espResetApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc, | ||||
| 
 | ||||
| boolean sdCardSizeApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc, void *pData) | ||||
| { | ||||
|   (void)HRD; | ||||
| 	SAB *p = (SAB *)pData; | ||||
| 	char buffer[200]; | ||||
| 	double size = p->getSdCardManager().getSize(GBYTE); | ||||
| @ -209,6 +215,7 @@ boolean sdCardSizeApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc | ||||
| 
 | ||||
| boolean staWifiInfoApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc, void *pData) | ||||
| { | ||||
|   (void)HRD; | ||||
| 	SAB *p = (SAB *)pData; | ||||
| 	char buffer[300]; | ||||
|   IPAddress IP = p->getConnectivityManager().localIP(); | ||||
| @ -236,6 +243,8 @@ boolean staWifiInfoApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *w | ||||
| 
 | ||||
| boolean apScannerApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc, void *pData) | ||||
| { | ||||
|   (void)HRD; | ||||
|   (void)pData; | ||||
|   uint8_t number = WiFi.scanNetworks(); | ||||
|   wc->print("HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n["); | ||||
|      | ||||
| @ -250,6 +259,7 @@ boolean apScannerApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc, | ||||
| 
 | ||||
| boolean systemInfoApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc, void *pData) | ||||
| { | ||||
|   (void)HRD; | ||||
|   SAB *p = (SAB *)pData; | ||||
|   char buffer[300]; | ||||
|   uint32_t freeMem; | ||||
| @ -267,6 +277,7 @@ boolean systemInfoApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc | ||||
| 
 | ||||
| boolean powerInfoApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc, void *pData) | ||||
| { | ||||
|   (void)HRD; | ||||
|   SAB *p = (SAB *)pData; | ||||
|   char buffer[300]; | ||||
|   PowerManager::PowerInfo pi = p->getPowerManager().getPowerInfo(); | ||||
|  | ||||
| @ -90,7 +90,7 @@ void PCF8574::digitalReadAll(boolean array[8]) | ||||
| 
 | ||||
| boolean PCF8574::getPinMode(Pin pin) | ||||
| { | ||||
| 	return _pddr & pin == 0 ? INPUT : OUTPUT; | ||||
| 	return (_pddr & pin) == 0 ? INPUT : OUTPUT; | ||||
| } | ||||
| 
 | ||||
| void PCF8574::getPinModeAll(boolean array[8]) | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user