aboutsummaryrefslogtreecommitdiff
path: root/src/helpers/ArduinoSerialInterface.h
diff options
context:
space:
mode:
authorScott Powell <sqij@protonmail.com>2025-01-28 23:26:55 +1100
committerScott Powell <sqij@protonmail.com>2025-01-28 23:26:55 +1100
commitcd81878e92ecdc6cc3746f2d007a4f4eebf08a2d (patch)
treebba93767b79a20a95e58aef5bb6ff37caed68323 /src/helpers/ArduinoSerialInterface.h
parentd9dc76f1979906d1d0f294085fc931603aff170a (diff)
* added helpers/ArduinoSerialInterface, for the 'companion radio'
* .ini, target envs: Heltec_v3_companion_radio_usb & Heltec_v3_companion_radio_ble
Diffstat (limited to 'src/helpers/ArduinoSerialInterface.h')
-rw-r--r--src/helpers/ArduinoSerialInterface.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/helpers/ArduinoSerialInterface.h b/src/helpers/ArduinoSerialInterface.h
new file mode 100644
index 00000000..2666016d
--- /dev/null
+++ b/src/helpers/ArduinoSerialInterface.h
@@ -0,0 +1,29 @@
+#pragma once
+
+#include "BaseSerialInterface.h"
+#include <Arduino.h>
+
+class ArduinoSerialInterface : public BaseSerialInterface {
+ bool _isEnabled;
+ uint8_t _state;
+ uint8_t _frame_len;
+ uint8_t rx_len;
+ HardwareSerial* _serial;
+ uint8_t rx_buf[MAX_FRAME_SIZE];
+
+public:
+ ArduinoSerialInterface() { _isEnabled = false; _state = 0; }
+
+ void begin(HardwareSerial& serial) { _serial = &serial; }
+
+ // BaseSerialInterface methods
+ void enable() override;
+ void disable() override;
+ bool isEnabled() const override { return _isEnabled; }
+
+ bool isConnected() const override;
+
+ bool isWriteBusy() const override;
+ size_t writeFrame(const uint8_t src[], size_t len) override;
+ size_t checkRecvFrame(uint8_t dest[]) override;
+}; \ No newline at end of file