MQTT keepalive and reset devices on master boot

close #1
This commit is contained in:
2025-05-11 20:29:33 +02:00
parent 5c1a32cda2
commit 8995401782
2 changed files with 36 additions and 2 deletions

View File

@ -12,6 +12,7 @@
// needs global define
#define DATA_STOP_BYTE 0x00
#define DATA_RESET_BYTE 0xFF
#define ROTATOR1_TRIGGER_BIT 1
#define ROTATOR1_HIGH_BIT 2
#define ROTATOR2_TRIGGER_BIT 4
@ -95,6 +96,17 @@ void i2cRequest() {
}
}
void i2cReceive(int bytes) {
for (int i = 0; i < bytes && Wire.available(); i++) {
byte data = Wire.read();
if (data == DATA_RESET_BYTE) {
writerPos = readerPos = 0;
} else {
// nothing else yet implemented
}
}
}
uint8_t address = 0;
void setup() {
Serial.begin(115200);
@ -120,6 +132,7 @@ void setup() {
Wire.begin(address);
Wire.onRequest(i2cRequest);
Wire.onReceive(i2cReceive);
}
void loop() {