mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2026-10-30 21:44:24 +00:00
HoTT, XN297 emu: compute the hop and CRC xorout tables (-1.2 KB) (#1199)
* HoTT: compute the hop table from the hop value (-1 KB) The 16 hop tables are generated from the 16 bit value sent in packet[0..1]: the C library rand() LCG (low 16 bits: x = x * 0x4E6D + 0x3039) seeded with it drives forward Fisher-Yates shuffles, first of the order of the 5 bands of 15 channels, then of the channels of each band, hop i being in the band at position i%5. This gives back the 16 tables bit for bit, and for any seed a 75 channel permutation with the same band structure. * XN297 emu: compute the CRC xorout instead of the 4 tables The XN297 CRC is CRC-16/CCITT with init 0xFFFF and xorout 0xFFFF over the unscrambled address, pcf and payload, sent scrambled. The emulation computes it from 0xB5D2 over the bits as sent, so the xorout for a CRC over n bits is CRC(init 0xFFFF^0xB5D2) of n scramble (or zero) bits, xor 0xFFFF, xor the 16 scramble bits at the CRC. The scramble bits come from the LFSR behind xn297_scramble[] (1110001, then s[i] = s[i-7] ^ s[i-3]), which also covers the last enhanced entries, past the end of that table. It is the generator Goebish gave for the scramble sequence in a comment on https://mcumix.blogspot.com/2016/07/reverse-engineering-24ghz-rf-chip-xn297.html (seed 0x71, feedback bit 6 ^ bit 2, MSB first). All the entries of the 4 tables are given back but two: entry 0 (3 byte address, no payload) was a 0 placeholder, and scrambled entry 1 (3 byte address, 1 byte payload) was 0x3448 where the formula gives 0xE348.
This commit is contained in:
@@ -41,6 +41,7 @@ static void __attribute__((unused)) XN297_RFChannel(uint8_t);
|
||||
static void __attribute__((unused)) XN297_SetPower();
|
||||
static void __attribute__((unused)) XN297_SetFreqOffset();
|
||||
static bool __attribute__((unused)) XN297_IsPacketSent();
|
||||
static uint16_t __attribute__((unused)) XN297_crc_xorout(bool, uint16_t);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user