From 0ca5ab0e1dddd654bad4d2215eb72ddbbd959850 Mon Sep 17 00:00:00 2001 From: Linar Yusupov Date: Tue, 14 May 2024 10:18:04 +0300 Subject: [PATCH] [Legacy] a placeholder for recent Air V7 --- .../SoftRF/src/protocol/radio/Legacy.cpp | 36 +++++++++++++++++++ .../source/SoftRF/src/protocol/radio/Legacy.h | 35 +++++++++++++++++- 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/software/firmware/source/SoftRF/src/protocol/radio/Legacy.cpp b/software/firmware/source/SoftRF/src/protocol/radio/Legacy.cpp index 03af95127..468ca4050 100644 --- a/software/firmware/source/SoftRF/src/protocol/radio/Legacy.cpp +++ b/software/firmware/source/SoftRF/src/protocol/radio/Legacy.cpp @@ -141,11 +141,19 @@ static const uint32_t table[8] = LEGACY_KEY1; void make_key(uint32_t key[4], uint32_t timestamp, uint32_t address) { int8_t i, ndx; for (i = 0; i < 4; i++) { +#if USE_AIR_V6 ndx = ((timestamp >> 23) & 1) ? i+4 : i ; +#elif USE_AIR_V7 + ndx = i ; +#else +#error "Unknown AIR protocol version" +#endif /* USE_AIR_Vx */ key[i] = obscure(table[ndx] ^ ((timestamp >> 6) ^ address), LEGACY_KEY2) ^ LEGACY_KEY3; } } +#if USE_AIR_V6 + bool legacy_decode(void *legacy_pkt, ufo_t *this_aircraft, ufo_t *fop) { legacy_packet_t *pkt = (legacy_packet_t *) legacy_pkt; @@ -319,3 +327,31 @@ size_t legacy_encode(void *legacy_pkt, ufo_t *this_aircraft) { return (sizeof(legacy_packet_t)); } + +#elif USE_AIR_V7 +/* + * Volunteer contributors are welcome: + * https://pastebin.com/YB1ppAbt + */ + +bool legacy_decode(void *legacy_pkt, ufo_t *this_aircraft, ufo_t *fop) { + + legacy_packet_t *pkt = (legacy_packet_t *) legacy_pkt; + + /* TODO */ + + return false /* true */; +} + +size_t legacy_encode(void *legacy_pkt, ufo_t *this_aircraft) { + + legacy_packet_t *pkt = (legacy_packet_t *) legacy_pkt; + + /* TODO */ + + return (sizeof(legacy_packet_t)); +} + +#else +#error "Unknown AIR protocol version" +#endif /* USE_AIR_Vx */ diff --git a/software/firmware/source/SoftRF/src/protocol/radio/Legacy.h b/software/firmware/source/SoftRF/src/protocol/radio/Legacy.h index 913c31c9f..33762ef7e 100644 --- a/software/firmware/source/SoftRF/src/protocol/radio/Legacy.h +++ b/software/firmware/source/SoftRF/src/protocol/radio/Legacy.h @@ -35,8 +35,23 @@ #define LEGACY_TX_INTERVAL_MIN 600 /* in ms */ #define LEGACY_TX_INTERVAL_MAX 1400 +#define USE_AIR_V6 1 +#define USE_AIR_V7 0 + +#if USE_AIR_V6 #define LEGACY_KEY1 { 0xe43276df, 0xdca83759, 0x9802b8ac, 0x4675a56b, \ 0xfc78ea65, 0x804b90ea, 0xb76542cd, 0x329dfa32 } +#elif USE_AIR_V7 +/* + * Volunteer contributors are welcome: + * https://pastebin.com/YB1ppAbt + */ + +#define LEGACY_KEY1 { 0xA5F9B21C, 0xAB3F9D12, 0xC6F34E34, 0xD72FA378 } +#else +#error "Unknown AIR protocol version" +#endif /* USE_AIR_Vx */ + #define LEGACY_KEY2 0x045d9f3b #define LEGACY_KEY3 0x87b562f4 @@ -115,6 +130,8 @@ enum TX_STATUS_ON }; +#if USE_AIR_V6 + typedef struct { /********************/ unsigned int addr:24; @@ -144,7 +161,23 @@ typedef struct { /********************/ } __attribute__((packed)) legacy_packet_t; -bool legacy_decode(void *, ufo_t *, ufo_t *); +#elif USE_AIR_V7 +/* + * Volunteer contributors are welcome: + * https://pastebin.com/YB1ppAbt + */ + +typedef struct { + + /* TODO */ + +} __attribute__((packed)) legacy_packet_t; + +#else +#error "Unknown AIR protocol version" +#endif /* USE_AIR_Vx */ + +bool legacy_decode(void *, ufo_t *, ufo_t *); size_t legacy_encode(void *, ufo_t *); extern const rf_proto_desc_t legacy_proto_desc;