mirror of
https://protopirate.net/ProtoPirate/ProtoPirate.git
synced 2026-10-22 20:11:18 +00:00
update from main
This commit is contained in:
commit
ee2e004b3a
7 files changed
+79
-40
No files matched your search
@@ -0,0 +1,22 @@
|
||||
//#define ENABLE_TIMING_TUNER_SCENE
|
||||
#define ENABLE_SUB_DECODE_SCENE
|
||||
|
||||
// #define ENABLE_EMULATE_FEATURE
|
||||
|
||||
#define REMOVE_LOGS
|
||||
|
||||
#ifdef REMOVE_LOGS
|
||||
// Undefine existing macros
|
||||
#undef FURI_LOG_E
|
||||
#undef FURI_LOG_W
|
||||
#undef FURI_LOG_I
|
||||
#undef FURI_LOG_D
|
||||
#undef FURI_LOG_T
|
||||
// Define empty macros
|
||||
#define FURI_LOG_E(tag, format, ...)
|
||||
#define FURI_LOG_W(tag, format, ...)
|
||||
#define FURI_LOG_I(tag, format, ...)
|
||||
#define FURI_LOG_D(tag, format, ...)
|
||||
#define FURI_LOG_T(tag, format, ...)
|
||||
|
||||
#endif // REMOVE_LOGS
|
||||
+20
-8
@@ -57,7 +57,7 @@ typedef struct SubGhzProtocolDecoderFordV0 {
|
||||
uint32_t count;
|
||||
uint8_t bs_magic;
|
||||
} SubGhzProtocolDecoderFordV0;
|
||||
|
||||
#ifdef ENABLE_EMULATE_FEATURE
|
||||
typedef struct SubGhzProtocolEncoderFordV0 {
|
||||
SubGhzProtocolEncoderBase base;
|
||||
SubGhzProtocolBlockEncoder encoder;
|
||||
@@ -71,7 +71,7 @@ typedef struct SubGhzProtocolEncoderFordV0 {
|
||||
uint8_t bs;
|
||||
uint8_t bs_magic;
|
||||
} SubGhzProtocolEncoderFordV0;
|
||||
|
||||
#endif
|
||||
typedef enum {
|
||||
FordV0DecoderStepReset = 0,
|
||||
FordV0DecoderStepPreamble,
|
||||
@@ -92,6 +92,7 @@ static void decode_ford_v0(
|
||||
uint8_t* button,
|
||||
uint32_t* count,
|
||||
uint8_t* bs_magic);
|
||||
#ifdef ENABLE_EMULATE_FEATURE
|
||||
static void encode_ford_v0(
|
||||
uint8_t header_byte,
|
||||
uint32_t serial,
|
||||
@@ -99,6 +100,7 @@ static void encode_ford_v0(
|
||||
uint32_t count,
|
||||
uint8_t bs,
|
||||
uint64_t* key1);
|
||||
#endif
|
||||
static bool ford_v0_process_data(SubGhzProtocolDecoderFordV0* instance);
|
||||
|
||||
// =============================================================================
|
||||
@@ -116,6 +118,7 @@ const SubGhzProtocolDecoder subghz_protocol_ford_v0_decoder = {
|
||||
.get_string = subghz_protocol_decoder_ford_v0_get_string,
|
||||
};
|
||||
|
||||
#ifdef ENABLE_EMULATE_FEATURE
|
||||
const SubGhzProtocolEncoder subghz_protocol_ford_v0_encoder = {
|
||||
.alloc = subghz_protocol_encoder_ford_v0_alloc,
|
||||
.free = subghz_protocol_encoder_ford_v0_free,
|
||||
@@ -123,6 +126,15 @@ const SubGhzProtocolEncoder subghz_protocol_ford_v0_encoder = {
|
||||
.stop = subghz_protocol_encoder_ford_v0_stop,
|
||||
.yield = subghz_protocol_encoder_ford_v0_yield,
|
||||
};
|
||||
#else
|
||||
const SubGhzProtocolEncoder subghz_protocol_ford_v0_encoder = {
|
||||
.alloc = NULL,
|
||||
.free = NULL,
|
||||
.deserialize = NULL,
|
||||
.stop = NULL,
|
||||
.yield = NULL,
|
||||
};
|
||||
#endif
|
||||
|
||||
const SubGhzProtocol ford_protocol_v0 = {
|
||||
.name = FORD_PROTOCOL_V0_NAME,
|
||||
@@ -137,13 +149,13 @@ const SubGhzProtocol ford_protocol_v0 = {
|
||||
// BS CALCULATION
|
||||
// BS = (counter_low_byte + 0x6F + (button << 4)) & 0xFF
|
||||
// =============================================================================
|
||||
|
||||
#ifdef ENABLE_EMULATE_FEATURE
|
||||
static uint8_t ford_v0_calculate_bs(uint32_t count, uint8_t button, uint8_t bs_magic) {
|
||||
//Do the BS calculation, move right the overflow bit if neccesary
|
||||
uint16_t result = ((uint16_t)count & 0xFF) + bs_magic + (button << 4);
|
||||
return (uint8_t)(result - ((result & 0xFF00) ? 0x80 : 0));
|
||||
}
|
||||
|
||||
#endif
|
||||
// =============================================================================
|
||||
// CRC FUNCTIONS
|
||||
// =============================================================================
|
||||
@@ -173,7 +185,7 @@ static uint8_t ford_v0_calculate_crc(uint8_t* buf) {
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_EMULATE_FEATURE
|
||||
static uint8_t ford_v0_calculate_crc_for_tx(uint64_t key1, uint8_t bs) {
|
||||
uint8_t buf[16] = {0};
|
||||
|
||||
@@ -186,7 +198,7 @@ static uint8_t ford_v0_calculate_crc_for_tx(uint64_t key1, uint8_t bs) {
|
||||
uint8_t crc = ford_v0_calculate_crc(buf);
|
||||
return crc ^ 0x80;
|
||||
}
|
||||
|
||||
#endif
|
||||
static bool ford_v0_verify_crc(uint64_t key1, uint16_t key2) {
|
||||
uint8_t buf[16] = {0};
|
||||
|
||||
@@ -273,7 +285,7 @@ static void decode_ford_v0(
|
||||
// =============================================================================
|
||||
// ENCODE FUNCTION
|
||||
// =============================================================================
|
||||
|
||||
#ifdef ENABLE_EMULATE_FEATURE
|
||||
static void encode_ford_v0(
|
||||
uint8_t header_byte,
|
||||
uint32_t serial,
|
||||
@@ -681,7 +693,7 @@ LevelDuration subghz_protocol_encoder_ford_v0_yield(void* context) {
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
// =============================================================================
|
||||
// DECODER IMPLEMENTATION
|
||||
// =============================================================================
|
||||
|
||||
+14
-4
@@ -89,6 +89,7 @@ struct SubGhzProtocolDecoderPSA {
|
||||
uint8_t decrypted_type;
|
||||
};
|
||||
|
||||
#ifdef ENABLE_EMULATE_FEATURE
|
||||
struct SubGhzProtocolEncoderPSA {
|
||||
SubGhzProtocolEncoderBase base;
|
||||
SubGhzProtocolBlockEncoder encoder;
|
||||
@@ -107,7 +108,7 @@ struct SubGhzProtocolEncoderPSA {
|
||||
uint16_t crc;
|
||||
bool is_running;
|
||||
};
|
||||
|
||||
#endif
|
||||
const SubGhzProtocolDecoder subghz_protocol_psa_decoder = {
|
||||
.alloc = subghz_protocol_decoder_psa_alloc,
|
||||
.free = subghz_protocol_decoder_psa_free,
|
||||
@@ -118,7 +119,7 @@ const SubGhzProtocolDecoder subghz_protocol_psa_decoder = {
|
||||
.deserialize = subghz_protocol_decoder_psa_deserialize,
|
||||
.get_string = subghz_protocol_decoder_psa_get_string,
|
||||
};
|
||||
|
||||
#ifdef ENABLE_EMULATE_FEATURE
|
||||
const SubGhzProtocolEncoder subghz_protocol_psa_encoder = {
|
||||
.alloc = subghz_protocol_encoder_psa_alloc,
|
||||
.free = subghz_protocol_encoder_psa_free,
|
||||
@@ -126,7 +127,15 @@ const SubGhzProtocolEncoder subghz_protocol_psa_encoder = {
|
||||
.stop = subghz_protocol_encoder_psa_stop,
|
||||
.yield = subghz_protocol_encoder_psa_yield,
|
||||
};
|
||||
|
||||
#else
|
||||
const SubGhzProtocolEncoder subghz_protocol_psa_encoder = {
|
||||
.alloc = NULL,
|
||||
.free = NULL,
|
||||
.deserialize = NULL,
|
||||
.stop = NULL,
|
||||
.yield = NULL,
|
||||
};
|
||||
#endif
|
||||
const SubGhzProtocol psa_protocol = {
|
||||
.name = PSA_PROTOCOL_NAME,
|
||||
.type = SubGhzProtocolTypeDynamic,
|
||||
@@ -146,6 +155,7 @@ static uint8_t psa_calculate_tea_crc(uint32_t v0, uint32_t v1);
|
||||
static void psa_tea_encrypt(uint32_t* v0, uint32_t* v1, const uint32_t* key);
|
||||
static void psa_unpack_tea_result_to_buffer(uint8_t* buffer, uint32_t v0, uint32_t v1);
|
||||
|
||||
#ifdef ENABLE_EMULATE_FEATURE
|
||||
static void psa_second_stage_xor_encrypt(uint8_t* buffer) {
|
||||
uint8_t E6 = buffer[8];
|
||||
uint8_t E7 = buffer[9];
|
||||
@@ -750,7 +760,7 @@ LevelDuration subghz_protocol_encoder_psa_yield(void* context) {
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
static uint32_t psa_abs_diff(uint32_t a, uint32_t b) {
|
||||
if(a < b) {
|
||||
return b - a;
|
||||
|
||||
+17
-3
@@ -125,7 +125,7 @@ static void vag_tea_decrypt(uint32_t* v0, uint32_t* v1, const uint32_t* key_sche
|
||||
*v0 -= (((*v1 << 4) ^ (*v1 >> 5)) + *v1) ^ (sum + key_schedule[sum & 3]);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_EMULATE_FEATURE
|
||||
static void vag_tea_encrypt(uint32_t* v0, uint32_t* v1, const uint32_t* key_schedule) {
|
||||
uint32_t sum = 0;
|
||||
for(int i = 0; i < VAG_TEA_ROUNDS; i++) {
|
||||
@@ -134,7 +134,7 @@ static void vag_tea_encrypt(uint32_t* v0, uint32_t* v1, const uint32_t* key_sche
|
||||
*v1 += (((*v0 << 4) ^ (*v0 >> 5)) + *v0) ^ (sum + key_schedule[(sum >> 11) & 3]);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
static bool vag_dispatch_type_1_2(uint8_t dispatch) {
|
||||
return (dispatch == 0x2A || dispatch == 0x1C || dispatch == 0x46);
|
||||
}
|
||||
@@ -449,7 +449,7 @@ const SubGhzProtocolDecoder subghz_protocol_vag_decoder = {
|
||||
.deserialize = subghz_protocol_decoder_vag_deserialize,
|
||||
.get_string = subghz_protocol_decoder_vag_get_string,
|
||||
};
|
||||
|
||||
#ifdef ENABLE_EMULATE_FEATURE
|
||||
const SubGhzProtocolEncoder subghz_protocol_vag_encoder = {
|
||||
.alloc = subghz_protocol_encoder_vag_alloc,
|
||||
.free = subghz_protocol_encoder_vag_free,
|
||||
@@ -457,6 +457,15 @@ const SubGhzProtocolEncoder subghz_protocol_vag_encoder = {
|
||||
.stop = subghz_protocol_encoder_vag_stop,
|
||||
.yield = subghz_protocol_encoder_vag_yield,
|
||||
};
|
||||
#else
|
||||
const SubGhzProtocolEncoder subghz_protocol_vag_encoder = {
|
||||
.alloc = NULL,
|
||||
.free = NULL,
|
||||
.deserialize = NULL,
|
||||
.stop = NULL,
|
||||
.yield = NULL,
|
||||
};
|
||||
#endif
|
||||
|
||||
const SubGhzProtocol vag_protocol = {
|
||||
.name = VAG_PROTOCOL_NAME,
|
||||
@@ -1030,6 +1039,8 @@ SubGhzProtocolStatus
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_EMULATE_FEATURE
|
||||
|
||||
typedef struct SubGhzProtocolEncoderVAG {
|
||||
SubGhzProtocolEncoderBase base;
|
||||
SubGhzBlockGeneric generic;
|
||||
@@ -1599,6 +1610,7 @@ static void vag_encoder_build_type3_4(SubGhzProtocolEncoderVAG* instance) {
|
||||
FURI_LOG_W(TAG, "WARNING: Pulse count %zu != expected 518!", index);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void subghz_protocol_decoder_vag_get_string(void* context, FuriString* output) {
|
||||
furi_check(context);
|
||||
@@ -1665,6 +1677,7 @@ void subghz_protocol_decoder_vag_get_string(void* context, FuriString* output) {
|
||||
|
||||
#define VAG_ENCODER_UPLOAD_MAX_SIZE 680
|
||||
|
||||
#ifdef ENABLE_EMULATE_FEATURE
|
||||
void* subghz_protocol_encoder_vag_alloc(SubGhzEnvironment* environment) {
|
||||
UNUSED(environment);
|
||||
FURI_LOG_I(TAG, "VAG encoder alloc");
|
||||
@@ -2003,3 +2016,4 @@ SubGhzProtocolStatus
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
+1
-23
@@ -23,32 +23,10 @@
|
||||
#include <lib/subghz/devices/devices.h>
|
||||
#include <lib/subghz/subghz_file_encoder_worker.h>
|
||||
#include <dialogs/dialogs.h>
|
||||
#include "defines.h"
|
||||
|
||||
#define PROTOPIRATE_KEYSTORE_DIR_NAME APP_ASSETS_PATH("encrypted")
|
||||
|
||||
//#define ENABLE_TIMING_TUNER_SCENE
|
||||
//#define ENABLE_SUB_DECODE_SCENE
|
||||
|
||||
//#define ENABLE_EMULATE_FEATURE
|
||||
|
||||
#define REMOVE_LOGS
|
||||
|
||||
#ifdef REMOVE_LOGS
|
||||
// Undefine existing macros
|
||||
#undef FURI_LOG_E
|
||||
#undef FURI_LOG_W
|
||||
#undef FURI_LOG_I
|
||||
#undef FURI_LOG_D
|
||||
#undef FURI_LOG_T
|
||||
// Define empty macros
|
||||
#define FURI_LOG_E(tag, format, ...)
|
||||
#define FURI_LOG_W(tag, format, ...)
|
||||
#define FURI_LOG_I(tag, format, ...)
|
||||
#define FURI_LOG_D(tag, format, ...)
|
||||
#define FURI_LOG_T(tag, format, ...)
|
||||
|
||||
#endif // REMOVE_LOGS
|
||||
|
||||
typedef struct ProtoPirateApp ProtoPirateApp;
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// scenes/protopirate_scene_config.h
|
||||
|
||||
//#define ENABLE_TIMING_TUNER_SCENE
|
||||
//#define ENABLE_SUB_DECODE_SCENE
|
||||
#include "../defines.h"
|
||||
|
||||
ADD_SCENE(protopirate, start, Start)
|
||||
#ifdef ENABLE_SUB_DECODE_SCENE
|
||||
@@ -13,7 +12,9 @@ ADD_SCENE(protopirate, receiver_config, ReceiverConfig)
|
||||
ADD_SCENE(protopirate, receiver_info, ReceiverInfo)
|
||||
ADD_SCENE(protopirate, saved, Saved)
|
||||
ADD_SCENE(protopirate, saved_info, SavedInfo)
|
||||
#ifdef ENABLE_EMULATE_FEATURE
|
||||
ADD_SCENE(protopirate, emulate, Emulate)
|
||||
#endif
|
||||
#ifdef ENABLE_TIMING_TUNER_SCENE
|
||||
ADD_SCENE(protopirate, timing_tuner, TimingTuner)
|
||||
#endif
|
||||
@@ -1,5 +1,6 @@
|
||||
// scenes/protopirate_scene_emulate.c
|
||||
#include "../protopirate_app_i.h"
|
||||
#ifdef ENABLE_EMULATE_FEATURE
|
||||
#include "../helpers/protopirate_storage.h"
|
||||
#include "../protocols/protocol_items.h"
|
||||
|
||||
@@ -735,3 +736,4 @@ void protopirate_scene_emulate_on_exit(void* context) {
|
||||
view_set_input_callback(app->view_about, NULL);
|
||||
view_set_context(app->view_about, NULL);
|
||||
}
|
||||
#endif
|
||||
Reference in new issue
Block a user