Skip to content

Commit 9f50f1c

Browse files
committed
mod: DECODER_BUFFER_SIZE as a library parameter
RPCRequest buffer size is 1/4 of decoder's
1 parent c0f30c6 commit 9f50f1c

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

src/Arduino_RPClite.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include "Arduino.h"
1616

17+
#define DECODER_BUFFER_SIZE 1024
1718
//#define HANDLE_RPC_ERRORS
1819
#include "transport.h"
1920
#include "client.h"

src/decoder.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@
1919
using namespace RpcUtils::detail;
2020

2121
#define MIN_RPC_BYTES 4
22-
23-
#define MAX_BUFFER_SIZE 1024
2422
#define CHUNK_SIZE 32
2523

26-
template<size_t BufferSize = MAX_BUFFER_SIZE>
24+
template<size_t BufferSize = DECODER_BUFFER_SIZE>
2725
class RpcDecoder {
2826

2927
public:

src/decoder_manager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class RpcDecoderManager {
5151
struct DecoderStorage {
5252
union {
5353
RpcDecoder<> instance;
54-
uint8_t raw[sizeof(RpcDecoder<>)];
54+
uint8_t raw[sizeof(RpcDecoder<>)]{};
5555
};
5656

5757
DecoderStorage() {}

src/request.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#ifndef RPCLITE_REQUEST_H
1313
#define RPCLITE_REQUEST_H
1414

15-
#define DEFAULT_RPC_BUFFER_SIZE 256
15+
#define DEFAULT_RPC_BUFFER_SIZE (DECODER_BUFFER_SIZE / 4)
1616

1717

1818
#include "rpclite_utils.h"
@@ -21,7 +21,7 @@ template<size_t BufferSize = DEFAULT_RPC_BUFFER_SIZE>
2121
class RPCRequest {
2222

2323
public:
24-
uint8_t buffer[BufferSize] = {};
24+
uint8_t buffer[BufferSize]{};
2525
size_t size = 0;
2626
int type = NO_MSG;
2727
uint32_t msg_id = 0;

0 commit comments

Comments
 (0)