[FL-2920] WS: add protocol Acurite-606TX, LaCrosse_TX141THBv2 (#1898)

* WS: add protocol Acurite-606TX
* WS: history, added display of the channel (if any) in the general list
* WS: added display of the button state if it is on the transmitter, and displaying the data that is in the signal
* WS: fix batt info
* WS: add protocol LaCrosse_TX141THBv2
* WS; fix syntax
* Furi: bump api_symbols version

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Skorpionm
2022-10-20 21:26:28 +04:00
committed by GitHub
parent 33892ebfb7
commit c1bb10a694
16 changed files with 1016 additions and 50 deletions

View File

@@ -79,4 +79,141 @@ uint8_t subghz_protocol_blocks_crc8(
}
}
return remainder;
}
uint8_t subghz_protocol_blocks_crc8le(
uint8_t const message[],
unsigned nBytes,
uint8_t polynomial,
uint8_t init) {
uint8_t remainder = subghz_protocol_blocks_reverse_key(init, 8);
unsigned byte, bit;
polynomial = subghz_protocol_blocks_reverse_key(polynomial, 8);
for(byte = 0; byte < nBytes; ++byte) {
remainder ^= message[byte];
for(bit = 0; bit < 8; ++bit) {
if(remainder & 1) {
remainder = (remainder >> 1) ^ polynomial;
} else {
remainder = (remainder >> 1);
}
}
}
return remainder;
}
uint16_t subghz_protocol_blocks_crc16lsb(
uint8_t const message[],
unsigned nBytes,
uint16_t polynomial,
uint16_t init) {
uint16_t remainder = init;
unsigned byte, bit;
for(byte = 0; byte < nBytes; ++byte) {
remainder ^= message[byte];
for(bit = 0; bit < 8; ++bit) {
if(remainder & 1) {
remainder = (remainder >> 1) ^ polynomial;
} else {
remainder = (remainder >> 1);
}
}
}
return remainder;
}
uint16_t subghz_protocol_blocks_crc16(
uint8_t const message[],
unsigned nBytes,
uint16_t polynomial,
uint16_t init) {
uint16_t remainder = init;
unsigned byte, bit;
for(byte = 0; byte < nBytes; ++byte) {
remainder ^= message[byte] << 8;
for(bit = 0; bit < 8; ++bit) {
if(remainder & 0x8000) {
remainder = (remainder << 1) ^ polynomial;
} else {
remainder = (remainder << 1);
}
}
}
return remainder;
}
uint8_t subghz_protocol_blocks_lfsr_digest8(
uint8_t const message[],
unsigned bytes,
uint8_t gen,
uint8_t key) {
uint8_t sum = 0;
for(unsigned k = 0; k < bytes; ++k) {
uint8_t data = message[k];
for(int i = 7; i >= 0; --i) {
// XOR key into sum if data bit is set
if((data >> i) & 1) sum ^= key;
// roll the key right (actually the lsb is dropped here)
// and apply the gen (needs to include the dropped lsb as msb)
if(key & 1)
key = (key >> 1) ^ gen;
else
key = (key >> 1);
}
}
return sum;
}
uint8_t subghz_protocol_blocks_lfsr_digest8_reflect(
uint8_t const message[],
int bytes,
uint8_t gen,
uint8_t key) {
uint8_t sum = 0;
// Process message from last byte to first byte (reflected)
for(int k = bytes - 1; k >= 0; --k) {
uint8_t data = message[k];
// Process individual bits of each byte (reflected)
for(int i = 0; i < 8; ++i) {
// XOR key into sum if data bit is set
if((data >> i) & 1) {
sum ^= key;
}
// roll the key left (actually the lsb is dropped here)
// and apply the gen (needs to include the dropped lsb as msb)
if(key & 0x80)
key = (key << 1) ^ gen;
else
key = (key << 1);
}
}
return sum;
}
uint16_t subghz_protocol_blocks_lfsr_digest16(
uint8_t const message[],
unsigned bytes,
uint16_t gen,
uint16_t key) {
uint16_t sum = 0;
for(unsigned k = 0; k < bytes; ++k) {
uint8_t data = message[k];
for(int i = 7; i >= 0; --i) {
// if data bit is set then xor with key
if((data >> i) & 1) sum ^= key;
// roll the key right (actually the lsb is dropped here)
// and apply the gen (needs to include the dropped lsb as msb)
if(key & 1)
key = (key >> 1) ^ gen;
else
key = (key >> 1);
}
}
return sum;
}

View File

@@ -19,7 +19,7 @@ extern "C" {
* @param key In data
* @param count_bit number of data bits
* @return Reverse data
*/
**/
uint64_t subghz_protocol_blocks_reverse_key(uint64_t key, uint8_t count_bit);
/**
@@ -27,7 +27,7 @@ uint64_t subghz_protocol_blocks_reverse_key(uint64_t key, uint8_t count_bit);
* @param key In data
* @param count_bit number of data bits
* @return parity
*/
**/
uint8_t subghz_protocol_blocks_get_parity(uint64_t key, uint8_t count_bit);
/**
@@ -37,7 +37,7 @@ uint8_t subghz_protocol_blocks_get_parity(uint64_t key, uint8_t count_bit);
* @param polynomial CRC polynomial
* @param init starting crc value
* @return CRC value
*/
**/
uint8_t subghz_protocol_blocks_crc4(
uint8_t const message[],
unsigned nBytes,
@@ -51,7 +51,7 @@ uint8_t subghz_protocol_blocks_crc4(
* @param polynomial CRC polynomial
* @param init starting crc value
* @return CRC value
*/
**/
uint8_t subghz_protocol_blocks_crc7(
uint8_t const message[],
unsigned nBytes,
@@ -67,13 +67,100 @@ uint8_t subghz_protocol_blocks_crc7(
* @param polynomial byte is from x^7 to x^0 (x^8 is implicitly one)
* @param init starting crc value
* @return CRC value
*/
**/
uint8_t subghz_protocol_blocks_crc8(
uint8_t const message[],
unsigned nBytes,
uint8_t polynomial,
uint8_t init);
/**
* "Little-endian" Cyclic Redundancy Check CRC-8 LE
* Input and output are reflected, i.e. least significant bit is shifted in first.
* @param message array of bytes to check
* @param nBytes number of bytes in message
* @param polynomial CRC polynomial
* @param init starting crc value
* @return CRC value
**/
uint8_t subghz_protocol_blocks_crc8le(
uint8_t const message[],
unsigned nBytes,
uint8_t polynomial,
uint8_t init);
/**
* CRC-16 LSB.
* Input and output are reflected, i.e. least significant bit is shifted in first.
* Note that poly and init already need to be reflected.
* @param message array of bytes to check
* @param nBytes number of bytes in message
* @param polynomial CRC polynomial
* @param init starting crc value
* @return CRC value
**/
uint16_t subghz_protocol_blocks_crc16lsb(
uint8_t const message[],
unsigned nBytes,
uint16_t polynomial,
uint16_t init);
/**
* CRC-16.
* @param message array of bytes to check
* @param nBytes number of bytes in message
* @param polynomial CRC polynomial
* @param init starting crc value
* @return CRC value
**/
uint16_t subghz_protocol_blocks_crc16(
uint8_t const message[],
unsigned nBytes,
uint16_t polynomial,
uint16_t init);
/**
* Digest-8 by "LFSR-based Toeplitz hash".
* @param message bytes of message data
* @param bytes number of bytes to digest
* @param gen key stream generator, needs to includes the MSB if the LFSR is rolling
* @param key initial key
* @return digest value
**/
uint8_t subghz_protocol_blocks_lfsr_digest8(
uint8_t const message[],
unsigned bytes,
uint8_t gen,
uint8_t key);
/**
* Digest-8 by "LFSR-based Toeplitz hash", byte reflect, bit reflect.
* @param message bytes of message data
* @param bytes number of bytes to digest
* @param gen key stream generator, needs to includes the MSB if the LFSR is rolling
* @param key initial key
* @return digest value
**/
uint8_t subghz_protocol_blocks_lfsr_digest8_reflect(
uint8_t const message[],
int bytes,
uint8_t gen,
uint8_t key);
/**
* Digest-16 by "LFSR-based Toeplitz hash".
* @param message bytes of message data
* @param bytes number of bytes to digest
* @param gen key stream generator, needs to includes the MSB if the LFSR is rolling
* @param key initial key
* @return digest value
**/
uint16_t subghz_protocol_blocks_lfsr_digest16(
uint8_t const message[],
unsigned bytes,
uint16_t gen,
uint16_t key);
#ifdef __cplusplus
}
#endif