Reimplement WebSerial

This commit is contained in:
iranl
2025-06-30 20:35:54 +02:00
parent 6c74d62531
commit cac2ca9a60
11 changed files with 317 additions and 63 deletions

View File

@@ -75,7 +75,7 @@ void MqttLogger::sendBuffer()
{
bool doSerial = this->mode==MqttLoggerMode::SerialOnly || this->mode==MqttLoggerMode::MqttAndSerial || this->mode==MqttLoggerMode::MqttAndSerialAndWeb || this->mode==MqttLoggerMode::SerialAndWeb;
bool doWebSerial = this->mode==MqttLoggerMode::MqttAndSerialAndWeb || this->mode==MqttLoggerMode::SerialAndWeb;
if (this->mode!=MqttLoggerMode::SerialOnly && this->mode!=MqttLoggerMode::SerialAndWeb && this->client != NULL && this->client->connected())
if (this->mode!=MqttLoggerMode::SerialOnly && this->mode!=MqttLoggerMode::SerialAndWeb && this->client != NULL && this->client->connected())
{
this->client->publish(topic, 0, true, this->buffer, this->bufferCnt);
}
@@ -88,10 +88,9 @@ void MqttLogger::sendBuffer()
Serial.write(this->buffer, this->bufferCnt);
Serial.println();
}
if (doWebSerial)
if (doWebSerial && websocketHandler != nullptr)
{
//WebSerial.write(this->buffer, this->bufferCnt);
//WebSerial.println();
websocketHandler->sendAll(HTTPD_WS_TYPE_TEXT, this->buffer, this->bufferCnt);
}
this->bufferCnt=0;
}

View File

@@ -12,10 +12,11 @@
#include <Arduino.h>
#include <Print.h>
#include <espMqttClient.h>
//#include "MycilaWebSerial.h"
#include "PsychicWebSocket.h"
#define MQTT_MAX_PACKET_SIZE 1024
extern PsychicWebSocketHandler* websocketHandler;
extern bool coredumpPrinted;
enum MqttLoggerMode {

View File

@@ -306,6 +306,7 @@ String PsychicRequest::getCookie(const char* key)
if (!hasCookie(key, &size))
return cookie;
//Following line is needed until https://github.com/espressif/esp-idf/pull/16202 is merged and available in ESP-IDF 5.5 (beta2/RC/final)
size = httpd_req_get_hdr_value_len(this->_req, "Cookie");
// allocate cookie buffer... keep it on the stack