Skip to content

Commit

Permalink
Changing the return status of the receive function
Browse files Browse the repository at this point in the history
Invalid message scenario added
  • Loading branch information
SimonPucheu committed Feb 13, 2024
1 parent 6f26b97 commit 00b5911
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/Bluetooth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Bluetooth.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 00b5911

Please sign in to comment.