mirror of
https://github.com/D4C1-Labs/Flipper-ARF.git
synced 2026-03-29 13:59:52 +00:00
Compare commits
2 Commits
dev-22daa7
...
dev-cb9aee
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb9aee6422 | ||
|
|
b720fac88a |
110
applications/main/subghz/resources/subghz/assets/setting_user
Normal file
110
applications/main/subghz/resources/subghz/assets/setting_user
Normal file
@@ -0,0 +1,110 @@
|
||||
# to use manual settings and prevent them from being deleted on upgrade, rename *_user.example files to *_user
|
||||
Filetype: Flipper SubGhz Setting File
|
||||
Version: 1
|
||||
# Add Standard frequencies included with firmware and place user frequencies after them
|
||||
#Add_standard_frequencies: false
|
||||
|
||||
# Default Frequency: used as default for "Read" and "Read Raw"
|
||||
#Default_frequency: 433920000
|
||||
|
||||
# Frequencies used for "Read", "Read Raw" and "Frequency Analyzer"
|
||||
Frequency: 300000000
|
||||
Frequency: 302757000
|
||||
Frequency: 303000000
|
||||
Frequency: 303875000
|
||||
Frequency: 303900000
|
||||
Frequency: 304250000
|
||||
Frequency: 307000000
|
||||
Frequency: 307500000
|
||||
Frequency: 307800000
|
||||
Frequency: 309000000
|
||||
Frequency: 310000000
|
||||
Frequency: 312000000
|
||||
Frequency: 312100000
|
||||
Frequency: 312200000
|
||||
Frequency: 313000000
|
||||
Frequency: 313850000
|
||||
Frequency: 314000000
|
||||
Frequency: 314350000
|
||||
Frequency: 314980000
|
||||
Frequency: 315000000
|
||||
Frequency: 318000000
|
||||
Frequency: 320000000
|
||||
Frequency: 320150000
|
||||
Frequency: 330000000
|
||||
Frequency: 345000000
|
||||
Frequency: 348000000
|
||||
Frequency: 350000000
|
||||
Frequency: 387000000
|
||||
Frequency: 390000000
|
||||
Frequency: 418000000
|
||||
Frequency: 430000000
|
||||
Frequency: 430500000
|
||||
Frequency: 431000000
|
||||
Frequency: 431500000
|
||||
Frequency: 433075000
|
||||
Frequency: 433220000
|
||||
Frequency: 433420000
|
||||
Frequency: 433657070
|
||||
Frequency: 433880000
|
||||
Frequency: 433889000
|
||||
Frequency: 433900000
|
||||
Frequency: 433910000
|
||||
Frequency: 433920000
|
||||
Frequency: 433930000
|
||||
Frequency: 433940000
|
||||
Frequency: 433950000
|
||||
Frequency: 433960000
|
||||
Frequency: 434075000
|
||||
Frequency: 434176948
|
||||
Frequency: 434190000
|
||||
Frequency: 434390000
|
||||
Frequency: 434420000
|
||||
Frequency: 434620000
|
||||
Frequency: 434775000
|
||||
Frequency: 438900000
|
||||
Frequency: 440175000
|
||||
Frequency: 462750000
|
||||
Frequency: 464000000
|
||||
Frequency: 467750000
|
||||
Frequency: 779000000
|
||||
Frequency: 868350000
|
||||
Frequency: 868400000
|
||||
Frequency: 868460000
|
||||
Frequency: 868800000
|
||||
Frequency: 868950000
|
||||
Frequency: 906400000
|
||||
Frequency: 915000000
|
||||
Frequency: 925000000
|
||||
Frequency: 928000000
|
||||
|
||||
# Frequencies used for hopping mode (keep this list small or flipper will miss signal)
|
||||
Hopper_frequency: 315000000
|
||||
Hopper_frequency: 433920000
|
||||
Hopper_frequency: 434420000
|
||||
Hopper_frequency: 868350000
|
||||
|
||||
# Presets used for preset hopping mode (cycles through these modulations)
|
||||
Hopping_Preset: AM650
|
||||
Hopping_Preset: FM476
|
||||
Hopping_Preset: FM95
|
||||
|
||||
# Custom preset
|
||||
# format for CC1101 "Custom_preset_data:" XX YY XX YY .. 00 00 ZZ ZZ ZZ ZZ ZZ ZZ ZZ ZZ, where: XX-register, YY - register data, 00 00 - end load register, ZZ - 8 byte Pa table register
|
||||
|
||||
Custom_preset_name: A1
|
||||
Custom_preset_module: CC1101
|
||||
Custom_preset_data: 02 0D 0B 06 08 32 07 04 14 00 13 00 12 30 11 F8 10 C9 15 14 18 18 19 16 1D 91 1C 00 1B 07 20 FB 22 00 21 55 00 00 00 С0 00 00 00 00 00 00
|
||||
|
||||
Custom_preset_name: FM95
|
||||
Custom_preset_module: CC1101
|
||||
Custom_preset_data: 02 0D 0B 06 08 32 07 04 14 00 13 02 12 04 11 83 10 67 15 24 18 18 19 16 1D 91 1C 00 1B 07 20 FB 22 10 21 56 00 00 C0 00 00 00 00 00 00 00
|
||||
|
||||
Custom_preset_name: F3
|
||||
Custom_preset_module: CC1101
|
||||
Custom_preset_data: 02 0D 03 47 08 32 0B 06 0C 00 0D 10 0E B0 0F 71 10 CA 11 83 12 80 13 22 14 F8 15 42 16 07 17 30 18 18 19 1D 1A 1C 1B 43 1C 40 1D 91 20 FB 21 B6 22 00 23 E9 24 2A 25 00 26 1F 2C 81 2D 35 2E 09 00 00 12 0E 1D 34 60 84 C8 C0
|
||||
|
||||
#2-FSK 200khz BW / 135kHz Filter/ 15.86Khz Deviation + Ramping
|
||||
Custom_preset_name: FM15k
|
||||
Custom_preset_module: CC1101
|
||||
Custom_preset_data: 02 0D 03 47 08 32 0B 06 15 32 14 00 13 00 12 00 11 32 10 A7 18 18 19 1D 1D 92 1C 00 1B 04 20 FB 22 17 21 B6 00 00 00 12 0E 34 60 C5 C1 C0
|
||||
@@ -1,47 +0,0 @@
|
||||
# to use manual settings and prevent them from being deleted on upgrade, rename *_user.example files to *_user
|
||||
Filetype: Flipper SubGhz Setting File
|
||||
Version: 1
|
||||
# Add Standard frequencies included with firmware and place user frequencies after them
|
||||
#Add_standard_frequencies: true
|
||||
|
||||
# Default Frequency: used as default for "Read" and "Read Raw"
|
||||
#Default_frequency: 433920000
|
||||
|
||||
# Frequencies used for "Read", "Read Raw" and "Frequency Analyzer"
|
||||
#Frequency: 300000000
|
||||
#Frequency: 310000000
|
||||
#Frequency: 320000000
|
||||
|
||||
# Frequencies used for hopping mode (keep this list small or flipper will miss signal)
|
||||
#Hopper_frequency: 300000000
|
||||
#Hopper_frequency: 310000000
|
||||
#Hopper_frequency: 310000000
|
||||
|
||||
# Custom preset
|
||||
# format for CC1101 "Custom_preset_data:" XX YY XX YY .. 00 00 ZZ ZZ ZZ ZZ ZZ ZZ ZZ ZZ, where: XX-register, YY - register data, 00 00 - end load register, ZZ - 8 byte Pa table register
|
||||
|
||||
#Custom_preset_name: FM95
|
||||
#Custom_preset_module: CC1101
|
||||
#Custom_preset_data: 02 0D 0B 06 08 32 07 04 14 00 13 02 12 04 11 83 10 67 15 24 18 18 19 16 1D 91 1C 00 1B 07 20 FB 22 10 21 56 00 00 C0 00 00 00 00 00 00 00
|
||||
|
||||
#2-FSK 200khz BW / 135kHz Filter/ 15.86Khz Deviation + Ramping
|
||||
#Custom_preset_name: FM15k
|
||||
#Custom_preset_module: CC1101
|
||||
#Custom_preset_data: 02 0D 03 47 08 32 0B 06 15 32 14 00 13 00 12 00 11 32 10 A7 18 18 19 1D 1D 92 1C 00 1B 04 20 FB 22 17 21 B6 00 00 00 12 0E 34 60 C5 C1 C0
|
||||
|
||||
#Custom_preset_name: Pagers
|
||||
#Custom_preset_module: CC1101
|
||||
#Custom_preset_data: 02 0D 07 04 08 32 0B 06 10 64 11 93 12 0C 13 02 14 00 15 15 18 18 19 16 1B 07 1C 00 1D 91 20 FB 21 56 22 10 00 00 C0 00 00 00 00 00 00 00
|
||||
|
||||
#Custom_preset_name: AM_1
|
||||
#Custom_preset_module: CC1101
|
||||
#Custom_preset_data: 02 0D 03 07 08 32 0B 06 14 00 13 00 12 30 11 32 10 17 18 18 19 18 1D 91 1C 00 1B 07 20 FB 22 11 21 B6 00 00 00 C0 00 00 00 00 00 00
|
||||
|
||||
#Custom_preset_name: AM_2
|
||||
#Custom_preset_module: CC1101
|
||||
#Custom_preset_data: 02 0D 03 07 08 32 0B 06 14 00 13 00 12 30 11 32 10 17 18 18 19 18 1D 91 1C 00 1B 07 20 FB 22 11 21 B6 00 00 00 C0 00 00 00 00 00 00
|
||||
|
||||
# Presets used for preset hopping mode (cycles through these modulations)
|
||||
#Hopping_Preset: AM650
|
||||
#Hopping_Preset: FM238
|
||||
#Hopping_Preset: FM476
|
||||
363
lib/subghz/protocols/keyfinder.c
Normal file
363
lib/subghz/protocols/keyfinder.c
Normal file
@@ -0,0 +1,363 @@
|
||||
#include "keyfinder.h"
|
||||
#include "../blocks/const.h"
|
||||
#include "../blocks/decoder.h"
|
||||
#include "../blocks/encoder.h"
|
||||
#include "../blocks/generic.h"
|
||||
#include "../blocks/math.h"
|
||||
|
||||
#define TAG "SubGhzProtocolKeyFinder"
|
||||
|
||||
static const SubGhzBlockConst subghz_protocol_keyfinder_const = {
|
||||
.te_short = 400,
|
||||
.te_long = 1200,
|
||||
.te_delta = 150,
|
||||
.min_count_bit_for_found = 24,
|
||||
};
|
||||
|
||||
struct SubGhzProtocolDecoderKeyFinder {
|
||||
SubGhzProtocolDecoderBase base;
|
||||
|
||||
SubGhzBlockDecoder decoder;
|
||||
SubGhzBlockGeneric generic;
|
||||
uint8_t end_count;
|
||||
};
|
||||
|
||||
struct SubGhzProtocolEncoderKeyFinder {
|
||||
SubGhzProtocolEncoderBase base;
|
||||
|
||||
SubGhzProtocolBlockEncoder encoder;
|
||||
SubGhzBlockGeneric generic;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
KeyFinderDecoderStepReset = 0,
|
||||
KeyFinderDecoderStepSaveDuration,
|
||||
KeyFinderDecoderStepCheckDuration,
|
||||
KeyFinderDecoderStepFinish,
|
||||
} KeyFinderDecoderStep;
|
||||
|
||||
const SubGhzProtocolDecoder subghz_protocol_keyfinder_decoder = {
|
||||
.alloc = subghz_protocol_decoder_keyfinder_alloc,
|
||||
.free = subghz_protocol_decoder_keyfinder_free,
|
||||
|
||||
.feed = subghz_protocol_decoder_keyfinder_feed,
|
||||
.reset = subghz_protocol_decoder_keyfinder_reset,
|
||||
|
||||
.get_hash_data = subghz_protocol_decoder_keyfinder_get_hash_data,
|
||||
.serialize = subghz_protocol_decoder_keyfinder_serialize,
|
||||
.deserialize = subghz_protocol_decoder_keyfinder_deserialize,
|
||||
.get_string = subghz_protocol_decoder_keyfinder_get_string,
|
||||
};
|
||||
|
||||
const SubGhzProtocolEncoder subghz_protocol_keyfinder_encoder = {
|
||||
.alloc = subghz_protocol_encoder_keyfinder_alloc,
|
||||
.free = subghz_protocol_encoder_keyfinder_free,
|
||||
|
||||
.deserialize = subghz_protocol_encoder_keyfinder_deserialize,
|
||||
.stop = subghz_protocol_encoder_keyfinder_stop,
|
||||
.yield = subghz_protocol_encoder_keyfinder_yield,
|
||||
};
|
||||
|
||||
const SubGhzProtocol subghz_protocol_keyfinder = {
|
||||
.name = SUBGHZ_PROTOCOL_KEYFINDER_NAME,
|
||||
.type = SubGhzProtocolTypeStatic,
|
||||
.flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable |
|
||||
SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save | SubGhzProtocolFlag_Send,
|
||||
|
||||
.decoder = &subghz_protocol_keyfinder_decoder,
|
||||
.encoder = &subghz_protocol_keyfinder_encoder,
|
||||
};
|
||||
|
||||
void* subghz_protocol_encoder_keyfinder_alloc(SubGhzEnvironment* environment) {
|
||||
UNUSED(environment);
|
||||
SubGhzProtocolEncoderKeyFinder* instance = malloc(sizeof(SubGhzProtocolEncoderKeyFinder));
|
||||
|
||||
instance->base.protocol = &subghz_protocol_keyfinder;
|
||||
instance->generic.protocol_name = instance->base.protocol->name;
|
||||
|
||||
instance->encoder.repeat = 5;
|
||||
instance->encoder.size_upload = 60;
|
||||
instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration));
|
||||
instance->encoder.is_running = false;
|
||||
return instance;
|
||||
}
|
||||
|
||||
void subghz_protocol_encoder_keyfinder_free(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolEncoderKeyFinder* instance = context;
|
||||
free(instance->encoder.upload);
|
||||
free(instance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generating an upload from data.
|
||||
* @param instance Pointer to a SubGhzProtocolEncoderKeyFinder instance
|
||||
*/
|
||||
static void
|
||||
subghz_protocol_encoder_keyfinder_get_upload(SubGhzProtocolEncoderKeyFinder* instance) {
|
||||
furi_assert(instance);
|
||||
size_t index = 0;
|
||||
|
||||
// Send key data 24 bit first
|
||||
for(uint8_t i = instance->generic.data_count_bit; i > 0; i--) {
|
||||
if(bit_read(instance->generic.data, i - 1)) {
|
||||
// Send bit 1
|
||||
instance->encoder.upload[index++] =
|
||||
level_duration_make(true, (uint32_t)subghz_protocol_keyfinder_const.te_short);
|
||||
instance->encoder.upload[index++] =
|
||||
level_duration_make(false, (uint32_t)subghz_protocol_keyfinder_const.te_long);
|
||||
|
||||
} else {
|
||||
// Send bit 0
|
||||
instance->encoder.upload[index++] =
|
||||
level_duration_make(true, (uint32_t)subghz_protocol_keyfinder_const.te_long);
|
||||
instance->encoder.upload[index++] =
|
||||
level_duration_make(false, (uint32_t)subghz_protocol_keyfinder_const.te_short);
|
||||
}
|
||||
}
|
||||
// End bits (3 times then 1 more with gap 4k us)
|
||||
for(uint8_t i = 0; i < 3; i++) {
|
||||
instance->encoder.upload[index++] =
|
||||
level_duration_make(true, (uint32_t)subghz_protocol_keyfinder_const.te_short);
|
||||
instance->encoder.upload[index++] =
|
||||
level_duration_make(false, (uint32_t)subghz_protocol_keyfinder_const.te_short);
|
||||
}
|
||||
instance->encoder.upload[index++] =
|
||||
level_duration_make(true, (uint32_t)subghz_protocol_keyfinder_const.te_short);
|
||||
instance->encoder.upload[index++] =
|
||||
level_duration_make(false, (uint32_t)subghz_protocol_keyfinder_const.te_short * 10);
|
||||
|
||||
instance->encoder.size_upload = index;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Analysis of received data
|
||||
* @param instance Pointer to a SubGhzBlockGeneric* instance
|
||||
*/
|
||||
static void subghz_protocol_keyfinder_check_remote_controller(SubGhzBlockGeneric* instance) {
|
||||
instance->serial = instance->data >> 4;
|
||||
instance->btn = instance->data & 0xF;
|
||||
}
|
||||
|
||||
SubGhzProtocolStatus
|
||||
subghz_protocol_encoder_keyfinder_deserialize(void* context, FlipperFormat* flipper_format) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolEncoderKeyFinder* instance = context;
|
||||
SubGhzProtocolStatus ret = SubGhzProtocolStatusError;
|
||||
do {
|
||||
ret = subghz_block_generic_deserialize_check_count_bit(
|
||||
&instance->generic,
|
||||
flipper_format,
|
||||
subghz_protocol_keyfinder_const.min_count_bit_for_found);
|
||||
if(ret != SubGhzProtocolStatusOk) {
|
||||
break;
|
||||
}
|
||||
// Optional value
|
||||
flipper_format_read_uint32(
|
||||
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
|
||||
|
||||
subghz_protocol_keyfinder_check_remote_controller(&instance->generic);
|
||||
subghz_protocol_encoder_keyfinder_get_upload(instance);
|
||||
instance->encoder.is_running = true;
|
||||
} while(false);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void subghz_protocol_encoder_keyfinder_stop(void* context) {
|
||||
SubGhzProtocolEncoderKeyFinder* instance = context;
|
||||
instance->encoder.is_running = false;
|
||||
}
|
||||
|
||||
LevelDuration subghz_protocol_encoder_keyfinder_yield(void* context) {
|
||||
SubGhzProtocolEncoderKeyFinder* instance = context;
|
||||
|
||||
if(instance->encoder.repeat == 0 || !instance->encoder.is_running) {
|
||||
instance->encoder.is_running = false;
|
||||
return level_duration_reset();
|
||||
}
|
||||
|
||||
LevelDuration ret = instance->encoder.upload[instance->encoder.front];
|
||||
|
||||
if(++instance->encoder.front == instance->encoder.size_upload) {
|
||||
if(!subghz_block_generic_global.endless_tx) instance->encoder.repeat--;
|
||||
instance->encoder.front = 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void* subghz_protocol_decoder_keyfinder_alloc(SubGhzEnvironment* environment) {
|
||||
UNUSED(environment);
|
||||
SubGhzProtocolDecoderKeyFinder* instance = malloc(sizeof(SubGhzProtocolDecoderKeyFinder));
|
||||
instance->base.protocol = &subghz_protocol_keyfinder;
|
||||
instance->generic.protocol_name = instance->base.protocol->name;
|
||||
return instance;
|
||||
}
|
||||
|
||||
void subghz_protocol_decoder_keyfinder_free(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderKeyFinder* instance = context;
|
||||
free(instance);
|
||||
}
|
||||
|
||||
void subghz_protocol_decoder_keyfinder_reset(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderKeyFinder* instance = context;
|
||||
instance->decoder.parser_step = KeyFinderDecoderStepReset;
|
||||
}
|
||||
|
||||
void subghz_protocol_decoder_keyfinder_feed(void* context, bool level, volatile uint32_t duration) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderKeyFinder* instance = context;
|
||||
|
||||
// KeyFinder Decoder
|
||||
// 2026.03 - @xMasterX (MMX)
|
||||
|
||||
// Key samples
|
||||
//
|
||||
// 433.92 MHz AM650
|
||||
// Serial ID Serial ID
|
||||
// RED - C396F E = 11000011100101101111 1110
|
||||
// PURPLE - C396F B = 11000011100101101111 1011
|
||||
// GREEN - C396F D = 11000011100101101111 1101
|
||||
// BLUE - C396F C = 11000011100101101111 1100
|
||||
|
||||
switch(instance->decoder.parser_step) {
|
||||
case KeyFinderDecoderStepReset:
|
||||
if((!level) && (DURATION_DIFF(duration, subghz_protocol_keyfinder_const.te_short * 10) <
|
||||
subghz_protocol_keyfinder_const.te_delta * 5)) {
|
||||
//Found GAP
|
||||
instance->decoder.decode_data = 0;
|
||||
instance->decoder.decode_count_bit = 0;
|
||||
instance->decoder.parser_step = KeyFinderDecoderStepSaveDuration;
|
||||
}
|
||||
break;
|
||||
case KeyFinderDecoderStepSaveDuration:
|
||||
if(instance->decoder.decode_count_bit ==
|
||||
subghz_protocol_keyfinder_const.min_count_bit_for_found) {
|
||||
if((level) && (DURATION_DIFF(duration, subghz_protocol_keyfinder_const.te_short) <
|
||||
subghz_protocol_keyfinder_const.te_delta)) {
|
||||
instance->end_count++;
|
||||
if(instance->end_count == 4) {
|
||||
instance->decoder.parser_step = KeyFinderDecoderStepFinish;
|
||||
instance->end_count = 0;
|
||||
}
|
||||
} else if(
|
||||
(!level) && (DURATION_DIFF(duration, subghz_protocol_keyfinder_const.te_short) <
|
||||
subghz_protocol_keyfinder_const.te_delta)) {
|
||||
break;
|
||||
} else {
|
||||
instance->decoder.decode_data = 0;
|
||||
instance->decoder.decode_count_bit = 0;
|
||||
instance->end_count = 0;
|
||||
instance->decoder.parser_step = KeyFinderDecoderStepReset;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if(level) {
|
||||
instance->decoder.te_last = duration;
|
||||
instance->decoder.parser_step = KeyFinderDecoderStepCheckDuration;
|
||||
} else {
|
||||
instance->decoder.parser_step = KeyFinderDecoderStepReset;
|
||||
}
|
||||
break;
|
||||
case KeyFinderDecoderStepCheckDuration:
|
||||
if(!level) {
|
||||
// Bit 1 is short and long timing = 400us HIGH (te_last) and 1200us LOW
|
||||
if((DURATION_DIFF(instance->decoder.te_last, subghz_protocol_keyfinder_const.te_short) <
|
||||
subghz_protocol_keyfinder_const.te_delta) &&
|
||||
(DURATION_DIFF(duration, subghz_protocol_keyfinder_const.te_long) <
|
||||
subghz_protocol_keyfinder_const.te_delta)) {
|
||||
subghz_protocol_blocks_add_bit(&instance->decoder, 1);
|
||||
instance->decoder.parser_step = KeyFinderDecoderStepSaveDuration;
|
||||
// Bit 0 is long and short timing = 1200us HIGH (te_last) and 400us LOW
|
||||
} else if(
|
||||
(DURATION_DIFF(instance->decoder.te_last, subghz_protocol_keyfinder_const.te_long) <
|
||||
subghz_protocol_keyfinder_const.te_delta) &&
|
||||
(DURATION_DIFF(duration, subghz_protocol_keyfinder_const.te_short) <
|
||||
subghz_protocol_keyfinder_const.te_delta)) {
|
||||
subghz_protocol_blocks_add_bit(&instance->decoder, 0);
|
||||
instance->decoder.parser_step = KeyFinderDecoderStepSaveDuration;
|
||||
} else {
|
||||
instance->decoder.parser_step = KeyFinderDecoderStepReset;
|
||||
}
|
||||
} else {
|
||||
instance->decoder.parser_step = KeyFinderDecoderStepReset;
|
||||
}
|
||||
break;
|
||||
case KeyFinderDecoderStepFinish:
|
||||
// If got 24 bits key reading is finished
|
||||
if(instance->decoder.decode_count_bit ==
|
||||
subghz_protocol_keyfinder_const.min_count_bit_for_found) {
|
||||
instance->generic.data = instance->decoder.decode_data;
|
||||
instance->generic.data_count_bit = instance->decoder.decode_count_bit;
|
||||
if(instance->base.callback)
|
||||
instance->base.callback(&instance->base, instance->base.context);
|
||||
}
|
||||
instance->decoder.decode_data = 0;
|
||||
instance->decoder.decode_count_bit = 0;
|
||||
instance->end_count = 0;
|
||||
instance->decoder.parser_step = KeyFinderDecoderStepReset;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t subghz_protocol_decoder_keyfinder_get_hash_data(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderKeyFinder* instance = context;
|
||||
return subghz_protocol_blocks_get_hash_data(
|
||||
&instance->decoder, (instance->decoder.decode_count_bit / 8) + 1);
|
||||
}
|
||||
|
||||
SubGhzProtocolStatus subghz_protocol_decoder_keyfinder_serialize(
|
||||
void* context,
|
||||
FlipperFormat* flipper_format,
|
||||
SubGhzRadioPreset* preset) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderKeyFinder* instance = context;
|
||||
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
|
||||
}
|
||||
|
||||
SubGhzProtocolStatus
|
||||
subghz_protocol_decoder_keyfinder_deserialize(void* context, FlipperFormat* flipper_format) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderKeyFinder* instance = context;
|
||||
return subghz_block_generic_deserialize_check_count_bit(
|
||||
&instance->generic,
|
||||
flipper_format,
|
||||
subghz_protocol_keyfinder_const.min_count_bit_for_found);
|
||||
}
|
||||
|
||||
void subghz_protocol_decoder_keyfinder_get_string(void* context, FuriString* output) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderKeyFinder* instance = context;
|
||||
|
||||
subghz_protocol_keyfinder_check_remote_controller(&instance->generic);
|
||||
|
||||
uint64_t code_found_reverse = subghz_protocol_blocks_reverse_key(
|
||||
instance->generic.data, instance->generic.data_count_bit);
|
||||
|
||||
// for future use
|
||||
// // push protocol data to global variable
|
||||
// subghz_block_generic_global.btn_is_available = false;
|
||||
// subghz_block_generic_global.current_btn = instance->generic.btn;
|
||||
// subghz_block_generic_global.btn_length_bit = 4;
|
||||
// //
|
||||
|
||||
furi_string_cat_printf(
|
||||
output,
|
||||
"%s %db\r\n"
|
||||
"Key: 0x%06lX\r\n"
|
||||
"Yek: 0x%06lX\r\n"
|
||||
"Serial: 0x%05lX\r\n"
|
||||
"ID: 0x%0X",
|
||||
instance->generic.protocol_name,
|
||||
instance->generic.data_count_bit,
|
||||
(uint32_t)(instance->generic.data & 0xFFFFFF),
|
||||
(uint32_t)(code_found_reverse & 0xFFFFFF),
|
||||
instance->generic.serial,
|
||||
instance->generic.btn);
|
||||
}
|
||||
109
lib/subghz/protocols/keyfinder.h
Normal file
109
lib/subghz/protocols/keyfinder.h
Normal file
@@ -0,0 +1,109 @@
|
||||
#pragma once
|
||||
|
||||
#include "base.h"
|
||||
|
||||
#define SUBGHZ_PROTOCOL_KEYFINDER_NAME "KeyFinder"
|
||||
|
||||
typedef struct SubGhzProtocolDecoderKeyFinder SubGhzProtocolDecoderKeyFinder;
|
||||
typedef struct SubGhzProtocolEncoderKeyFinder SubGhzProtocolEncoderKeyFinder;
|
||||
|
||||
extern const SubGhzProtocolDecoder subghz_protocol_keyfinder_decoder;
|
||||
extern const SubGhzProtocolEncoder subghz_protocol_keyfinder_encoder;
|
||||
extern const SubGhzProtocol subghz_protocol_keyfinder;
|
||||
|
||||
/**
|
||||
* Allocate SubGhzProtocolEncoderKeyFinder.
|
||||
* @param environment Pointer to a SubGhzEnvironment instance
|
||||
* @return SubGhzProtocolEncoderKeyFinder* pointer to a SubGhzProtocolEncoderKeyFinder instance
|
||||
*/
|
||||
void* subghz_protocol_encoder_keyfinder_alloc(SubGhzEnvironment* environment);
|
||||
|
||||
/**
|
||||
* Free SubGhzProtocolEncoderKeyFinder.
|
||||
* @param context Pointer to a SubGhzProtocolEncoderKeyFinder instance
|
||||
*/
|
||||
void subghz_protocol_encoder_keyfinder_free(void* context);
|
||||
|
||||
/**
|
||||
* Deserialize and generating an upload to send.
|
||||
* @param context Pointer to a SubGhzProtocolEncoderKeyFinder instance
|
||||
* @param flipper_format Pointer to a FlipperFormat instance
|
||||
* @return status
|
||||
*/
|
||||
SubGhzProtocolStatus
|
||||
subghz_protocol_encoder_keyfinder_deserialize(void* context, FlipperFormat* flipper_format);
|
||||
|
||||
/**
|
||||
* Forced transmission stop.
|
||||
* @param context Pointer to a SubGhzProtocolEncoderKeyFinder instance
|
||||
*/
|
||||
void subghz_protocol_encoder_keyfinder_stop(void* context);
|
||||
|
||||
/**
|
||||
* Getting the level and duration of the upload to be loaded into DMA.
|
||||
* @param context Pointer to a SubGhzProtocolEncoderKeyFinder instance
|
||||
* @return LevelDuration
|
||||
*/
|
||||
LevelDuration subghz_protocol_encoder_keyfinder_yield(void* context);
|
||||
|
||||
/**
|
||||
* Allocate SubGhzProtocolDecoderKeyFinder.
|
||||
* @param environment Pointer to a SubGhzEnvironment instance
|
||||
* @return SubGhzProtocolDecoderKeyFinder* pointer to a SubGhzProtocolDecoderKeyFinder instance
|
||||
*/
|
||||
void* subghz_protocol_decoder_keyfinder_alloc(SubGhzEnvironment* environment);
|
||||
|
||||
/**
|
||||
* Free SubGhzProtocolDecoderKeyFinder.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderKeyFinder instance
|
||||
*/
|
||||
void subghz_protocol_decoder_keyfinder_free(void* context);
|
||||
|
||||
/**
|
||||
* Reset decoder SubGhzProtocolDecoderKeyFinder.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderKeyFinder instance
|
||||
*/
|
||||
void subghz_protocol_decoder_keyfinder_reset(void* context);
|
||||
|
||||
/**
|
||||
* Parse a raw sequence of levels and durations received from the air.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderKeyFinder instance
|
||||
* @param level Signal level true-high false-low
|
||||
* @param duration Duration of this level in, us
|
||||
*/
|
||||
void subghz_protocol_decoder_keyfinder_feed(void* context, bool level, uint32_t duration);
|
||||
|
||||
/**
|
||||
* Getting the hash sum of the last randomly received parcel.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderKeyFinder instance
|
||||
* @return hash Hash sum
|
||||
*/
|
||||
uint8_t subghz_protocol_decoder_keyfinder_get_hash_data(void* context);
|
||||
|
||||
/**
|
||||
* Serialize data SubGhzProtocolDecoderKeyFinder.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderKeyFinder instance
|
||||
* @param flipper_format Pointer to a FlipperFormat instance
|
||||
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
|
||||
* @return status
|
||||
*/
|
||||
SubGhzProtocolStatus subghz_protocol_decoder_keyfinder_serialize(
|
||||
void* context,
|
||||
FlipperFormat* flipper_format,
|
||||
SubGhzRadioPreset* preset);
|
||||
|
||||
/**
|
||||
* Deserialize data SubGhzProtocolDecoderKeyFinder.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderKeyFinder instance
|
||||
* @param flipper_format Pointer to a FlipperFormat instance
|
||||
* @return status
|
||||
*/
|
||||
SubGhzProtocolStatus
|
||||
subghz_protocol_decoder_keyfinder_deserialize(void* context, FlipperFormat* flipper_format);
|
||||
|
||||
/**
|
||||
* Getting a textual representation of the received data.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderKeyFinder instance
|
||||
* @param output Resulting text
|
||||
*/
|
||||
void subghz_protocol_decoder_keyfinder_get_string(void* context, FuriString* output);
|
||||
@@ -1,49 +0,0 @@
|
||||
#include "keys.h"
|
||||
|
||||
#define KIA_KEY1 10u
|
||||
#define KIA_KEY2 11u
|
||||
#define KIA_KEY3 12u
|
||||
#define KIA_KEY4 13u
|
||||
|
||||
uint64_t kia_mf_key = 0;
|
||||
uint64_t kia_v6_a_key = 0;
|
||||
uint64_t kia_v6_b_key = 0;
|
||||
uint64_t kia_v5_key = 0;
|
||||
|
||||
void protopirate_keys_load(SubGhzEnvironment* environment) {
|
||||
SubGhzKeystore* keystore = subghz_environment_get_keystore(environment);
|
||||
// Load keys from secure keystore
|
||||
for
|
||||
M_EACH(manufacture_code, *subghz_keystore_get_data(keystore), SubGhzKeyArray_t) {
|
||||
switch(manufacture_code->type) {
|
||||
case KIA_KEY1:
|
||||
kia_mf_key = manufacture_code->key;
|
||||
break;
|
||||
case KIA_KEY2:
|
||||
kia_v6_a_key = manufacture_code->key;
|
||||
break;
|
||||
case KIA_KEY3:
|
||||
kia_v6_b_key = manufacture_code->key;
|
||||
break;
|
||||
case KIA_KEY4:
|
||||
kia_v5_key = manufacture_code->key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t get_kia_mf_key(void) {
|
||||
return kia_mf_key;
|
||||
}
|
||||
|
||||
uint64_t get_kia_v6_keystore_a(void) {
|
||||
return kia_v6_a_key;
|
||||
}
|
||||
|
||||
uint64_t get_kia_v6_keystore_b(void) {
|
||||
return kia_v6_b_key;
|
||||
}
|
||||
|
||||
uint64_t get_kia_v5_key(void) {
|
||||
return kia_v5_key;
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <lib/subghz/environment.h>
|
||||
#include <lib/subghz/subghz_keystore.h>
|
||||
|
||||
extern uint64_t kia_mf_key;
|
||||
extern uint64_t kia_v6_a_key;
|
||||
extern uint64_t kia_v6_b_key;
|
||||
extern uint64_t kia_v5_key;
|
||||
|
||||
uint64_t get_kia_mf_key(void);
|
||||
|
||||
uint64_t get_kia_v6_keystore_b(void);
|
||||
|
||||
uint64_t get_kia_v6_keystore_a(void);
|
||||
|
||||
uint64_t get_kia_v5_key(void);
|
||||
|
||||
void protopirate_keys_load(SubGhzEnvironment* environment);
|
||||
@@ -53,7 +53,8 @@ const SubGhzProtocol* const subghz_protocol_registry_items[] = {
|
||||
&subghz_protocol_roger,
|
||||
//&subghz_protocol_elplast,
|
||||
//&subghz_protocol_treadmill37,
|
||||
&subghz_protocol_beninca_arc,
|
||||
&subghz_protocol_beninca_arc,
|
||||
&subghz_protocol_keyfinder,
|
||||
//&subghz_protocol_jarolift,
|
||||
&subghz_protocol_vag,
|
||||
&subghz_protocol_porsche_cayenne,
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
#include "elplast.h"
|
||||
#include "treadmill37.h"
|
||||
#include "beninca_arc.h"
|
||||
#include "keyfinder.h"
|
||||
#include "jarolift.h"
|
||||
#include "vag.h"
|
||||
#include "porsche_cayenne.h"
|
||||
|
||||
Reference in New Issue
Block a user