More compact module sensors was added

This commit is contained in:
2024-01-05 23:21:31 +07:00
parent 89940fbec2
commit b86af180ab
9 changed files with 213 additions and 47 deletions

View File

@@ -30,9 +30,12 @@ void BluetoothDispatcher::tick() {
_buffer += (char)_controller->read();
}
if (_buffer.endsWith("\r")) {
_serial->println(_buffer.substring(0, _buffer.lastIndexOf("\r")));
char buffer[_buffer_size];
_buffer.substring(0, _buffer.lastIndexOf('\r'), buffer);
_serial->println(buffer); // print the payload
_buffer.clear();
_controller->write((uint8_t *)"Hello, world!", strlen("Hello, world!"));
// TODO: add callback, that receive new state
}
if (_buffer.length() > _buffer_size) {
_buffer.clear();

View File

@@ -1,7 +1,6 @@
#include "Arduino.h"
#include "BluetoothSerial.h"
#include "HardwareSerial.h"
#include "Stream.h"
#include "mString.h"
/* Check the ESP configuration */
#if not defined(CONFIG_BT_ENABLED) || not defined(CONFIG_BLUEDROID_ENABLED)
@@ -37,6 +36,6 @@ class BluetoothDispatcher {
bool _confirmRequestDone = false;
BluetoothSerial *_controller = nullptr;
HardwareSerial *_serial = nullptr;
static constexpr int _buffer_size = 256;
String _buffer;
static constexpr uint16_t _buffer_size = 256;
mString<_buffer_size> _buffer;
};