mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-07-29 02:08:10 -07:00
bipki removal procedure
don't worry, they are in other app
This commit is contained in:
@@ -1,276 +0,0 @@
|
||||
#include "kia.h"
|
||||
|
||||
#include "../blocks/const.h"
|
||||
#include "../blocks/decoder.h"
|
||||
#include "../blocks/encoder.h"
|
||||
#include "../blocks/generic.h"
|
||||
#include "../blocks/math.h"
|
||||
|
||||
#define TAG "SubGhzProtocoKia"
|
||||
|
||||
static const SubGhzBlockConst subghz_protocol_kia_const = {
|
||||
.te_short = 250,
|
||||
.te_long = 500,
|
||||
.te_delta = 100,
|
||||
.min_count_bit_for_found = 61,
|
||||
};
|
||||
|
||||
struct SubGhzProtocolDecoderKIA {
|
||||
SubGhzProtocolDecoderBase base;
|
||||
|
||||
SubGhzBlockDecoder decoder;
|
||||
SubGhzBlockGeneric generic;
|
||||
|
||||
uint16_t header_count;
|
||||
};
|
||||
|
||||
struct SubGhzProtocolEncoderKIA {
|
||||
SubGhzProtocolEncoderBase base;
|
||||
|
||||
SubGhzProtocolBlockEncoder encoder;
|
||||
SubGhzBlockGeneric generic;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
KIADecoderStepReset = 0,
|
||||
KIADecoderStepCheckPreambula,
|
||||
KIADecoderStepSaveDuration,
|
||||
KIADecoderStepCheckDuration,
|
||||
} KIADecoderStep;
|
||||
|
||||
const SubGhzProtocolDecoder subghz_protocol_kia_decoder = {
|
||||
.alloc = subghz_protocol_decoder_kia_alloc,
|
||||
.free = subghz_protocol_decoder_kia_free,
|
||||
|
||||
.feed = subghz_protocol_decoder_kia_feed,
|
||||
.reset = subghz_protocol_decoder_kia_reset,
|
||||
|
||||
.get_hash_data = subghz_protocol_decoder_kia_get_hash_data,
|
||||
.serialize = subghz_protocol_decoder_kia_serialize,
|
||||
.deserialize = subghz_protocol_decoder_kia_deserialize,
|
||||
.get_string = subghz_protocol_decoder_kia_get_string,
|
||||
};
|
||||
|
||||
const SubGhzProtocolEncoder subghz_protocol_kia_encoder = {
|
||||
.alloc = NULL,
|
||||
.free = NULL,
|
||||
|
||||
.deserialize = NULL,
|
||||
.stop = NULL,
|
||||
.yield = NULL,
|
||||
};
|
||||
|
||||
const SubGhzProtocol subghz_protocol_kia = {
|
||||
.name = SUBGHZ_PROTOCOL_KIA_NAME,
|
||||
.type = SubGhzProtocolTypeDynamic,
|
||||
.flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_FM | SubGhzProtocolFlag_Decodable |
|
||||
SubGhzProtocolFlag_Cars,
|
||||
|
||||
.decoder = &subghz_protocol_kia_decoder,
|
||||
.encoder = &subghz_protocol_kia_encoder,
|
||||
};
|
||||
|
||||
void* subghz_protocol_decoder_kia_alloc(SubGhzEnvironment* environment) {
|
||||
UNUSED(environment);
|
||||
SubGhzProtocolDecoderKIA* instance = malloc(sizeof(SubGhzProtocolDecoderKIA));
|
||||
instance->base.protocol = &subghz_protocol_kia;
|
||||
instance->generic.protocol_name = instance->base.protocol->name;
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
void subghz_protocol_decoder_kia_free(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderKIA* instance = context;
|
||||
free(instance);
|
||||
}
|
||||
|
||||
void subghz_protocol_decoder_kia_reset(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderKIA* instance = context;
|
||||
instance->decoder.parser_step = KIADecoderStepReset;
|
||||
}
|
||||
|
||||
void subghz_protocol_decoder_kia_feed(void* context, bool level, uint32_t duration) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderKIA* instance = context;
|
||||
|
||||
switch(instance->decoder.parser_step) {
|
||||
case KIADecoderStepReset:
|
||||
if((level) && (DURATION_DIFF(duration, subghz_protocol_kia_const.te_short) <
|
||||
subghz_protocol_kia_const.te_delta)) {
|
||||
instance->decoder.parser_step = KIADecoderStepCheckPreambula;
|
||||
instance->decoder.te_last = duration;
|
||||
instance->header_count = 0;
|
||||
}
|
||||
break;
|
||||
case KIADecoderStepCheckPreambula:
|
||||
if(level) {
|
||||
if((DURATION_DIFF(duration, subghz_protocol_kia_const.te_short) <
|
||||
subghz_protocol_kia_const.te_delta) ||
|
||||
(DURATION_DIFF(duration, subghz_protocol_kia_const.te_long) <
|
||||
subghz_protocol_kia_const.te_delta)) {
|
||||
instance->decoder.te_last = duration;
|
||||
} else {
|
||||
instance->decoder.parser_step = KIADecoderStepReset;
|
||||
}
|
||||
} else if(
|
||||
(DURATION_DIFF(duration, subghz_protocol_kia_const.te_short) <
|
||||
subghz_protocol_kia_const.te_delta) &&
|
||||
(DURATION_DIFF(instance->decoder.te_last, subghz_protocol_kia_const.te_short) <
|
||||
subghz_protocol_kia_const.te_delta)) {
|
||||
// Found header
|
||||
instance->header_count++;
|
||||
break;
|
||||
} else if(
|
||||
(DURATION_DIFF(duration, subghz_protocol_kia_const.te_long) <
|
||||
subghz_protocol_kia_const.te_delta) &&
|
||||
(DURATION_DIFF(instance->decoder.te_last, subghz_protocol_kia_const.te_long) <
|
||||
subghz_protocol_kia_const.te_delta)) {
|
||||
// Found start bit
|
||||
if(instance->header_count > 15) {
|
||||
instance->decoder.parser_step = KIADecoderStepSaveDuration;
|
||||
instance->decoder.decode_data = 0;
|
||||
instance->decoder.decode_count_bit = 1;
|
||||
subghz_protocol_blocks_add_bit(&instance->decoder, 1);
|
||||
} else {
|
||||
instance->decoder.parser_step = KIADecoderStepReset;
|
||||
}
|
||||
} else {
|
||||
instance->decoder.parser_step = KIADecoderStepReset;
|
||||
}
|
||||
break;
|
||||
case KIADecoderStepSaveDuration:
|
||||
if(level) {
|
||||
if(duration >=
|
||||
(subghz_protocol_kia_const.te_long + subghz_protocol_kia_const.te_delta * 2UL)) {
|
||||
//Found stop bit
|
||||
instance->decoder.parser_step = KIADecoderStepReset;
|
||||
if(instance->decoder.decode_count_bit ==
|
||||
subghz_protocol_kia_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;
|
||||
break;
|
||||
} else {
|
||||
instance->decoder.te_last = duration;
|
||||
instance->decoder.parser_step = KIADecoderStepCheckDuration;
|
||||
}
|
||||
|
||||
} else {
|
||||
instance->decoder.parser_step = KIADecoderStepReset;
|
||||
}
|
||||
break;
|
||||
case KIADecoderStepCheckDuration:
|
||||
if(!level) {
|
||||
if((DURATION_DIFF(instance->decoder.te_last, subghz_protocol_kia_const.te_short) <
|
||||
subghz_protocol_kia_const.te_delta) &&
|
||||
(DURATION_DIFF(duration, subghz_protocol_kia_const.te_short) <
|
||||
subghz_protocol_kia_const.te_delta)) {
|
||||
subghz_protocol_blocks_add_bit(&instance->decoder, 0);
|
||||
instance->decoder.parser_step = KIADecoderStepSaveDuration;
|
||||
} else if(
|
||||
(DURATION_DIFF(instance->decoder.te_last, subghz_protocol_kia_const.te_long) <
|
||||
subghz_protocol_kia_const.te_delta) &&
|
||||
(DURATION_DIFF(duration, subghz_protocol_kia_const.te_long) <
|
||||
subghz_protocol_kia_const.te_delta)) {
|
||||
subghz_protocol_blocks_add_bit(&instance->decoder, 1);
|
||||
instance->decoder.parser_step = KIADecoderStepSaveDuration;
|
||||
} else {
|
||||
instance->decoder.parser_step = KIADecoderStepReset;
|
||||
}
|
||||
} else {
|
||||
instance->decoder.parser_step = KIADecoderStepReset;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t subghz_protocol_kia_crc8(uint8_t* data, size_t len) {
|
||||
uint8_t crc = 0x08;
|
||||
size_t i, j;
|
||||
for(i = 0; i < len; i++) {
|
||||
crc ^= data[i];
|
||||
for(j = 0; j < 8; j++) {
|
||||
if((crc & 0x80) != 0)
|
||||
crc = (uint8_t)((crc << 1) ^ 0x7F);
|
||||
else
|
||||
crc <<= 1;
|
||||
}
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Analysis of received data
|
||||
* @param instance Pointer to a SubGhzBlockGeneric* instance
|
||||
*/
|
||||
static void subghz_protocol_kia_check_remote_controller(SubGhzBlockGeneric* instance) {
|
||||
/*
|
||||
* 0x0F 0112 43B04EC 1 7D
|
||||
* 0x0F 0113 43B04EC 1 DF
|
||||
* 0x0F 0114 43B04EC 1 30
|
||||
* 0x0F 0115 43B04EC 2 13
|
||||
* 0x0F 0116 43B04EC 3 F5
|
||||
* CNT Serial K CRC8 Kia (CRC8, poly 0x7f, start_crc 0x08)
|
||||
*/
|
||||
|
||||
instance->serial = (uint32_t)((instance->data >> 12) & 0x0FFFFFFF);
|
||||
instance->btn = (instance->data >> 8) & 0x0F;
|
||||
instance->cnt = (instance->data >> 40) & 0xFFFF;
|
||||
}
|
||||
|
||||
uint8_t subghz_protocol_decoder_kia_get_hash_data(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderKIA* instance = context;
|
||||
return subghz_protocol_blocks_get_hash_data(
|
||||
&instance->decoder, (instance->decoder.decode_count_bit / 8) + 1);
|
||||
}
|
||||
|
||||
SubGhzProtocolStatus subghz_protocol_decoder_kia_serialize(
|
||||
void* context,
|
||||
FlipperFormat* flipper_format,
|
||||
SubGhzRadioPreset* preset) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderKIA* instance = context;
|
||||
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
|
||||
}
|
||||
|
||||
SubGhzProtocolStatus
|
||||
subghz_protocol_decoder_kia_deserialize(void* context, FlipperFormat* flipper_format) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderKIA* instance = context;
|
||||
return subghz_block_generic_deserialize_check_count_bit(
|
||||
&instance->generic, flipper_format, subghz_protocol_kia_const.min_count_bit_for_found);
|
||||
}
|
||||
|
||||
void subghz_protocol_decoder_kia_get_string(void* context, FuriString* output) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderKIA* instance = context;
|
||||
|
||||
subghz_protocol_kia_check_remote_controller(&instance->generic);
|
||||
uint32_t code_found_hi = instance->generic.data >> 32;
|
||||
uint32_t code_found_lo = instance->generic.data & 0x00000000ffffffff;
|
||||
|
||||
// use 'Cntr:' instead of 'Cnt:' to exclude this protocol counter from Counter edit
|
||||
subghz_block_generic_global.cnt_length_bit = 16;
|
||||
subghz_block_generic_global.current_cnt = instance->generic.cnt;
|
||||
|
||||
furi_string_cat_printf(
|
||||
output,
|
||||
"%s %dbit\r\n"
|
||||
"Key:%08lX%08lX\r\n"
|
||||
"Sn:%07lX Btn:%X\r\n"
|
||||
"Cntr:%04lX\r\n",
|
||||
instance->generic.protocol_name,
|
||||
instance->generic.data_count_bit,
|
||||
code_found_hi,
|
||||
code_found_lo,
|
||||
instance->generic.serial,
|
||||
instance->generic.btn,
|
||||
instance->generic.cnt);
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "base.h"
|
||||
|
||||
#define SUBGHZ_PROTOCOL_KIA_NAME "KIA Seed"
|
||||
|
||||
typedef struct SubGhzProtocolDecoderKIA SubGhzProtocolDecoderKIA;
|
||||
typedef struct SubGhzProtocolEncoderKIA SubGhzProtocolEncoderKIA;
|
||||
|
||||
extern const SubGhzProtocolDecoder subghz_protocol_kia_decoder;
|
||||
extern const SubGhzProtocolEncoder subghz_protocol_kia_encoder;
|
||||
extern const SubGhzProtocol subghz_protocol_kia;
|
||||
|
||||
/**
|
||||
* Allocate SubGhzProtocolDecoderKIA.
|
||||
* @param environment Pointer to a SubGhzEnvironment instance
|
||||
* @return SubGhzProtocolDecoderKIA* pointer to a SubGhzProtocolDecoderKIA instance
|
||||
*/
|
||||
void* subghz_protocol_decoder_kia_alloc(SubGhzEnvironment* environment);
|
||||
|
||||
/**
|
||||
* Free SubGhzProtocolDecoderKIA.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderKIA instance
|
||||
*/
|
||||
void subghz_protocol_decoder_kia_free(void* context);
|
||||
|
||||
/**
|
||||
* Reset decoder SubGhzProtocolDecoderKIA.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderKIA instance
|
||||
*/
|
||||
void subghz_protocol_decoder_kia_reset(void* context);
|
||||
|
||||
/**
|
||||
* Parse a raw sequence of levels and durations received from the air.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderKIA instance
|
||||
* @param level Signal level true-high false-low
|
||||
* @param duration Duration of this level in, us
|
||||
*/
|
||||
void subghz_protocol_decoder_kia_feed(void* context, bool level, uint32_t duration);
|
||||
|
||||
/**
|
||||
* Getting the hash sum of the last randomly received parcel.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderKIA instance
|
||||
* @return hash Hash sum
|
||||
*/
|
||||
uint8_t subghz_protocol_decoder_kia_get_hash_data(void* context);
|
||||
|
||||
/**
|
||||
* Serialize data SubGhzProtocolDecoderKIA.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderKIA 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_kia_serialize(
|
||||
void* context,
|
||||
FlipperFormat* flipper_format,
|
||||
SubGhzRadioPreset* preset);
|
||||
|
||||
/**
|
||||
* Deserialize data SubGhzProtocolDecoderKIA.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderKIA instance
|
||||
* @param flipper_format Pointer to a FlipperFormat instance
|
||||
* @return status
|
||||
*/
|
||||
SubGhzProtocolStatus
|
||||
subghz_protocol_decoder_kia_deserialize(void* context, FlipperFormat* flipper_format);
|
||||
|
||||
/**
|
||||
* Getting a textual representation of the received data.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderKIA instance
|
||||
* @param output Resulting text
|
||||
*/
|
||||
void subghz_protocol_decoder_kia_get_string(void* context, FuriString* output);
|
||||
@@ -1,59 +1,31 @@
|
||||
#include "protocol_items.h" // IWYU pragma: keep
|
||||
|
||||
const SubGhzProtocol* const subghz_protocol_registry_items[] = {
|
||||
&subghz_protocol_gate_tx,
|
||||
&subghz_protocol_keeloq,
|
||||
&subghz_protocol_star_line,
|
||||
&subghz_protocol_nice_flo,
|
||||
&subghz_protocol_came,
|
||||
&subghz_protocol_faac_slh,
|
||||
&subghz_protocol_nice_flor_s,
|
||||
&subghz_protocol_came_twee,
|
||||
&subghz_protocol_came_atomo,
|
||||
&subghz_protocol_nero_sketch,
|
||||
&subghz_protocol_ido,
|
||||
&subghz_protocol_kia,
|
||||
&subghz_protocol_hormann,
|
||||
&subghz_protocol_nero_radio,
|
||||
&subghz_protocol_somfy_telis,
|
||||
&subghz_protocol_somfy_keytis,
|
||||
&subghz_protocol_scher_khan,
|
||||
&subghz_protocol_princeton,
|
||||
&subghz_protocol_raw,
|
||||
&subghz_protocol_linear,
|
||||
&subghz_protocol_secplus_v2,
|
||||
&subghz_protocol_secplus_v1,
|
||||
&subghz_protocol_megacode,
|
||||
&subghz_protocol_holtek,
|
||||
&subghz_protocol_chamb_code,
|
||||
&subghz_protocol_power_smart,
|
||||
&subghz_protocol_marantec,
|
||||
&subghz_protocol_bett,
|
||||
&subghz_protocol_doitrand,
|
||||
&subghz_protocol_phoenix_v2,
|
||||
&subghz_protocol_honeywell_wdb,
|
||||
&subghz_protocol_magellan,
|
||||
&subghz_protocol_intertechno_v3,
|
||||
&subghz_protocol_clemsa,
|
||||
&subghz_protocol_ansonic,
|
||||
&subghz_protocol_smc5326,
|
||||
&subghz_protocol_holtek_th12x,
|
||||
&subghz_protocol_linear_delta3,
|
||||
&subghz_protocol_dooya,
|
||||
&subghz_protocol_alutech_at_4n,
|
||||
&subghz_protocol_kinggates_stylo_4k,
|
||||
&subghz_protocol_bin_raw,
|
||||
&subghz_protocol_mastercode,
|
||||
&subghz_protocol_honeywell,
|
||||
&subghz_protocol_legrand,
|
||||
&subghz_protocol_dickert_mahs,
|
||||
&subghz_protocol_gangqi,
|
||||
&subghz_protocol_marantec24,
|
||||
&subghz_protocol_hollarm,
|
||||
&subghz_protocol_hay21,
|
||||
&subghz_protocol_revers_rb2,
|
||||
&subghz_protocol_feron,
|
||||
&subghz_protocol_roger,
|
||||
&subghz_protocol_gate_tx, &subghz_protocol_keeloq,
|
||||
&subghz_protocol_nice_flo, &subghz_protocol_came,
|
||||
&subghz_protocol_faac_slh, &subghz_protocol_nice_flor_s,
|
||||
&subghz_protocol_came_twee, &subghz_protocol_came_atomo,
|
||||
&subghz_protocol_nero_sketch, &subghz_protocol_ido,
|
||||
&subghz_protocol_hormann, &subghz_protocol_nero_radio,
|
||||
&subghz_protocol_somfy_telis, &subghz_protocol_somfy_keytis,
|
||||
&subghz_protocol_princeton, &subghz_protocol_raw,
|
||||
&subghz_protocol_linear, &subghz_protocol_secplus_v2,
|
||||
&subghz_protocol_secplus_v1, &subghz_protocol_megacode,
|
||||
&subghz_protocol_holtek, &subghz_protocol_chamb_code,
|
||||
&subghz_protocol_power_smart, &subghz_protocol_marantec,
|
||||
&subghz_protocol_bett, &subghz_protocol_doitrand,
|
||||
&subghz_protocol_phoenix_v2, &subghz_protocol_honeywell_wdb,
|
||||
&subghz_protocol_magellan, &subghz_protocol_intertechno_v3,
|
||||
&subghz_protocol_clemsa, &subghz_protocol_ansonic,
|
||||
&subghz_protocol_smc5326, &subghz_protocol_holtek_th12x,
|
||||
&subghz_protocol_linear_delta3, &subghz_protocol_dooya,
|
||||
&subghz_protocol_alutech_at_4n, &subghz_protocol_kinggates_stylo_4k,
|
||||
&subghz_protocol_bin_raw, &subghz_protocol_mastercode,
|
||||
&subghz_protocol_honeywell, &subghz_protocol_legrand,
|
||||
&subghz_protocol_dickert_mahs, &subghz_protocol_gangqi,
|
||||
&subghz_protocol_marantec24, &subghz_protocol_hollarm,
|
||||
&subghz_protocol_hay21, &subghz_protocol_revers_rb2,
|
||||
&subghz_protocol_feron, &subghz_protocol_roger,
|
||||
&subghz_protocol_elplast,
|
||||
};
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#include "princeton.h"
|
||||
#include "keeloq.h"
|
||||
#include "star_line.h"
|
||||
#include "nice_flo.h"
|
||||
#include "came.h"
|
||||
#include "faac_slh.h"
|
||||
@@ -13,12 +12,10 @@
|
||||
#include "came_atomo.h"
|
||||
#include "nero_sketch.h"
|
||||
#include "ido.h"
|
||||
#include "kia.h"
|
||||
#include "hormann.h"
|
||||
#include "nero_radio.h"
|
||||
#include "somfy_telis.h"
|
||||
#include "somfy_keytis.h"
|
||||
#include "scher_khan.h"
|
||||
#include "gate_tx.h"
|
||||
#include "raw.h"
|
||||
#include "linear.h"
|
||||
|
||||
@@ -64,7 +64,8 @@ const SubGhzProtocol subghz_protocol_revers_rb2 = {
|
||||
.name = SUBGHZ_PROTOCOL_REVERSRB2_NAME,
|
||||
.type = SubGhzProtocolTypeStatic,
|
||||
.flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable |
|
||||
SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save | SubGhzProtocolFlag_Send,
|
||||
SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save | SubGhzProtocolFlag_Send |
|
||||
SubGhzProtocolFlag_ReversRB2,
|
||||
|
||||
.decoder = &subghz_protocol_revers_rb2_decoder,
|
||||
.encoder = &subghz_protocol_revers_rb2_encoder,
|
||||
|
||||
@@ -1,320 +0,0 @@
|
||||
#include "scher_khan.h"
|
||||
|
||||
#include "../blocks/const.h"
|
||||
#include "../blocks/decoder.h"
|
||||
#include "../blocks/encoder.h"
|
||||
#include "../blocks/generic.h"
|
||||
#include "../blocks/math.h"
|
||||
|
||||
//https://phreakerclub.com/72
|
||||
//https://phreakerclub.com/forum/showthread.php?t=7&page=2
|
||||
//https://phreakerclub.com/forum/showthread.php?t=274&highlight=magicar
|
||||
//!!! https://phreakerclub.com/forum/showthread.php?t=489&highlight=magicar&page=5
|
||||
|
||||
#define TAG "SubGhzProtocolScherKhan"
|
||||
|
||||
static const SubGhzBlockConst subghz_protocol_scher_khan_const = {
|
||||
.te_short = 750,
|
||||
.te_long = 1100,
|
||||
.te_delta = 150,
|
||||
.min_count_bit_for_found = 35,
|
||||
};
|
||||
|
||||
struct SubGhzProtocolDecoderScherKhan {
|
||||
SubGhzProtocolDecoderBase base;
|
||||
|
||||
SubGhzBlockDecoder decoder;
|
||||
SubGhzBlockGeneric generic;
|
||||
|
||||
uint16_t header_count;
|
||||
const char* protocol_name;
|
||||
};
|
||||
|
||||
struct SubGhzProtocolEncoderScherKhan {
|
||||
SubGhzProtocolEncoderBase base;
|
||||
|
||||
SubGhzProtocolBlockEncoder encoder;
|
||||
SubGhzBlockGeneric generic;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
ScherKhanDecoderStepReset = 0,
|
||||
ScherKhanDecoderStepCheckPreambula,
|
||||
ScherKhanDecoderStepSaveDuration,
|
||||
ScherKhanDecoderStepCheckDuration,
|
||||
} ScherKhanDecoderStep;
|
||||
|
||||
const SubGhzProtocolDecoder subghz_protocol_scher_khan_decoder = {
|
||||
.alloc = subghz_protocol_decoder_scher_khan_alloc,
|
||||
.free = subghz_protocol_decoder_scher_khan_free,
|
||||
|
||||
.feed = subghz_protocol_decoder_scher_khan_feed,
|
||||
.reset = subghz_protocol_decoder_scher_khan_reset,
|
||||
|
||||
.get_hash_data = subghz_protocol_decoder_scher_khan_get_hash_data,
|
||||
.serialize = subghz_protocol_decoder_scher_khan_serialize,
|
||||
.deserialize = subghz_protocol_decoder_scher_khan_deserialize,
|
||||
.get_string = subghz_protocol_decoder_scher_khan_get_string,
|
||||
};
|
||||
|
||||
const SubGhzProtocolEncoder subghz_protocol_scher_khan_encoder = {
|
||||
.alloc = NULL,
|
||||
.free = NULL,
|
||||
|
||||
.deserialize = NULL,
|
||||
.stop = NULL,
|
||||
.yield = NULL,
|
||||
};
|
||||
|
||||
const SubGhzProtocol subghz_protocol_scher_khan = {
|
||||
.name = SUBGHZ_PROTOCOL_SCHER_KHAN_NAME,
|
||||
.type = SubGhzProtocolTypeDynamic,
|
||||
.flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_FM | SubGhzProtocolFlag_Decodable |
|
||||
SubGhzProtocolFlag_Save | SubGhzProtocolFlag_Cars,
|
||||
|
||||
.decoder = &subghz_protocol_scher_khan_decoder,
|
||||
.encoder = &subghz_protocol_scher_khan_encoder,
|
||||
};
|
||||
|
||||
void* subghz_protocol_decoder_scher_khan_alloc(SubGhzEnvironment* environment) {
|
||||
UNUSED(environment);
|
||||
SubGhzProtocolDecoderScherKhan* instance = malloc(sizeof(SubGhzProtocolDecoderScherKhan));
|
||||
instance->base.protocol = &subghz_protocol_scher_khan;
|
||||
instance->generic.protocol_name = instance->base.protocol->name;
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
void subghz_protocol_decoder_scher_khan_free(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderScherKhan* instance = context;
|
||||
free(instance);
|
||||
}
|
||||
|
||||
void subghz_protocol_decoder_scher_khan_reset(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderScherKhan* instance = context;
|
||||
instance->decoder.parser_step = ScherKhanDecoderStepReset;
|
||||
}
|
||||
|
||||
void subghz_protocol_decoder_scher_khan_feed(void* context, bool level, uint32_t duration) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderScherKhan* instance = context;
|
||||
|
||||
switch(instance->decoder.parser_step) {
|
||||
case ScherKhanDecoderStepReset:
|
||||
if((level) && (DURATION_DIFF(duration, subghz_protocol_scher_khan_const.te_short * 2) <
|
||||
subghz_protocol_scher_khan_const.te_delta)) {
|
||||
instance->decoder.parser_step = ScherKhanDecoderStepCheckPreambula;
|
||||
instance->decoder.te_last = duration;
|
||||
instance->header_count = 0;
|
||||
}
|
||||
break;
|
||||
case ScherKhanDecoderStepCheckPreambula:
|
||||
if(level) {
|
||||
if((DURATION_DIFF(duration, subghz_protocol_scher_khan_const.te_short * 2) <
|
||||
subghz_protocol_scher_khan_const.te_delta) ||
|
||||
(DURATION_DIFF(duration, subghz_protocol_scher_khan_const.te_short) <
|
||||
subghz_protocol_scher_khan_const.te_delta)) {
|
||||
instance->decoder.te_last = duration;
|
||||
} else {
|
||||
instance->decoder.parser_step = ScherKhanDecoderStepReset;
|
||||
}
|
||||
} else if(
|
||||
(DURATION_DIFF(duration, subghz_protocol_scher_khan_const.te_short * 2) <
|
||||
subghz_protocol_scher_khan_const.te_delta) ||
|
||||
(DURATION_DIFF(duration, subghz_protocol_scher_khan_const.te_short) <
|
||||
subghz_protocol_scher_khan_const.te_delta)) {
|
||||
if(DURATION_DIFF(
|
||||
instance->decoder.te_last, subghz_protocol_scher_khan_const.te_short * 2) <
|
||||
subghz_protocol_scher_khan_const.te_delta) {
|
||||
// Found header
|
||||
instance->header_count++;
|
||||
break;
|
||||
} else if(
|
||||
DURATION_DIFF(
|
||||
instance->decoder.te_last, subghz_protocol_scher_khan_const.te_short) <
|
||||
subghz_protocol_scher_khan_const.te_delta) {
|
||||
// Found start bit
|
||||
if(instance->header_count >= 2) {
|
||||
instance->decoder.parser_step = ScherKhanDecoderStepSaveDuration;
|
||||
instance->decoder.decode_data = 0;
|
||||
instance->decoder.decode_count_bit = 1;
|
||||
} else {
|
||||
instance->decoder.parser_step = ScherKhanDecoderStepReset;
|
||||
}
|
||||
} else {
|
||||
instance->decoder.parser_step = ScherKhanDecoderStepReset;
|
||||
}
|
||||
} else {
|
||||
instance->decoder.parser_step = ScherKhanDecoderStepReset;
|
||||
}
|
||||
break;
|
||||
case ScherKhanDecoderStepSaveDuration:
|
||||
if(level) {
|
||||
if(duration >= (subghz_protocol_scher_khan_const.te_delta * 2UL +
|
||||
subghz_protocol_scher_khan_const.te_long)) {
|
||||
//Found stop bit
|
||||
instance->decoder.parser_step = ScherKhanDecoderStepReset;
|
||||
if(instance->decoder.decode_count_bit >=
|
||||
subghz_protocol_scher_khan_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;
|
||||
break;
|
||||
} else {
|
||||
instance->decoder.te_last = duration;
|
||||
instance->decoder.parser_step = ScherKhanDecoderStepCheckDuration;
|
||||
}
|
||||
|
||||
} else {
|
||||
instance->decoder.parser_step = ScherKhanDecoderStepReset;
|
||||
}
|
||||
break;
|
||||
case ScherKhanDecoderStepCheckDuration:
|
||||
if(!level) {
|
||||
if((DURATION_DIFF(
|
||||
instance->decoder.te_last, subghz_protocol_scher_khan_const.te_short) <
|
||||
subghz_protocol_scher_khan_const.te_delta) &&
|
||||
(DURATION_DIFF(duration, subghz_protocol_scher_khan_const.te_short) <
|
||||
subghz_protocol_scher_khan_const.te_delta)) {
|
||||
subghz_protocol_blocks_add_bit(&instance->decoder, 0);
|
||||
instance->decoder.parser_step = ScherKhanDecoderStepSaveDuration;
|
||||
} else if(
|
||||
(DURATION_DIFF(
|
||||
instance->decoder.te_last, subghz_protocol_scher_khan_const.te_long) <
|
||||
subghz_protocol_scher_khan_const.te_delta) &&
|
||||
(DURATION_DIFF(duration, subghz_protocol_scher_khan_const.te_long) <
|
||||
subghz_protocol_scher_khan_const.te_delta)) {
|
||||
subghz_protocol_blocks_add_bit(&instance->decoder, 1);
|
||||
instance->decoder.parser_step = ScherKhanDecoderStepSaveDuration;
|
||||
} else {
|
||||
instance->decoder.parser_step = ScherKhanDecoderStepReset;
|
||||
}
|
||||
} else {
|
||||
instance->decoder.parser_step = ScherKhanDecoderStepReset;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Analysis of received data
|
||||
* @param instance Pointer to a SubGhzBlockGeneric* instance
|
||||
* @param protocol_name
|
||||
*/
|
||||
static void subghz_protocol_scher_khan_check_remote_controller(
|
||||
SubGhzBlockGeneric* instance,
|
||||
const char** protocol_name) {
|
||||
/*
|
||||
* MAGICAR 51 bit 00000001A99121DE83C3 MAGIC CODE, Dynamic
|
||||
* 0E8C1619E830C -> 000011101000110000010110 0001 1001 1110 1000001100001100
|
||||
* 0E8C1629D830D -> 000011101000110000010110 0010 1001 1101 1000001100001101
|
||||
* 0E8C1649B830E -> 000011101000110000010110 0100 1001 1011 1000001100001110
|
||||
* 0E8C16897830F -> 000011101000110000010110 1000 1001 0111 1000001100001111
|
||||
* Serial Key Ser ~Key CNT
|
||||
*/
|
||||
|
||||
switch(instance->data_count_bit) {
|
||||
case 35: //MAGIC CODE, Static
|
||||
*protocol_name = "MAGIC CODE, Static";
|
||||
instance->serial = 0;
|
||||
instance->btn = 0;
|
||||
instance->cnt = 0;
|
||||
break;
|
||||
case 51: //MAGIC CODE, Dynamic
|
||||
*protocol_name = "MAGIC CODE, Dynamic";
|
||||
instance->serial = ((instance->data >> 24) & 0xFFFFFF0) | ((instance->data >> 20) & 0x0F);
|
||||
instance->btn = (instance->data >> 24) & 0x0F;
|
||||
instance->cnt = instance->data & 0xFFFF;
|
||||
break;
|
||||
case 57: //MAGIC CODE PRO / PRO2
|
||||
*protocol_name = "MAGIC CODE PRO/PRO2";
|
||||
instance->serial = 0;
|
||||
instance->btn = 0;
|
||||
instance->cnt = 0;
|
||||
break;
|
||||
case 63: //MAGIC CODE, Dynamic Response
|
||||
*protocol_name = "MAGIC CODE, Response";
|
||||
instance->serial = 0;
|
||||
instance->btn = 0;
|
||||
instance->cnt = 0;
|
||||
break;
|
||||
case 64: //MAGICAR, Response ???
|
||||
*protocol_name = "MAGICAR, Response";
|
||||
instance->serial = 0;
|
||||
instance->btn = 0;
|
||||
instance->cnt = 0;
|
||||
break;
|
||||
case 81: // MAGIC CODE PRO / PRO2 Response ???
|
||||
case 82: // MAGIC CODE PRO / PRO2 Response ???
|
||||
*protocol_name = "MAGIC CODE PRO,\n Response";
|
||||
instance->serial = 0;
|
||||
instance->btn = 0;
|
||||
instance->cnt = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
*protocol_name = "Unknown";
|
||||
instance->serial = 0;
|
||||
instance->btn = 0;
|
||||
instance->cnt = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t subghz_protocol_decoder_scher_khan_get_hash_data(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderScherKhan* instance = context;
|
||||
return subghz_protocol_blocks_get_hash_data(
|
||||
&instance->decoder, (instance->decoder.decode_count_bit / 8) + 1);
|
||||
}
|
||||
|
||||
SubGhzProtocolStatus subghz_protocol_decoder_scher_khan_serialize(
|
||||
void* context,
|
||||
FlipperFormat* flipper_format,
|
||||
SubGhzRadioPreset* preset) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderScherKhan* instance = context;
|
||||
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
|
||||
}
|
||||
|
||||
SubGhzProtocolStatus
|
||||
subghz_protocol_decoder_scher_khan_deserialize(void* context, FlipperFormat* flipper_format) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderScherKhan* instance = context;
|
||||
return subghz_block_generic_deserialize(&instance->generic, flipper_format);
|
||||
}
|
||||
|
||||
void subghz_protocol_decoder_scher_khan_get_string(void* context, FuriString* output) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderScherKhan* instance = context;
|
||||
|
||||
subghz_protocol_scher_khan_check_remote_controller(
|
||||
&instance->generic, &instance->protocol_name);
|
||||
|
||||
// use 'Cntr:' instead of 'Cnt:' to exclude this protocol counter from Counter edit
|
||||
// push protocol data to global variable
|
||||
subghz_block_generic_global.cnt_length_bit = 16;
|
||||
subghz_block_generic_global.current_cnt = instance->generic.cnt;
|
||||
|
||||
furi_string_cat_printf(
|
||||
output,
|
||||
"%s %dbit\r\n"
|
||||
"Key:0x%lX%08lX\r\n"
|
||||
"Sn:%07lX Btn:%X\r\n"
|
||||
"Cntr:%04lX\r\n"
|
||||
"Pt: %s\r\n",
|
||||
instance->generic.protocol_name,
|
||||
instance->generic.data_count_bit,
|
||||
(uint32_t)(instance->generic.data >> 32),
|
||||
(uint32_t)instance->generic.data,
|
||||
instance->generic.serial,
|
||||
instance->generic.btn,
|
||||
instance->generic.cnt,
|
||||
instance->protocol_name);
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "base.h"
|
||||
|
||||
#define SUBGHZ_PROTOCOL_SCHER_KHAN_NAME "Scher-Khan"
|
||||
|
||||
typedef struct SubGhzProtocolDecoderScherKhan SubGhzProtocolDecoderScherKhan;
|
||||
typedef struct SubGhzProtocolEncoderScherKhan SubGhzProtocolEncoderScherKhan;
|
||||
|
||||
extern const SubGhzProtocolDecoder subghz_protocol_scher_khan_decoder;
|
||||
extern const SubGhzProtocolEncoder subghz_protocol_scher_khan_encoder;
|
||||
extern const SubGhzProtocol subghz_protocol_scher_khan;
|
||||
|
||||
/**
|
||||
* Allocate SubGhzProtocolDecoderScherKhan.
|
||||
* @param environment Pointer to a SubGhzEnvironment instance
|
||||
* @return SubGhzProtocolDecoderScherKhan* pointer to a SubGhzProtocolDecoderScherKhan instance
|
||||
*/
|
||||
void* subghz_protocol_decoder_scher_khan_alloc(SubGhzEnvironment* environment);
|
||||
|
||||
/**
|
||||
* Free SubGhzProtocolDecoderScherKhan.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderScherKhan instance
|
||||
*/
|
||||
void subghz_protocol_decoder_scher_khan_free(void* context);
|
||||
|
||||
/**
|
||||
* Reset decoder SubGhzProtocolDecoderScherKhan.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderScherKhan instance
|
||||
*/
|
||||
void subghz_protocol_decoder_scher_khan_reset(void* context);
|
||||
|
||||
/**
|
||||
* Parse a raw sequence of levels and durations received from the air.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderScherKhan instance
|
||||
* @param level Signal level true-high false-low
|
||||
* @param duration Duration of this level in, us
|
||||
*/
|
||||
void subghz_protocol_decoder_scher_khan_feed(void* context, bool level, uint32_t duration);
|
||||
|
||||
/**
|
||||
* Getting the hash sum of the last randomly received parcel.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderScherKhan instance
|
||||
* @return hash Hash sum
|
||||
*/
|
||||
uint8_t subghz_protocol_decoder_scher_khan_get_hash_data(void* context);
|
||||
|
||||
/**
|
||||
* Serialize data SubGhzProtocolDecoderScherKhan.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderScherKhan 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_scher_khan_serialize(
|
||||
void* context,
|
||||
FlipperFormat* flipper_format,
|
||||
SubGhzRadioPreset* preset);
|
||||
|
||||
/**
|
||||
* Deserialize data SubGhzProtocolDecoderScherKhan.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderScherKhan instance
|
||||
* @param flipper_format Pointer to a FlipperFormat instance
|
||||
* @return status
|
||||
*/
|
||||
SubGhzProtocolStatus
|
||||
subghz_protocol_decoder_scher_khan_deserialize(void* context, FlipperFormat* flipper_format);
|
||||
|
||||
/**
|
||||
* Getting a textual representation of the received data.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderScherKhan instance
|
||||
* @param output Resulting text
|
||||
*/
|
||||
void subghz_protocol_decoder_scher_khan_get_string(void* context, FuriString* output);
|
||||
@@ -1,747 +0,0 @@
|
||||
#include "star_line.h"
|
||||
#include "keeloq_common.h"
|
||||
|
||||
#include "../subghz_keystore.h"
|
||||
#include <m-array.h>
|
||||
|
||||
#include "../blocks/const.h"
|
||||
#include "../blocks/decoder.h"
|
||||
#include "../blocks/encoder.h"
|
||||
#include "../blocks/generic.h"
|
||||
#include "../blocks/math.h"
|
||||
|
||||
#include "../subghz_keystore_i.h"
|
||||
|
||||
#define TAG "SubGhzProtocolStarLine"
|
||||
|
||||
static const SubGhzBlockConst subghz_protocol_star_line_const = {
|
||||
.te_short = 250,
|
||||
.te_long = 500,
|
||||
.te_delta = 120,
|
||||
.min_count_bit_for_found = 64,
|
||||
};
|
||||
|
||||
struct SubGhzProtocolDecoderStarLine {
|
||||
SubGhzProtocolDecoderBase base;
|
||||
|
||||
SubGhzBlockDecoder decoder;
|
||||
SubGhzBlockGeneric generic;
|
||||
|
||||
uint16_t header_count;
|
||||
SubGhzKeystore* keystore;
|
||||
const char* manufacture_name;
|
||||
|
||||
FuriString* manufacture_from_file;
|
||||
};
|
||||
|
||||
struct SubGhzProtocolEncoderStarLine {
|
||||
SubGhzProtocolEncoderBase base;
|
||||
|
||||
SubGhzProtocolBlockEncoder encoder;
|
||||
SubGhzBlockGeneric generic;
|
||||
|
||||
SubGhzKeystore* keystore;
|
||||
const char* manufacture_name;
|
||||
|
||||
FuriString* manufacture_from_file;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
StarLineDecoderStepReset = 0,
|
||||
StarLineDecoderStepCheckPreambula,
|
||||
StarLineDecoderStepSaveDuration,
|
||||
StarLineDecoderStepCheckDuration,
|
||||
} StarLineDecoderStep;
|
||||
|
||||
const SubGhzProtocolDecoder subghz_protocol_star_line_decoder = {
|
||||
.alloc = subghz_protocol_decoder_star_line_alloc,
|
||||
.free = subghz_protocol_decoder_star_line_free,
|
||||
|
||||
.feed = subghz_protocol_decoder_star_line_feed,
|
||||
.reset = subghz_protocol_decoder_star_line_reset,
|
||||
|
||||
.get_hash_data = subghz_protocol_decoder_star_line_get_hash_data,
|
||||
.serialize = subghz_protocol_decoder_star_line_serialize,
|
||||
.deserialize = subghz_protocol_decoder_star_line_deserialize,
|
||||
.get_string = subghz_protocol_decoder_star_line_get_string,
|
||||
};
|
||||
|
||||
const SubGhzProtocolEncoder subghz_protocol_star_line_encoder = {
|
||||
.alloc = subghz_protocol_encoder_star_line_alloc,
|
||||
.free = subghz_protocol_encoder_star_line_free,
|
||||
|
||||
.deserialize = subghz_protocol_encoder_star_line_deserialize,
|
||||
.stop = subghz_protocol_encoder_star_line_stop,
|
||||
.yield = subghz_protocol_encoder_star_line_yield,
|
||||
};
|
||||
|
||||
const SubGhzProtocol subghz_protocol_star_line = {
|
||||
.name = SUBGHZ_PROTOCOL_STAR_LINE_NAME,
|
||||
.type = SubGhzProtocolTypeDynamic,
|
||||
.flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable |
|
||||
SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save | SubGhzProtocolFlag_Send |
|
||||
SubGhzProtocolFlag_Cars,
|
||||
|
||||
.decoder = &subghz_protocol_star_line_decoder,
|
||||
.encoder = &subghz_protocol_star_line_encoder,
|
||||
};
|
||||
|
||||
/**
|
||||
* Analysis of received data
|
||||
* @param instance Pointer to a SubGhzBlockGeneric* instance
|
||||
* @param keystore Pointer to a SubGhzKeystore* instance
|
||||
* @param manufacture_name
|
||||
*/
|
||||
static void subghz_protocol_star_line_check_remote_controller(
|
||||
SubGhzBlockGeneric* instance,
|
||||
SubGhzKeystore* keystore,
|
||||
const char** manufacture_name);
|
||||
|
||||
void* subghz_protocol_encoder_star_line_alloc(SubGhzEnvironment* environment) {
|
||||
SubGhzProtocolEncoderStarLine* instance = malloc(sizeof(SubGhzProtocolEncoderStarLine));
|
||||
|
||||
instance->base.protocol = &subghz_protocol_star_line;
|
||||
instance->generic.protocol_name = instance->base.protocol->name;
|
||||
instance->keystore = subghz_environment_get_keystore(environment);
|
||||
|
||||
instance->manufacture_from_file = furi_string_alloc();
|
||||
|
||||
instance->encoder.repeat = 10;
|
||||
instance->encoder.size_upload = 256;
|
||||
instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration));
|
||||
instance->encoder.is_running = false;
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
void subghz_protocol_encoder_star_line_free(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolEncoderStarLine* instance = context;
|
||||
furi_string_free(instance->manufacture_from_file);
|
||||
free(instance->encoder.upload);
|
||||
free(instance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Key generation from simple data
|
||||
* @param instance Pointer to a SubGhzProtocolEncoderKeeloq* instance
|
||||
* @param btn Button number, 4 bit
|
||||
*/
|
||||
static bool
|
||||
subghz_protocol_star_line_gen_data(SubGhzProtocolEncoderStarLine* instance, uint8_t btn) {
|
||||
// Check for OFEX (overflow experimental) mode
|
||||
if(furi_hal_subghz_get_rolling_counter_mult() != -0x7FFFFFFF) {
|
||||
// standart counter mode. PULL data from subghz_block_generic_global variables
|
||||
if(!subghz_block_generic_global_counter_override_get(&instance->generic.cnt)) {
|
||||
// if counter_override_get return FALSE then counter was not changed and we increase counter by standart mult value
|
||||
if((instance->generic.cnt + furi_hal_subghz_get_rolling_counter_mult()) > 0xFFFF) {
|
||||
instance->generic.cnt = 0;
|
||||
} else {
|
||||
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if((instance->generic.cnt + 0x1) > 0xFFFF) {
|
||||
instance->generic.cnt = 0;
|
||||
} else if(instance->generic.cnt >= 0x1 && instance->generic.cnt != 0xFFFE) {
|
||||
instance->generic.cnt = 0xFFFE;
|
||||
} else {
|
||||
instance->generic.cnt++;
|
||||
}
|
||||
}
|
||||
uint32_t fix = btn << 24 | instance->generic.serial;
|
||||
uint32_t decrypt = btn << 24 | (instance->generic.serial & 0xFF) << 16 | instance->generic.cnt;
|
||||
uint32_t hop = 0;
|
||||
uint64_t man = 0;
|
||||
uint64_t code_found_reverse;
|
||||
int res = 0;
|
||||
|
||||
if(instance->manufacture_name == 0x0) {
|
||||
instance->manufacture_name = "";
|
||||
}
|
||||
|
||||
if(strcmp(instance->manufacture_name, "Unknown") == 0) {
|
||||
code_found_reverse = subghz_protocol_blocks_reverse_key(
|
||||
instance->generic.data, instance->generic.data_count_bit);
|
||||
hop = code_found_reverse & 0x00000000ffffffff;
|
||||
} else {
|
||||
uint8_t kl_type_en = instance->keystore->kl_type;
|
||||
for
|
||||
M_EACH(
|
||||
manufacture_code,
|
||||
*subghz_keystore_get_data(instance->keystore),
|
||||
SubGhzKeyArray_t) {
|
||||
res = strcmp(
|
||||
furi_string_get_cstr(manufacture_code->name), instance->manufacture_name);
|
||||
if(res == 0) {
|
||||
switch(manufacture_code->type) {
|
||||
case KEELOQ_LEARNING_SIMPLE:
|
||||
//Simple Learning
|
||||
hop =
|
||||
subghz_protocol_keeloq_common_encrypt(decrypt, manufacture_code->key);
|
||||
break;
|
||||
case KEELOQ_LEARNING_NORMAL:
|
||||
//Normal Learning
|
||||
man = subghz_protocol_keeloq_common_normal_learning(
|
||||
fix, manufacture_code->key);
|
||||
hop = subghz_protocol_keeloq_common_encrypt(decrypt, man);
|
||||
break;
|
||||
case KEELOQ_LEARNING_UNKNOWN:
|
||||
if(kl_type_en == 1) {
|
||||
hop = subghz_protocol_keeloq_common_encrypt(
|
||||
decrypt, manufacture_code->key);
|
||||
}
|
||||
if(kl_type_en == 2) {
|
||||
man = subghz_protocol_keeloq_common_normal_learning(
|
||||
fix, manufacture_code->key);
|
||||
hop = subghz_protocol_keeloq_common_encrypt(decrypt, man);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(hop) {
|
||||
uint64_t yek = (uint64_t)fix << 32 | hop;
|
||||
instance->generic.data =
|
||||
subghz_protocol_blocks_reverse_key(yek, instance->generic.data_count_bit);
|
||||
return true;
|
||||
} else {
|
||||
instance->manufacture_name = "Unknown";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool subghz_protocol_star_line_create_data(
|
||||
void* context,
|
||||
FlipperFormat* flipper_format,
|
||||
uint32_t serial,
|
||||
uint8_t btn,
|
||||
uint16_t cnt,
|
||||
const char* manufacture_name,
|
||||
SubGhzRadioPreset* preset) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolEncoderStarLine* instance = context;
|
||||
instance->generic.serial = serial;
|
||||
instance->generic.cnt = cnt;
|
||||
instance->manufacture_name = manufacture_name;
|
||||
instance->generic.data_count_bit = 64;
|
||||
bool res = subghz_protocol_star_line_gen_data(instance, btn);
|
||||
if(res) {
|
||||
return SubGhzProtocolStatusOk ==
|
||||
subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generating an upload from data.
|
||||
* @param instance Pointer to a SubGhzProtocolEncoderKeeloq instance
|
||||
* @return true On success
|
||||
*/
|
||||
static bool subghz_protocol_encoder_star_line_get_upload(
|
||||
SubGhzProtocolEncoderStarLine* instance,
|
||||
uint8_t btn) {
|
||||
furi_assert(instance);
|
||||
|
||||
// Gen new key
|
||||
if(!subghz_protocol_star_line_gen_data(instance, btn)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t index = 0;
|
||||
size_t size_upload = 6 * 2 + (instance->generic.data_count_bit * 2);
|
||||
if(size_upload > instance->encoder.size_upload) {
|
||||
FURI_LOG_E(TAG, "Size upload exceeds allocated encoder buffer.");
|
||||
return false;
|
||||
} else {
|
||||
instance->encoder.size_upload = size_upload;
|
||||
}
|
||||
|
||||
//Send header
|
||||
for(uint8_t i = 6; i > 0; i--) {
|
||||
instance->encoder.upload[index++] =
|
||||
level_duration_make(true, (uint32_t)subghz_protocol_star_line_const.te_long * 2);
|
||||
instance->encoder.upload[index++] =
|
||||
level_duration_make(false, (uint32_t)subghz_protocol_star_line_const.te_long * 2);
|
||||
}
|
||||
|
||||
//Send key data
|
||||
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_star_line_const.te_long);
|
||||
instance->encoder.upload[index++] =
|
||||
level_duration_make(false, (uint32_t)subghz_protocol_star_line_const.te_long);
|
||||
} else {
|
||||
//send bit 0
|
||||
instance->encoder.upload[index++] =
|
||||
level_duration_make(true, (uint32_t)subghz_protocol_star_line_const.te_short);
|
||||
instance->encoder.upload[index++] =
|
||||
level_duration_make(false, (uint32_t)subghz_protocol_star_line_const.te_short);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
SubGhzProtocolStatus
|
||||
subghz_protocol_encoder_star_line_deserialize(void* context, FlipperFormat* flipper_format) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolEncoderStarLine* instance = context;
|
||||
SubGhzProtocolStatus res = SubGhzProtocolStatusError;
|
||||
do {
|
||||
if(SubGhzProtocolStatusOk !=
|
||||
subghz_block_generic_deserialize(&instance->generic, flipper_format)) {
|
||||
FURI_LOG_E(TAG, "Deserialize error");
|
||||
break;
|
||||
}
|
||||
|
||||
// Read manufacturer from file
|
||||
if(flipper_format_read_string(
|
||||
flipper_format, "Manufacture", instance->manufacture_from_file)) {
|
||||
instance->manufacture_name = furi_string_get_cstr(instance->manufacture_from_file);
|
||||
instance->keystore->mfname = instance->manufacture_name;
|
||||
} else {
|
||||
FURI_LOG_D(TAG, "ENCODER: Missing Manufacture");
|
||||
}
|
||||
|
||||
subghz_protocol_star_line_check_remote_controller(
|
||||
&instance->generic, instance->keystore, &instance->manufacture_name);
|
||||
|
||||
//optional parameter parameter
|
||||
flipper_format_read_uint32(
|
||||
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
|
||||
|
||||
subghz_protocol_encoder_star_line_get_upload(instance, instance->generic.btn);
|
||||
|
||||
if(!flipper_format_rewind(flipper_format)) {
|
||||
FURI_LOG_E(TAG, "Rewind error");
|
||||
break;
|
||||
}
|
||||
uint8_t key_data[sizeof(uint64_t)] = {0};
|
||||
for(size_t i = 0; i < sizeof(uint64_t); i++) {
|
||||
key_data[sizeof(uint64_t) - i - 1] = (instance->generic.data >> i * 8) & 0xFF;
|
||||
}
|
||||
if(!flipper_format_update_hex(flipper_format, "Key", key_data, sizeof(uint64_t))) {
|
||||
FURI_LOG_E(TAG, "Unable to add Key");
|
||||
break;
|
||||
}
|
||||
|
||||
instance->encoder.is_running = true;
|
||||
|
||||
res = SubGhzProtocolStatusOk;
|
||||
} while(false);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void subghz_protocol_encoder_star_line_stop(void* context) {
|
||||
SubGhzProtocolEncoderStarLine* instance = context;
|
||||
instance->encoder.is_running = false;
|
||||
}
|
||||
|
||||
LevelDuration subghz_protocol_encoder_star_line_yield(void* context) {
|
||||
SubGhzProtocolEncoderStarLine* 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) {
|
||||
instance->encoder.repeat--;
|
||||
instance->encoder.front = 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void* subghz_protocol_decoder_star_line_alloc(SubGhzEnvironment* environment) {
|
||||
SubGhzProtocolDecoderStarLine* instance = malloc(sizeof(SubGhzProtocolDecoderStarLine));
|
||||
instance->base.protocol = &subghz_protocol_star_line;
|
||||
instance->generic.protocol_name = instance->base.protocol->name;
|
||||
|
||||
instance->manufacture_from_file = furi_string_alloc();
|
||||
|
||||
instance->keystore = subghz_environment_get_keystore(environment);
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
void subghz_protocol_decoder_star_line_free(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderStarLine* instance = context;
|
||||
furi_string_free(instance->manufacture_from_file);
|
||||
|
||||
free(instance);
|
||||
}
|
||||
|
||||
void subghz_protocol_decoder_star_line_reset(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderStarLine* instance = context;
|
||||
instance->decoder.parser_step = StarLineDecoderStepReset;
|
||||
// TODO
|
||||
instance->keystore->mfname = "";
|
||||
instance->keystore->kl_type = 0;
|
||||
}
|
||||
|
||||
void subghz_protocol_decoder_star_line_feed(void* context, bool level, uint32_t duration) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderStarLine* instance = context;
|
||||
|
||||
switch(instance->decoder.parser_step) {
|
||||
case StarLineDecoderStepReset:
|
||||
if(level) {
|
||||
if(DURATION_DIFF(duration, subghz_protocol_star_line_const.te_long * 2) <
|
||||
subghz_protocol_star_line_const.te_delta * 2) {
|
||||
instance->decoder.parser_step = StarLineDecoderStepCheckPreambula;
|
||||
instance->header_count++;
|
||||
} else if(instance->header_count > 4) {
|
||||
instance->decoder.decode_data = 0;
|
||||
instance->decoder.decode_count_bit = 0;
|
||||
instance->decoder.te_last = duration;
|
||||
instance->decoder.parser_step = StarLineDecoderStepCheckDuration;
|
||||
}
|
||||
} else {
|
||||
instance->header_count = 0;
|
||||
}
|
||||
break;
|
||||
case StarLineDecoderStepCheckPreambula:
|
||||
if((!level) && (DURATION_DIFF(duration, subghz_protocol_star_line_const.te_long * 2) <
|
||||
subghz_protocol_star_line_const.te_delta * 2)) {
|
||||
//Found Preambula
|
||||
instance->decoder.parser_step = StarLineDecoderStepReset;
|
||||
} else {
|
||||
instance->header_count = 0;
|
||||
instance->decoder.parser_step = StarLineDecoderStepReset;
|
||||
}
|
||||
break;
|
||||
case StarLineDecoderStepSaveDuration:
|
||||
if(level) {
|
||||
if(duration >= (subghz_protocol_star_line_const.te_long +
|
||||
subghz_protocol_star_line_const.te_delta)) {
|
||||
instance->decoder.parser_step = StarLineDecoderStepReset;
|
||||
if((instance->decoder.decode_count_bit >=
|
||||
subghz_protocol_star_line_const.min_count_bit_for_found) &&
|
||||
(instance->decoder.decode_count_bit <=
|
||||
subghz_protocol_star_line_const.min_count_bit_for_found + 2)) {
|
||||
if(instance->generic.data != instance->decoder.decode_data) {
|
||||
instance->generic.data = instance->decoder.decode_data;
|
||||
instance->generic.data_count_bit =
|
||||
subghz_protocol_star_line_const.min_count_bit_for_found;
|
||||
if(instance->base.callback)
|
||||
instance->base.callback(&instance->base, instance->base.context);
|
||||
}
|
||||
}
|
||||
instance->decoder.decode_data = 0;
|
||||
instance->decoder.decode_count_bit = 0;
|
||||
instance->header_count = 0;
|
||||
break;
|
||||
} else {
|
||||
instance->decoder.te_last = duration;
|
||||
instance->decoder.parser_step = StarLineDecoderStepCheckDuration;
|
||||
}
|
||||
|
||||
} else {
|
||||
instance->decoder.parser_step = StarLineDecoderStepReset;
|
||||
}
|
||||
break;
|
||||
case StarLineDecoderStepCheckDuration:
|
||||
if(!level) {
|
||||
if((DURATION_DIFF(instance->decoder.te_last, subghz_protocol_star_line_const.te_short) <
|
||||
subghz_protocol_star_line_const.te_delta) &&
|
||||
(DURATION_DIFF(duration, subghz_protocol_star_line_const.te_short) <
|
||||
subghz_protocol_star_line_const.te_delta)) {
|
||||
if(instance->decoder.decode_count_bit <
|
||||
subghz_protocol_star_line_const.min_count_bit_for_found) {
|
||||
subghz_protocol_blocks_add_bit(&instance->decoder, 0);
|
||||
} else {
|
||||
instance->decoder.decode_count_bit++;
|
||||
}
|
||||
instance->decoder.parser_step = StarLineDecoderStepSaveDuration;
|
||||
} else if(
|
||||
(DURATION_DIFF(instance->decoder.te_last, subghz_protocol_star_line_const.te_long) <
|
||||
subghz_protocol_star_line_const.te_delta) &&
|
||||
(DURATION_DIFF(duration, subghz_protocol_star_line_const.te_long) <
|
||||
subghz_protocol_star_line_const.te_delta)) {
|
||||
if(instance->decoder.decode_count_bit <
|
||||
subghz_protocol_star_line_const.min_count_bit_for_found) {
|
||||
subghz_protocol_blocks_add_bit(&instance->decoder, 1);
|
||||
} else {
|
||||
instance->decoder.decode_count_bit++;
|
||||
}
|
||||
instance->decoder.parser_step = StarLineDecoderStepSaveDuration;
|
||||
} else {
|
||||
instance->decoder.parser_step = StarLineDecoderStepReset;
|
||||
}
|
||||
} else {
|
||||
instance->decoder.parser_step = StarLineDecoderStepReset;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validation of decrypt data.
|
||||
* @param instance Pointer to a SubGhzBlockGeneric instance
|
||||
* @param decrypt Decrypd data
|
||||
* @param btn Button number, 4 bit
|
||||
* @param end_serial decrement the last 10 bits of the serial number
|
||||
* @return true On success
|
||||
*/
|
||||
static inline bool subghz_protocol_star_line_check_decrypt(
|
||||
SubGhzBlockGeneric* instance,
|
||||
uint32_t decrypt,
|
||||
uint8_t btn,
|
||||
uint32_t end_serial) {
|
||||
furi_assert(instance);
|
||||
if((decrypt >> 24 == btn) && ((((uint16_t)(decrypt >> 16)) & 0x00FF) == end_serial)) {
|
||||
instance->cnt = decrypt & 0x0000FFFF;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checking the accepted code against the database manafacture key
|
||||
* @param instance Pointer to a SubGhzBlockGeneric* instance
|
||||
* @param fix Fix part of the parcel
|
||||
* @param hop Hop encrypted part of the parcel
|
||||
* @param keystore Pointer to a SubGhzKeystore* instance
|
||||
* @param manufacture_name
|
||||
* @return true on successful search
|
||||
*/
|
||||
static uint8_t subghz_protocol_star_line_check_remote_controller_selector(
|
||||
SubGhzBlockGeneric* instance,
|
||||
uint32_t fix,
|
||||
uint32_t hop,
|
||||
SubGhzKeystore* keystore,
|
||||
const char** manufacture_name) {
|
||||
uint16_t end_serial = (uint16_t)(fix & 0xFF);
|
||||
uint8_t btn = (uint8_t)(fix >> 24);
|
||||
uint32_t decrypt = 0;
|
||||
uint64_t man_normal_learning;
|
||||
bool mf_not_set = false;
|
||||
// TODO:
|
||||
// if(mfname == 0x0) {
|
||||
// mfname = "";
|
||||
// }
|
||||
|
||||
const char* mfname = keystore->mfname;
|
||||
|
||||
if(strcmp(mfname, "Unknown") == 0) {
|
||||
return 1;
|
||||
} else if(strcmp(mfname, "") == 0) {
|
||||
mf_not_set = true;
|
||||
}
|
||||
for
|
||||
M_EACH(manufacture_code, *subghz_keystore_get_data(keystore), SubGhzKeyArray_t) {
|
||||
if(mf_not_set || (strcmp(furi_string_get_cstr(manufacture_code->name), mfname) == 0)) {
|
||||
switch(manufacture_code->type) {
|
||||
case KEELOQ_LEARNING_SIMPLE:
|
||||
// Simple Learning
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, manufacture_code->key);
|
||||
if(subghz_protocol_star_line_check_decrypt(
|
||||
instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = furi_string_get_cstr(manufacture_code->name);
|
||||
keystore->mfname = *manufacture_name;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case KEELOQ_LEARNING_NORMAL:
|
||||
// Normal Learning
|
||||
// https://phreakerclub.com/forum/showpost.php?p=43557&postcount=37
|
||||
man_normal_learning =
|
||||
subghz_protocol_keeloq_common_normal_learning(fix, manufacture_code->key);
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man_normal_learning);
|
||||
if(subghz_protocol_star_line_check_decrypt(
|
||||
instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = furi_string_get_cstr(manufacture_code->name);
|
||||
keystore->mfname = *manufacture_name;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case KEELOQ_LEARNING_UNKNOWN:
|
||||
// Simple Learning
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, manufacture_code->key);
|
||||
if(subghz_protocol_star_line_check_decrypt(
|
||||
instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = furi_string_get_cstr(manufacture_code->name);
|
||||
keystore->mfname = *manufacture_name;
|
||||
keystore->kl_type = 1;
|
||||
return 1;
|
||||
}
|
||||
// Check for mirrored man
|
||||
uint64_t man_rev = 0;
|
||||
uint64_t man_rev_byte = 0;
|
||||
for(uint8_t i = 0; i < 64; i += 8) {
|
||||
man_rev_byte = (uint8_t)(manufacture_code->key >> i);
|
||||
man_rev = man_rev | man_rev_byte << (56 - i);
|
||||
}
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man_rev);
|
||||
if(subghz_protocol_star_line_check_decrypt(
|
||||
instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = furi_string_get_cstr(manufacture_code->name);
|
||||
keystore->mfname = *manufacture_name;
|
||||
keystore->kl_type = 1;
|
||||
return 1;
|
||||
}
|
||||
//###########################
|
||||
// Normal Learning
|
||||
// https://phreakerclub.com/forum/showpost.php?p=43557&postcount=37
|
||||
man_normal_learning =
|
||||
subghz_protocol_keeloq_common_normal_learning(fix, manufacture_code->key);
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man_normal_learning);
|
||||
if(subghz_protocol_star_line_check_decrypt(
|
||||
instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = furi_string_get_cstr(manufacture_code->name);
|
||||
keystore->mfname = *manufacture_name;
|
||||
keystore->kl_type = 2;
|
||||
return 1;
|
||||
}
|
||||
// Check for mirrored man
|
||||
man_normal_learning =
|
||||
subghz_protocol_keeloq_common_normal_learning(fix, man_rev);
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man_normal_learning);
|
||||
if(subghz_protocol_star_line_check_decrypt(
|
||||
instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = furi_string_get_cstr(manufacture_code->name);
|
||||
keystore->mfname = *manufacture_name;
|
||||
keystore->kl_type = 2;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*manufacture_name = "Unknown";
|
||||
keystore->mfname = "Unknown";
|
||||
instance->cnt = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Analysis of received data
|
||||
* @param instance Pointer to a SubGhzBlockGeneric* instance
|
||||
* @param keystore Pointer to a SubGhzKeystore* instance
|
||||
* @param manufacture_name
|
||||
*/
|
||||
static void subghz_protocol_star_line_check_remote_controller(
|
||||
SubGhzBlockGeneric* instance,
|
||||
SubGhzKeystore* keystore,
|
||||
const char** manufacture_name) {
|
||||
uint64_t key = subghz_protocol_blocks_reverse_key(instance->data, instance->data_count_bit);
|
||||
uint32_t key_fix = key >> 32;
|
||||
uint32_t key_hop = key & 0x00000000ffffffff;
|
||||
|
||||
subghz_protocol_star_line_check_remote_controller_selector(
|
||||
instance, key_fix, key_hop, keystore, manufacture_name);
|
||||
|
||||
instance->serial = key_fix & 0x00FFFFFF;
|
||||
instance->btn = key_fix >> 24;
|
||||
}
|
||||
|
||||
uint8_t subghz_protocol_decoder_star_line_get_hash_data(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderStarLine* instance = context;
|
||||
return subghz_protocol_blocks_get_hash_data(
|
||||
&instance->decoder, (instance->decoder.decode_count_bit / 8) + 1);
|
||||
}
|
||||
|
||||
SubGhzProtocolStatus subghz_protocol_decoder_star_line_serialize(
|
||||
void* context,
|
||||
FlipperFormat* flipper_format,
|
||||
SubGhzRadioPreset* preset) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderStarLine* instance = context;
|
||||
subghz_protocol_star_line_check_remote_controller(
|
||||
&instance->generic, instance->keystore, &instance->manufacture_name);
|
||||
SubGhzProtocolStatus ret =
|
||||
subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
|
||||
|
||||
if((ret == SubGhzProtocolStatusOk) &&
|
||||
!flipper_format_write_string_cstr(
|
||||
flipper_format, "Manufacture", instance->manufacture_name)) {
|
||||
FURI_LOG_E(TAG, "Unable to add manufacture name");
|
||||
ret = SubGhzProtocolStatusErrorParserOthers;
|
||||
}
|
||||
if((ret == SubGhzProtocolStatusOk) &&
|
||||
instance->generic.data_count_bit !=
|
||||
subghz_protocol_star_line_const.min_count_bit_for_found) {
|
||||
FURI_LOG_E(TAG, "Wrong number of bits in key");
|
||||
ret = SubGhzProtocolStatusErrorParserOthers;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
SubGhzProtocolStatus
|
||||
subghz_protocol_decoder_star_line_deserialize(void* context, FlipperFormat* flipper_format) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderStarLine* instance = context;
|
||||
SubGhzProtocolStatus res = SubGhzProtocolStatusError;
|
||||
do {
|
||||
if(SubGhzProtocolStatusOk !=
|
||||
subghz_block_generic_deserialize(&instance->generic, flipper_format)) {
|
||||
FURI_LOG_E(TAG, "Deserialize error");
|
||||
break;
|
||||
}
|
||||
|
||||
// Read manufacturer from file
|
||||
if(flipper_format_read_string(
|
||||
flipper_format, "Manufacture", instance->manufacture_from_file)) {
|
||||
instance->manufacture_name = furi_string_get_cstr(instance->manufacture_from_file);
|
||||
instance->keystore->mfname = instance->manufacture_name;
|
||||
} else {
|
||||
FURI_LOG_D(TAG, "DECODER: Missing Manufacture");
|
||||
}
|
||||
|
||||
res = SubGhzProtocolStatusOk;
|
||||
} while(false);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void subghz_protocol_decoder_star_line_get_string(void* context, FuriString* output) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderStarLine* instance = context;
|
||||
|
||||
subghz_protocol_star_line_check_remote_controller(
|
||||
&instance->generic, instance->keystore, &instance->manufacture_name);
|
||||
|
||||
uint32_t code_found_hi = instance->generic.data >> 32;
|
||||
uint32_t code_found_lo = instance->generic.data & 0x00000000ffffffff;
|
||||
|
||||
uint64_t code_found_reverse = subghz_protocol_blocks_reverse_key(
|
||||
instance->generic.data, instance->generic.data_count_bit);
|
||||
uint32_t code_found_reverse_hi = code_found_reverse >> 32;
|
||||
uint32_t code_found_reverse_lo = code_found_reverse & 0x00000000ffffffff;
|
||||
|
||||
// push protocol data to global variable
|
||||
subghz_block_generic_global.cnt_is_available = true;
|
||||
subghz_block_generic_global.cnt_length_bit = 16;
|
||||
subghz_block_generic_global.current_cnt = instance->generic.cnt;
|
||||
|
||||
furi_string_cat_printf(
|
||||
output,
|
||||
"%s %dbit\r\n"
|
||||
"Key:%08lX%08lX\r\n"
|
||||
"Fix:0x%08lX Cnt:%04lX\r\n"
|
||||
"Hop:0x%08lX Btn:%02X\r\n"
|
||||
"MF:%s\r\n",
|
||||
instance->generic.protocol_name,
|
||||
instance->generic.data_count_bit,
|
||||
code_found_hi,
|
||||
code_found_lo,
|
||||
code_found_reverse_hi,
|
||||
instance->generic.cnt,
|
||||
code_found_reverse_lo,
|
||||
instance->generic.btn,
|
||||
instance->manufacture_name);
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "base.h"
|
||||
|
||||
#define SUBGHZ_PROTOCOL_STAR_LINE_NAME "Star Line"
|
||||
|
||||
typedef struct SubGhzProtocolDecoderStarLine SubGhzProtocolDecoderStarLine;
|
||||
typedef struct SubGhzProtocolEncoderStarLine SubGhzProtocolEncoderStarLine;
|
||||
|
||||
extern const SubGhzProtocolDecoder subghz_protocol_star_line_decoder;
|
||||
extern const SubGhzProtocolEncoder subghz_protocol_star_line_encoder;
|
||||
extern const SubGhzProtocol subghz_protocol_star_line;
|
||||
|
||||
/**
|
||||
* Allocate SubGhzProtocolEncoderStarLine.
|
||||
* @param environment Pointer to a SubGhzEnvironment instance
|
||||
* @return SubGhzProtocolEncoderStarLine* pointer to a SubGhzProtocolEncoderStarLine instance
|
||||
*/
|
||||
void* subghz_protocol_encoder_star_line_alloc(SubGhzEnvironment* environment);
|
||||
|
||||
/**
|
||||
* Free SubGhzProtocolEncoderStarLine.
|
||||
* @param context Pointer to a SubGhzProtocolEncoderStarLine instance
|
||||
*/
|
||||
void subghz_protocol_encoder_star_line_free(void* context);
|
||||
|
||||
/**
|
||||
* Deserialize and generating an upload to send.
|
||||
* @param context Pointer to a SubGhzProtocolEncoderStarLine instance
|
||||
* @param flipper_format Pointer to a FlipperFormat instance
|
||||
* @return true On success
|
||||
*/
|
||||
SubGhzProtocolStatus
|
||||
subghz_protocol_encoder_star_line_deserialize(void* context, FlipperFormat* flipper_format);
|
||||
|
||||
/**
|
||||
* Forced transmission stop.
|
||||
* @param context Pointer to a SubGhzProtocolEncoderStarLine instance
|
||||
*/
|
||||
void subghz_protocol_encoder_star_line_stop(void* context);
|
||||
|
||||
/**
|
||||
* Getting the level and duration of the upload to be loaded into DMA.
|
||||
* @param context Pointer to a SubGhzProtocolEncoderStarLine instance
|
||||
* @return LevelDuration
|
||||
*/
|
||||
LevelDuration subghz_protocol_encoder_star_line_yield(void* context);
|
||||
|
||||
/**
|
||||
* Allocate SubGhzProtocolDecoderStarLine.
|
||||
* @param environment Pointer to a SubGhzEnvironment instance
|
||||
* @return SubGhzProtocolDecoderStarLine* pointer to a SubGhzProtocolDecoderStarLine instance
|
||||
*/
|
||||
void* subghz_protocol_decoder_star_line_alloc(SubGhzEnvironment* environment);
|
||||
|
||||
/**
|
||||
* Free SubGhzProtocolDecoderStarLine.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderStarLine instance
|
||||
*/
|
||||
void subghz_protocol_decoder_star_line_free(void* context);
|
||||
|
||||
/**
|
||||
* Reset decoder SubGhzProtocolDecoderStarLine.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderStarLine instance
|
||||
*/
|
||||
void subghz_protocol_decoder_star_line_reset(void* context);
|
||||
|
||||
/**
|
||||
* Parse a raw sequence of levels and durations received from the air.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderStarLine instance
|
||||
* @param level Signal level true-high false-low
|
||||
* @param duration Duration of this level in, us
|
||||
*/
|
||||
void subghz_protocol_decoder_star_line_feed(void* context, bool level, uint32_t duration);
|
||||
|
||||
/**
|
||||
* Getting the hash sum of the last randomly received parcel.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderStarLine instance
|
||||
* @return hash Hash sum
|
||||
*/
|
||||
uint8_t subghz_protocol_decoder_star_line_get_hash_data(void* context);
|
||||
|
||||
/**
|
||||
* Serialize data SubGhzProtocolDecoderStarLine.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderStarLine 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_star_line_serialize(
|
||||
void* context,
|
||||
FlipperFormat* flipper_format,
|
||||
SubGhzRadioPreset* preset);
|
||||
|
||||
/**
|
||||
* Deserialize data SubGhzProtocolDecoderStarLine.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderStarLine instance
|
||||
* @param flipper_format Pointer to a FlipperFormat instance
|
||||
* @return status
|
||||
*/
|
||||
SubGhzProtocolStatus
|
||||
subghz_protocol_decoder_star_line_deserialize(void* context, FlipperFormat* flipper_format);
|
||||
|
||||
/**
|
||||
* Getting a textual representation of the received data.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderStarLine instance
|
||||
* @param output Resulting text
|
||||
*/
|
||||
void subghz_protocol_decoder_star_line_get_string(void* context, FuriString* output);
|
||||
+1
-1
@@ -125,7 +125,7 @@ typedef enum {
|
||||
SubGhzProtocolFlag_Load = (1 << 8),
|
||||
SubGhzProtocolFlag_Send = (1 << 9),
|
||||
SubGhzProtocolFlag_BinRAW = (1 << 10),
|
||||
SubGhzProtocolFlag_Cars = (1 << 11),
|
||||
SubGhzProtocolFlag_ReversRB2 = (1 << 11),
|
||||
SubGhzProtocolFlag_Alarms = (1 << 12),
|
||||
SubGhzProtocolFlag_Sensors = (1 << 13),
|
||||
SubGhzProtocolFlag_Princeton = (1 << 14),
|
||||
|
||||
Reference in New Issue
Block a user