4 #include "crsf_protocol.h"
6 enum CustomTelemSubTypeID
: uint8_t {
7 CRSF_AP_CUSTOM_TELEM_SINGLE_PACKET_PASSTHROUGH
= 0xF0,
8 CRSF_AP_CUSTOM_TELEM_STATUS_TEXT
= 0xF1,
9 CRSF_AP_CUSTOM_TELEM_MULTI_PACKET_PASSTHROUGH
= 0xF2,
18 typedef struct crsf_telemetry_package_t
{
22 volatile bool updated
;
24 } crsf_telemetry_package_t
;
26 #define PAYLOAD_DATA(type0, type1, type2, type3, type4, type5)\
28 CRSF_TELEMETRY_TOTAL_SIZE(CRSF_FRAME_##type0##_PAYLOAD_SIZE) + \
29 CRSF_TELEMETRY_TOTAL_SIZE(CRSF_FRAME_##type1##_PAYLOAD_SIZE) + \
30 CRSF_TELEMETRY_TOTAL_SIZE(CRSF_FRAME_##type2##_PAYLOAD_SIZE) + \
31 CRSF_TELEMETRY_TOTAL_SIZE(CRSF_FRAME_##type3##_PAYLOAD_SIZE) + \
32 CRSF_TELEMETRY_TOTAL_SIZE(CRSF_FRAME_##type4##_PAYLOAD_SIZE) + \
33 CRSF_TELEMETRY_TOTAL_SIZE(CRSF_FRAME_##type5##_PAYLOAD_SIZE) + \
34 CRSF_TELEMETRY_TOTAL_SIZE(CRSF_FRAME_GENERAL_RESP_PAYLOAD_SIZE) + \
35 CRSF_TELEMETRY_TOTAL_SIZE(CRSF_FRAME_GENERAL_RESP_PAYLOAD_SIZE)]; \
36 crsf_telemetry_package_t payloadTypes[] = {\
37 {CRSF_FRAMETYPE_##type0, CRSF_TELEMETRY_TOTAL_SIZE(CRSF_FRAME_##type0##_PAYLOAD_SIZE), false, false, 0},\
38 {CRSF_FRAMETYPE_##type1, CRSF_TELEMETRY_TOTAL_SIZE(CRSF_FRAME_##type1##_PAYLOAD_SIZE), false, false, 0},\
39 {CRSF_FRAMETYPE_##type2, CRSF_TELEMETRY_TOTAL_SIZE(CRSF_FRAME_##type2##_PAYLOAD_SIZE), false, false, 0},\
40 {CRSF_FRAMETYPE_##type3, CRSF_TELEMETRY_TOTAL_SIZE(CRSF_FRAME_##type3##_PAYLOAD_SIZE), false, false, 0},\
41 {CRSF_FRAMETYPE_##type4, CRSF_TELEMETRY_TOTAL_SIZE(CRSF_FRAME_##type4##_PAYLOAD_SIZE), false, false, 0},\
42 {CRSF_FRAMETYPE_##type5, CRSF_TELEMETRY_TOTAL_SIZE(CRSF_FRAME_##type5##_PAYLOAD_SIZE), false, false, 0},\
43 {0, CRSF_TELEMETRY_TOTAL_SIZE(CRSF_FRAME_GENERAL_RESP_PAYLOAD_SIZE), false, false, 0},\
44 {0, CRSF_TELEMETRY_TOTAL_SIZE(CRSF_FRAME_GENERAL_RESP_PAYLOAD_SIZE), false, false, 0}};\
45 const uint8_t payloadTypesCount = (sizeof(payloadTypes)/sizeof(crsf_telemetry_package_t))
51 bool RXhandleUARTin(uint8_t data
);
53 bool ShouldCallBootloader();
54 bool ShouldCallEnterBind();
55 bool ShouldCallUpdateModelMatch();
56 bool ShouldSendDeviceFrame();
57 uint8_t GetUpdatedModelMatch() { return modelMatchId
; }
58 bool GetNextPayload(uint8_t* nextPayloadSize
, uint8_t **payloadData
);
59 uint8_t UpdatedPayloadCount();
60 uint8_t ReceivedPackagesCount();
61 bool AppendTelemetryPackage(uint8_t *package
);
63 void AppendToPackage(volatile crsf_telemetry_package_t
*current
);
64 uint8_t CRSFinBuffer
[CRSF_MAX_PACKET_LEN
];
65 telemetry_state_s telemetry_state
;
66 uint8_t currentTelemetryByte
;
67 uint8_t currentPayloadIndex
;
68 volatile crsf_telemetry_package_t
*telemetryPackageHead
;
69 uint8_t receivedPackages
;
72 bool callUpdateModelMatch
;