11#ifndef BLE_SERIAL_MTU_OVERHEAD
12#define BLE_SERIAL_MTU_OVERHEAD 5
16#define BLE_SERIAL_HEADER_SIZE 2
19#define BLE_SERIAL_MAX_VALUE_LEN 512
22#ifndef BLE_SERIAL_BUFFER_SIZE
23#define BLE_SERIAL_BUFFER_SIZE 4096
27#ifndef BLE_SERIAL_PACKET_COUNT
28#define BLE_SERIAL_PACKET_COUNT 100
47 void resize(
int bytes,
int packets,
bool framed) {
81 LOGE(
"BLESerial: read size %d too small: it must be >= %d", len, size);
187 return result < max ? result : max;
203 memcpy(str, data, len <
sizeof(str) - 1 ? len :
sizeof(str) - 1);
204 int sample_rate = 0, channels = 0, bits = 0;
205 if (sscanf(str,
"%d:%d:%d", &sample_rate, &channels, &bits) == 3) {
247 LOGW(
"BLESerial: invalid audio info");
256 packet[0] = len & 0xFF;
257 packet[1] = (len >> 8) & 0xFF;
263 int len = packet[0] | (packet[1] << 8);
266 LOGW(
"BLESerial: incomplete packet: %d of %d bytes", max, len);
289 virtual bool begin(
const char *name) = 0;
302 LOGD(
"BLESerialServer::write: %d", (
int)len);
306 LOGE(
"BLESerial: frame of %d bytes > max %d", (
int)len,
packetSize());
340 if (len == 0)
return;
345 LOGW(
"BLESerial: receive buffer full: %d bytes lost", (
int)len);
389 bool begin(
const char *localName,
int seconds) {
392 LOGE(
"BLESerial: starting BLE failed");
414 if (result > 0)
return result;
424 LOGE(
"BLESerial: frame of %d bytes > max %d", (
int)len,
packetSize());
430 for (
size_t j = 0; j < len; j++) {
#define LOGW(...)
Definition AudioLoggerIDF.h:29
#define TRACEI()
Definition AudioLoggerIDF.h:32
#define TRACED()
Definition AudioLoggerIDF.h:31
#define LOGI(...)
Definition AudioLoggerIDF.h:28
#define LOGD(...)
Definition AudioLoggerIDF.h:27
#define LOGE(...)
Definition AudioLoggerIDF.h:30
#define BLE_SERIAL_HEADER_SIZE
Size of the length header in the packets which are read by the client.
Definition BLESerialStream.h:16
#define BLE_SERIAL_PACKET_COUNT
Default max number of packets in the buffers in framed mode.
Definition BLESerialStream.h:28
#define BLE_SERIAL_MTU_OVERHEAD
Bytes which are reserved in each BLE packet for the ATT protocol.
Definition BLESerialStream.h:12
#define BLE_SERIAL_MAX_VALUE_LEN
Max length of a characteristic value defined by the BLE specification.
Definition BLESerialStream.h:19
#define BLE_SERIAL_BUFFER_SIZE
Default size of the receive and transmit buffers in bytes.
Definition BLESerialStream.h:23
#define DEFAULT_BUFFER_SIZE
Definition avr.h:20