makes GPIO_PIN_RST optional for the sx1276
[ExpressLRS.git] / src / lib / StubbornSender / stubborn_sender.h
blobbe9fd5b8c5f7f81996a6ce9c0ac8fcd7b3fd58a5
1 #pragma once
3 #include <cstdint>
5 // The number of times to resend the same package index before going to RESYNC
6 #define SSENDER_MAX_MISSED_PACKETS 20
8 typedef enum {
9 SENDER_IDLE = 0,
10 SENDING,
11 WAIT_UNTIL_NEXT_CONFIRM,
12 RESYNC,
13 RESYNC_THEN_SEND, // perform a RESYNC then go to SENDING
14 } stubborn_sender_state_s;
16 class StubbornSender
18 public:
19 StubbornSender(uint8_t maxPackageIndex);
20 void ResetState();
21 void UpdateTelemetryRate(uint16_t airRate, uint8_t tlmRatio, uint8_t tlmBurst);
22 void SetDataToTransmit(uint8_t lengthToTransmit, uint8_t* dataToTransmit, uint8_t bytesPerCall);
23 void GetCurrentPayload(uint8_t *packageIndex, uint8_t *count, uint8_t **currentData);
24 void ConfirmCurrentPayload(bool telemetryConfirmValue);
25 bool IsActive();
26 uint16_t GetMaxPacketsBeforeResync() const { return maxWaitCount; }
27 private:
28 uint8_t *data;
29 uint8_t length;
30 uint8_t bytesPerCall;
31 uint8_t currentOffset;
32 uint8_t currentPackage;
33 bool waitUntilTelemetryConfirm;
34 bool resetState;
35 uint16_t waitCount;
36 uint16_t maxWaitCount;
37 uint8_t maxPackageIndex;
38 volatile stubborn_sender_state_s senderState;