Skip to content

Commit

Permalink
[Legacy] a placeholder for recent Air V7
Browse files Browse the repository at this point in the history
  • Loading branch information
lyusupov committed May 14, 2024
1 parent 8198299 commit 0ca5ab0
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
36 changes: 36 additions & 0 deletions software/firmware/source/SoftRF/src/protocol/radio/Legacy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
35 changes: 34 additions & 1 deletion software/firmware/source/SoftRF/src/protocol/radio/Legacy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -115,6 +130,8 @@ enum
TX_STATUS_ON
};

#if USE_AIR_V6

typedef struct {
/********************/
unsigned int addr:24;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 0ca5ab0

Please sign in to comment.