Compare commits

...

2 Commits

Author SHA1 Message Date
29b30aeb0b [FW] Added logging 2026-05-17 13:07:24 +01:00
a2429d4dbc [FW] Fixed null terminator 2026-05-17 13:06:59 +01:00
4 changed files with 13 additions and 3 deletions

View File

@ -15,8 +15,10 @@ Each packet is constructed as follows:
- `uint8_t`: A basic XOR checksum of all the previous bytes, XORed with `0x55`.
- `null`: A null terminator (0x00).
The firmware can also send logs by sending the initial character `/`, followed by ASCII text, then a null terminator (`0x00`)
### Commands:
- Connect (`0x01`): Used to get the firmware into its ready state, and out of it's initial mode of repeating `WHSPAH\n`. Responds with `0x01`.
- Connect (`0x01`): Used to get the firmware into its ready state, and out of it's initial mode of repeating `/WHSPAH\x00`. Responds with `0x01`.
- Ping (`0x02`): Needs to be send at least once every 500ms, otherwise the firmware will reset into its initial mode. Responds with `0x02`.
- Transmit (`0x10`): Transmits a CaiXianlin packet. The command's arguments are as follows:
- `uint16_t`: Transmitter ID

View File

@ -47,7 +47,7 @@ namespace {
}
checksum ^= 0x55;
Serial.write(checksum);
Serial.write(0x00);
Serial.write((char) 0x00);
}
}
@ -62,7 +62,8 @@ void CMDProcessor::process() {
CMDProcessor::connected = false;
reset();
} else if (!CMDProcessor::connected && millis() - lastPing > 250) {
Serial.print("WHSPAH\n");
Serial.print("/WHSPAH");
Serial.print((char) 0x00);
lastPing = millis();
}

View File

@ -2,3 +2,9 @@
#include "./CaiXianlin.h"
CaiXianlin::Transmitter* RFTransmitter = nullptr;
void sendLog(char* message) {
Serial.write("/");
Serial.write(message);
Serial.write((char) 0x00);
}

View File

@ -4,5 +4,6 @@
#include "./CaiXianlin.h"
extern CaiXianlin::Transmitter* RFTransmitter;
void sendLog(char* message);
#endif // Header define