Added new test to check the TCPServer base class stability

This commit is contained in:
anschrammh 2020-12-13 21:52:29 +01:00
parent ea0c82d8e4
commit 1dfe399d56
2 changed files with 72 additions and 0 deletions

View File

@ -0,0 +1,17 @@
#ifndef STRESSSERVER_H
#define STRESSSERVER_H
#include "TCPServer.h"
template <class T>
class StressServer : public TCPServer<T>
{
public:
StressServer(uint16_t port = 1234, uint8_t maxClient = MAX_CLIENT, uint16_t clientDataBufferSize = 255):TCPServer<T>(port, maxClient, clientDataBufferSize)
{}
protected:
private:
};
#endif //STRESSSERVER_H

View File

@ -0,0 +1,55 @@
/**
* This sketch was written in order to stress test the TCPServer and WEBServer classes used in my project and
* hopefully find why the WEBServer class isn't stable ...
* This test is aimed toward spotting possible causes of crash
* Created by Anatole SCHRAMM-HENRY the 12/12/2020
*/
#include "StressServer.h"
WiFiEventHandler gotIpEventHandler, disconnectedEventHandler;
StressServer<TCPClient> ss(1234,MAX_CLIENT,400);
unsigned long ts(0);
void setup()
{
Serial.begin(115200);
Serial.printf("\nSetup start\n");
gotIpEventHandler = WiFi.onStationModeGotIP(&(gotIp));
disconnectedEventHandler = WiFi.onStationModeDisconnected(&(lostCon));
WiFi.persistent(false);
WiFi.begin("Livebox-E46E","patricia");//Connect to AccessPoint as a STAtion
Serial.printf("Setup end\n");
}
void loop()
{
if(millis() - ts > 5000)
{
debugInfo();
ts = millis();
}
ss.run();
}
void debugInfo()
{
uint32_t freeMem;
uint16_t biggestContigMemBlock;
uint8_t frag;
ESP.getHeapStats(&freeMem, &biggestContigMemBlock, &frag);
Serial.printf("Free MEM : %lu\nHeap Frag : %u\nMax Block : %u\n",freeMem, frag, biggestContigMemBlock);
}
void gotIp(const WiFiEventStationModeGotIP& event)
{
Serial.print("Got IP : ");Serial.println(WiFi.localIP());
}
void lostCon(const WiFiEventStationModeDisconnected& event)
{
Serial.println("Lost connection");
}