mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-07-17 00:28:11 -07:00
Merge branch 'dev' of https://github.com/DarkFlippers/unleashed-firmware into xfw-dev
This commit is contained in:
@@ -37,7 +37,6 @@ DSTATUS disk_status (BYTE pdrv);
|
||||
DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count);
|
||||
DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count);
|
||||
DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
|
||||
DWORD get_fattime (void);
|
||||
|
||||
/* Disk Status Bits (DSTATUS) */
|
||||
|
||||
|
||||
@@ -90,13 +90,14 @@ bool troika_4k_parser_parse(NfcDeviceData* dev_data) {
|
||||
|
||||
uint8_t* temp_ptr = &data->block[8 * 4 + 1].value[5];
|
||||
uint16_t balance = ((temp_ptr[0] << 8) | temp_ptr[1]) / 25;
|
||||
temp_ptr = &data->block[8 * 4].value[3];
|
||||
temp_ptr = &data->block[8 * 4].value[2];
|
||||
uint32_t number = 0;
|
||||
for(size_t i = 0; i < 4; i++) {
|
||||
for(size_t i = 1; i < 5; i++) {
|
||||
number <<= 8;
|
||||
number |= temp_ptr[i];
|
||||
}
|
||||
number >>= 4;
|
||||
number |= (temp_ptr[0] & 0xf) << 28;
|
||||
|
||||
furi_string_printf(
|
||||
dev_data->parsed_data, "\e#Troika\nNum: %lu\nBalance: %u rur.", number, balance);
|
||||
|
||||
@@ -70,13 +70,14 @@ bool troika_parser_parse(NfcDeviceData* dev_data) {
|
||||
// Parse data
|
||||
uint8_t* temp_ptr = &data->block[8 * 4 + 1].value[5];
|
||||
uint16_t balance = ((temp_ptr[0] << 8) | temp_ptr[1]) / 25;
|
||||
temp_ptr = &data->block[8 * 4].value[3];
|
||||
temp_ptr = &data->block[8 * 4].value[2];
|
||||
uint32_t number = 0;
|
||||
for(size_t i = 0; i < 4; i++) {
|
||||
for(size_t i = 1; i < 5; i++) {
|
||||
number <<= 8;
|
||||
number |= temp_ptr[i];
|
||||
}
|
||||
number >>= 4;
|
||||
number |= (temp_ptr[0] & 0xf) << 28;
|
||||
|
||||
furi_string_printf(
|
||||
dev_data->parsed_data, "\e#Troika\nNum: %lu\nBalance: %u rur.", number, balance);
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
#include "custom_btn.h"
|
||||
|
||||
static uint8_t custom_btn_id;
|
||||
static uint8_t custom_btn_original;
|
||||
static uint8_t custom_btn_max_btns = 0;
|
||||
|
||||
void subghz_custom_btn_set(uint8_t b) {
|
||||
if(b > custom_btn_max_btns) {
|
||||
custom_btn_id = 0;
|
||||
} else {
|
||||
custom_btn_id = b;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t subghz_custom_btn_get() {
|
||||
return custom_btn_id;
|
||||
}
|
||||
|
||||
void subghz_custom_btn_set_original(uint8_t b) {
|
||||
custom_btn_original = b;
|
||||
}
|
||||
|
||||
uint8_t subghz_custom_btn_get_original() {
|
||||
return custom_btn_original;
|
||||
}
|
||||
|
||||
void subghz_custom_btn_set_max(uint8_t b) {
|
||||
custom_btn_max_btns = b;
|
||||
}
|
||||
|
||||
void subghz_custom_btns_reset() {
|
||||
custom_btn_original = 0;
|
||||
custom_btn_max_btns = 0;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void subghz_custom_btn_set(uint8_t b);
|
||||
|
||||
uint8_t subghz_custom_btn_get();
|
||||
|
||||
void subghz_custom_btn_set_original(uint8_t b);
|
||||
|
||||
uint8_t subghz_custom_btn_get_original();
|
||||
|
||||
void subghz_custom_btn_set_max(uint8_t b);
|
||||
|
||||
void subghz_custom_btns_reset();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -5,6 +5,8 @@
|
||||
#include "../blocks/generic.h"
|
||||
#include "../blocks/math.h"
|
||||
|
||||
#include "../blocks/custom_btn.h"
|
||||
|
||||
#define TAG "SubGhzProtocoAlutech_at_4n"
|
||||
|
||||
#define SUBGHZ_NO_ALUTECH_AT_4N_RAINBOW_TABLE 0xFFFFFFFF
|
||||
@@ -77,25 +79,6 @@ const SubGhzProtocol subghz_protocol_alutech_at_4n = {
|
||||
.encoder = &subghz_protocol_alutech_at_4n_encoder,
|
||||
};
|
||||
|
||||
static uint8_t al_btn_temp_id;
|
||||
static uint8_t al_btn_temp_id_original;
|
||||
|
||||
void alutech_set_btn(uint8_t b) {
|
||||
al_btn_temp_id = b;
|
||||
}
|
||||
|
||||
uint8_t alutech_get_original_btn() {
|
||||
return al_btn_temp_id_original;
|
||||
}
|
||||
|
||||
uint8_t alutech_get_custom_btn() {
|
||||
return al_btn_temp_id;
|
||||
}
|
||||
|
||||
void alutech_reset_original_btn() {
|
||||
al_btn_temp_id_original = 0;
|
||||
}
|
||||
|
||||
void* subghz_protocol_encoder_alutech_at_4n_alloc(SubGhzEnvironment* environment) {
|
||||
UNUSED(environment);
|
||||
SubGhzProtocolEncoderAlutech_at_4n* instance =
|
||||
@@ -341,13 +324,16 @@ static bool subghz_protocol_encoder_alutech_at_4n_get_upload(
|
||||
furi_assert(instance);
|
||||
|
||||
// Save original button for later use
|
||||
if(al_btn_temp_id_original == 0) {
|
||||
al_btn_temp_id_original = btn;
|
||||
if(subghz_custom_btn_get_original() == 0) {
|
||||
subghz_custom_btn_set_original(btn);
|
||||
}
|
||||
|
||||
uint8_t custom_btn_id = subghz_custom_btn_get();
|
||||
uint8_t original_btn_num = subghz_custom_btn_get_original();
|
||||
|
||||
// Set custom button
|
||||
if(al_btn_temp_id == 1) {
|
||||
switch(al_btn_temp_id_original) {
|
||||
if(custom_btn_id == 1) {
|
||||
switch(original_btn_num) {
|
||||
case 0x11:
|
||||
btn = 0x22;
|
||||
break;
|
||||
@@ -368,8 +354,8 @@ static bool subghz_protocol_encoder_alutech_at_4n_get_upload(
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(al_btn_temp_id == 2) {
|
||||
switch(al_btn_temp_id_original) {
|
||||
if(custom_btn_id == 2) {
|
||||
switch(original_btn_num) {
|
||||
case 0x11:
|
||||
btn = 0x44;
|
||||
break;
|
||||
@@ -390,8 +376,8 @@ static bool subghz_protocol_encoder_alutech_at_4n_get_upload(
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(al_btn_temp_id == 3) {
|
||||
switch(al_btn_temp_id_original) {
|
||||
if(custom_btn_id == 3) {
|
||||
switch(original_btn_num) {
|
||||
case 0x11:
|
||||
btn = 0x33;
|
||||
break;
|
||||
@@ -412,8 +398,8 @@ static bool subghz_protocol_encoder_alutech_at_4n_get_upload(
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(al_btn_temp_id == 4) {
|
||||
switch(al_btn_temp_id_original) {
|
||||
if(custom_btn_id == 4) {
|
||||
switch(original_btn_num) {
|
||||
case 0x11:
|
||||
btn = 0xFF;
|
||||
break;
|
||||
@@ -435,8 +421,8 @@ static bool subghz_protocol_encoder_alutech_at_4n_get_upload(
|
||||
}
|
||||
}
|
||||
|
||||
if((al_btn_temp_id == 0) && (al_btn_temp_id_original != 0)) {
|
||||
btn = al_btn_temp_id_original;
|
||||
if((custom_btn_id == 0) && (original_btn_num != 0)) {
|
||||
btn = original_btn_num;
|
||||
}
|
||||
//gen new key
|
||||
if(subghz_protocol_alutech_at_4n_gen_data(instance, btn)) {
|
||||
@@ -735,9 +721,10 @@ static void subghz_protocol_alutech_at_4n_remote_controller(
|
||||
}
|
||||
|
||||
// Save original button for later use
|
||||
if(al_btn_temp_id_original == 0) {
|
||||
al_btn_temp_id_original = instance->btn;
|
||||
if(subghz_custom_btn_get_original() == 0) {
|
||||
subghz_custom_btn_set_original(instance->btn);
|
||||
}
|
||||
subghz_custom_btn_set_max(4);
|
||||
}
|
||||
|
||||
uint8_t subghz_protocol_decoder_alutech_at_4n_get_hash_data(void* context) {
|
||||
|
||||
@@ -14,14 +14,6 @@ extern const SubGhzProtocolDecoder subghz_protocol_alutech_at_4n_decoder;
|
||||
extern const SubGhzProtocolEncoder subghz_protocol_alutech_at_4n_encoder;
|
||||
extern const SubGhzProtocol subghz_protocol_alutech_at_4n;
|
||||
|
||||
// Custom buttons
|
||||
void alutech_set_btn(uint8_t b);
|
||||
|
||||
uint8_t alutech_get_original_btn();
|
||||
uint8_t alutech_get_custom_btn();
|
||||
|
||||
void alutech_reset_original_btn();
|
||||
|
||||
/**
|
||||
* Allocate SubGhzProtocolEncoderAlutech_at_4n.
|
||||
* @param environment Pointer to a SubGhzEnvironment instance
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include "../blocks/generic.h"
|
||||
#include "../blocks/math.h"
|
||||
|
||||
#include "../blocks/custom_btn.h"
|
||||
|
||||
#define TAG "SubGhzProtocolKeeloq"
|
||||
|
||||
static const SubGhzBlockConst subghz_protocol_keeloq_const = {
|
||||
@@ -86,25 +88,12 @@ const SubGhzProtocol subghz_protocol_keeloq = {
|
||||
|
||||
static const char* mfname;
|
||||
static uint8_t kl_type;
|
||||
static uint8_t btn_temp_id;
|
||||
static uint8_t btn_temp_id_original;
|
||||
static uint8_t klq_prog_mode;
|
||||
static uint16_t temp_counter;
|
||||
|
||||
void keeloq_set_btn(uint8_t b) {
|
||||
btn_temp_id = b;
|
||||
}
|
||||
|
||||
uint8_t keeloq_get_original_btn() {
|
||||
return btn_temp_id_original;
|
||||
}
|
||||
|
||||
uint8_t keeloq_get_custom_btn() {
|
||||
return btn_temp_id;
|
||||
}
|
||||
|
||||
void keeloq_reset_original_btn() {
|
||||
btn_temp_id_original = 0;
|
||||
subghz_custom_btn_set_original(0);
|
||||
subghz_custom_btn_set_max(0);
|
||||
temp_counter = 0;
|
||||
klq_prog_mode = 0;
|
||||
}
|
||||
@@ -243,9 +232,9 @@ static bool subghz_protocol_keeloq_gen_data(
|
||||
decrypt = btn << 28 | (instance->generic.serial & 0xFF) << 16 | instance->generic.cnt;
|
||||
}
|
||||
|
||||
// Beninca -> 4bit serial - simple XOR
|
||||
// Beninca / Allmatic -> no serial - simple XOR
|
||||
if(strcmp(instance->manufacture_name, "Beninca") == 0) {
|
||||
decrypt = btn << 28 | (instance->generic.serial & 0xF) << 16 | instance->generic.cnt;
|
||||
decrypt = btn << 28 | (0x000) << 16 | instance->generic.cnt;
|
||||
}
|
||||
|
||||
if(strcmp(instance->manufacture_name, "Unknown") == 0) {
|
||||
@@ -384,8 +373,8 @@ static bool
|
||||
furi_assert(instance);
|
||||
|
||||
// Save original button
|
||||
if(btn_temp_id_original == 0) {
|
||||
btn_temp_id_original = btn;
|
||||
if(subghz_custom_btn_get_original() == 0) {
|
||||
subghz_custom_btn_set_original(btn);
|
||||
}
|
||||
|
||||
if(instance->manufacture_name == 0x0) {
|
||||
@@ -402,9 +391,12 @@ static bool
|
||||
klq_last_custom_btn = 0xF;
|
||||
}
|
||||
|
||||
uint8_t custom_btn_id = subghz_custom_btn_get();
|
||||
uint8_t original_btn_num = subghz_custom_btn_get_original();
|
||||
|
||||
// Set custom button
|
||||
if(btn_temp_id == 1) {
|
||||
switch(btn_temp_id_original) {
|
||||
if(custom_btn_id == 1) {
|
||||
switch(original_btn_num) {
|
||||
case 0x1:
|
||||
btn = 0x2;
|
||||
break;
|
||||
@@ -429,8 +421,8 @@ static bool
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(btn_temp_id == 2) {
|
||||
switch(btn_temp_id_original) {
|
||||
if(custom_btn_id == 2) {
|
||||
switch(original_btn_num) {
|
||||
case 0x1:
|
||||
btn = 0x4;
|
||||
break;
|
||||
@@ -455,8 +447,8 @@ static bool
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(btn_temp_id == 3) {
|
||||
switch(btn_temp_id_original) {
|
||||
if(custom_btn_id == 3) {
|
||||
switch(original_btn_num) {
|
||||
case 0x1:
|
||||
btn = 0x8;
|
||||
break;
|
||||
@@ -481,8 +473,8 @@ static bool
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(btn_temp_id == 4) {
|
||||
switch(btn_temp_id_original) {
|
||||
if(custom_btn_id == 4) {
|
||||
switch(original_btn_num) {
|
||||
case 0x1:
|
||||
btn = klq_last_custom_btn;
|
||||
break;
|
||||
@@ -508,8 +500,8 @@ static bool
|
||||
}
|
||||
}
|
||||
|
||||
if((btn_temp_id == 0) && (btn_temp_id_original != 0)) {
|
||||
btn = btn_temp_id_original;
|
||||
if((custom_btn_id == 0) && (original_btn_num != 0)) {
|
||||
btn = original_btn_num;
|
||||
}
|
||||
|
||||
// Generate new key
|
||||
@@ -1213,9 +1205,10 @@ static void subghz_protocol_keeloq_check_remote_controller(
|
||||
instance->btn = key_fix >> 28;
|
||||
|
||||
// Save original button for later use
|
||||
if(btn_temp_id_original == 0) {
|
||||
btn_temp_id_original = instance->btn;
|
||||
if(subghz_custom_btn_get_original() == 0) {
|
||||
subghz_custom_btn_set_original(instance->btn);
|
||||
}
|
||||
subghz_custom_btn_set_max(4);
|
||||
}
|
||||
|
||||
uint8_t subghz_protocol_decoder_keeloq_get_hash_data(void* context) {
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "base.h"
|
||||
|
||||
#include "../blocks/custom_btn.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -19,11 +21,6 @@ void keeloq_reset_mfname();
|
||||
|
||||
void keeloq_reset_kl_type();
|
||||
|
||||
void keeloq_set_btn(uint8_t b);
|
||||
|
||||
uint8_t keeloq_get_original_btn();
|
||||
uint8_t keeloq_get_custom_btn();
|
||||
|
||||
void keeloq_reset_original_btn();
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "../blocks/generic.h"
|
||||
#include "../blocks/math.h"
|
||||
|
||||
#include "../blocks/custom_btn.h"
|
||||
|
||||
/*
|
||||
* https://phreakerclub.com/1615
|
||||
* https://phreakerclub.com/forum/showthread.php?t=2360
|
||||
@@ -84,25 +86,6 @@ const SubGhzProtocol subghz_protocol_nice_flor_s = {
|
||||
.encoder = &subghz_protocol_nice_flor_s_encoder,
|
||||
};
|
||||
|
||||
static uint8_t n_btn_temp_id;
|
||||
static uint8_t n_btn_temp_id_original;
|
||||
|
||||
void nice_flors_set_btn(uint8_t b) {
|
||||
n_btn_temp_id = b;
|
||||
}
|
||||
|
||||
uint8_t nice_flors_get_original_btn() {
|
||||
return n_btn_temp_id_original;
|
||||
}
|
||||
|
||||
uint8_t nice_flors_get_custom_btn() {
|
||||
return n_btn_temp_id;
|
||||
}
|
||||
|
||||
void nice_flors_reset_original_btn() {
|
||||
n_btn_temp_id_original = 0;
|
||||
}
|
||||
|
||||
static void subghz_protocol_nice_flor_s_remote_controller(
|
||||
SubGhzBlockGeneric* instance,
|
||||
const char* file_name);
|
||||
@@ -148,13 +131,16 @@ static void subghz_protocol_encoder_nice_flor_s_get_upload(
|
||||
btn = instance->generic.btn;
|
||||
|
||||
// Save original button for later use
|
||||
if(n_btn_temp_id_original == 0) {
|
||||
n_btn_temp_id_original = btn;
|
||||
if(subghz_custom_btn_get_original() == 0) {
|
||||
subghz_custom_btn_set_original(btn);
|
||||
}
|
||||
|
||||
uint8_t custom_btn_id = subghz_custom_btn_get();
|
||||
uint8_t original_btn_num = subghz_custom_btn_get_original();
|
||||
|
||||
// Set custom button
|
||||
if(n_btn_temp_id == 1) {
|
||||
switch(n_btn_temp_id_original) {
|
||||
if(custom_btn_id == 1) {
|
||||
switch(original_btn_num) {
|
||||
case 0x1:
|
||||
btn = 0x2;
|
||||
break;
|
||||
@@ -172,8 +158,8 @@ static void subghz_protocol_encoder_nice_flor_s_get_upload(
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(n_btn_temp_id == 2) {
|
||||
switch(n_btn_temp_id_original) {
|
||||
if(custom_btn_id == 2) {
|
||||
switch(original_btn_num) {
|
||||
case 0x1:
|
||||
btn = 0x4;
|
||||
break;
|
||||
@@ -191,8 +177,8 @@ static void subghz_protocol_encoder_nice_flor_s_get_upload(
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(n_btn_temp_id == 3) {
|
||||
switch(n_btn_temp_id_original) {
|
||||
if(custom_btn_id == 3) {
|
||||
switch(original_btn_num) {
|
||||
case 0x1:
|
||||
btn = 0x8;
|
||||
break;
|
||||
@@ -211,8 +197,8 @@ static void subghz_protocol_encoder_nice_flor_s_get_upload(
|
||||
}
|
||||
}
|
||||
|
||||
if((n_btn_temp_id == 0) && (n_btn_temp_id_original != 0)) {
|
||||
btn = n_btn_temp_id_original;
|
||||
if((custom_btn_id == 0) && (original_btn_num != 0)) {
|
||||
btn = original_btn_num;
|
||||
}
|
||||
|
||||
size_t size_upload = ((instance->generic.data_count_bit * 2) + ((37 + 2 + 2) * 2) * 16);
|
||||
@@ -756,9 +742,10 @@ static void subghz_protocol_nice_flor_s_remote_controller(
|
||||
}
|
||||
|
||||
// Save original button for later use
|
||||
if(n_btn_temp_id_original == 0) {
|
||||
n_btn_temp_id_original = instance->btn;
|
||||
if(subghz_custom_btn_get_original() == 0) {
|
||||
subghz_custom_btn_set_original(instance->btn);
|
||||
}
|
||||
subghz_custom_btn_set_max(3);
|
||||
}
|
||||
|
||||
uint8_t subghz_protocol_decoder_nice_flor_s_get_hash_data(void* context) {
|
||||
|
||||
@@ -15,14 +15,6 @@ extern const SubGhzProtocolDecoder subghz_protocol_nice_flor_s_decoder;
|
||||
extern const SubGhzProtocolEncoder subghz_protocol_nice_flor_s_encoder;
|
||||
extern const SubGhzProtocol subghz_protocol_nice_flor_s;
|
||||
|
||||
// Custom buttons
|
||||
void nice_flors_set_btn(uint8_t b);
|
||||
|
||||
uint8_t nice_flors_get_original_btn();
|
||||
uint8_t nice_flors_get_custom_btn();
|
||||
|
||||
void nice_flors_reset_original_btn();
|
||||
|
||||
/**
|
||||
* Allocate SubGhzProtocolEncoderNiceFlorS.
|
||||
* @param environment Pointer to a SubGhzEnvironment instance
|
||||
|
||||
@@ -220,18 +220,48 @@ static void subghz_protocol_scher_khan_check_remote_controller(
|
||||
*/
|
||||
|
||||
switch(instance->data_count_bit) {
|
||||
// case 35: //MAGIC CODE, Static
|
||||
// instance->protocol_name = "MAGIC CODE, Static";
|
||||
// break;
|
||||
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
|
||||
// instance->protocol_name = "MAGIC CODE PRO / PRO2";
|
||||
// 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 ???
|
||||
*protocol_name = "MAGIC CODE PRO,\n Response";
|
||||
instance->serial = 0;
|
||||
instance->btn = 0;
|
||||
instance->cnt = 0;
|
||||
break;
|
||||
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";
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include "../blocks/generic.h"
|
||||
#include "../blocks/math.h"
|
||||
|
||||
#include "../blocks/custom_btn.h"
|
||||
|
||||
/*
|
||||
* Help
|
||||
* https://github.com/argilo/secplus
|
||||
@@ -83,25 +85,6 @@ const SubGhzProtocol subghz_protocol_secplus_v2 = {
|
||||
.encoder = &subghz_protocol_secplus_v2_encoder,
|
||||
};
|
||||
|
||||
static uint8_t sc_btn_temp_id;
|
||||
static uint8_t sc_btn_temp_id_original;
|
||||
|
||||
void secplus2_set_btn(uint8_t b) {
|
||||
sc_btn_temp_id = b;
|
||||
}
|
||||
|
||||
uint8_t secplus2_get_original_btn() {
|
||||
return sc_btn_temp_id_original;
|
||||
}
|
||||
|
||||
uint8_t secplus2_get_custom_btn() {
|
||||
return sc_btn_temp_id;
|
||||
}
|
||||
|
||||
void secplus2_reset_original_btn() {
|
||||
sc_btn_temp_id_original = 0;
|
||||
}
|
||||
|
||||
void* subghz_protocol_encoder_secplus_v2_alloc(SubGhzEnvironment* environment) {
|
||||
UNUSED(environment);
|
||||
SubGhzProtocolEncoderSecPlus_v2* instance = malloc(sizeof(SubGhzProtocolEncoderSecPlus_v2));
|
||||
@@ -359,9 +342,10 @@ static void
|
||||
}
|
||||
|
||||
// Save original button for later use
|
||||
if(sc_btn_temp_id_original == 0) {
|
||||
sc_btn_temp_id_original = instance->btn;
|
||||
if(subghz_custom_btn_get_original() == 0) {
|
||||
subghz_custom_btn_set_original(instance->btn);
|
||||
}
|
||||
subghz_custom_btn_set_max(3);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -398,13 +382,16 @@ static uint64_t subghz_protocol_secplus_v2_encode_half(uint8_t roll_array[], uin
|
||||
|
||||
static void subghz_protocol_secplus_v2_encode(SubGhzProtocolEncoderSecPlus_v2* instance) {
|
||||
// Save original button for later use
|
||||
if(sc_btn_temp_id_original == 0) {
|
||||
sc_btn_temp_id_original = instance->generic.btn;
|
||||
if(subghz_custom_btn_get_original() == 0) {
|
||||
subghz_custom_btn_set_original(instance->generic.btn);
|
||||
}
|
||||
|
||||
uint8_t custom_btn_id = subghz_custom_btn_get();
|
||||
uint8_t original_btn_num = subghz_custom_btn_get_original();
|
||||
|
||||
// Set custom button
|
||||
if(sc_btn_temp_id == 1) {
|
||||
switch(sc_btn_temp_id_original) {
|
||||
if(custom_btn_id == 1) {
|
||||
switch(original_btn_num) {
|
||||
case 0x68:
|
||||
instance->generic.btn = 0x80;
|
||||
break;
|
||||
@@ -422,8 +409,8 @@ static void subghz_protocol_secplus_v2_encode(SubGhzProtocolEncoderSecPlus_v2* i
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(sc_btn_temp_id == 2) {
|
||||
switch(sc_btn_temp_id_original) {
|
||||
if(custom_btn_id == 2) {
|
||||
switch(original_btn_num) {
|
||||
case 0x68:
|
||||
instance->generic.btn = 0x81;
|
||||
break;
|
||||
@@ -441,8 +428,8 @@ static void subghz_protocol_secplus_v2_encode(SubGhzProtocolEncoderSecPlus_v2* i
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(sc_btn_temp_id == 3) {
|
||||
switch(sc_btn_temp_id_original) {
|
||||
if(custom_btn_id == 3) {
|
||||
switch(original_btn_num) {
|
||||
case 0x68:
|
||||
instance->generic.btn = 0xE2;
|
||||
break;
|
||||
@@ -460,8 +447,8 @@ static void subghz_protocol_secplus_v2_encode(SubGhzProtocolEncoderSecPlus_v2* i
|
||||
break;
|
||||
}
|
||||
}
|
||||
if((sc_btn_temp_id == 0) && (sc_btn_temp_id_original != 0)) {
|
||||
instance->generic.btn = sc_btn_temp_id_original;
|
||||
if((custom_btn_id == 0) && (original_btn_num != 0)) {
|
||||
instance->generic.btn = original_btn_num;
|
||||
}
|
||||
uint32_t fixed_1[1] = {instance->generic.btn << 12 | instance->generic.serial >> 20};
|
||||
uint32_t fixed_2[1] = {instance->generic.serial & 0xFFFFF};
|
||||
|
||||
@@ -14,14 +14,6 @@ extern const SubGhzProtocolDecoder subghz_protocol_secplus_v2_decoder;
|
||||
extern const SubGhzProtocolEncoder subghz_protocol_secplus_v2_encoder;
|
||||
extern const SubGhzProtocol subghz_protocol_secplus_v2;
|
||||
|
||||
// Custom buttons
|
||||
void secplus2_set_btn(uint8_t b);
|
||||
|
||||
uint8_t secplus2_get_original_btn();
|
||||
uint8_t secplus2_get_custom_btn();
|
||||
|
||||
void secplus2_reset_original_btn();
|
||||
|
||||
/**
|
||||
* Allocate SubGhzProtocolEncoderSecPlus_v2.
|
||||
* @param environment Pointer to a SubGhzEnvironment instance
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include "../blocks/generic.h"
|
||||
#include "../blocks/math.h"
|
||||
|
||||
#include "../blocks/custom_btn.h"
|
||||
|
||||
#define TAG "SubGhzProtocolSomfyTelis"
|
||||
|
||||
static const SubGhzBlockConst subghz_protocol_somfy_telis_const = {
|
||||
@@ -73,25 +75,6 @@ const SubGhzProtocol subghz_protocol_somfy_telis = {
|
||||
.encoder = &subghz_protocol_somfy_telis_encoder,
|
||||
};
|
||||
|
||||
static uint8_t st_btn_temp_id;
|
||||
static uint8_t st_btn_temp_id_original;
|
||||
|
||||
void somfy_telis_set_btn(uint8_t b) {
|
||||
st_btn_temp_id = b;
|
||||
}
|
||||
|
||||
uint8_t somfy_telis_get_original_btn() {
|
||||
return st_btn_temp_id_original;
|
||||
}
|
||||
|
||||
uint8_t somfy_telis_get_custom_btn() {
|
||||
return st_btn_temp_id;
|
||||
}
|
||||
|
||||
void somfy_telis_reset_original_btn() {
|
||||
st_btn_temp_id_original = 0;
|
||||
}
|
||||
|
||||
void* subghz_protocol_encoder_somfy_telis_alloc(SubGhzEnvironment* environment) {
|
||||
UNUSED(environment);
|
||||
SubGhzProtocolEncoderSomfyTelis* instance = malloc(sizeof(SubGhzProtocolEncoderSomfyTelis));
|
||||
@@ -128,13 +111,16 @@ static bool subghz_protocol_somfy_telis_gen_data(
|
||||
}
|
||||
|
||||
// Save original button for later use
|
||||
if(st_btn_temp_id_original == 0) {
|
||||
st_btn_temp_id_original = btn;
|
||||
if(subghz_custom_btn_get_original() == 0) {
|
||||
subghz_custom_btn_set_original(btn);
|
||||
}
|
||||
|
||||
uint8_t custom_btn_id = subghz_custom_btn_get();
|
||||
uint8_t original_btn_num = subghz_custom_btn_get_original();
|
||||
|
||||
// Set custom button
|
||||
if(st_btn_temp_id == 1) {
|
||||
switch(st_btn_temp_id_original) {
|
||||
if(custom_btn_id == 1) {
|
||||
switch(original_btn_num) {
|
||||
case 0x1:
|
||||
btn = 0x2;
|
||||
break;
|
||||
@@ -152,8 +138,8 @@ static bool subghz_protocol_somfy_telis_gen_data(
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(st_btn_temp_id == 2) {
|
||||
switch(st_btn_temp_id_original) {
|
||||
if(custom_btn_id == 2) {
|
||||
switch(original_btn_num) {
|
||||
case 0x1:
|
||||
btn = 0x4;
|
||||
break;
|
||||
@@ -171,8 +157,8 @@ static bool subghz_protocol_somfy_telis_gen_data(
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(st_btn_temp_id == 3) {
|
||||
switch(st_btn_temp_id_original) {
|
||||
if(custom_btn_id == 3) {
|
||||
switch(original_btn_num) {
|
||||
case 0x1:
|
||||
btn = 0x8;
|
||||
break;
|
||||
@@ -191,8 +177,8 @@ static bool subghz_protocol_somfy_telis_gen_data(
|
||||
}
|
||||
}
|
||||
|
||||
if((st_btn_temp_id == 0) && (st_btn_temp_id_original != 0)) {
|
||||
btn = st_btn_temp_id_original;
|
||||
if((custom_btn_id == 0) && (original_btn_num != 0)) {
|
||||
btn = original_btn_num;
|
||||
}
|
||||
|
||||
if(instance->generic.cnt < 0xFFFF) {
|
||||
@@ -684,9 +670,10 @@ static void subghz_protocol_somfy_telis_check_remote_controller(SubGhzBlockGener
|
||||
instance->serial = data & 0xFFFFFF; // address
|
||||
|
||||
// Save original button for later use
|
||||
if(st_btn_temp_id_original == 0) {
|
||||
st_btn_temp_id_original = instance->btn;
|
||||
if(subghz_custom_btn_get_original() == 0) {
|
||||
subghz_custom_btn_set_original(instance->btn);
|
||||
}
|
||||
subghz_custom_btn_set_max(3);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,14 +15,6 @@ extern const SubGhzProtocolDecoder subghz_protocol_somfy_telis_decoder;
|
||||
extern const SubGhzProtocolEncoder subghz_protocol_somfy_telis_encoder;
|
||||
extern const SubGhzProtocol subghz_protocol_somfy_telis;
|
||||
|
||||
// Custom buttons
|
||||
void somfy_telis_set_btn(uint8_t b);
|
||||
|
||||
uint8_t somfy_telis_get_original_btn();
|
||||
uint8_t somfy_telis_get_custom_btn();
|
||||
|
||||
void somfy_telis_reset_original_btn();
|
||||
|
||||
/**
|
||||
* Allocate SubGhzProtocolEncoderSomfyTelis.
|
||||
* @param environment Pointer to a SubGhzEnvironment instance
|
||||
|
||||
@@ -419,11 +419,14 @@ void subghz_protocol_decoder_star_line_feed(void* context, bool level, uint32_t
|
||||
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) {
|
||||
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 = instance->decoder.decode_count_bit;
|
||||
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);
|
||||
}
|
||||
@@ -447,14 +450,24 @@ void subghz_protocol_decoder_star_line_feed(void* context, bool level, uint32_t
|
||||
subghz_protocol_star_line_const.te_delta) &&
|
||||
(DURATION_DIFF(duration, subghz_protocol_star_line_const.te_short) <
|
||||
subghz_protocol_star_line_const.te_delta)) {
|
||||
subghz_protocol_blocks_add_bit(&instance->decoder, 0);
|
||||
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)) {
|
||||
subghz_protocol_blocks_add_bit(&instance->decoder, 1);
|
||||
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;
|
||||
|
||||
@@ -28,6 +28,7 @@ env.Append(
|
||||
File("stream/buffered_file_stream.h"),
|
||||
File("protocols/protocol_dict.h"),
|
||||
File("pretty_format.h"),
|
||||
File("hex.h"),
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user