Grouped common class initialization directives in one private method and enabled new TCPKeepAlive setting for WEB and FTP servers
This commit is contained in:
parent
125a02c0e6
commit
0c622c600b
@ -19,6 +19,30 @@ _pcf(_boardConfig.getI2C_IOExpanderAddress(), Wire),
|
|||||||
_ioManager(_pcf),
|
_ioManager(_pcf),
|
||||||
_taskSchedulerManager(_rtcManager),
|
_taskSchedulerManager(_rtcManager),
|
||||||
_error(0)
|
_error(0)
|
||||||
|
{
|
||||||
|
initCommonConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
SAB::SAB(const BoardConfig boardConfig, const unsigned int webServerPort, const unsigned int ftpServerPort) : _boardConfig(boardConfig),
|
||||||
|
_sdCardManager(_boardConfig.getSPI_SDCard_cs(), _boardConfig.getSPISpeed()),
|
||||||
|
_display(_boardConfig.getScreenWidth(), _boardConfig.getScreenHeight(), &Wire),
|
||||||
|
_screenManager(_display, &_sdCardManager),
|
||||||
|
_rtc(),
|
||||||
|
_rtcManager(_rtc),
|
||||||
|
_connectivityManager(NULL),
|
||||||
|
//_webServerManager(webServerPort, &_sdCardManager),
|
||||||
|
_webServer(webServerPort, &_sdCardManager, 10),
|
||||||
|
_ftpServer(ftpServerPort, &_sdCardManager, "ESP8266", "12345678"),
|
||||||
|
_dbWSServer(81),
|
||||||
|
_pcf(_boardConfig.getI2C_IOExpanderAddress(), Wire),
|
||||||
|
_ioManager(_pcf),
|
||||||
|
_taskSchedulerManager(_rtcManager),
|
||||||
|
_error(0)
|
||||||
|
{
|
||||||
|
initCommonConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SAB::initCommonConfig()
|
||||||
{
|
{
|
||||||
//We set the gpio up
|
//We set the gpio up
|
||||||
initGPIO();
|
initGPIO();
|
||||||
@ -44,49 +68,11 @@ _error(0)
|
|||||||
if(!_pcf.begin()){_error |= IO_INIT_ERR;}
|
if(!_pcf.begin()){_error |= IO_INIT_ERR;}
|
||||||
|
|
||||||
_powerUpTime = _rtcManager.getDateTime();
|
_powerUpTime = _rtcManager.getDateTime();
|
||||||
_dbWSServer.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
SAB::SAB(const BoardConfig boardConfig, const unsigned int webServerPort, const unsigned int ftpServerPort) : _boardConfig(boardConfig),
|
//We set the different servers :
|
||||||
_sdCardManager(_boardConfig.getSPI_SDCard_cs(), _boardConfig.getSPISpeed()),
|
|
||||||
_display(_boardConfig.getScreenWidth(), _boardConfig.getScreenHeight(), &Wire),
|
|
||||||
_screenManager(_display, &_sdCardManager),
|
|
||||||
_rtc(),
|
|
||||||
_rtcManager(_rtc),
|
|
||||||
_connectivityManager(NULL),
|
|
||||||
//_webServerManager(webServerPort, &_sdCardManager),
|
|
||||||
_webServer(webServerPort, &_sdCardManager, 10),
|
|
||||||
_ftpServer(ftpServerPort, &_sdCardManager, "ESP8266", "12345678"),
|
|
||||||
_dbWSServer(81),
|
|
||||||
_pcf(_boardConfig.getI2C_IOExpanderAddress(), Wire),
|
|
||||||
_ioManager(_pcf),
|
|
||||||
_taskSchedulerManager(_rtcManager),
|
|
||||||
_error(0)
|
|
||||||
{
|
|
||||||
//We set the gpio up
|
|
||||||
initGPIO();
|
|
||||||
Serial.begin(115200, SERIAL_8N1, SERIAL_TX_ONLY);
|
|
||||||
Serial.println();
|
|
||||||
delay(200);
|
|
||||||
//We initialize the pins for the I2C communication
|
|
||||||
Wire.begin(_boardConfig.getI2C_sda(), _boardConfig.getI2C_scl());
|
|
||||||
if(!_rtc.begin()) _error |= RTC_BEGIN_ERR;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SAB::_rtcManagerP = &_rtcManager;
|
|
||||||
}
|
|
||||||
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
|
|
||||||
{
|
|
||||||
_sdCardManager.setTimeCallback(&(SAB::myTimeCallback));
|
|
||||||
}
|
|
||||||
_screenManager.init();
|
|
||||||
_connectivityManager = new ConnectivityManager(_sdCardManager);
|
|
||||||
if(!_pcf.begin()){_error |= IO_INIT_ERR;}
|
|
||||||
|
|
||||||
_powerUpTime = _rtcManager.getDateTime();
|
|
||||||
_dbWSServer.begin();
|
_dbWSServer.begin();
|
||||||
|
_webServer.enableTcpKeepAlive(15,5,5);
|
||||||
|
_ftpServer.enableTcpKeepAlive(15,5,5);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SAB::initGPIO()
|
void SAB::initGPIO()
|
||||||
|
@ -49,6 +49,7 @@ class SAB
|
|||||||
private:
|
private:
|
||||||
void initGPIO();
|
void initGPIO();
|
||||||
static time_t myTimeCallback();
|
static time_t myTimeCallback();
|
||||||
|
void initCommonConfig();
|
||||||
const BoardConfig _boardConfig;
|
const BoardConfig _boardConfig;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user