diff --git a/src/software_test/tcpServerStress_test/StressServer.h b/src/software_test/tcpServerStress_test/StressServer.h new file mode 100644 index 0000000..c7329c4 --- /dev/null +++ b/src/software_test/tcpServerStress_test/StressServer.h @@ -0,0 +1,17 @@ +#ifndef STRESSSERVER_H +#define STRESSSERVER_H +#include "TCPServer.h" + +template +class StressServer : public TCPServer +{ + public: + StressServer(uint16_t port = 1234, uint8_t maxClient = MAX_CLIENT, uint16_t clientDataBufferSize = 255):TCPServer(port, maxClient, clientDataBufferSize) + {} + + + protected: + private: +}; + +#endif //STRESSSERVER_H diff --git a/src/software_test/tcpServerStress_test/tcpServerStress_test.ino b/src/software_test/tcpServerStress_test/tcpServerStress_test.ino new file mode 100644 index 0000000..d1c1e83 --- /dev/null +++ b/src/software_test/tcpServerStress_test/tcpServerStress_test.ino @@ -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 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"); +}