subghz marantec protocol implement crc verification and add manually

fix crc function, add valid/invalid display (does not affect TX) and use new crc sum in add manually menu
This commit is contained in:
MX
2025-07-06 18:42:16 +03:00
parent 6ae1ce6861
commit 43b35019ed
6 changed files with 99 additions and 4 deletions

View File

@@ -126,6 +126,8 @@ typedef enum {
SetTypeHollarm_433,
SetTypeReversRB2_433,
SetTypeMarantec24_868,
SetTypeMarantec_433,
SetTypeMarantec_868,
SetTypeLinear_300_00,
// SetTypeNeroSketch, //Deleted in OFW
// SetTypeNeroRadio, //Deleted in OFW

View File

@@ -6,6 +6,7 @@
#include <lib/subghz/protocols/secplus_v1.h>
#include <lib/subghz/protocols/secplus_v2.h>
#include <lib/subghz/protocols/nice_flor_s.h>
#include <lib/subghz/protocols/marantec.h>
#include <flipper_format/flipper_format_i.h>
#include <lib/toolbox/stream/stream.h>
@@ -395,3 +396,27 @@ void subghz_txrx_gen_serial_gangqi(uint64_t* result_key) {
// serial | const_and_button
*result_key = (serial << 18) | (const_and_button << 10) | (bytesum << 2);
}
void subghz_txrx_gen_key_marantec(uint64_t* result_key) {
uint64_t randkey = (uint64_t)rand();
uint32_t serial = (uint32_t)((randkey) & 0xFFFFF);
// 0x130 is the constant
// 0x4 is the button code
// 0x86 is the serial constant
// serial is random value that we pre generate above
// At the end we will put the crc sum
uint64_t full_key_no_crc = (uint64_t)((uint64_t)0x130 << 40 | (uint64_t)serial << 20 |
(uint64_t)0x4 << 16 | (uint64_t)0x86 << 8);
uint8_t tdata[6] = {
full_key_no_crc >> 48,
full_key_no_crc >> 40,
full_key_no_crc >> 32,
full_key_no_crc >> 24,
full_key_no_crc >> 16,
full_key_no_crc >> 8};
uint8_t crc = subghz_protocol_marantec_crc8(tdata, sizeof(tdata));
*result_key = ((full_key_no_crc >> 8) << 8) | crc;
}

View File

@@ -153,3 +153,10 @@ bool subghz_txrx_gen_secplus_v1_protocol(
* @return uint64_t if success
*/
void subghz_txrx_gen_serial_gangqi(uint64_t* result_key);
/**
* Generate key for Marantec protocol
*
* @param result_key Pointer to a uint64_t where the key will be stored
*/
void subghz_txrx_gen_key_marantec(uint64_t* result_key);