Added new test to check the TCPServer base class stability
This commit is contained in:
parent
ea0c82d8e4
commit
1dfe399d56
17
src/software_test/tcpServerStress_test/StressServer.h
Normal file
17
src/software_test/tcpServerStress_test/StressServer.h
Normal 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
|
@ -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");
|
||||
}
|
Loading…
Reference in New Issue
Block a user