Skip to content

Commit

Permalink
Reverse address
Browse files Browse the repository at this point in the history
  • Loading branch information
goebish committed May 20, 2019
1 parent 12e5d07 commit a5b8391
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ SDR Panchip XN297(L) dumper

![Screenshot](https://i.imgur.com/MEDWbKr.png)

### Requirements
- gnuradio, tested with 3.7.13.4
- 2.4 Ghz, 4 MHz bandwidth capable SDR device, tested with HackRF One

17 changes: 11 additions & 6 deletions xn297 decoder/xn297decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ void xn297decoder::decodeStd()
const uint16_t crc_initial = 0xb5d2;
const uint8_t crc_size = 2;

static uint8_t byte, bit_count, byte_count, crc_index;
static uint8_t byte, bit_count, byte_count, crc_index, address[5];
static bool in_packet = false;
static uint16_t crc, packet_crc;
static QString log;
Expand Down Expand Up @@ -205,16 +205,22 @@ void xn297decoder::decodeStd()
if (byte_count < addressLength) {
crc = crc16_update(crc, byte, 8);
byte = byte ^ (scrambled ? xn297_scramble[byte_count] : 0);
address[addressLength-1-byte_count] = byte;
}
else if (byte_count < addressLength + payloadLength) {
crc = crc16_update(crc, byte, 8);
byte = bit_reverse(byte ^ (scrambled ? xn297_scramble[byte_count] : 0));
}
if (byte_count == addressLength || byte_count == addressLength + payloadLength)
if (byte_count == addressLength) {
for (uint8_t j = 0; j < addressLength; j++) {
log += temp.sprintf("%02x ", address[j]);
}
}
if(byte_count == addressLength || byte_count == addressLength + payloadLength)
log += "<b>|</b> ";
if (byte_count < addressLength + payloadLength)
if (byte_count >= addressLength && byte_count < addressLength + payloadLength)
log += temp.sprintf("%02X ", byte);
else // crc bytes
else if (byte_count >= addressLength + payloadLength) // crc bytes
packet_crc |= (uint16_t)byte << (8 * crc_index--);
bit_count = 0;
byte = 0;
Expand Down Expand Up @@ -291,10 +297,9 @@ void xn297decoder::decodeEnhanced()
}
bit_count++;
if (bit_count > 7) {
// TODO: reverse address
if (byte_count < addressLength) {
crc = crc16_update(crc, byte, 8);
address[address_index++] = byte ^ (scrambled ? xn297_scramble[byte_count] : 0);
address[addressLength-1-address_index++] = byte ^ (scrambled ? xn297_scramble[byte_count] : 0);
}
else if (byte_count == addressLength) { // 8 msb of PCF
crc = crc16_update(crc, byte, 8);
Expand Down

0 comments on commit a5b8391

Please sign in to comment.