Skip to content

Commit

Permalink
Added Serial reset code
Browse files Browse the repository at this point in the history
  • Loading branch information
Levi-Lesches committed May 30, 2023
1 parent 332504f commit c7aa1ef
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions BURT_serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@ void BurtSerial::update() {
int length = Serial.available();
if (length == 0) return;
uint8_t input[length];
Serial.readBytes((char*) input, length);
int receivedLength = Serial.readBytes((char*) input, length);

if (!isConnected) tryConnect(input, length);
else handler(input, length);
if (!isConnected) {
tryConnect(input, length);
} else if (receivedLength == 4 && (input[0] == 0 && input[1] == 0 && input[2] == 0 && input[3] == 0)) {
// This is our special "reset" code. Respond with 1111
uint8_t response[4] = {0x01, 0x01, 0x01, 0x01};
Serial.write(response, 4);
isConnected = false;
} else {
handler(input, length);
}
}

void BurtSerial::tryConnect(uint8_t* input, int length) {
Expand Down

0 comments on commit c7aa1ef

Please sign in to comment.