From 00b5911fe6f73f17a73f78d64bfbc3bbb49fbbfe Mon Sep 17 00:00:00 2001 From: Simon Pucheu <104694344+SimonPucheu@users.noreply.github.com> Date: Tue, 13 Feb 2024 14:22:08 +0100 Subject: [PATCH] Changing the return status of the receive function Invalid message scenario added --- src/Bluetooth.cpp | 7 ++++--- src/Bluetooth.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Bluetooth.cpp b/src/Bluetooth.cpp index 9726a8e..61268af 100644 --- a/src/Bluetooth.cpp +++ b/src/Bluetooth.cpp @@ -17,7 +17,7 @@ Bluetooth::Bluetooth(Stream *iSerial, int *iSizes, int iNumValues, char iEndChar * * @return bool true if a complet new message is detected and false otherwise */ -bool Bluetooth::receive() +int Bluetooth::receive() { while (serial->available() > 0) { @@ -31,11 +31,12 @@ bool Bluetooth::receive() Intpressor::extract(json["a"], message.sizes, message.numValues, message.values); json.clear(); empty(); - return true; + return 0; } + return 1; } } - return false; + return 2; } /** diff --git a/src/Bluetooth.h b/src/Bluetooth.h index dead2f2..08c1450 100644 --- a/src/Bluetooth.h +++ b/src/Bluetooth.h @@ -9,7 +9,7 @@ class Bluetooth { public: Bluetooth(Stream *iSerial, int *iSizes, int iNumValues, char iEndChar); - bool receive(); + int receive(); bool send(); void empty(); char endChar;