refactor: remove unused legacy frame format code

The old [0xC8][dest][src][type][size][payload][crc] format was never
used with real hardware. Remove cel_crsf_frame_legacy, *_legacy()
functions, and update tests/tools accordingly.
This commit is contained in:
2026-06-14 20:49:45 +02:00
parent df3d399610
commit dde27ab566
4 changed files with 18 additions and 222 deletions
+2 -47
View File
@@ -133,52 +133,7 @@ void cel_crsf_channel_default(int16_t channels[16]) {
}
/* --------------------------------------------------------------------------- */
/* Deprecated (old frame format) */
/* Telemetry parsing */
/* --------------------------------------------------------------------------- */
int cel_crsf_frame_validate(cel_crsf_frame_legacy const* frame) {
uint8_t data[260];
size_t offset = 0;
data[offset++] = frame->destination;
data[offset++] = frame->source;
data[offset++] = frame->type;
data[offset++] = frame->size;
memcpy(data + offset, frame->payload, frame->size);
offset += frame->size;
uint8_t calc_crc = cel_crsf_crc(data, offset);
return calc_crc == frame->crc ? 0 : -1;
}
int cel_crsf_frame_parse_legacy(cel_crsf_frame_legacy* frame, uint8_t const* buf,
size_t len) {
if (frame == NULL || buf == NULL) return -1;
if (len < 5) return -1;
if (buf[0] != CEL_CRSF_FRAME_HEADER) return -1;
frame->destination = buf[1];
frame->source = buf[2];
frame->type = buf[3];
frame->size = buf[4];
uint8_t size = buf[4];
size_t total = 6 + size;
if (len < total) return -1;
memcpy(frame->payload, buf + 5, size);
frame->crc = buf[5 + size];
return cel_crsf_frame_validate(frame);
}
size_t cel_crsf_frame_build_legacy(uint8_t* dst, uint8_t destination,
uint8_t source, uint8_t type,
uint8_t const* payload, uint8_t size) {
if (dst == NULL) return 0;
dst[0] = CEL_CRSF_FRAME_HEADER;
dst[1] = destination;
dst[2] = source;
dst[3] = type;
dst[4] = size;
if (payload != NULL && size > 0) {
memcpy(dst + 5, payload, size);
}
uint8_t crc = cel_crsf_crc(dst + 1, 3 + 1 + size);
dst[5 + size] = crc;
return 1 + 3 + 1 + size + 1;
}
/* See crsf_telemetry.c */
-19
View File
@@ -109,22 +109,3 @@ void cel_crsf_channel_default(int16_t channels[16]);
/* Parameter protocol — see crsf_param.h */
#include "celrs/crsf_param.h"
/* --- Deprecated (old frame format: [0xC8][dest][src][type][size][payload][crc]) --- */
/* Deprecated frame structure (old format). Use cel_crsf_frame instead. */
typedef struct {
uint8_t destination;
uint8_t source;
uint8_t type;
uint8_t size;
uint8_t payload[255];
uint8_t crc;
} cel_crsf_frame_legacy;
int cel_crsf_frame_validate(cel_crsf_frame_legacy const* frame);
int cel_crsf_frame_parse_legacy(cel_crsf_frame_legacy* frame, uint8_t const* buf,
size_t len);
size_t cel_crsf_frame_build_legacy(uint8_t* dst, uint8_t destination,
uint8_t source, uint8_t type,
uint8_t const* payload, uint8_t size);