tuning logs, max queue size, preallocate strings, all working

This commit is contained in:
Torsten Ruger 2021-07-03 21:23:07 +03:00
parent 9c6b39fd50
commit 8f32fb0c94
2 changed files with 8 additions and 9 deletions

View File

@ -1,22 +1,20 @@
#include <Arduino.h>
#include <queue>
#include <list>
class WsSerial{
std::queue<String> debug;
std::list<String> debug;
public:
inline void print(const String& line){
// enable debug the debugging Serial.println(line.c_str());
debug.push(line);
}
inline void print(const String& line){ println(line); }
inline void println(const String& line){
// enable debug the debugging Serial.println(line.c_str());
debug.push(line);
if(debug.size() > 100 ) debug.pop_back();
debug.push_front(line);
}
inline void println(const float num){ println(String(num)) ; };
inline const String& first(){ return debug.front();};
inline void pop(){ debug.pop(); };
inline void pop(){ return debug.pop_front();};
inline bool empty(){ return debug.empty();};
};

View File

@ -83,7 +83,8 @@ void server_setup(){
DEBUG_OUT.println("log start");
AsyncWebServerResponse *response = request->beginChunkedResponse("text/html", [](uint8_t *buffer, size_t maxLen, size_t index) -> size_t {
if(debug_out.empty()) return 0;
String to_send = String(maxLen);
String to_send = String();
to_send.reserve(maxLen);
while(!debug_out.empty()){
String add_next = debug_out.first();
if( (add_next.length() + 5 + to_send.length() ) > maxLen ) break ; // dont overflow buffer