Arduino Core 3 (#407)
* Add and remove libs and components for Arduino Core 3 * Arduino Core 3 * Add back Solo1 * Change ESP32-S3 to 4MB build * Update README.md * Fix retain and number of retries * Fix rolling log * Fix defaults * Fix BleScanner on Solo1 * Export settings * Import settings * Fix HA Battery voltage * Change submodule * Update espMqttClient and AsyncTCP * Webserial and MQTT/Network reconnecting * Update nuki_ble --------- Co-authored-by: iranl <iranl@github.com>
This commit is contained in:
40
lib/ESP Async WebServer/examples/StreamFiles/StreamString.h
Normal file
40
lib/ESP Async WebServer/examples/StreamFiles/StreamString.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include <Stream.h>
|
||||
|
||||
class StreamString : public Stream {
|
||||
public:
|
||||
size_t write(const uint8_t* p, size_t n) override { return _buffer.concat(reinterpret_cast<const char*>(p), n) ? n : 0; }
|
||||
size_t write(uint8_t c) override { return _buffer.concat(static_cast<char>(c)) ? 1 : 0; }
|
||||
void flush() override {}
|
||||
|
||||
int available() override { return static_cast<int>(_buffer.length()); }
|
||||
|
||||
int read() override {
|
||||
if (_buffer.length() == 0)
|
||||
return -1;
|
||||
char c = _buffer[0];
|
||||
_buffer.remove(0, 1);
|
||||
return c;
|
||||
}
|
||||
|
||||
#if defined(TARGET_RP2040)
|
||||
size_t readBytes(char* buffer, size_t length) {
|
||||
#else
|
||||
size_t readBytes(char* buffer, size_t length) override {
|
||||
#endif
|
||||
if (length > _buffer.length())
|
||||
length = _buffer.length();
|
||||
// Don't use _str.ToCharArray() because it inserts a terminator
|
||||
memcpy(buffer, _buffer.c_str(), length);
|
||||
_buffer.remove(0, static_cast<unsigned int>(length));
|
||||
return length;
|
||||
}
|
||||
|
||||
int peek() override { return _buffer.length() > 0 ? _buffer[0] : -1; }
|
||||
|
||||
const String& buffer() const { return _buffer; }
|
||||
|
||||
private:
|
||||
String _buffer;
|
||||
};
|
||||
Reference in New Issue
Block a user