mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Merge remote-tracking branch 'ul/dev' into mntm-dev --nobuild
This commit is contained in:
@@ -275,14 +275,27 @@ static bool subghz_protocol_alutech_at_4n_gen_data(
|
||||
instance->generic.serial = (uint32_t)(data >> 24) & 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
if(instance->generic.cnt < 0xFFFF) {
|
||||
if((instance->generic.cnt + furi_hal_subghz_get_rolling_counter_mult()) > 0xFFFF) {
|
||||
// Check for OFEX (overflow experimental) mode
|
||||
if(furi_hal_subghz_get_rolling_counter_mult() != 0xFFFE) {
|
||||
if(instance->generic.cnt < 0xFFFF) {
|
||||
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 >= 0xFFFF) &&
|
||||
(furi_hal_subghz_get_rolling_counter_mult() != 0)) {
|
||||
instance->generic.cnt = 0;
|
||||
} else {
|
||||
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
|
||||
}
|
||||
} else if((instance->generic.cnt >= 0xFFFF) && (furi_hal_subghz_get_rolling_counter_mult() != 0)) {
|
||||
instance->generic.cnt = 0;
|
||||
} else {
|
||||
if((instance->generic.cnt + 0x1) > 0xFFFF) {
|
||||
instance->generic.cnt = 0;
|
||||
} else if(instance->generic.cnt >= 0x1 && instance->generic.cnt != 0xFFFE) {
|
||||
instance->generic.cnt = furi_hal_subghz_get_rolling_counter_mult();
|
||||
} else {
|
||||
instance->generic.cnt++;
|
||||
}
|
||||
}
|
||||
crc = subghz_protocol_alutech_at_4n_decrypt_data_crc((uint8_t)(instance->generic.cnt & 0xFF));
|
||||
data = (uint64_t)crc << 56 | (uint64_t)instance->generic.serial << 24 |
|
||||
|
||||
@@ -187,14 +187,27 @@ static void subghz_protocol_encoder_came_atomo_get_upload(
|
||||
|
||||
uint8_t pack[8] = {};
|
||||
|
||||
if(instance->generic.cnt < 0xFFFF) {
|
||||
if((instance->generic.cnt + furi_hal_subghz_get_rolling_counter_mult()) > 0xFFFF) {
|
||||
// Check for OFEX (overflow experimental) mode
|
||||
if(furi_hal_subghz_get_rolling_counter_mult() != 0xFFFE) {
|
||||
if(instance->generic.cnt < 0xFFFF) {
|
||||
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 >= 0xFFFF) &&
|
||||
(furi_hal_subghz_get_rolling_counter_mult() != 0)) {
|
||||
instance->generic.cnt = 0;
|
||||
} else {
|
||||
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
|
||||
}
|
||||
} else if((instance->generic.cnt >= 0xFFFF) && (furi_hal_subghz_get_rolling_counter_mult() != 0)) {
|
||||
instance->generic.cnt = 0;
|
||||
} else {
|
||||
if((instance->generic.cnt + 0x1) > 0xFFFF) {
|
||||
instance->generic.cnt = 0;
|
||||
} else if(instance->generic.cnt >= 0x1 && instance->generic.cnt != 0xFFFE) {
|
||||
instance->generic.cnt = furi_hal_subghz_get_rolling_counter_mult();
|
||||
} else {
|
||||
instance->generic.cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
// Save original button for later use
|
||||
@@ -420,8 +433,11 @@ void subghz_protocol_decoder_came_atomo_feed(void* context, bool level, uint32_t
|
||||
ManchesterEvent event = ManchesterEventReset;
|
||||
switch(instance->decoder.parser_step) {
|
||||
case CameAtomoDecoderStepReset:
|
||||
if((!level) && (DURATION_DIFF(duration, subghz_protocol_came_atomo_const.te_long * 60) <
|
||||
subghz_protocol_came_atomo_const.te_delta * 40)) {
|
||||
// There are two known options for the header: 72K us (TOP42R, TOP44R) or 12k us (found on TOP44RBN)
|
||||
if((!level) && ((DURATION_DIFF(duration, subghz_protocol_came_atomo_const.te_long * 10) <
|
||||
subghz_protocol_came_atomo_const.te_delta * 20) ||
|
||||
(DURATION_DIFF(duration, subghz_protocol_came_atomo_const.te_long * 60) <
|
||||
subghz_protocol_came_atomo_const.te_delta * 40))) {
|
||||
//Found header CAME
|
||||
instance->decoder.parser_step = CameAtomoDecoderStepDecoderData;
|
||||
instance->decoder.decode_data = 0;
|
||||
|
||||
@@ -142,7 +142,7 @@ static bool subghz_protocol_faac_slh_gen_data(SubGhzProtocolEncoderFaacSLH* inst
|
||||
data_prg[0] = 0x00;
|
||||
|
||||
if(allow_zero_seed || (instance->generic.seed != 0x0)) {
|
||||
if(!(furi_hal_subghz_get_rolling_counter_mult() >= 0xFFFF)) {
|
||||
if(!(furi_hal_subghz_get_rolling_counter_mult() >= 0xFFFE)) {
|
||||
if(instance->generic.cnt < 0xFFFFF) {
|
||||
if((instance->generic.cnt + furi_hal_subghz_get_rolling_counter_mult()) >
|
||||
0xFFFFF) {
|
||||
@@ -160,7 +160,7 @@ static bool subghz_protocol_faac_slh_gen_data(SubGhzProtocolEncoderFaacSLH* inst
|
||||
}
|
||||
|
||||
if(temp_counter_backup != 0x0) {
|
||||
if(!(furi_hal_subghz_get_rolling_counter_mult() >= 0xFFFF)) {
|
||||
if(!(furi_hal_subghz_get_rolling_counter_mult() >= 0xFFFE)) {
|
||||
if(temp_counter_backup < 0xFFFFF) {
|
||||
if((temp_counter_backup + furi_hal_subghz_get_rolling_counter_mult()) >
|
||||
0xFFFFF) {
|
||||
@@ -242,7 +242,7 @@ static bool subghz_protocol_faac_slh_gen_data(SubGhzProtocolEncoderFaacSLH* inst
|
||||
}
|
||||
|
||||
if(allow_zero_seed || (instance->generic.seed != 0x0)) {
|
||||
if(!(furi_hal_subghz_get_rolling_counter_mult() >= 0xFFFF)) {
|
||||
if(!(furi_hal_subghz_get_rolling_counter_mult() >= 0xFFFE)) {
|
||||
if(instance->generic.cnt < 0xFFFFF) {
|
||||
if((instance->generic.cnt + furi_hal_subghz_get_rolling_counter_mult()) >
|
||||
0xFFFFF) {
|
||||
|
||||
@@ -147,17 +147,28 @@ static void subghz_protocol_encoder_hay21_get_upload(SubGhzProtocolEncoderHay21*
|
||||
instance->generic.btn = subghz_protocol_hay21_get_btn_code();
|
||||
|
||||
// Counter increment
|
||||
if(instance->generic.cnt < 0xF) {
|
||||
if((instance->generic.cnt + furi_hal_subghz_get_rolling_counter_mult()) > 0xF) {
|
||||
// Check for OFEX (overflow experimental) mode
|
||||
if(furi_hal_subghz_get_rolling_counter_mult() != 0xFFFE) {
|
||||
if(instance->generic.cnt < 0xF) {
|
||||
if((instance->generic.cnt + furi_hal_subghz_get_rolling_counter_mult()) > 0xF) {
|
||||
instance->generic.cnt = 0;
|
||||
} else {
|
||||
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
|
||||
}
|
||||
if(furi_hal_subghz_get_rolling_counter_mult() >= 0xF) {
|
||||
instance->generic.cnt = 0xF;
|
||||
}
|
||||
} else if(instance->generic.cnt >= 0xF) {
|
||||
instance->generic.cnt = 0;
|
||||
}
|
||||
} else {
|
||||
if((instance->generic.cnt + 0x1) > 0xF) {
|
||||
instance->generic.cnt = 0;
|
||||
} else if(instance->generic.cnt >= 0x1 && instance->generic.cnt != 0xE) {
|
||||
instance->generic.cnt = 0xE;
|
||||
} else {
|
||||
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
|
||||
instance->generic.cnt++;
|
||||
}
|
||||
if(furi_hal_subghz_get_rolling_counter_mult() >= 0xF) {
|
||||
instance->generic.cnt = 0xF;
|
||||
}
|
||||
} else if(instance->generic.cnt >= 0xF) {
|
||||
instance->generic.cnt = 0;
|
||||
}
|
||||
|
||||
// Reconstruction of the data
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
#include "honeywell.h"
|
||||
#include <lib/toolbox/manchester_decoder.h>
|
||||
|
||||
//Created by HTotoo 2023-10-30
|
||||
//Got a lot of help from LiQuiDz.
|
||||
//Protocol decoding help from: https://github.com/merbanan/rtl_433/blob/master/src/devices/honeywell.c
|
||||
#include <lib/toolbox/manchester_decoder.h>
|
||||
#include <lib/toolbox/manchester_encoder.h>
|
||||
#include "../blocks/const.h"
|
||||
#include "../blocks/decoder.h"
|
||||
#include "../blocks/encoder.h"
|
||||
#include "../blocks/generic.h"
|
||||
#include "../blocks/math.h"
|
||||
|
||||
// Created by HTotoo 2023-10-30
|
||||
// Got a lot of help from LiQuiDz.
|
||||
// Protocol decoding help from: https://github.com/merbanan/rtl_433/blob/master/src/devices/honeywell.c
|
||||
// Fixes and style changes to use similar codebase as other protocols by @xMasterX 2025-10
|
||||
|
||||
/*
|
||||
64 bit packets, repeated multiple times per open/close event.
|
||||
@@ -23,6 +31,95 @@ Data layout:
|
||||
|
||||
#define TAG "SubGhzProtocolHoneywell"
|
||||
|
||||
static const SubGhzBlockConst subghz_protocol_honeywell_const = {
|
||||
.te_long = 280,
|
||||
.te_short = 143,
|
||||
.te_delta = 51,
|
||||
.min_count_bit_for_found = 64,
|
||||
};
|
||||
|
||||
struct SubGhzProtocolDecoderHoneywell {
|
||||
SubGhzProtocolDecoderBase base;
|
||||
SubGhzBlockGeneric generic;
|
||||
SubGhzBlockDecoder decoder;
|
||||
ManchesterState manchester_saved_state;
|
||||
};
|
||||
|
||||
struct SubGhzProtocolEncoderHoneywell {
|
||||
SubGhzProtocolEncoderBase base;
|
||||
SubGhzBlockGeneric generic;
|
||||
SubGhzProtocolBlockEncoder encoder;
|
||||
};
|
||||
|
||||
const SubGhzProtocolDecoder subghz_protocol_honeywell_decoder = {
|
||||
.alloc = subghz_protocol_decoder_honeywell_alloc,
|
||||
.free = subghz_protocol_decoder_honeywell_free,
|
||||
.feed = subghz_protocol_decoder_honeywell_feed,
|
||||
.reset = subghz_protocol_decoder_honeywell_reset,
|
||||
.get_hash_data = NULL,
|
||||
.get_hash_data_long = subghz_protocol_decoder_honeywell_get_hash_data,
|
||||
.serialize = subghz_protocol_decoder_honeywell_serialize,
|
||||
.deserialize = subghz_protocol_decoder_honeywell_deserialize,
|
||||
.get_string = subghz_protocol_decoder_honeywell_get_string,
|
||||
.get_string_brief = NULL,
|
||||
};
|
||||
|
||||
const SubGhzProtocolEncoder subghz_protocol_honeywell_encoder = {
|
||||
.alloc = subghz_protocol_encoder_honeywell_alloc,
|
||||
.free = subghz_protocol_encoder_honeywell_free,
|
||||
.deserialize = subghz_protocol_encoder_honeywell_deserialize,
|
||||
.stop = subghz_protocol_encoder_honeywell_stop,
|
||||
.yield = subghz_protocol_encoder_honeywell_yield,
|
||||
};
|
||||
|
||||
const SubGhzProtocol subghz_protocol_honeywell = {
|
||||
.name = SUBGHZ_PROTOCOL_HONEYWELL_NAME,
|
||||
.type = SubGhzProtocolTypeStatic,
|
||||
.flag = SubGhzProtocolFlag_315 | SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable |
|
||||
SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save | SubGhzProtocolFlag_Send,
|
||||
.encoder = &subghz_protocol_honeywell_encoder,
|
||||
.decoder = &subghz_protocol_honeywell_decoder,
|
||||
.filter = SubGhzProtocolFilter_Sensors,
|
||||
|
||||
};
|
||||
|
||||
static void subghz_protocol_decoder_honeywell_addbit(void* context, bool data);
|
||||
|
||||
void* subghz_protocol_decoder_honeywell_alloc(SubGhzEnvironment* environment) {
|
||||
UNUSED(environment);
|
||||
SubGhzProtocolDecoderHoneywell* instance = malloc(sizeof(SubGhzProtocolDecoderHoneywell));
|
||||
instance->base.protocol = &subghz_protocol_honeywell;
|
||||
instance->generic.protocol_name = instance->base.protocol->name;
|
||||
return instance;
|
||||
}
|
||||
|
||||
void* subghz_protocol_encoder_honeywell_alloc(SubGhzEnvironment* environment) {
|
||||
UNUSED(environment);
|
||||
SubGhzProtocolEncoderHoneywell* instance = malloc(sizeof(SubGhzProtocolEncoderHoneywell));
|
||||
|
||||
instance->base.protocol = &subghz_protocol_honeywell;
|
||||
instance->generic.protocol_name = instance->base.protocol->name;
|
||||
|
||||
instance->encoder.repeat = 4;
|
||||
instance->encoder.size_upload = 64 * 2 + 10;
|
||||
instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration));
|
||||
instance->encoder.is_running = false;
|
||||
return instance;
|
||||
}
|
||||
|
||||
void subghz_protocol_encoder_honeywell_free(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolEncoderHoneywell* instance = context;
|
||||
free(instance->encoder.upload);
|
||||
free(instance);
|
||||
}
|
||||
|
||||
void subghz_protocol_decoder_honeywell_free(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderHoneywell* instance = context;
|
||||
free(instance);
|
||||
}
|
||||
|
||||
uint16_t subghz_protocol_honeywell_crc16(
|
||||
uint8_t const message[],
|
||||
unsigned nBytes,
|
||||
@@ -44,195 +141,6 @@ uint16_t subghz_protocol_honeywell_crc16(
|
||||
return remainder;
|
||||
}
|
||||
|
||||
void subghz_protocol_decoder_honeywell_free(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderHoneywell* instance = context;
|
||||
free(instance);
|
||||
}
|
||||
|
||||
void subghz_protocol_decoder_honeywell_reset(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderHoneywell* instance = context;
|
||||
instance->decoder.decode_data = 0;
|
||||
instance->decoder.decode_count_bit = 0;
|
||||
}
|
||||
|
||||
void subghz_protocol_decoder_honeywell_addbit(void* context, bool data) {
|
||||
SubGhzProtocolDecoderHoneywell* instance = context;
|
||||
instance->decoder.decode_data = (instance->decoder.decode_data << 1) | data;
|
||||
instance->decoder.decode_count_bit++;
|
||||
|
||||
if(instance->decoder.decode_count_bit < 62) return;
|
||||
|
||||
uint16_t preamble = (instance->decoder.decode_data >> 48) & 0xFFFF;
|
||||
//can be multiple, since flipper can't read it well..
|
||||
if(preamble == 0b0011111111111110 || preamble == 0b0111111111111110 ||
|
||||
preamble == 0b1111111111111110) {
|
||||
uint8_t datatocrc[4];
|
||||
datatocrc[0] = (instance->decoder.decode_data >> 40) & 0xFFFF;
|
||||
datatocrc[1] = (instance->decoder.decode_data >> 32) & 0xFFFF;
|
||||
datatocrc[2] = (instance->decoder.decode_data >> 24) & 0xFFFF;
|
||||
datatocrc[3] = (instance->decoder.decode_data >> 16) & 0xFFFF;
|
||||
uint8_t channel = (instance->decoder.decode_data >> 44) & 0xF;
|
||||
uint16_t crc_calc = 0;
|
||||
if(channel == 0x2 || channel == 0x4 || channel == 0xA) {
|
||||
// 2GIG brand
|
||||
crc_calc = subghz_protocol_honeywell_crc16(datatocrc, 4, 0x8050, 0);
|
||||
} else if(channel == 0x8) {
|
||||
crc_calc = subghz_protocol_honeywell_crc16(datatocrc, 4, 0x8005, 0);
|
||||
} else {
|
||||
instance->decoder.decode_data = 0;
|
||||
instance->decoder.decode_count_bit = 0;
|
||||
return;
|
||||
}
|
||||
uint16_t crc = instance->decoder.decode_data & 0xFFFF;
|
||||
if(crc == crc_calc) {
|
||||
//the data is good. process it.
|
||||
instance->generic.data = instance->decoder.decode_data;
|
||||
instance->generic.data_count_bit =
|
||||
instance->decoder
|
||||
.decode_count_bit; //maybe set it to 64, and hack the first 2 bits to 1! will see if replay needs it
|
||||
if(instance->base.callback)
|
||||
instance->base.callback(&instance->base, instance->base.context);
|
||||
instance->decoder.decode_data = 0;
|
||||
instance->decoder.decode_count_bit = 0;
|
||||
} else {
|
||||
instance->decoder.decode_data = 0;
|
||||
instance->decoder.decode_count_bit = 0;
|
||||
return;
|
||||
}
|
||||
} else if(instance->decoder.decode_count_bit >= 64) {
|
||||
instance->decoder.decode_data = 0;
|
||||
instance->decoder.decode_count_bit = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void subghz_protocol_decoder_honeywell_feed(void* context, bool level, uint32_t duration) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderHoneywell* instance = context;
|
||||
|
||||
ManchesterEvent event = ManchesterEventReset;
|
||||
if(!level) {
|
||||
if(DURATION_DIFF(duration, subghz_protocol_honeywell_const.te_short) <
|
||||
subghz_protocol_honeywell_const.te_delta) {
|
||||
event = ManchesterEventShortLow;
|
||||
} else if(
|
||||
DURATION_DIFF(duration, subghz_protocol_honeywell_const.te_long) <
|
||||
subghz_protocol_honeywell_const.te_delta * 2) {
|
||||
event = ManchesterEventLongLow;
|
||||
}
|
||||
} else {
|
||||
if(DURATION_DIFF(duration, subghz_protocol_honeywell_const.te_short) <
|
||||
subghz_protocol_honeywell_const.te_delta) {
|
||||
event = ManchesterEventShortHigh;
|
||||
} else if(
|
||||
DURATION_DIFF(duration, subghz_protocol_honeywell_const.te_long) <
|
||||
subghz_protocol_honeywell_const.te_delta * 2) {
|
||||
event = ManchesterEventLongHigh;
|
||||
}
|
||||
}
|
||||
if(event != ManchesterEventReset) {
|
||||
bool data;
|
||||
bool data_ok = manchester_advance(
|
||||
instance->manchester_saved_state, event, &instance->manchester_saved_state, &data);
|
||||
if(data_ok) {
|
||||
subghz_protocol_decoder_honeywell_addbit(instance, data);
|
||||
}
|
||||
} else {
|
||||
instance->decoder.decode_data = 0;
|
||||
instance->decoder.decode_count_bit = 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t subghz_protocol_decoder_honeywell_get_hash_data(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderHoneywell* instance = context;
|
||||
return subghz_protocol_blocks_get_hash_data_long(
|
||||
&instance->decoder, (instance->decoder.decode_count_bit / 8) + 1);
|
||||
}
|
||||
|
||||
SubGhzProtocolStatus subghz_protocol_decoder_honeywell_serialize(
|
||||
void* context,
|
||||
FlipperFormat* flipper_format,
|
||||
SubGhzRadioPreset* preset) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderHoneywell* instance = context;
|
||||
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
|
||||
}
|
||||
|
||||
SubGhzProtocolStatus
|
||||
subghz_protocol_decoder_honeywell_deserialize(void* context, FlipperFormat* flipper_format) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderHoneywell* instance = context;
|
||||
return subghz_block_generic_deserialize_check_count_bit(
|
||||
&instance->generic,
|
||||
flipper_format,
|
||||
subghz_protocol_honeywell_const.min_count_bit_for_found);
|
||||
}
|
||||
|
||||
void subghz_protocol_decoder_honeywell_get_string(void* context, FuriString* output) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderHoneywell* instance = context;
|
||||
|
||||
// Parse here and not in decode to avoid visual glitches when loading from file
|
||||
instance->generic.serial = (instance->generic.data >> 24) & 0xFFFFF;
|
||||
instance->generic.btn = (instance->generic.data >> 16) &
|
||||
0xFF; //not exactly button, but can contain btn data too.
|
||||
|
||||
uint8_t channel = (instance->generic.data >> 44) & 0xF;
|
||||
uint8_t contact = (instance->generic.btn & 0x80) >> 7;
|
||||
uint8_t tamper = (instance->generic.btn & 0x40) >> 6;
|
||||
uint8_t reed = (instance->generic.btn & 0x20) >> 5;
|
||||
uint8_t alarm = (instance->generic.btn & 0x10) >> 4;
|
||||
uint8_t battery_low = (instance->generic.btn & 0x08) >> 3;
|
||||
uint8_t heartbeat = (instance->generic.btn & 0x04) >> 2;
|
||||
|
||||
furi_string_cat_printf(
|
||||
output,
|
||||
"%s\r\n%dbit "
|
||||
"Sn:%07lu\r\nCh:%u Bat:%d Hb: %d\r\n"
|
||||
"L1: %u, L2: %u, L3: %u, L4: %u\r\n",
|
||||
instance->generic.protocol_name,
|
||||
instance->generic.data_count_bit,
|
||||
instance->generic.serial,
|
||||
channel,
|
||||
battery_low,
|
||||
heartbeat,
|
||||
contact,
|
||||
reed,
|
||||
alarm,
|
||||
tamper);
|
||||
}
|
||||
|
||||
void* subghz_protocol_decoder_honeywell_alloc(SubGhzEnvironment* environment) {
|
||||
UNUSED(environment);
|
||||
SubGhzProtocolDecoderHoneywell* instance = malloc(sizeof(SubGhzProtocolDecoderHoneywell));
|
||||
instance->base.protocol = &subghz_protocol_honeywell;
|
||||
instance->generic.protocol_name = instance->base.protocol->name;
|
||||
return instance;
|
||||
}
|
||||
|
||||
void* subghz_protocol_encoder_honeywell_alloc(SubGhzEnvironment* environment) {
|
||||
UNUSED(environment);
|
||||
SubGhzProtocolEncoderHoneywell* instance = malloc(sizeof(SubGhzProtocolEncoderHoneywell));
|
||||
|
||||
instance->base.protocol = &subghz_protocol_honeywell;
|
||||
instance->generic.protocol_name = instance->base.protocol->name;
|
||||
|
||||
instance->encoder.repeat = 3;
|
||||
instance->encoder.size_upload = 64 * 2 + 10;
|
||||
instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration));
|
||||
instance->encoder.is_running = false;
|
||||
return instance;
|
||||
}
|
||||
|
||||
void subghz_protocol_encoder_honeywell_free(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolEncoderHoneywell* instance = context;
|
||||
free(instance->encoder.upload);
|
||||
free(instance);
|
||||
}
|
||||
static LevelDuration
|
||||
subghz_protocol_encoder_honeywell_add_duration_to_upload(ManchesterEncoderResult result) {
|
||||
LevelDuration data = {.duration = 0, .level = 0};
|
||||
@@ -286,6 +194,10 @@ static void
|
||||
if(level_duration_get_level(instance->encoder.upload[index])) {
|
||||
index++;
|
||||
}
|
||||
//Send delay
|
||||
instance->encoder.upload[index++] =
|
||||
level_duration_make(false, (uint32_t)subghz_protocol_honeywell_const.te_long * 300);
|
||||
|
||||
instance->encoder.size_upload = index;
|
||||
}
|
||||
|
||||
@@ -340,35 +252,188 @@ LevelDuration subghz_protocol_encoder_honeywell_yield(void* context) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
const SubGhzProtocolDecoder subghz_protocol_honeywell_decoder = {
|
||||
.alloc = subghz_protocol_decoder_honeywell_alloc,
|
||||
.free = subghz_protocol_decoder_honeywell_free,
|
||||
.feed = subghz_protocol_decoder_honeywell_feed,
|
||||
.reset = subghz_protocol_decoder_honeywell_reset,
|
||||
.get_hash_data = NULL,
|
||||
.get_hash_data_long = subghz_protocol_decoder_honeywell_get_hash_data,
|
||||
.serialize = subghz_protocol_decoder_honeywell_serialize,
|
||||
.deserialize = subghz_protocol_decoder_honeywell_deserialize,
|
||||
.get_string = subghz_protocol_decoder_honeywell_get_string,
|
||||
.get_string_brief = NULL,
|
||||
};
|
||||
void subghz_protocol_decoder_honeywell_reset(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderHoneywell* instance = context;
|
||||
instance->decoder.decode_data = 0;
|
||||
instance->decoder.decode_count_bit = 0;
|
||||
}
|
||||
|
||||
const SubGhzProtocolEncoder subghz_protocol_honeywell_encoder = {
|
||||
.alloc = subghz_protocol_encoder_honeywell_alloc,
|
||||
.free = subghz_protocol_encoder_honeywell_free,
|
||||
.deserialize = subghz_protocol_encoder_honeywell_deserialize,
|
||||
.stop = subghz_protocol_encoder_honeywell_stop,
|
||||
.yield = subghz_protocol_encoder_honeywell_yield,
|
||||
};
|
||||
void subghz_protocol_decoder_honeywell_feed(void* context, bool level, uint32_t duration) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderHoneywell* instance = context;
|
||||
|
||||
const SubGhzProtocol subghz_protocol_honeywell = {
|
||||
.name = SUBGHZ_PROTOCOL_HONEYWELL_NAME,
|
||||
.type = SubGhzProtocolTypeStatic,
|
||||
.flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 |
|
||||
SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load |
|
||||
SubGhzProtocolFlag_Save | SubGhzProtocolFlag_Send,
|
||||
.encoder = &subghz_protocol_honeywell_encoder,
|
||||
.decoder = &subghz_protocol_honeywell_decoder,
|
||||
ManchesterEvent event = ManchesterEventReset;
|
||||
if(!level) {
|
||||
if(DURATION_DIFF(duration, subghz_protocol_honeywell_const.te_short) <
|
||||
subghz_protocol_honeywell_const.te_delta) {
|
||||
event = ManchesterEventShortLow;
|
||||
} else if(
|
||||
DURATION_DIFF(duration, subghz_protocol_honeywell_const.te_long) <
|
||||
subghz_protocol_honeywell_const.te_delta * 2) {
|
||||
event = ManchesterEventLongLow;
|
||||
}
|
||||
} else {
|
||||
if(DURATION_DIFF(duration, subghz_protocol_honeywell_const.te_short) <
|
||||
subghz_protocol_honeywell_const.te_delta) {
|
||||
event = ManchesterEventShortHigh;
|
||||
} else if(
|
||||
DURATION_DIFF(duration, subghz_protocol_honeywell_const.te_long) <
|
||||
subghz_protocol_honeywell_const.te_delta * 2) {
|
||||
event = ManchesterEventLongHigh;
|
||||
}
|
||||
}
|
||||
if(event != ManchesterEventReset) {
|
||||
bool data;
|
||||
bool data_ok = manchester_advance(
|
||||
instance->manchester_saved_state, event, &instance->manchester_saved_state, &data);
|
||||
if(data_ok) {
|
||||
subghz_protocol_decoder_honeywell_addbit(instance, data);
|
||||
}
|
||||
} else {
|
||||
instance->decoder.decode_data = 0;
|
||||
instance->decoder.decode_count_bit = 0;
|
||||
}
|
||||
}
|
||||
|
||||
.filter = SubGhzProtocolFilter_Sensors,
|
||||
};
|
||||
static void subghz_protocol_decoder_honeywell_addbit(void* context, bool data) {
|
||||
SubGhzProtocolDecoderHoneywell* instance = context;
|
||||
instance->decoder.decode_data = (instance->decoder.decode_data << 1) | data;
|
||||
instance->decoder.decode_count_bit++;
|
||||
|
||||
if(instance->decoder.decode_count_bit < 62) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint16_t preamble = (instance->decoder.decode_data >> 48) & 0xFFFF;
|
||||
//can be multiple, since flipper can't read it well.. (it can, but the sensors are not that good, there are multiple of variations seen)
|
||||
if(preamble == 0b0011111111111110 || preamble == 0b0111111111111110 ||
|
||||
preamble == 0b1111111111111110) {
|
||||
uint8_t datatocrc[4];
|
||||
datatocrc[0] = (instance->decoder.decode_data >> 40) & 0xFF;
|
||||
datatocrc[1] = (instance->decoder.decode_data >> 32) & 0xFF;
|
||||
datatocrc[2] = (instance->decoder.decode_data >> 24) & 0xFF;
|
||||
datatocrc[3] = (instance->decoder.decode_data >> 16) & 0xFF;
|
||||
uint8_t channel = (instance->decoder.decode_data >> 44) & 0xF;
|
||||
uint16_t crc_calc = 0;
|
||||
if(channel == 0x2 || channel == 0x4 || channel == 0xA) {
|
||||
// 2GIG brand
|
||||
crc_calc = subghz_protocol_honeywell_crc16(datatocrc, 4, 0x8050, 0);
|
||||
} else if(channel == 0x8) {
|
||||
crc_calc = subghz_protocol_honeywell_crc16(datatocrc, 4, 0x8005, 0);
|
||||
} else {
|
||||
instance->decoder.decode_data = 0;
|
||||
instance->decoder.decode_count_bit = 0;
|
||||
return;
|
||||
}
|
||||
uint16_t crc = instance->decoder.decode_data & 0xFFFF;
|
||||
if(crc == crc_calc) {
|
||||
// Removing possible artifacts from higher bits and setting header to FF FE
|
||||
instance->generic.data =
|
||||
((((((0xFF << 16) | ((instance->decoder.decode_data >> 40) & 0xFFFF)) << 16) |
|
||||
((instance->decoder.decode_data >> 24) & 0xFFFF))
|
||||
<< 16) |
|
||||
((instance->decoder.decode_data >> 8) & 0xFFFF))
|
||||
<< 8 |
|
||||
(instance->decoder.decode_data & 0xFF);
|
||||
instance->generic.data_count_bit = 64;
|
||||
if(instance->base.callback)
|
||||
instance->base.callback(&instance->base, instance->base.context);
|
||||
instance->decoder.decode_data = 0;
|
||||
instance->decoder.decode_count_bit = 0;
|
||||
} else {
|
||||
instance->decoder.decode_data = 0;
|
||||
instance->decoder.decode_count_bit = 0;
|
||||
return;
|
||||
}
|
||||
} else if(instance->decoder.decode_count_bit >= 64) {
|
||||
instance->decoder.decode_data = 0;
|
||||
instance->decoder.decode_count_bit = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t subghz_protocol_decoder_honeywell_get_hash_data(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderHoneywell* instance = context;
|
||||
return subghz_protocol_blocks_get_hash_data_long(
|
||||
&instance->decoder, (instance->decoder.decode_count_bit / 8) + 1);
|
||||
}
|
||||
|
||||
SubGhzProtocolStatus subghz_protocol_decoder_honeywell_serialize(
|
||||
void* context,
|
||||
FlipperFormat* flipper_format,
|
||||
SubGhzRadioPreset* preset) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderHoneywell* instance = context;
|
||||
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
|
||||
}
|
||||
|
||||
SubGhzProtocolStatus
|
||||
subghz_protocol_decoder_honeywell_deserialize(void* context, FlipperFormat* flipper_format) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderHoneywell* instance = context;
|
||||
|
||||
SubGhzProtocolStatus res = SubGhzProtocolStatusError;
|
||||
res = subghz_block_generic_deserialize(&instance->generic, flipper_format);
|
||||
if(res != SubGhzProtocolStatusOk) {
|
||||
return res;
|
||||
}
|
||||
|
||||
if(instance->generic.data_count_bit != 64) {
|
||||
if(instance->generic.data_count_bit < 62) {
|
||||
return SubGhzProtocolStatusErrorValueBitCount;
|
||||
}
|
||||
// Removing possible artifacts from higher bits and setting header to FF FE
|
||||
instance->generic.data =
|
||||
((((((0xFF << 16) | ((instance->generic.data >> 40) & 0xFFFF)) << 16) |
|
||||
((instance->generic.data >> 24) & 0xFFFF))
|
||||
<< 16) |
|
||||
((instance->generic.data >> 8) & 0xFFFF))
|
||||
<< 8 |
|
||||
(instance->generic.data & 0xFF);
|
||||
instance->generic.data_count_bit = 64;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void subghz_protocol_decoder_honeywell_get_string(void* context, FuriString* output) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderHoneywell* instance = context;
|
||||
|
||||
uint32_t code_found_hi = instance->generic.data >> 32;
|
||||
uint32_t code_found_lo = instance->generic.data & 0x00000000ffffffff;
|
||||
|
||||
instance->generic.serial = (instance->generic.data >> 24) & 0xFFFFF;
|
||||
uint8_t sensor_status = (instance->generic.data >> 16) & 0xFF;
|
||||
|
||||
uint8_t channel = (instance->generic.data >> 44) & 0xF;
|
||||
uint8_t contact = (sensor_status & 0x80) >> 7;
|
||||
uint8_t tamper = (sensor_status & 0x40) >> 6;
|
||||
uint8_t reed = (sensor_status & 0x20) >> 5;
|
||||
uint8_t alarm = (sensor_status & 0x10) >> 4;
|
||||
uint8_t battery_low = (sensor_status & 0x08) >> 3;
|
||||
uint8_t heartbeat = (sensor_status & 0x04) >> 2;
|
||||
|
||||
furi_string_cat_printf(
|
||||
output,
|
||||
"%s\r\n%dbit "
|
||||
"Sn:%07lu Ch:%u\r\n"
|
||||
"LowBat:%d HB: %d Cont: %s\r\n"
|
||||
"Key:%08lX%08lX\r\n"
|
||||
"State: L1:%u L2:%u L3:%u L4:%u",
|
||||
instance->generic.protocol_name,
|
||||
instance->generic.data_count_bit,
|
||||
instance->generic.serial,
|
||||
channel,
|
||||
battery_low,
|
||||
heartbeat,
|
||||
contact ? "open" : "closed",
|
||||
code_found_hi,
|
||||
code_found_lo,
|
||||
contact,
|
||||
reed,
|
||||
alarm,
|
||||
tamper);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <lib/subghz/protocols/base.h>
|
||||
|
||||
#include <lib/subghz/blocks/const.h>
|
||||
#include <lib/subghz/blocks/decoder.h>
|
||||
#include <lib/subghz/blocks/encoder.h>
|
||||
#include "base.h"
|
||||
#include "../blocks/generic.h"
|
||||
#include <lib/subghz/blocks/math.h>
|
||||
#include <lib/toolbox/manchester_decoder.h>
|
||||
#include <lib/toolbox/manchester_encoder.h>
|
||||
|
||||
#define SUBGHZ_PROTOCOL_HONEYWELL_NAME "Honeywell Sec"
|
||||
|
||||
@@ -20,42 +11,99 @@ extern const SubGhzProtocolDecoder subghz_protocol_honeywell_decoder;
|
||||
extern const SubGhzProtocolEncoder subghz_protocol_honeywell_encoder;
|
||||
extern const SubGhzProtocol subghz_protocol_honeywell;
|
||||
|
||||
/**
|
||||
* Allocate SubGhzProtocolEncoderHoneywell.
|
||||
* @param environment Pointer to a SubGhzEnvironment instance
|
||||
* @return SubGhzProtocolEncoderHoneywell* pointer to a SubGhzProtocolEncoderHoneywell instance
|
||||
*/
|
||||
void* subghz_protocol_encoder_honeywell_alloc(SubGhzEnvironment* environment);
|
||||
|
||||
/**
|
||||
* Free SubGhzProtocolEncoderHoneywell.
|
||||
* @param context Pointer to a SubGhzProtocolEncoderHoneywell instance
|
||||
*/
|
||||
void subghz_protocol_encoder_honeywell_free(void* context);
|
||||
|
||||
/**
|
||||
* Deserialize and generating an upload to send.
|
||||
* @param context Pointer to a SubGhzProtocolEncoderHoneywell instance
|
||||
* @param flipper_format Pointer to a FlipperFormat instance
|
||||
* @return status
|
||||
*/
|
||||
SubGhzProtocolStatus
|
||||
subghz_protocol_encoder_honeywell_deserialize(void* context, FlipperFormat* flipper_format);
|
||||
|
||||
/**
|
||||
* Forced transmission stop.
|
||||
* @param context Pointer to a SubGhzProtocolEncoderHoneywell instance
|
||||
*/
|
||||
void subghz_protocol_encoder_honeywell_stop(void* context);
|
||||
|
||||
/**
|
||||
* Getting the level and duration of the upload to be loaded into DMA.
|
||||
* @param context Pointer to a SubGhzProtocolEncoderHoneywell instance
|
||||
* @return LevelDuration
|
||||
*/
|
||||
LevelDuration subghz_protocol_encoder_honeywell_yield(void* context);
|
||||
|
||||
/**
|
||||
* Allocate SubGhzProtocolDecoderHoneywell.
|
||||
* @param environment Pointer to a SubGhzEnvironment instance
|
||||
* @return SubGhzProtocolDecoderHoneywell* pointer to a SubGhzProtocolDecoderHoneywell instance
|
||||
*/
|
||||
void* subghz_protocol_decoder_honeywell_alloc(SubGhzEnvironment* environment);
|
||||
|
||||
/**
|
||||
* Free SubGhzProtocolDecoderHoneywell.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderHoneywell instance
|
||||
*/
|
||||
void subghz_protocol_decoder_honeywell_free(void* context);
|
||||
|
||||
/**
|
||||
* Reset decoder SubGhzProtocolDecoderHoneywell.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderHoneywell instance
|
||||
*/
|
||||
void subghz_protocol_decoder_honeywell_reset(void* context);
|
||||
|
||||
/**
|
||||
* Parse a raw sequence of levels and durations received from the air.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderHoneywell instance
|
||||
* @param level Signal level true-high false-low
|
||||
* @param duration Duration of this level in, us
|
||||
*/
|
||||
void subghz_protocol_decoder_honeywell_feed(void* context, bool level, uint32_t duration);
|
||||
|
||||
/**
|
||||
* Getting the hash sum of the last randomly received parcel.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderHoneywell instance
|
||||
* @return hash Hash sum
|
||||
*/
|
||||
uint32_t subghz_protocol_decoder_honeywell_get_hash_data(void* context);
|
||||
|
||||
/**
|
||||
* Serialize data SubGhzProtocolDecoderHoneywell.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderHoneywell 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_honeywell_serialize(
|
||||
void* context,
|
||||
FlipperFormat* flipper_format,
|
||||
SubGhzRadioPreset* preset);
|
||||
|
||||
/**
|
||||
* Deserialize data SubGhzProtocolDecoderHoneywell.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderHoneywell instance
|
||||
* @param flipper_format Pointer to a FlipperFormat instance
|
||||
* @return status
|
||||
*/
|
||||
SubGhzProtocolStatus
|
||||
subghz_protocol_decoder_honeywell_deserialize(void* context, FlipperFormat* flipper_format);
|
||||
|
||||
/**
|
||||
* Getting a textual representation of the received data.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderHoneywell instance
|
||||
* @param output Resulting text
|
||||
*/
|
||||
void subghz_protocol_decoder_honeywell_get_string(void* context, FuriString* output);
|
||||
|
||||
static const SubGhzBlockConst subghz_protocol_honeywell_const = {
|
||||
.te_long = 280,
|
||||
.te_short = 143,
|
||||
.te_delta = 51,
|
||||
.min_count_bit_for_found = 62,
|
||||
};
|
||||
|
||||
struct SubGhzProtocolDecoderHoneywell {
|
||||
SubGhzProtocolDecoderBase base;
|
||||
SubGhzBlockGeneric generic;
|
||||
SubGhzBlockDecoder decoder;
|
||||
ManchesterState manchester_saved_state;
|
||||
};
|
||||
|
||||
struct SubGhzProtocolEncoderHoneywell {
|
||||
SubGhzProtocolEncoderBase base;
|
||||
SubGhzBlockGeneric generic;
|
||||
SubGhzProtocolBlockEncoder encoder;
|
||||
};
|
||||
|
||||
@@ -184,18 +184,29 @@ static bool subghz_protocol_keeloq_gen_data(
|
||||
if(counter_up && prog_mode == PROG_MODE_OFF) {
|
||||
// Counter increment conditions
|
||||
|
||||
// If counter is 0xFFFF we will reset it to 0
|
||||
if(instance->generic.cnt < 0xFFFF) {
|
||||
// Increase counter with value set in global settings (mult)
|
||||
if((instance->generic.cnt + furi_hal_subghz_get_rolling_counter_mult()) > 0xFFFF) {
|
||||
// Check for OFEX (overflow experimental) mode
|
||||
if(furi_hal_subghz_get_rolling_counter_mult() != 0xFFFE) {
|
||||
// If counter is 0xFFFF we will reset it to 0
|
||||
if(instance->generic.cnt < 0xFFFF) {
|
||||
// Increase counter with value set in global settings (mult)
|
||||
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 >= 0xFFFF) &&
|
||||
(furi_hal_subghz_get_rolling_counter_mult() != 0)) {
|
||||
instance->generic.cnt = 0;
|
||||
} else {
|
||||
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
|
||||
}
|
||||
} else if(
|
||||
(instance->generic.cnt >= 0xFFFF) &&
|
||||
(furi_hal_subghz_get_rolling_counter_mult() != 0)) {
|
||||
instance->generic.cnt = 0;
|
||||
} else {
|
||||
if((instance->generic.cnt + 0x1) > 0xFFFF) {
|
||||
instance->generic.cnt = 0;
|
||||
} else if(instance->generic.cnt >= 0x1 && instance->generic.cnt != 0xFFFE) {
|
||||
instance->generic.cnt = furi_hal_subghz_get_rolling_counter_mult();
|
||||
} else {
|
||||
instance->generic.cnt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(prog_mode == PROG_MODE_OFF) {
|
||||
|
||||
@@ -157,14 +157,27 @@ static bool subghz_protocol_kinggates_stylo_4k_gen_data(
|
||||
}
|
||||
instance->generic.cnt = decrypt & 0xFFFF;
|
||||
|
||||
if(instance->generic.cnt < 0xFFFF) {
|
||||
if((instance->generic.cnt + furi_hal_subghz_get_rolling_counter_mult()) > 0xFFFF) {
|
||||
// Check for OFEX (overflow experimental) mode
|
||||
if(furi_hal_subghz_get_rolling_counter_mult() != 0xFFFE) {
|
||||
if(instance->generic.cnt < 0xFFFF) {
|
||||
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 >= 0xFFFF) &&
|
||||
(furi_hal_subghz_get_rolling_counter_mult() != 0)) {
|
||||
instance->generic.cnt = 0;
|
||||
} else {
|
||||
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
|
||||
}
|
||||
} else if((instance->generic.cnt >= 0xFFFF) && (furi_hal_subghz_get_rolling_counter_mult() != 0)) {
|
||||
instance->generic.cnt = 0;
|
||||
} else {
|
||||
if((instance->generic.cnt + 0x1) > 0xFFFF) {
|
||||
instance->generic.cnt = 0;
|
||||
} else if(instance->generic.cnt >= 0x1 && instance->generic.cnt != 0xFFFE) {
|
||||
instance->generic.cnt = furi_hal_subghz_get_rolling_counter_mult();
|
||||
} else {
|
||||
instance->generic.cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
instance->generic.btn = (fix >> 17) & 0x0F;
|
||||
|
||||
@@ -155,15 +155,29 @@ static void subghz_protocol_encoder_nice_flor_s_get_upload(
|
||||
instance->encoder.size_upload = size_upload;
|
||||
}
|
||||
|
||||
if(instance->generic.cnt < 0xFFFF) {
|
||||
if((instance->generic.cnt + furi_hal_subghz_get_rolling_counter_mult()) > 0xFFFF) {
|
||||
// Check for OFEX (overflow experimental) mode
|
||||
if(furi_hal_subghz_get_rolling_counter_mult() != 0xFFFE) {
|
||||
if(instance->generic.cnt < 0xFFFF) {
|
||||
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 >= 0xFFFF) &&
|
||||
(furi_hal_subghz_get_rolling_counter_mult() != 0)) {
|
||||
instance->generic.cnt = 0;
|
||||
} else {
|
||||
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
|
||||
}
|
||||
} else if((instance->generic.cnt >= 0xFFFF) && (furi_hal_subghz_get_rolling_counter_mult() != 0)) {
|
||||
instance->generic.cnt = 0;
|
||||
} else {
|
||||
if((instance->generic.cnt + 0x1) > 0xFFFF) {
|
||||
instance->generic.cnt = 0;
|
||||
} else if(instance->generic.cnt >= 0x1 && instance->generic.cnt != 0xFFFE) {
|
||||
instance->generic.cnt = furi_hal_subghz_get_rolling_counter_mult();
|
||||
} else {
|
||||
instance->generic.cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t decrypt = ((uint64_t)instance->generic.serial << 16) | instance->generic.cnt;
|
||||
uint64_t enc_part = subghz_protocol_nice_flor_s_encrypt(decrypt, file_name);
|
||||
|
||||
|
||||
@@ -254,14 +254,27 @@ static bool
|
||||
btn = subghz_protocol_phoenix_v2_get_btn_code();
|
||||
|
||||
// Reconstruction of the data
|
||||
if(instance->generic.cnt < 0xFFFF) {
|
||||
if((instance->generic.cnt + furi_hal_subghz_get_rolling_counter_mult()) > 0xFFFF) {
|
||||
// Check for OFEX (overflow experimental) mode
|
||||
if(furi_hal_subghz_get_rolling_counter_mult() != 0xFFFE) {
|
||||
if(instance->generic.cnt < 0xFFFF) {
|
||||
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 >= 0xFFFF) &&
|
||||
(furi_hal_subghz_get_rolling_counter_mult() != 0)) {
|
||||
instance->generic.cnt = 0;
|
||||
} else {
|
||||
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
|
||||
}
|
||||
} else if((instance->generic.cnt >= 0xFFFF) && (furi_hal_subghz_get_rolling_counter_mult() != 0)) {
|
||||
instance->generic.cnt = 0;
|
||||
} else {
|
||||
if((instance->generic.cnt + 0x1) > 0xFFFF) {
|
||||
instance->generic.cnt = 0;
|
||||
} else if(instance->generic.cnt >= 0x1 && instance->generic.cnt != 0xFFFE) {
|
||||
instance->generic.cnt = furi_hal_subghz_get_rolling_counter_mult();
|
||||
} else {
|
||||
instance->generic.cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t local_data_rev = subghz_protocol_blocks_reverse_key(
|
||||
|
||||
@@ -132,14 +132,27 @@ static bool
|
||||
instance->generic.cnt = (data >> 24) & 0xFFFF;
|
||||
instance->generic.serial = data & 0xFFFFFF;
|
||||
|
||||
if(instance->generic.cnt < 0xFFFF) {
|
||||
if((instance->generic.cnt + furi_hal_subghz_get_rolling_counter_mult()) > 0xFFFF) {
|
||||
// Check for OFEX (overflow experimental) mode
|
||||
if(furi_hal_subghz_get_rolling_counter_mult() != 0xFFFE) {
|
||||
if(instance->generic.cnt < 0xFFFF) {
|
||||
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 >= 0xFFFF) &&
|
||||
(furi_hal_subghz_get_rolling_counter_mult() != 0)) {
|
||||
instance->generic.cnt = 0;
|
||||
} else {
|
||||
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
|
||||
}
|
||||
} else if((instance->generic.cnt >= 0xFFFF) && (furi_hal_subghz_get_rolling_counter_mult() != 0)) {
|
||||
instance->generic.cnt = 0;
|
||||
} else {
|
||||
if((instance->generic.cnt + 0x1) > 0xFFFF) {
|
||||
instance->generic.cnt = 0;
|
||||
} else if(instance->generic.cnt >= 0x1 && instance->generic.cnt != 0xFFFE) {
|
||||
instance->generic.cnt = furi_hal_subghz_get_rolling_counter_mult();
|
||||
} else {
|
||||
instance->generic.cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t frame[10];
|
||||
|
||||
@@ -126,14 +126,27 @@ static bool subghz_protocol_somfy_telis_gen_data(
|
||||
|
||||
btn = subghz_protocol_somfy_telis_get_btn_code();
|
||||
|
||||
if(instance->generic.cnt < 0xFFFF) {
|
||||
if((instance->generic.cnt + furi_hal_subghz_get_rolling_counter_mult()) > 0xFFFF) {
|
||||
// Check for OFEX (overflow experimental) mode
|
||||
if(furi_hal_subghz_get_rolling_counter_mult() != 0xFFFE) {
|
||||
if(instance->generic.cnt < 0xFFFF) {
|
||||
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 >= 0xFFFF) &&
|
||||
(furi_hal_subghz_get_rolling_counter_mult() != 0)) {
|
||||
instance->generic.cnt = 0;
|
||||
} else {
|
||||
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
|
||||
}
|
||||
} else if((instance->generic.cnt >= 0xFFFF) && (furi_hal_subghz_get_rolling_counter_mult() != 0)) {
|
||||
instance->generic.cnt = 0;
|
||||
} else {
|
||||
if((instance->generic.cnt + 0x1) > 0xFFFF) {
|
||||
instance->generic.cnt = 0;
|
||||
} else if(instance->generic.cnt >= 0x1 && instance->generic.cnt != 0xFFFE) {
|
||||
instance->generic.cnt = furi_hal_subghz_get_rolling_counter_mult();
|
||||
} else {
|
||||
instance->generic.cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t frame[7];
|
||||
|
||||
@@ -132,14 +132,27 @@ void subghz_protocol_encoder_star_line_free(void* context) {
|
||||
*/
|
||||
static bool
|
||||
subghz_protocol_star_line_gen_data(SubGhzProtocolEncoderStarLine* instance, uint8_t btn) {
|
||||
if(instance->generic.cnt < 0xFFFF) {
|
||||
if((instance->generic.cnt + furi_hal_subghz_get_rolling_counter_mult()) > 0xFFFF) {
|
||||
// Check for OFEX (overflow experimental) mode
|
||||
if(furi_hal_subghz_get_rolling_counter_mult() != 0xFFFE) {
|
||||
if(instance->generic.cnt < 0xFFFF) {
|
||||
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 >= 0xFFFF) &&
|
||||
(furi_hal_subghz_get_rolling_counter_mult() != 0)) {
|
||||
instance->generic.cnt = 0;
|
||||
} else {
|
||||
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
|
||||
}
|
||||
} else if((instance->generic.cnt >= 0xFFFF) && (furi_hal_subghz_get_rolling_counter_mult() != 0)) {
|
||||
instance->generic.cnt = 0;
|
||||
} else {
|
||||
if((instance->generic.cnt + 0x1) > 0xFFFF) {
|
||||
instance->generic.cnt = 0;
|
||||
} else if(instance->generic.cnt >= 0x1 && instance->generic.cnt != 0xFFFE) {
|
||||
instance->generic.cnt = furi_hal_subghz_get_rolling_counter_mult();
|
||||
} 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;
|
||||
|
||||
Reference in New Issue
Block a user