Merge branch 'dev' into ntag-auto-pwd-capture

This commit is contained in:
Yukai Li
2022-10-26 21:11:37 -06:00
478 changed files with 10935 additions and 1665 deletions
+10
View File
@@ -786,6 +786,16 @@ ELFFileLoadStatus elf_file_load_sections(ELFFile* elf) {
FURI_LOG_D(TAG, "Trampoline cache size: %u", AddressCache_size(elf->trampoline_cache));
AddressCache_clear(elf->relocation_cache);
{
size_t total_size = 0;
for(ELFSectionDict_it(it, elf->sections); !ELFSectionDict_end_p(it);
ELFSectionDict_next(it)) {
ELFSectionDict_itref_t* itref = ELFSectionDict_ref(it);
total_size += itref->value.size;
}
FURI_LOG_I(TAG, "Total size of loaded sections: %u", total_size);
}
return status;
}
+9 -1
View File
@@ -57,6 +57,7 @@ struct InfraredWorker {
InfraredDecoderHandler* infrared_decoder;
NotificationApp* notification;
bool blink_enable;
bool decode_enable;
union {
struct {
@@ -131,7 +132,8 @@ static void infrared_worker_process_timeout(InfraredWorker* instance) {
static void
infrared_worker_process_timings(InfraredWorker* instance, uint32_t duration, bool level) {
const InfraredMessage* message_decoded =
infrared_decode(instance->infrared_decoder, level, duration);
instance->decode_enable ? infrared_decode(instance->infrared_decoder, level, duration) :
NULL;
if(message_decoded) {
instance->signal.message = *message_decoded;
instance->signal.timings_cnt = 0;
@@ -233,6 +235,7 @@ InfraredWorker* infrared_worker_alloc() {
instance->infrared_decoder = infrared_alloc_decoder();
instance->infrared_encoder = infrared_alloc_encoder();
instance->blink_enable = false;
instance->decode_enable = true;
instance->notification = furi_record_open(RECORD_NOTIFICATION);
instance->state = InfraredWorkerStateIdle;
@@ -316,6 +319,11 @@ void infrared_worker_rx_enable_blink_on_receiving(InfraredWorker* instance, bool
instance->blink_enable = enable;
}
void infrared_worker_rx_enable_signal_decoding(InfraredWorker* instance, bool enable) {
furi_assert(instance);
instance->decode_enable = enable;
}
void infrared_worker_tx_start(InfraredWorker* instance) {
furi_assert(instance);
furi_assert(instance->state == InfraredWorkerStateIdle);
+8
View File
@@ -76,6 +76,14 @@ void infrared_worker_rx_set_received_signal_callback(
*/
void infrared_worker_rx_enable_blink_on_receiving(InfraredWorker* instance, bool enable);
/** Enable decoding of received infrared signals.
*
* @param[in] instance - instance of InfraredWorker
* @param[in] enable - true if you want to enable decoding
* false otherwise
*/
void infrared_worker_rx_enable_signal_decoding(InfraredWorker* instance, bool enable);
/** Clarify is received signal either decoded or raw
*
* @param[in] signal - received signal
+1 -1
View File
@@ -2,7 +2,7 @@ Import("env")
env.Append(
LINT_SOURCES=[
"#/lib/lfrfid",
"lib/lfrfid",
],
CPPPATH=[
"#/lib/lfrfid",
+1 -1
View File
@@ -207,7 +207,7 @@ bool protocol_awid_write_data(ProtocolAwid* protocol, void* data) {
// Fix incorrect length byte
if(protocol->data[0] != 26 && protocol->data[0] != 50 && protocol->data[0] != 37 &&
protocol->data[0] != 34 && protocol->data[0] != 36 ) {
protocol->data[0] != 34 && protocol->data[0] != 36) {
protocol->data[0] = 26;
}
+18 -4
View File
@@ -44,7 +44,10 @@ MfClassicDict* mf_classic_dict_alloc(MfClassicDictType dict_type) {
do {
if(dict_type == MfClassicDictTypeFlipper) {
if(!buffered_file_stream_open(
dict->stream, MF_CLASSIC_DICT_FLIPPER_PATH, FSAM_READ, FSOM_OPEN_EXISTING)) {
dict->stream,
MF_CLASSIC_DICT_FLIPPER_PATH,
FSAM_READ_WRITE,
FSOM_OPEN_EXISTING)) {
buffered_file_stream_close(dict->stream);
break;
}
@@ -59,12 +62,24 @@ MfClassicDict* mf_classic_dict_alloc(MfClassicDictType dict_type) {
dict->stream,
MF_CLASSIC_DICT_UNIT_TEST_PATH,
FSAM_READ_WRITE,
FSOM_CREATE_ALWAYS)) {
FSOM_OPEN_ALWAYS)) {
buffered_file_stream_close(dict->stream);
break;
}
}
// Check for new line ending
if(!stream_eof(dict->stream)) {
if(!stream_seek(dict->stream, -1, StreamOffsetFromEnd)) break;
uint8_t last_char = 0;
if(stream_read(dict->stream, &last_char, 1) != 1) break;
if(last_char != '\n') {
FURI_LOG_D(TAG, "Adding new line ending");
if(stream_write_char(dict->stream, '\n') != 1) break;
}
if(!stream_rewind(dict->stream)) break;
}
// Read total amount of keys
FuriString* next_line;
next_line = furi_string_alloc();
@@ -73,14 +88,13 @@ MfClassicDict* mf_classic_dict_alloc(MfClassicDictType dict_type) {
FURI_LOG_T(TAG, "No keys left in dict");
break;
}
furi_string_trim(next_line);
FURI_LOG_T(
TAG,
"Read line: %s, len: %d",
furi_string_get_cstr(next_line),
furi_string_size(next_line));
if(furi_string_get_char(next_line, 0) == '#') continue;
if(furi_string_size(next_line) != NFC_MF_CLASSIC_KEY_LEN - 1) continue;
if(furi_string_size(next_line) != NFC_MF_CLASSIC_KEY_LEN) continue;
dict->total_keys++;
}
furi_string_free(next_line);
+1 -1
View File
@@ -924,7 +924,7 @@ static bool nfc_device_save_mifare_classic_keys(NfcDevice* dev) {
file, furi_string_get_cstr(temp_str), sec_tr->key_a, 6);
}
if(!key_save_success) break;
if(FURI_BIT(data->key_a_mask, i)) {
if(FURI_BIT(data->key_b_mask, i)) {
furi_string_printf(temp_str, "Key B sector %d", i);
key_save_success = flipper_format_write_hex(
file, furi_string_get_cstr(temp_str), sec_tr->key_b, 6);
Submodule lib/scons deleted from c2d1f09f61
+6
View File
@@ -11,6 +11,12 @@ env.Append(
File("#/lib/subghz/subghz_tx_rx_worker.h"),
File("#/lib/subghz/transmitter.h"),
File("#/lib/subghz/protocols/raw.h"),
File("#/lib/subghz/blocks/const.h"),
File("#/lib/subghz/blocks/decoder.h"),
File("#/lib/subghz/blocks/encoder.h"),
File("#/lib/subghz/blocks/generic.h"),
File("#/lib/subghz/blocks/math.h"),
File("#/lib/subghz/subghz_setting.h"),
],
)
+8
View File
@@ -4,9 +4,17 @@
#include <stdint.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
const uint16_t te_long;
const uint16_t te_short;
const uint16_t te_delta;
const uint8_t min_count_bit_for_found;
} SubGhzBlockConst;
#ifdef __cplusplus
}
#endif
+10
View File
@@ -7,6 +7,16 @@ void subghz_protocol_blocks_add_bit(SubGhzBlockDecoder* decoder, uint8_t bit) {
decoder->decode_count_bit++;
}
void subghz_protocol_blocks_add_to_128_bit(
SubGhzBlockDecoder* decoder,
uint8_t bit,
uint64_t* head_64_bit) {
if(++decoder->decode_count_bit > 64) {
(*head_64_bit) = ((*head_64_bit) << 1) | (decoder->decode_data >> 63);
}
decoder->decode_data = decoder->decode_data << 1 | bit;
}
uint8_t subghz_protocol_blocks_get_hash_data(SubGhzBlockDecoder* decoder, size_t len) {
uint8_t hash = 0;
uint8_t* p = (uint8_t*)&decoder->decode_data;
+19
View File
@@ -4,6 +4,10 @@
#include <stdint.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct SubGhzBlockDecoder SubGhzBlockDecoder;
struct SubGhzBlockDecoder {
@@ -20,9 +24,24 @@ struct SubGhzBlockDecoder {
*/
void subghz_protocol_blocks_add_bit(SubGhzBlockDecoder* decoder, uint8_t bit);
/**
* Add data to_128 bit when decoding.
* @param decoder Pointer to a SubGhzBlockDecoder instance
* @param head_64_bit Pointer to a head_64_bit
* @param bit data, 1bit
*/
void subghz_protocol_blocks_add_to_128_bit(
SubGhzBlockDecoder* decoder,
uint8_t bit,
uint64_t* head_64_bit);
/**
* Getting the hash sum of the last randomly received parcel.
* @param decoder Pointer to a SubGhzBlockDecoder instance
* @return hash Hash sum
*/
uint8_t subghz_protocol_blocks_get_hash_data(SubGhzBlockDecoder* decoder, size_t len);
#ifdef __cplusplus
}
#endif
+8
View File
@@ -6,6 +6,10 @@
#include <lib/toolbox/level_duration.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
bool is_running;
size_t repeat;
@@ -50,3 +54,7 @@ size_t subghz_protocol_blocks_get_upload(
LevelDuration* upload,
size_t max_size_upload,
uint32_t duration_bit);
#ifdef __cplusplus
}
#endif
+1 -1
View File
@@ -23,7 +23,7 @@ void subghz_block_generic_get_preset_name(const char* preset_name, FuriString* p
bool subghz_block_generic_serialize(
SubGhzBlockGeneric* instance,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(instance);
bool res = false;
FuriString* temp_str;
+10 -2
View File
@@ -9,6 +9,10 @@
#include "furi_hal.h"
#include "../types.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct SubGhzBlockGeneric SubGhzBlockGeneric;
struct SubGhzBlockGeneric {
@@ -31,13 +35,13 @@ void subghz_block_generic_get_preset_name(const char* preset_name, FuriString* p
* Serialize data SubGhzBlockGeneric.
* @param instance Pointer to a SubGhzBlockGeneric instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_block_generic_serialize(
SubGhzBlockGeneric* instance,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzBlockGeneric.
@@ -46,3 +50,7 @@ bool subghz_block_generic_serialize(
* @return true On success
*/
bool subghz_block_generic_deserialize(SubGhzBlockGeneric* instance, FlipperFormat* flipper_format);
#ifdef __cplusplus
}
#endif
+234 -7
View File
@@ -1,17 +1,244 @@
#include "math.h"
uint64_t subghz_protocol_blocks_reverse_key(uint64_t key, uint8_t count_bit) {
uint64_t key_reverse = 0;
for(uint8_t i = 0; i < count_bit; i++) {
key_reverse = key_reverse << 1 | bit_read(key, i);
uint64_t subghz_protocol_blocks_reverse_key(uint64_t key, uint8_t bit_count) {
uint64_t reverse_key = 0;
for(uint8_t i = 0; i < bit_count; i++) {
reverse_key = reverse_key << 1 | bit_read(key, i);
}
return key_reverse;
return reverse_key;
}
uint8_t subghz_protocol_blocks_get_parity(uint64_t key, uint8_t count_bit) {
uint8_t subghz_protocol_blocks_get_parity(uint64_t key, uint8_t bit_count) {
uint8_t parity = 0;
for(uint8_t i = 0; i < count_bit; i++) {
for(uint8_t i = 0; i < bit_count; i++) {
parity += bit_read(key, i);
}
return parity & 0x01;
}
uint8_t subghz_protocol_blocks_crc4(
uint8_t const message[],
size_t size,
uint8_t polynomial,
uint8_t init) {
uint8_t remainder = init << 4; // LSBs are unused
uint8_t poly = polynomial << 4;
uint8_t bit;
while(size--) {
remainder ^= *message++;
for(bit = 0; bit < 8; bit++) {
if(remainder & 0x80) {
remainder = (remainder << 1) ^ poly;
} else {
remainder = (remainder << 1);
}
}
}
return remainder >> 4 & 0x0f; // discard the LSBs
}
uint8_t subghz_protocol_blocks_crc7(
uint8_t const message[],
size_t size,
uint8_t polynomial,
uint8_t init) {
uint8_t remainder = init << 1; // LSB is unused
uint8_t poly = polynomial << 1;
for(size_t byte = 0; byte < size; ++byte) {
remainder ^= message[byte];
for(uint8_t bit = 0; bit < 8; ++bit) {
if(remainder & 0x80) {
remainder = (remainder << 1) ^ poly;
} else {
remainder = (remainder << 1);
}
}
}
return remainder >> 1 & 0x7f; // discard the LSB
}
uint8_t subghz_protocol_blocks_crc8(
uint8_t const message[],
size_t size,
uint8_t polynomial,
uint8_t init) {
uint8_t remainder = init;
for(size_t byte = 0; byte < size; ++byte) {
remainder ^= message[byte];
for(uint8_t bit = 0; bit < 8; ++bit) {
if(remainder & 0x80) {
remainder = (remainder << 1) ^ polynomial;
} else {
remainder = (remainder << 1);
}
}
}
return remainder;
}
uint8_t subghz_protocol_blocks_crc8le(
uint8_t const message[],
size_t size,
uint8_t polynomial,
uint8_t init) {
uint8_t remainder = subghz_protocol_blocks_reverse_key(init, 8);
polynomial = subghz_protocol_blocks_reverse_key(polynomial, 8);
for(size_t byte = 0; byte < size; ++byte) {
remainder ^= message[byte];
for(uint8_t bit = 0; bit < 8; ++bit) {
if(remainder & 1) {
remainder = (remainder >> 1) ^ polynomial;
} else {
remainder = (remainder >> 1);
}
}
}
return remainder;
}
uint16_t subghz_protocol_blocks_crc16lsb(
uint8_t const message[],
size_t size,
uint16_t polynomial,
uint16_t init) {
uint16_t remainder = init;
for(size_t byte = 0; byte < size; ++byte) {
remainder ^= message[byte];
for(uint8_t bit = 0; bit < 8; ++bit) {
if(remainder & 1) {
remainder = (remainder >> 1) ^ polynomial;
} else {
remainder = (remainder >> 1);
}
}
}
return remainder;
}
uint16_t subghz_protocol_blocks_crc16(
uint8_t const message[],
size_t size,
uint16_t polynomial,
uint16_t init) {
uint16_t remainder = init;
for(size_t byte = 0; byte < size; ++byte) {
remainder ^= message[byte] << 8;
for(uint8_t bit = 0; bit < 8; ++bit) {
if(remainder & 0x8000) {
remainder = (remainder << 1) ^ polynomial;
} else {
remainder = (remainder << 1);
}
}
}
return remainder;
}
uint8_t subghz_protocol_blocks_lfsr_digest8(
uint8_t const message[],
size_t size,
uint8_t gen,
uint8_t key) {
uint8_t sum = 0;
for(size_t byte = 0; byte < size; ++byte) {
uint8_t data = message[byte];
for(int i = 7; i >= 0; --i) {
// XOR key into sum if data bit is set
if((data >> i) & 1) sum ^= key;
// roll the key right (actually the LSB is dropped here)
// and apply the gen (needs to include the dropped LSB as MSB)
if(key & 1)
key = (key >> 1) ^ gen;
else
key = (key >> 1);
}
}
return sum;
}
uint8_t subghz_protocol_blocks_lfsr_digest8_reflect(
uint8_t const message[],
size_t size,
uint8_t gen,
uint8_t key) {
uint8_t sum = 0;
// Process message from last byte to first byte (reflected)
for(int byte = size - 1; byte >= 0; --byte) {
uint8_t data = message[byte];
// Process individual bits of each byte (reflected)
for(uint8_t i = 0; i < 8; ++i) {
// XOR key into sum if data bit is set
if((data >> i) & 1) {
sum ^= key;
}
// roll the key left (actually the LSB is dropped here)
// and apply the gen (needs to include the dropped lsb as MSB)
if(key & 0x80)
key = (key << 1) ^ gen;
else
key = (key << 1);
}
}
return sum;
}
uint16_t subghz_protocol_blocks_lfsr_digest16(
uint8_t const message[],
size_t size,
uint16_t gen,
uint16_t key) {
uint16_t sum = 0;
for(size_t byte = 0; byte < size; ++byte) {
uint8_t data = message[byte];
for(int8_t i = 7; i >= 0; --i) {
// if data bit is set then xor with key
if((data >> i) & 1) sum ^= key;
// roll the key right (actually the LSB is dropped here)
// and apply the gen (needs to include the dropped LSB as MSB)
if(key & 1)
key = (key >> 1) ^ gen;
else
key = (key >> 1);
}
}
return sum;
}
uint8_t subghz_protocol_blocks_add_bytes(uint8_t const message[], size_t size) {
uint32_t result = 0;
for(size_t i = 0; i < size; ++i) {
result += message[i];
}
return (uint8_t)result;
}
uint8_t subghz_protocol_blocks_parity8(uint8_t byte) {
byte ^= byte >> 4;
byte &= 0xf;
return (0x6996 >> byte) & 1;
}
uint8_t subghz_protocol_blocks_parity_bytes(uint8_t const message[], size_t size) {
uint8_t result = 0;
for(size_t i = 0; i < size; ++i) {
result ^= subghz_protocol_blocks_parity8(message[i]);
}
return result;
}
uint8_t subghz_protocol_blocks_xor_bytes(uint8_t const message[], size_t size) {
uint8_t result = 0;
for(size_t i = 0; i < size; ++i) {
result ^= message[i];
}
return result;
}
+201 -13
View File
@@ -9,19 +9,207 @@
#define bit_clear(value, bit) ((value) &= ~(1UL << (bit)))
#define bit_write(value, bit, bitvalue) (bitvalue ? bit_set(value, bit) : bit_clear(value, bit))
#define DURATION_DIFF(x, y) ((x < y) ? (y - x) : (x - y))
#define abs(x) ((x) > 0 ? (x) : -(x))
/**
* Flip the data bitwise.
* @param key In data
* @param count_bit number of data bits
* @return Reverse data
*/
uint64_t subghz_protocol_blocks_reverse_key(uint64_t key, uint8_t count_bit);
#ifdef __cplusplus
extern "C" {
#endif
/**
* Get parity the data bitwise.
* @param key In data
* @param count_bit number of data bits
* @return parity
/** Flip the data bitwise
*
* @param key In data
* @param bit_count number of data bits
*
* @return Reverse data
*/
uint8_t subghz_protocol_blocks_get_parity(uint64_t key, uint8_t count_bit);
uint64_t subghz_protocol_blocks_reverse_key(uint64_t key, uint8_t bit_count);
/** Get parity the data bitwise
*
* @param key In data
* @param bit_count number of data bits
*
* @return parity
*/
uint8_t subghz_protocol_blocks_get_parity(uint64_t key, uint8_t bit_count);
/** CRC-4
*
* @param message array of bytes to check
* @param size number of bytes in message
* @param polynomial CRC polynomial
* @param init starting crc value
*
* @return CRC value
*/
uint8_t subghz_protocol_blocks_crc4(
uint8_t const message[],
size_t size,
uint8_t polynomial,
uint8_t init);
/** CRC-7
*
* @param message array of bytes to check
* @param size number of bytes in message
* @param polynomial CRC polynomial
* @param init starting crc value
*
* @return CRC value
*/
uint8_t subghz_protocol_blocks_crc7(
uint8_t const message[],
size_t size,
uint8_t polynomial,
uint8_t init);
/** Generic Cyclic Redundancy Check CRC-8. Example polynomial: 0x31 = x8 + x5 +
* x4 + 1 (x8 is implicit) Example polynomial: 0x80 = x8 + x7 (a normal
* bit-by-bit parity XOR)
*
* @param message array of bytes to check
* @param size number of bytes in message
* @param polynomial byte is from x^7 to x^0 (x^8 is implicitly one)
* @param init starting crc value
*
* @return CRC value
*/
uint8_t subghz_protocol_blocks_crc8(
uint8_t const message[],
size_t size,
uint8_t polynomial,
uint8_t init);
/** "Little-endian" Cyclic Redundancy Check CRC-8 LE Input and output are
* reflected, i.e. least significant bit is shifted in first
*
* @param message array of bytes to check
* @param size number of bytes in message
* @param polynomial CRC polynomial
* @param init starting crc value
*
* @return CRC value
*/
uint8_t subghz_protocol_blocks_crc8le(
uint8_t const message[],
size_t size,
uint8_t polynomial,
uint8_t init);
/** CRC-16 LSB. Input and output are reflected, i.e. least significant bit is
* shifted in first. Note that poly and init already need to be reflected
*
* @param message array of bytes to check
* @param size number of bytes in message
* @param polynomial CRC polynomial
* @param init starting crc value
*
* @return CRC value
*/
uint16_t subghz_protocol_blocks_crc16lsb(
uint8_t const message[],
size_t size,
uint16_t polynomial,
uint16_t init);
/** CRC-16
*
* @param message array of bytes to check
* @param size number of bytes in message
* @param polynomial CRC polynomial
* @param init starting crc value
*
* @return CRC value
*/
uint16_t subghz_protocol_blocks_crc16(
uint8_t const message[],
size_t size,
uint16_t polynomial,
uint16_t init);
/** Digest-8 by "LFSR-based Toeplitz hash"
*
* @param message bytes of message data
* @param size number of bytes to digest
* @param gen key stream generator, needs to includes the MSB if the
* LFSR is rolling
* @param key initial key
*
* @return digest value
*/
uint8_t subghz_protocol_blocks_lfsr_digest8(
uint8_t const message[],
size_t size,
uint8_t gen,
uint8_t key);
/** Digest-8 by "LFSR-based Toeplitz hash", byte reflect, bit reflect
*
* @param message bytes of message data
* @param size number of bytes to digest
* @param gen key stream generator, needs to includes the MSB if the
* LFSR is rolling
* @param key initial key
*
* @return digest value
*/
uint8_t subghz_protocol_blocks_lfsr_digest8_reflect(
uint8_t const message[],
size_t size,
uint8_t gen,
uint8_t key);
/** Digest-16 by "LFSR-based Toeplitz hash"
*
* @param message bytes of message data
* @param size number of bytes to digest
* @param gen key stream generator, needs to includes the MSB if the
* LFSR is rolling
* @param key initial key
*
* @return digest value
*/
uint16_t subghz_protocol_blocks_lfsr_digest16(
uint8_t const message[],
size_t size,
uint16_t gen,
uint16_t key);
/** Compute Addition of a number of bytes
*
* @param message bytes of message data
* @param size number of bytes to sum
*
* @return summation value
*/
uint8_t subghz_protocol_blocks_add_bytes(uint8_t const message[], size_t size);
/** Compute bit parity of a single byte (8 bits)
*
* @param byte single byte to check
*
* @return 1 odd parity, 0 even parity
*/
uint8_t subghz_protocol_blocks_parity8(uint8_t byte);
/** Compute bit parity of a number of bytes
*
* @param message bytes of message data
* @param size number of bytes to sum
*
* @return 1 odd parity, 0 even parity
*/
uint8_t subghz_protocol_blocks_parity_bytes(uint8_t const message[], size_t size);
/** Compute XOR (byte-wide parity) of a number of bytes
*
* @param message bytes of message data
* @param size number of bytes to sum
*
* @return summation value, per bit-position 1 odd parity, 0 even parity
*/
uint8_t subghz_protocol_blocks_xor_bytes(uint8_t const message[], size_t size);
#ifdef __cplusplus
}
#endif
+33
View File
@@ -1,7 +1,9 @@
#include "environment.h"
#include "registry.h"
struct SubGhzEnvironment {
SubGhzKeystore* keystore;
const SubGhzProtocolRegistry* protocol_registry;
const char* came_atomo_rainbow_table_file_name;
const char* nice_flor_s_rainbow_table_file_name;
};
@@ -10,6 +12,7 @@ SubGhzEnvironment* subghz_environment_alloc() {
SubGhzEnvironment* instance = malloc(sizeof(SubGhzEnvironment));
instance->keystore = subghz_keystore_alloc();
instance->protocol_registry = NULL;
instance->came_atomo_rainbow_table_file_name = NULL;
instance->nice_flor_s_rainbow_table_file_name = NULL;
@@ -19,6 +22,9 @@ SubGhzEnvironment* subghz_environment_alloc() {
void subghz_environment_free(SubGhzEnvironment* instance) {
furi_assert(instance);
instance->protocol_registry = NULL;
instance->came_atomo_rainbow_table_file_name = NULL;
instance->nice_flor_s_rainbow_table_file_name = NULL;
subghz_keystore_free(instance->keystore);
free(instance);
@@ -65,3 +71,30 @@ const char*
return instance->nice_flor_s_rainbow_table_file_name;
}
void subghz_environment_set_protocol_registry(
SubGhzEnvironment* instance,
void* protocol_registry_items) {
furi_assert(instance);
const SubGhzProtocolRegistry* protocol_registry = protocol_registry_items;
instance->protocol_registry = protocol_registry;
}
void* subghz_environment_get_protocol_registry(SubGhzEnvironment* instance) {
furi_assert(instance);
furi_assert(instance->protocol_registry);
return (void*)instance->protocol_registry;
}
const char*
subghz_environment_get_protocol_name_registry(SubGhzEnvironment* instance, size_t idx) {
furi_assert(instance);
furi_assert(instance->protocol_registry);
const SubGhzProtocol* protocol =
subghz_protocol_registry_get_by_index(instance->protocol_registry, idx);
if(protocol != NULL) {
return protocol->name;
} else {
return NULL;
}
}
+24
View File
@@ -69,6 +69,30 @@ void subghz_environment_set_nice_flor_s_rainbow_table_file_name(
const char*
subghz_environment_get_nice_flor_s_rainbow_table_file_name(SubGhzEnvironment* instance);
/**
* Set list of protocols to work.
* @param instance Pointer to a SubGhzEnvironment instance
* @param protocol_registry_items Pointer to a SubGhzProtocolRegistry
*/
void subghz_environment_set_protocol_registry(
SubGhzEnvironment* instance,
void* protocol_registry_items);
/**
* Get list of protocols to work.
* @param instance Pointer to a SubGhzEnvironment instance
* @return Pointer to a SubGhzProtocolRegistry
*/
void* subghz_environment_get_protocol_registry(SubGhzEnvironment* instance);
/**
* Get list of protocols names.
* @param instance Pointer to a SubGhzEnvironment instance
* @param idx index protocols
* @return Pointer to a SubGhzProtocolRegistry
*/
const char* subghz_environment_get_protocol_name_registry(SubGhzEnvironment* instance, size_t idx);
#ifdef __cplusplus
}
#endif
+1 -1
View File
@@ -26,7 +26,7 @@ bool subghz_protocol_decoder_base_get_string(
bool subghz_protocol_decoder_base_serialize(
SubGhzProtocolDecoderBase* decoder_base,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
bool status = false;
if(decoder_base->protocol && decoder_base->protocol->decoder &&
+2 -2
View File
@@ -48,13 +48,13 @@ bool subghz_protocol_decoder_base_get_string(
* Serialize data SubGhzProtocolDecoderBase.
* @param decoder_base Pointer to a SubGhzProtocolDecoderBase instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_base_serialize(
SubGhzProtocolDecoderBase* decoder_base,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderBase.
+1 -1
View File
@@ -299,7 +299,7 @@ uint8_t subghz_protocol_decoder_bett_get_hash_data(void* context) {
bool subghz_protocol_decoder_bett_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderBETT* instance = context;
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
+2 -2
View File
@@ -83,13 +83,13 @@ uint8_t subghz_protocol_decoder_bett_get_hash_data(void* context);
* Serialize data SubGhzProtocolDecoderBETT.
* @param context Pointer to a SubGhzProtocolDecoderBETT instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_bett_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderBETT.
+11 -12
View File
@@ -16,6 +16,8 @@
#define CAME_24_COUNT_BIT 24
#define PRASTEL_COUNT_BIT 25
#define PRASTEL_NAME "Prastel"
#define AIRFORCE_COUNT_BIT 18
#define AIRFORCE_NAME "Airforce"
static const SubGhzBlockConst subghz_protocol_came_const = {
.te_short = 320,
@@ -86,7 +88,7 @@ void* subghz_protocol_encoder_came_alloc(SubGhzEnvironment* environment) {
instance->generic.protocol_name = instance->base.protocol->name;
instance->encoder.repeat = 10;
instance->encoder.size_upload = 52; //max 24bit*2 + 2 (start, stop)
instance->encoder.size_upload = 128;
instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration));
instance->encoder.is_running = false;
return instance;
@@ -151,10 +153,7 @@ bool subghz_protocol_encoder_came_deserialize(void* context, FlipperFormat* flip
FURI_LOG_E(TAG, "Deserialize error");
break;
}
if((instance->generic.data_count_bit !=
subghz_protocol_came_const.min_count_bit_for_found) &&
(instance->generic.data_count_bit != CAME_24_COUNT_BIT) &&
(instance->generic.data_count_bit != PRASTEL_COUNT_BIT)) {
if((instance->generic.data_count_bit > PRASTEL_COUNT_BIT)) {
FURI_LOG_E(TAG, "Wrong number of bits in key");
break;
}
@@ -296,7 +295,7 @@ uint8_t subghz_protocol_decoder_came_get_hash_data(void* context) {
bool subghz_protocol_decoder_came_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderCame* instance = context;
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
@@ -310,10 +309,7 @@ bool subghz_protocol_decoder_came_deserialize(void* context, FlipperFormat* flip
if(!subghz_block_generic_deserialize(&instance->generic, flipper_format)) {
break;
}
if((instance->generic.data_count_bit !=
subghz_protocol_came_const.min_count_bit_for_found) &&
(instance->generic.data_count_bit != CAME_24_COUNT_BIT) &&
(instance->generic.data_count_bit != PRASTEL_COUNT_BIT)) {
if((instance->generic.data_count_bit > PRASTEL_COUNT_BIT)) {
FURI_LOG_E(TAG, "Wrong number of bits in key");
break;
}
@@ -338,8 +334,11 @@ void subghz_protocol_decoder_came_get_string(void* context, FuriString* output)
"%s %dbit\r\n"
"Key:0x%08lX\r\n"
"Yek:0x%08lX\r\n",
(instance->generic.data_count_bit == PRASTEL_COUNT_BIT ? PRASTEL_NAME :
instance->generic.protocol_name),
(instance->generic.data_count_bit == PRASTEL_COUNT_BIT ?
PRASTEL_NAME :
(instance->generic.data_count_bit == AIRFORCE_COUNT_BIT ?
AIRFORCE_NAME :
instance->generic.protocol_name)),
instance->generic.data_count_bit,
code_found_lo,
code_found_reverse_lo);
+2 -2
View File
@@ -83,13 +83,13 @@ uint8_t subghz_protocol_decoder_came_get_hash_data(void* context);
* Serialize data SubGhzProtocolDecoderCame.
* @param context Pointer to a SubGhzProtocolDecoderCame instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_came_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderCame.
+1 -1
View File
@@ -301,7 +301,7 @@ uint8_t subghz_protocol_decoder_came_atomo_get_hash_data(void* context) {
bool subghz_protocol_decoder_came_atomo_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderCameAtomo* instance = context;
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
+2 -2
View File
@@ -48,13 +48,13 @@ uint8_t subghz_protocol_decoder_came_atomo_get_hash_data(void* context);
* Serialize data SubGhzProtocolDecoderCameAtomo.
* @param context Pointer to a SubGhzProtocolDecoderCameAtomo instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_came_atomo_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderCameAtomo.
+1 -1
View File
@@ -422,7 +422,7 @@ uint8_t subghz_protocol_decoder_came_twee_get_hash_data(void* context) {
bool subghz_protocol_decoder_came_twee_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderCameTwee* instance = context;
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
+2 -2
View File
@@ -83,13 +83,13 @@ uint8_t subghz_protocol_decoder_came_twee_get_hash_data(void* context);
* Serialize data SubGhzProtocolDecoderCameTwee.
* @param context Pointer to a SubGhzProtocolDecoderCameTwee instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_came_twee_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderCameTwee.
+1 -1
View File
@@ -427,7 +427,7 @@ uint8_t subghz_protocol_decoder_chamb_code_get_hash_data(void* context) {
bool subghz_protocol_decoder_chamb_code_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderChamb_Code* instance = context;
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
+2 -2
View File
@@ -83,13 +83,13 @@ uint8_t subghz_protocol_decoder_chamb_code_get_hash_data(void* context);
* Serialize data SubGhzProtocolDecoderChamb_Code.
* @param context Pointer to a SubGhzProtocolDecoderChamb_Code instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_chamb_code_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderChamb_Code.
+1 -1
View File
@@ -319,7 +319,7 @@ uint8_t subghz_protocol_decoder_clemsa_get_hash_data(void* context) {
bool subghz_protocol_decoder_clemsa_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderClemsa* instance = context;
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
+2 -2
View File
@@ -83,13 +83,13 @@ uint8_t subghz_protocol_decoder_clemsa_get_hash_data(void* context);
* Serialize data SubGhzProtocolDecoderClemsa.
* @param context Pointer to a SubGhzProtocolDecoderClemsa instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_clemsa_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderClemsa.
+1 -1
View File
@@ -313,7 +313,7 @@ uint8_t subghz_protocol_decoder_doitrand_get_hash_data(void* context) {
bool subghz_protocol_decoder_doitrand_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderDoitrand* instance = context;
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
+2 -2
View File
@@ -83,13 +83,13 @@ uint8_t subghz_protocol_decoder_doitrand_get_hash_data(void* context);
* Serialize data SubGhzProtocolDecoderDoitrand.
* @param context Pointer to a SubGhzProtocolDecoderDoitrand instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_doitrand_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderDoitrand.
+1 -1
View File
@@ -183,7 +183,7 @@ uint8_t subghz_protocol_decoder_faac_slh_get_hash_data(void* context) {
bool subghz_protocol_decoder_faac_slh_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderFaacSLH* instance = context;
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
+2 -2
View File
@@ -49,13 +49,13 @@ uint8_t subghz_protocol_decoder_faac_slh_get_hash_data(void* context);
* Serialize data SubGhzProtocolDecoderFaacSLH.
* @param context Pointer to a SubGhzProtocolDecoderFaacSLH instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_faac_slh_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderFaacSLH.
+1 -1
View File
@@ -293,7 +293,7 @@ uint8_t subghz_protocol_decoder_gate_tx_get_hash_data(void* context) {
bool subghz_protocol_decoder_gate_tx_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderGateTx* instance = context;
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
+2 -2
View File
@@ -83,13 +83,13 @@ uint8_t subghz_protocol_decoder_gate_tx_get_hash_data(void* context);
* Serialize data SubGhzProtocolDecoderGateTx.
* @param context Pointer to a SubGhzProtocolDecoderGateTx instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_gate_tx_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderGateTx.
+1 -1
View File
@@ -326,7 +326,7 @@ uint8_t subghz_protocol_decoder_holtek_get_hash_data(void* context) {
bool subghz_protocol_decoder_holtek_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderHoltek* instance = context;
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
+2 -2
View File
@@ -83,13 +83,13 @@ uint8_t subghz_protocol_decoder_holtek_get_hash_data(void* context);
* Serialize data SubGhzProtocolDecoderHoltek.
* @param context Pointer to a SubGhzProtocolDecoderHoltek instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_holtek_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderHoltek.
+1 -1
View File
@@ -348,7 +348,7 @@ uint8_t subghz_protocol_decoder_honeywell_wdb_get_hash_data(void* context) {
bool subghz_protocol_decoder_honeywell_wdb_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderHoneywell_WDB* instance = context;
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
+2 -2
View File
@@ -85,13 +85,13 @@ uint8_t subghz_protocol_decoder_honeywell_wdb_get_hash_data(void* context);
* Serialize data SubGhzProtocolDecoderHoneywell_WDB.
* @param context Pointer to a SubGhzProtocolDecoderHoneywell_WDB instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_honeywell_wdb_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderHoneywell_WDB.
+1 -1
View File
@@ -314,7 +314,7 @@ uint8_t subghz_protocol_decoder_hormann_get_hash_data(void* context) {
bool subghz_protocol_decoder_hormann_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderHormann* instance = context;
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
+2 -2
View File
@@ -83,13 +83,13 @@ uint8_t subghz_protocol_decoder_hormann_get_hash_data(void* context);
* Serialize data SubGhzProtocolDecoderHormann.
* @param context Pointer to a SubGhzProtocolDecoderHormann instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_hormann_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderHormann.
+1 -1
View File
@@ -182,7 +182,7 @@ uint8_t subghz_protocol_decoder_ido_get_hash_data(void* context) {
bool subghz_protocol_decoder_ido_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderIDo* instance = context;
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
+2 -2
View File
@@ -49,13 +49,13 @@ uint8_t subghz_protocol_decoder_ido_get_hash_data(void* context);
* Serialize data SubGhzProtocolDecoderIDo.
* @param context Pointer to a SubGhzProtocolDecoderIDo instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_ido_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderIDo.
+1 -1
View File
@@ -407,7 +407,7 @@ uint8_t subghz_protocol_decoder_intertechno_v3_get_hash_data(void* context) {
bool subghz_protocol_decoder_intertechno_v3_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderIntertechno_V3* instance = context;
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
+2 -2
View File
@@ -85,13 +85,13 @@ uint8_t subghz_protocol_decoder_intertechno_v3_get_hash_data(void* context);
* Serialize data SubGhzProtocolDecoderIntertechno_V3.
* @param context Pointer to a SubGhzProtocolDecoderIntertechno_V3 instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_intertechno_v3_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderIntertechno_V3.
+2 -2
View File
@@ -173,7 +173,7 @@ bool subghz_protocol_keeloq_create_data(
uint8_t btn,
uint16_t cnt,
const char* manufacture_name,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolEncoderKeeloq* instance = context;
instance->generic.serial = serial;
@@ -646,7 +646,7 @@ uint8_t subghz_protocol_decoder_keeloq_get_hash_data(void* context) {
bool subghz_protocol_decoder_keeloq_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderKeeloq* instance = context;
subghz_protocol_keeloq_check_remote_controller(
+4 -4
View File
@@ -32,7 +32,7 @@ void subghz_protocol_encoder_keeloq_free(void* context);
* @param btn Button number, 4 bit
* @param cnt Container value, 16 bit
* @param manufacture_name Name of manufacturer's key
* @param preset Modulation, SubGhzPresetDefinition
* @param preset Modulation, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_keeloq_create_data(
@@ -42,7 +42,7 @@ bool subghz_protocol_keeloq_create_data(
uint8_t btn,
uint16_t cnt,
const char* manufacture_name,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize and generating an upload to send.
@@ -103,13 +103,13 @@ uint8_t subghz_protocol_decoder_keeloq_get_hash_data(void* context);
* Serialize data SubGhzProtocolDecoderKeeloq.
* @param context Pointer to a SubGhzProtocolDecoderKeeloq instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_keeloq_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderKeeloq.
+1 -1
View File
@@ -233,7 +233,7 @@ uint8_t subghz_protocol_decoder_kia_get_hash_data(void* context) {
bool subghz_protocol_decoder_kia_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderKIA* instance = context;
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
+2 -2
View File
@@ -49,13 +49,13 @@ 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, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_kia_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderKIA.
+1 -1
View File
@@ -303,7 +303,7 @@ uint8_t subghz_protocol_decoder_linear_get_hash_data(void* context) {
bool subghz_protocol_decoder_linear_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderLinear* instance = context;
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
+2 -2
View File
@@ -83,13 +83,13 @@ uint8_t subghz_protocol_decoder_linear_get_hash_data(void* context);
* Serialize data SubGhzProtocolDecoderLinear.
* @param context Pointer to a SubGhzProtocolDecoderLinear instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_linear_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderLinear.
@@ -1,4 +1,4 @@
#include "magellen.h"
#include "magellan.h"
#include "../blocks/const.h"
#include "../blocks/decoder.h"
@@ -6,16 +6,16 @@
#include "../blocks/generic.h"
#include "../blocks/math.h"
#define TAG "SubGhzProtocolMagellen"
#define TAG "SubGhzProtocolMagellan"
static const SubGhzBlockConst subghz_protocol_magellen_const = {
static const SubGhzBlockConst subghz_protocol_magellan_const = {
.te_short = 200,
.te_long = 400,
.te_delta = 100,
.min_count_bit_for_found = 32,
};
struct SubGhzProtocolDecoderMagellen {
struct SubGhzProtocolDecoderMagellan {
SubGhzProtocolDecoderBase base;
SubGhzBlockDecoder decoder;
@@ -23,7 +23,7 @@ struct SubGhzProtocolDecoderMagellen {
uint16_t header_count;
};
struct SubGhzProtocolEncoderMagellen {
struct SubGhzProtocolEncoderMagellan {
SubGhzProtocolEncoderBase base;
SubGhzProtocolBlockEncoder encoder;
@@ -31,50 +31,50 @@ struct SubGhzProtocolEncoderMagellen {
};
typedef enum {
MagellenDecoderStepReset = 0,
MagellenDecoderStepCheckPreambula,
MagellenDecoderStepFoundPreambula,
MagellenDecoderStepSaveDuration,
MagellenDecoderStepCheckDuration,
} MagellenDecoderStep;
MagellanDecoderStepReset = 0,
MagellanDecoderStepCheckPreambula,
MagellanDecoderStepFoundPreambula,
MagellanDecoderStepSaveDuration,
MagellanDecoderStepCheckDuration,
} MagellanDecoderStep;
const SubGhzProtocolDecoder subghz_protocol_magellen_decoder = {
.alloc = subghz_protocol_decoder_magellen_alloc,
.free = subghz_protocol_decoder_magellen_free,
const SubGhzProtocolDecoder subghz_protocol_magellan_decoder = {
.alloc = subghz_protocol_decoder_magellan_alloc,
.free = subghz_protocol_decoder_magellan_free,
.feed = subghz_protocol_decoder_magellen_feed,
.reset = subghz_protocol_decoder_magellen_reset,
.feed = subghz_protocol_decoder_magellan_feed,
.reset = subghz_protocol_decoder_magellan_reset,
.get_hash_data = subghz_protocol_decoder_magellen_get_hash_data,
.serialize = subghz_protocol_decoder_magellen_serialize,
.deserialize = subghz_protocol_decoder_magellen_deserialize,
.get_string = subghz_protocol_decoder_magellen_get_string,
.get_hash_data = subghz_protocol_decoder_magellan_get_hash_data,
.serialize = subghz_protocol_decoder_magellan_serialize,
.deserialize = subghz_protocol_decoder_magellan_deserialize,
.get_string = subghz_protocol_decoder_magellan_get_string,
};
const SubGhzProtocolEncoder subghz_protocol_magellen_encoder = {
.alloc = subghz_protocol_encoder_magellen_alloc,
.free = subghz_protocol_encoder_magellen_free,
const SubGhzProtocolEncoder subghz_protocol_magellan_encoder = {
.alloc = subghz_protocol_encoder_magellan_alloc,
.free = subghz_protocol_encoder_magellan_free,
.deserialize = subghz_protocol_encoder_magellen_deserialize,
.stop = subghz_protocol_encoder_magellen_stop,
.yield = subghz_protocol_encoder_magellen_yield,
.deserialize = subghz_protocol_encoder_magellan_deserialize,
.stop = subghz_protocol_encoder_magellan_stop,
.yield = subghz_protocol_encoder_magellan_yield,
};
const SubGhzProtocol subghz_protocol_magellen = {
.name = SUBGHZ_PROTOCOL_MAGELLEN_NAME,
const SubGhzProtocol subghz_protocol_magellan = {
.name = SUBGHZ_PROTOCOL_MAGELLAN_NAME,
.type = SubGhzProtocolTypeStatic,
.flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable |
SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save | SubGhzProtocolFlag_Send,
.decoder = &subghz_protocol_magellen_decoder,
.encoder = &subghz_protocol_magellen_encoder,
.decoder = &subghz_protocol_magellan_decoder,
.encoder = &subghz_protocol_magellan_encoder,
};
void* subghz_protocol_encoder_magellen_alloc(SubGhzEnvironment* environment) {
void* subghz_protocol_encoder_magellan_alloc(SubGhzEnvironment* environment) {
UNUSED(environment);
SubGhzProtocolEncoderMagellen* instance = malloc(sizeof(SubGhzProtocolEncoderMagellen));
SubGhzProtocolEncoderMagellan* instance = malloc(sizeof(SubGhzProtocolEncoderMagellan));
instance->base.protocol = &subghz_protocol_magellen;
instance->base.protocol = &subghz_protocol_magellan;
instance->generic.protocol_name = instance->base.protocol->name;
instance->encoder.repeat = 10;
@@ -84,75 +84,75 @@ void* subghz_protocol_encoder_magellen_alloc(SubGhzEnvironment* environment) {
return instance;
}
void subghz_protocol_encoder_magellen_free(void* context) {
void subghz_protocol_encoder_magellan_free(void* context) {
furi_assert(context);
SubGhzProtocolEncoderMagellen* instance = context;
SubGhzProtocolEncoderMagellan* instance = context;
free(instance->encoder.upload);
free(instance);
}
/**
* Generating an upload from data.
* @param instance Pointer to a SubGhzProtocolEncoderMagellen instance
* @param instance Pointer to a SubGhzProtocolEncoderMagellan instance
* @return true On success
*/
static bool subghz_protocol_encoder_magellen_get_upload(SubGhzProtocolEncoderMagellen* instance) {
static bool subghz_protocol_encoder_magellan_get_upload(SubGhzProtocolEncoderMagellan* instance) {
furi_assert(instance);
size_t index = 0;
//Send header
instance->encoder.upload[index++] =
level_duration_make(true, (uint32_t)subghz_protocol_magellen_const.te_short * 4);
level_duration_make(true, (uint32_t)subghz_protocol_magellan_const.te_short * 4);
instance->encoder.upload[index++] =
level_duration_make(false, (uint32_t)subghz_protocol_magellen_const.te_short);
level_duration_make(false, (uint32_t)subghz_protocol_magellan_const.te_short);
for(uint8_t i = 0; i < 12; i++) {
instance->encoder.upload[index++] =
level_duration_make(true, (uint32_t)subghz_protocol_magellen_const.te_short);
level_duration_make(true, (uint32_t)subghz_protocol_magellan_const.te_short);
instance->encoder.upload[index++] =
level_duration_make(false, (uint32_t)subghz_protocol_magellen_const.te_short);
level_duration_make(false, (uint32_t)subghz_protocol_magellan_const.te_short);
}
instance->encoder.upload[index++] =
level_duration_make(true, (uint32_t)subghz_protocol_magellen_const.te_short);
level_duration_make(true, (uint32_t)subghz_protocol_magellan_const.te_short);
instance->encoder.upload[index++] =
level_duration_make(false, (uint32_t)subghz_protocol_magellen_const.te_long);
level_duration_make(false, (uint32_t)subghz_protocol_magellan_const.te_long);
//Send start bit
instance->encoder.upload[index++] =
level_duration_make(true, (uint32_t)subghz_protocol_magellen_const.te_long * 3);
level_duration_make(true, (uint32_t)subghz_protocol_magellan_const.te_long * 3);
instance->encoder.upload[index++] =
level_duration_make(false, (uint32_t)subghz_protocol_magellen_const.te_long);
level_duration_make(false, (uint32_t)subghz_protocol_magellan_const.te_long);
//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_magellen_const.te_short);
level_duration_make(true, (uint32_t)subghz_protocol_magellan_const.te_short);
instance->encoder.upload[index++] =
level_duration_make(false, (uint32_t)subghz_protocol_magellen_const.te_long);
level_duration_make(false, (uint32_t)subghz_protocol_magellan_const.te_long);
} else {
//send bit 0
instance->encoder.upload[index++] =
level_duration_make(true, (uint32_t)subghz_protocol_magellen_const.te_long);
level_duration_make(true, (uint32_t)subghz_protocol_magellan_const.te_long);
instance->encoder.upload[index++] =
level_duration_make(false, (uint32_t)subghz_protocol_magellen_const.te_short);
level_duration_make(false, (uint32_t)subghz_protocol_magellan_const.te_short);
}
}
//Send stop bit
instance->encoder.upload[index++] =
level_duration_make(true, (uint32_t)subghz_protocol_magellen_const.te_short);
level_duration_make(true, (uint32_t)subghz_protocol_magellan_const.te_short);
instance->encoder.upload[index++] =
level_duration_make(false, (uint32_t)subghz_protocol_magellen_const.te_long * 100);
level_duration_make(false, (uint32_t)subghz_protocol_magellan_const.te_long * 100);
instance->encoder.size_upload = index;
return true;
}
bool subghz_protocol_encoder_magellen_deserialize(void* context, FlipperFormat* flipper_format) {
bool subghz_protocol_encoder_magellan_deserialize(void* context, FlipperFormat* flipper_format) {
furi_assert(context);
SubGhzProtocolEncoderMagellen* instance = context;
SubGhzProtocolEncoderMagellan* instance = context;
bool res = false;
do {
if(!subghz_block_generic_deserialize(&instance->generic, flipper_format)) {
@@ -160,7 +160,7 @@ bool subghz_protocol_encoder_magellen_deserialize(void* context, FlipperFormat*
break;
}
if(instance->generic.data_count_bit !=
subghz_protocol_magellen_const.min_count_bit_for_found) {
subghz_protocol_magellan_const.min_count_bit_for_found) {
FURI_LOG_E(TAG, "Wrong number of bits in key");
break;
}
@@ -168,7 +168,7 @@ bool subghz_protocol_encoder_magellen_deserialize(void* context, FlipperFormat*
flipper_format_read_uint32(
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
if(!subghz_protocol_encoder_magellen_get_upload(instance)) break;
if(!subghz_protocol_encoder_magellan_get_upload(instance)) break;
instance->encoder.is_running = true;
res = true;
@@ -177,13 +177,13 @@ bool subghz_protocol_encoder_magellen_deserialize(void* context, FlipperFormat*
return res;
}
void subghz_protocol_encoder_magellen_stop(void* context) {
SubGhzProtocolEncoderMagellen* instance = context;
void subghz_protocol_encoder_magellan_stop(void* context) {
SubGhzProtocolEncoderMagellan* instance = context;
instance->encoder.is_running = false;
}
LevelDuration subghz_protocol_encoder_magellen_yield(void* context) {
SubGhzProtocolEncoderMagellen* instance = context;
LevelDuration subghz_protocol_encoder_magellan_yield(void* context) {
SubGhzProtocolEncoderMagellan* instance = context;
if(instance->encoder.repeat == 0 || !instance->encoder.is_running) {
instance->encoder.is_running = false;
@@ -200,27 +200,27 @@ LevelDuration subghz_protocol_encoder_magellen_yield(void* context) {
return ret;
}
void* subghz_protocol_decoder_magellen_alloc(SubGhzEnvironment* environment) {
void* subghz_protocol_decoder_magellan_alloc(SubGhzEnvironment* environment) {
UNUSED(environment);
SubGhzProtocolDecoderMagellen* instance = malloc(sizeof(SubGhzProtocolDecoderMagellen));
instance->base.protocol = &subghz_protocol_magellen;
SubGhzProtocolDecoderMagellan* instance = malloc(sizeof(SubGhzProtocolDecoderMagellan));
instance->base.protocol = &subghz_protocol_magellan;
instance->generic.protocol_name = instance->base.protocol->name;
return instance;
}
void subghz_protocol_decoder_magellen_free(void* context) {
void subghz_protocol_decoder_magellan_free(void* context) {
furi_assert(context);
SubGhzProtocolDecoderMagellen* instance = context;
SubGhzProtocolDecoderMagellan* instance = context;
free(instance);
}
void subghz_protocol_decoder_magellen_reset(void* context) {
void subghz_protocol_decoder_magellan_reset(void* context) {
furi_assert(context);
SubGhzProtocolDecoderMagellen* instance = context;
instance->decoder.parser_step = MagellenDecoderStepReset;
SubGhzProtocolDecoderMagellan* instance = context;
instance->decoder.parser_step = MagellanDecoderStepReset;
}
uint8_t subghz_protocol_magellen_crc8(uint8_t* data, size_t len) {
uint8_t subghz_protocol_magellan_crc8(uint8_t* data, size_t len) {
uint8_t crc = 0x00;
size_t i, j;
for(i = 0; i < len; i++) {
@@ -235,99 +235,99 @@ uint8_t subghz_protocol_magellen_crc8(uint8_t* data, size_t len) {
return crc;
}
static bool subghz_protocol_magellen_check_crc(SubGhzProtocolDecoderMagellen* instance) {
static bool subghz_protocol_magellan_check_crc(SubGhzProtocolDecoderMagellan* instance) {
uint8_t data[3] = {
instance->decoder.decode_data >> 24,
instance->decoder.decode_data >> 16,
instance->decoder.decode_data >> 8};
return (instance->decoder.decode_data & 0xFF) ==
subghz_protocol_magellen_crc8(data, sizeof(data));
subghz_protocol_magellan_crc8(data, sizeof(data));
}
void subghz_protocol_decoder_magellen_feed(void* context, bool level, uint32_t duration) {
void subghz_protocol_decoder_magellan_feed(void* context, bool level, uint32_t duration) {
furi_assert(context);
SubGhzProtocolDecoderMagellen* instance = context;
SubGhzProtocolDecoderMagellan* instance = context;
switch(instance->decoder.parser_step) {
case MagellenDecoderStepReset:
if((level) && (DURATION_DIFF(duration, subghz_protocol_magellen_const.te_short) <
subghz_protocol_magellen_const.te_delta)) {
instance->decoder.parser_step = MagellenDecoderStepCheckPreambula;
case MagellanDecoderStepReset:
if((level) && (DURATION_DIFF(duration, subghz_protocol_magellan_const.te_short) <
subghz_protocol_magellan_const.te_delta)) {
instance->decoder.parser_step = MagellanDecoderStepCheckPreambula;
instance->decoder.te_last = duration;
instance->header_count = 0;
}
break;
case MagellenDecoderStepCheckPreambula:
case MagellanDecoderStepCheckPreambula:
if(level) {
instance->decoder.te_last = duration;
} else {
if((DURATION_DIFF(instance->decoder.te_last, subghz_protocol_magellen_const.te_short) <
subghz_protocol_magellen_const.te_delta) &&
(DURATION_DIFF(duration, subghz_protocol_magellen_const.te_short) <
subghz_protocol_magellen_const.te_delta)) {
if((DURATION_DIFF(instance->decoder.te_last, subghz_protocol_magellan_const.te_short) <
subghz_protocol_magellan_const.te_delta) &&
(DURATION_DIFF(duration, subghz_protocol_magellan_const.te_short) <
subghz_protocol_magellan_const.te_delta)) {
// Found header
instance->header_count++;
} else if(
(DURATION_DIFF(instance->decoder.te_last, subghz_protocol_magellen_const.te_short) <
subghz_protocol_magellen_const.te_delta) &&
(DURATION_DIFF(duration, subghz_protocol_magellen_const.te_long) <
subghz_protocol_magellen_const.te_delta * 2) &&
(DURATION_DIFF(instance->decoder.te_last, subghz_protocol_magellan_const.te_short) <
subghz_protocol_magellan_const.te_delta) &&
(DURATION_DIFF(duration, subghz_protocol_magellan_const.te_long) <
subghz_protocol_magellan_const.te_delta * 2) &&
(instance->header_count > 10)) {
instance->decoder.parser_step = MagellenDecoderStepFoundPreambula;
instance->decoder.parser_step = MagellanDecoderStepFoundPreambula;
} else {
instance->decoder.parser_step = MagellenDecoderStepReset;
instance->decoder.parser_step = MagellanDecoderStepReset;
}
}
break;
case MagellenDecoderStepFoundPreambula:
case MagellanDecoderStepFoundPreambula:
if(level) {
instance->decoder.te_last = duration;
} else {
if((DURATION_DIFF(
instance->decoder.te_last, subghz_protocol_magellen_const.te_short * 6) <
subghz_protocol_magellen_const.te_delta * 3) &&
(DURATION_DIFF(duration, subghz_protocol_magellen_const.te_long) <
subghz_protocol_magellen_const.te_delta * 2)) {
instance->decoder.parser_step = MagellenDecoderStepSaveDuration;
instance->decoder.te_last, subghz_protocol_magellan_const.te_short * 6) <
subghz_protocol_magellan_const.te_delta * 3) &&
(DURATION_DIFF(duration, subghz_protocol_magellan_const.te_long) <
subghz_protocol_magellan_const.te_delta * 2)) {
instance->decoder.parser_step = MagellanDecoderStepSaveDuration;
instance->decoder.decode_data = 0;
instance->decoder.decode_count_bit = 0;
} else {
instance->decoder.parser_step = MagellenDecoderStepReset;
instance->decoder.parser_step = MagellanDecoderStepReset;
}
}
break;
case MagellenDecoderStepSaveDuration:
case MagellanDecoderStepSaveDuration:
if(level) {
instance->decoder.te_last = duration;
instance->decoder.parser_step = MagellenDecoderStepCheckDuration;
instance->decoder.parser_step = MagellanDecoderStepCheckDuration;
} else {
instance->decoder.parser_step = MagellenDecoderStepReset;
instance->decoder.parser_step = MagellanDecoderStepReset;
}
break;
case MagellenDecoderStepCheckDuration:
case MagellanDecoderStepCheckDuration:
if(!level) {
if((DURATION_DIFF(instance->decoder.te_last, subghz_protocol_magellen_const.te_short) <
subghz_protocol_magellen_const.te_delta) &&
(DURATION_DIFF(duration, subghz_protocol_magellen_const.te_long) <
subghz_protocol_magellen_const.te_delta)) {
if((DURATION_DIFF(instance->decoder.te_last, subghz_protocol_magellan_const.te_short) <
subghz_protocol_magellan_const.te_delta) &&
(DURATION_DIFF(duration, subghz_protocol_magellan_const.te_long) <
subghz_protocol_magellan_const.te_delta)) {
subghz_protocol_blocks_add_bit(&instance->decoder, 1);
instance->decoder.parser_step = MagellenDecoderStepSaveDuration;
instance->decoder.parser_step = MagellanDecoderStepSaveDuration;
} else if(
(DURATION_DIFF(instance->decoder.te_last, subghz_protocol_magellen_const.te_long) <
subghz_protocol_magellen_const.te_delta) &&
(DURATION_DIFF(duration, subghz_protocol_magellen_const.te_short) <
subghz_protocol_magellen_const.te_delta)) {
(DURATION_DIFF(instance->decoder.te_last, subghz_protocol_magellan_const.te_long) <
subghz_protocol_magellan_const.te_delta) &&
(DURATION_DIFF(duration, subghz_protocol_magellan_const.te_short) <
subghz_protocol_magellan_const.te_delta)) {
subghz_protocol_blocks_add_bit(&instance->decoder, 0);
instance->decoder.parser_step = MagellenDecoderStepSaveDuration;
} else if(duration >= (subghz_protocol_magellen_const.te_long * 3)) {
instance->decoder.parser_step = MagellanDecoderStepSaveDuration;
} else if(duration >= (subghz_protocol_magellan_const.te_long * 3)) {
//Found stop bit
if((instance->decoder.decode_count_bit ==
subghz_protocol_magellen_const.min_count_bit_for_found) &&
subghz_protocol_magellen_check_crc(instance)) {
subghz_protocol_magellan_const.min_count_bit_for_found) &&
subghz_protocol_magellan_check_crc(instance)) {
instance->generic.data = instance->decoder.decode_data;
instance->generic.data_count_bit = instance->decoder.decode_count_bit;
if(instance->base.callback)
@@ -335,12 +335,12 @@ void subghz_protocol_decoder_magellen_feed(void* context, bool level, uint32_t d
}
instance->decoder.decode_data = 0;
instance->decoder.decode_count_bit = 0;
instance->decoder.parser_step = MagellenDecoderStepReset;
instance->decoder.parser_step = MagellanDecoderStepReset;
} else {
instance->decoder.parser_step = MagellenDecoderStepReset;
instance->decoder.parser_step = MagellanDecoderStepReset;
}
} else {
instance->decoder.parser_step = MagellenDecoderStepReset;
instance->decoder.parser_step = MagellanDecoderStepReset;
}
break;
}
@@ -350,7 +350,7 @@ void subghz_protocol_decoder_magellen_feed(void* context, bool level, uint32_t d
* Analysis of received data
* @param instance Pointer to a SubGhzBlockGeneric* instance
*/
static void subghz_protocol_magellen_check_remote_controller(SubGhzBlockGeneric* instance) {
static void subghz_protocol_magellan_check_remote_controller(SubGhzBlockGeneric* instance) {
/*
* package 32b data 24b CRC8
* 0x037AE4828 => 001101111010111001001000 00101000
@@ -375,7 +375,7 @@ static void subghz_protocol_magellen_check_remote_controller(SubGhzBlockGeneric*
instance->btn = (data_rev >> 16) & 0xFF;
}
static void subghz_protocol_magellen_get_event_serialize(uint8_t event, FuriString* output) {
static void subghz_protocol_magellan_get_event_serialize(uint8_t event, FuriString* output) {
furi_string_cat_printf(
output,
"%s%s%s%s%s%s%s%s",
@@ -390,32 +390,32 @@ static void subghz_protocol_magellen_get_event_serialize(uint8_t event, FuriStri
((event >> 7) & 0x1 ? ", ?" : ""));
}
uint8_t subghz_protocol_decoder_magellen_get_hash_data(void* context) {
uint8_t subghz_protocol_decoder_magellan_get_hash_data(void* context) {
furi_assert(context);
SubGhzProtocolDecoderMagellen* instance = context;
SubGhzProtocolDecoderMagellan* instance = context;
return subghz_protocol_blocks_get_hash_data(
&instance->decoder, (instance->decoder.decode_count_bit / 8) + 1);
}
bool subghz_protocol_decoder_magellen_serialize(
bool subghz_protocol_decoder_magellan_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderMagellen* instance = context;
SubGhzProtocolDecoderMagellan* instance = context;
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
}
bool subghz_protocol_decoder_magellen_deserialize(void* context, FlipperFormat* flipper_format) {
bool subghz_protocol_decoder_magellan_deserialize(void* context, FlipperFormat* flipper_format) {
furi_assert(context);
SubGhzProtocolDecoderMagellen* instance = context;
SubGhzProtocolDecoderMagellan* instance = context;
bool ret = false;
do {
if(!subghz_block_generic_deserialize(&instance->generic, flipper_format)) {
break;
}
if(instance->generic.data_count_bit !=
subghz_protocol_magellen_const.min_count_bit_for_found) {
subghz_protocol_magellan_const.min_count_bit_for_found) {
FURI_LOG_E(TAG, "Wrong number of bits in key");
break;
}
@@ -424,10 +424,10 @@ bool subghz_protocol_decoder_magellen_deserialize(void* context, FlipperFormat*
return ret;
}
void subghz_protocol_decoder_magellen_get_string(void* context, FuriString* output) {
void subghz_protocol_decoder_magellan_get_string(void* context, FuriString* output) {
furi_assert(context);
SubGhzProtocolDecoderMagellen* instance = context;
subghz_protocol_magellen_check_remote_controller(&instance->generic);
SubGhzProtocolDecoderMagellan* instance = context;
subghz_protocol_magellan_check_remote_controller(&instance->generic);
furi_string_cat_printf(
output,
"%s %dbit\r\n"
@@ -441,5 +441,5 @@ void subghz_protocol_decoder_magellen_get_string(void* context, FuriString* outp
instance->generic.serial & 0xFF,
instance->generic.btn);
subghz_protocol_magellen_get_event_serialize(instance->generic.btn, output);
subghz_protocol_magellan_get_event_serialize(instance->generic.btn, output);
}
+107
View File
@@ -0,0 +1,107 @@
#pragma once
#include "base.h"
#define SUBGHZ_PROTOCOL_MAGELLAN_NAME "Magellan"
typedef struct SubGhzProtocolDecoderMagellan SubGhzProtocolDecoderMagellan;
typedef struct SubGhzProtocolEncoderMagellan SubGhzProtocolEncoderMagellan;
extern const SubGhzProtocolDecoder subghz_protocol_magellan_decoder;
extern const SubGhzProtocolEncoder subghz_protocol_magellan_encoder;
extern const SubGhzProtocol subghz_protocol_magellan;
/**
* Allocate SubGhzProtocolEncoderMagellan.
* @param environment Pointer to a SubGhzEnvironment instance
* @return SubGhzProtocolEncoderMagellan* pointer to a SubGhzProtocolEncoderMagellan instance
*/
void* subghz_protocol_encoder_magellan_alloc(SubGhzEnvironment* environment);
/**
* Free SubGhzProtocolEncoderMagellan.
* @param context Pointer to a SubGhzProtocolEncoderMagellan instance
*/
void subghz_protocol_encoder_magellan_free(void* context);
/**
* Deserialize and generating an upload to send.
* @param context Pointer to a SubGhzProtocolEncoderMagellan instance
* @param flipper_format Pointer to a FlipperFormat instance
* @return true On success
*/
bool subghz_protocol_encoder_magellan_deserialize(void* context, FlipperFormat* flipper_format);
/**
* Forced transmission stop.
* @param context Pointer to a SubGhzProtocolEncoderMagellan instance
*/
void subghz_protocol_encoder_magellan_stop(void* context);
/**
* Getting the level and duration of the upload to be loaded into DMA.
* @param context Pointer to a SubGhzProtocolEncoderMagellan instance
* @return LevelDuration
*/
LevelDuration subghz_protocol_encoder_magellan_yield(void* context);
/**
* Allocate SubGhzProtocolDecoderMagellan.
* @param environment Pointer to a SubGhzEnvironment instance
* @return SubGhzProtocolDecoderMagellan* pointer to a SubGhzProtocolDecoderMagellan instance
*/
void* subghz_protocol_decoder_magellan_alloc(SubGhzEnvironment* environment);
/**
* Free SubGhzProtocolDecoderMagellan.
* @param context Pointer to a SubGhzProtocolDecoderMagellan instance
*/
void subghz_protocol_decoder_magellan_free(void* context);
/**
* Reset decoder SubGhzProtocolDecoderMagellan.
* @param context Pointer to a SubGhzProtocolDecoderMagellan instance
*/
void subghz_protocol_decoder_magellan_reset(void* context);
/**
* Parse a raw sequence of levels and durations received from the air.
* @param context Pointer to a SubGhzProtocolDecoderMagellan instance
* @param level Signal level true-high false-low
* @param duration Duration of this level in, us
*/
void subghz_protocol_decoder_magellan_feed(void* context, bool level, uint32_t duration);
/**
* Getting the hash sum of the last randomly received parcel.
* @param context Pointer to a SubGhzProtocolDecoderMagellan instance
* @return hash Hash sum
*/
uint8_t subghz_protocol_decoder_magellan_get_hash_data(void* context);
/**
* Serialize data SubGhzProtocolDecoderMagellan.
* @param context Pointer to a SubGhzProtocolDecoderMagellan instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_magellan_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderMagellan.
* @param context Pointer to a SubGhzProtocolDecoderMagellan instance
* @param flipper_format Pointer to a FlipperFormat instance
* @return true On success
*/
bool subghz_protocol_decoder_magellan_deserialize(void* context, FlipperFormat* flipper_format);
/**
* Getting a textual representation of the received data.
* @param context Pointer to a SubGhzProtocolDecoderMagellan instance
* @param output Resulting text
*/
void subghz_protocol_decoder_magellan_get_string(void* context, FuriString* output);
-107
View File
@@ -1,107 +0,0 @@
#pragma once
#include "base.h"
#define SUBGHZ_PROTOCOL_MAGELLEN_NAME "Magellen"
typedef struct SubGhzProtocolDecoderMagellen SubGhzProtocolDecoderMagellen;
typedef struct SubGhzProtocolEncoderMagellen SubGhzProtocolEncoderMagellen;
extern const SubGhzProtocolDecoder subghz_protocol_magellen_decoder;
extern const SubGhzProtocolEncoder subghz_protocol_magellen_encoder;
extern const SubGhzProtocol subghz_protocol_magellen;
/**
* Allocate SubGhzProtocolEncoderMagellen.
* @param environment Pointer to a SubGhzEnvironment instance
* @return SubGhzProtocolEncoderMagellen* pointer to a SubGhzProtocolEncoderMagellen instance
*/
void* subghz_protocol_encoder_magellen_alloc(SubGhzEnvironment* environment);
/**
* Free SubGhzProtocolEncoderMagellen.
* @param context Pointer to a SubGhzProtocolEncoderMagellen instance
*/
void subghz_protocol_encoder_magellen_free(void* context);
/**
* Deserialize and generating an upload to send.
* @param context Pointer to a SubGhzProtocolEncoderMagellen instance
* @param flipper_format Pointer to a FlipperFormat instance
* @return true On success
*/
bool subghz_protocol_encoder_magellen_deserialize(void* context, FlipperFormat* flipper_format);
/**
* Forced transmission stop.
* @param context Pointer to a SubGhzProtocolEncoderMagellen instance
*/
void subghz_protocol_encoder_magellen_stop(void* context);
/**
* Getting the level and duration of the upload to be loaded into DMA.
* @param context Pointer to a SubGhzProtocolEncoderMagellen instance
* @return LevelDuration
*/
LevelDuration subghz_protocol_encoder_magellen_yield(void* context);
/**
* Allocate SubGhzProtocolDecoderMagellen.
* @param environment Pointer to a SubGhzEnvironment instance
* @return SubGhzProtocolDecoderMagellen* pointer to a SubGhzProtocolDecoderMagellen instance
*/
void* subghz_protocol_decoder_magellen_alloc(SubGhzEnvironment* environment);
/**
* Free SubGhzProtocolDecoderMagellen.
* @param context Pointer to a SubGhzProtocolDecoderMagellen instance
*/
void subghz_protocol_decoder_magellen_free(void* context);
/**
* Reset decoder SubGhzProtocolDecoderMagellen.
* @param context Pointer to a SubGhzProtocolDecoderMagellen instance
*/
void subghz_protocol_decoder_magellen_reset(void* context);
/**
* Parse a raw sequence of levels and durations received from the air.
* @param context Pointer to a SubGhzProtocolDecoderMagellen instance
* @param level Signal level true-high false-low
* @param duration Duration of this level in, us
*/
void subghz_protocol_decoder_magellen_feed(void* context, bool level, uint32_t duration);
/**
* Getting the hash sum of the last randomly received parcel.
* @param context Pointer to a SubGhzProtocolDecoderMagellen instance
* @return hash Hash sum
*/
uint8_t subghz_protocol_decoder_magellen_get_hash_data(void* context);
/**
* Serialize data SubGhzProtocolDecoderMagellen.
* @param context Pointer to a SubGhzProtocolDecoderMagellen instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
* @return true On success
*/
bool subghz_protocol_decoder_magellen_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
/**
* Deserialize data SubGhzProtocolDecoderMagellen.
* @param context Pointer to a SubGhzProtocolDecoderMagellen instance
* @param flipper_format Pointer to a FlipperFormat instance
* @return true On success
*/
bool subghz_protocol_decoder_magellen_deserialize(void* context, FlipperFormat* flipper_format);
/**
* Getting a textual representation of the received data.
* @param context Pointer to a SubGhzProtocolDecoderMagellen instance
* @param output Resulting text
*/
void subghz_protocol_decoder_magellen_get_string(void* context, FuriString* output);
+1 -1
View File
@@ -349,7 +349,7 @@ uint8_t subghz_protocol_decoder_marantec_get_hash_data(void* context) {
bool subghz_protocol_decoder_marantec_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderMarantec* instance = context;
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
+2 -2
View File
@@ -83,13 +83,13 @@ uint8_t subghz_protocol_decoder_marantec_get_hash_data(void* context);
* Serialize data SubGhzProtocolDecoderMarantec.
* @param context Pointer to a SubGhzProtocolDecoderMarantec instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_marantec_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderMarantec.
+1 -1
View File
@@ -384,7 +384,7 @@ uint8_t subghz_protocol_decoder_megacode_get_hash_data(void* context) {
bool subghz_protocol_decoder_megacode_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderMegaCode* instance = context;
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
+2 -2
View File
@@ -83,13 +83,13 @@ uint8_t subghz_protocol_decoder_megacode_get_hash_data(void* context);
* Serialize data SubGhzProtocolDecoderMegaCode.
* @param context Pointer to a SubGhzProtocolDecoderMegaCode instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_megacode_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderMegaCode.
+1 -1
View File
@@ -346,7 +346,7 @@ uint8_t subghz_protocol_decoder_nero_radio_get_hash_data(void* context) {
bool subghz_protocol_decoder_nero_radio_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderNeroRadio* instance = context;
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
+2 -2
View File
@@ -83,13 +83,13 @@ uint8_t subghz_protocol_decoder_nero_radio_get_hash_data(void* context);
* Serialize data SubGhzProtocolDecoderNeroRadio.
* @param context Pointer to a SubGhzProtocolDecoderNeroRadio instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_nero_radio_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderNeroRadio.
+1 -1
View File
@@ -331,7 +331,7 @@ uint8_t subghz_protocol_decoder_nero_sketch_get_hash_data(void* context) {
bool subghz_protocol_decoder_nero_sketch_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderNeroSketch* instance = context;
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
+2 -2
View File
@@ -83,13 +83,13 @@ uint8_t subghz_protocol_decoder_nero_sketch_get_hash_data(void* context);
* Serialize data SubGhzProtocolDecoderNeroSketch.
* @param context Pointer to a SubGhzProtocolDecoderNeroSketch instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_nero_sketch_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderNeroSketch.
+1 -1
View File
@@ -283,7 +283,7 @@ uint8_t subghz_protocol_decoder_nice_flo_get_hash_data(void* context) {
bool subghz_protocol_decoder_nice_flo_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderNiceFlo* instance = context;
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
+2 -2
View File
@@ -83,13 +83,13 @@ uint8_t subghz_protocol_decoder_nice_flo_get_hash_data(void* context);
* Serialize data SubGhzProtocolDecoderNiceFlo.
* @param context Pointer to a SubGhzProtocolDecoderNiceFlo instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_nice_flo_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderNiceFlo.
+1 -1
View File
@@ -330,7 +330,7 @@ uint8_t subghz_protocol_decoder_nice_flor_s_get_hash_data(void* context) {
bool subghz_protocol_decoder_nice_flor_s_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderNiceFlorS* instance = context;
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
+2 -2
View File
@@ -49,13 +49,13 @@ uint8_t subghz_protocol_decoder_nice_flor_s_get_hash_data(void* context);
* Serialize data SubGhzProtocolDecoderNiceFlorS.
* @param context Pointer to a SubGhzProtocolDecoderNiceFlorS instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_nice_flor_s_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderNiceFlorS.
-323
View File
@@ -1,323 +0,0 @@
#include "oregon2.h"
#include "../blocks/const.h"
#include "../blocks/decoder.h"
#include "../blocks/generic.h"
#include "../blocks/math.h"
#include <lib/toolbox/manchester_decoder.h>
#include <lib/flipper_format/flipper_format_i.h>
#define TAG "SubGhzProtocolOregon2"
static const SubGhzBlockConst oregon2_const = {
.te_long = 1000,
.te_short = 500,
.te_delta = 200,
.min_count_bit_for_found = 32,
};
#define OREGON2_PREAMBLE_BITS 19
#define OREGON2_PREAMBLE_MASK ((1 << (OREGON2_PREAMBLE_BITS + 1)) - 1)
#define OREGON2_SENSOR_ID(d) (((d) >> 16) & 0xFFFF)
#define OREGON2_CHECKSUM_BITS 8
// 15 ones + 0101 (inverted A)
#define OREGON2_PREAMBLE 0b1111111111111110101
// bit indicating the low battery
#define OREGON2_FLAG_BAT_LOW 0x4
struct SubGhzProtocolDecoderOregon2 {
SubGhzProtocolDecoderBase base;
SubGhzBlockDecoder decoder;
SubGhzBlockGeneric generic;
ManchesterState manchester_state;
bool prev_bit;
bool have_bit;
uint8_t var_bits;
uint32_t var_data;
};
typedef struct SubGhzProtocolDecoderOregon2 SubGhzProtocolDecoderOregon2;
typedef enum {
Oregon2DecoderStepReset = 0,
Oregon2DecoderStepFoundPreamble,
Oregon2DecoderStepVarData,
} Oregon2DecoderStep;
void* subghz_protocol_decoder_oregon2_alloc(SubGhzEnvironment* environment) {
UNUSED(environment);
SubGhzProtocolDecoderOregon2* instance = malloc(sizeof(SubGhzProtocolDecoderOregon2));
instance->base.protocol = &subghz_protocol_oregon2;
instance->generic.protocol_name = instance->base.protocol->name;
return instance;
}
void subghz_protocol_decoder_oregon2_free(void* context) {
furi_assert(context);
SubGhzProtocolDecoderOregon2* instance = context;
free(instance);
}
void subghz_protocol_decoder_oregon2_reset(void* context) {
furi_assert(context);
SubGhzProtocolDecoderOregon2* instance = context;
instance->decoder.parser_step = Oregon2DecoderStepReset;
instance->decoder.decode_data = 0UL;
instance->decoder.decode_count_bit = 0;
manchester_advance(
instance->manchester_state, ManchesterEventReset, &instance->manchester_state, NULL);
instance->have_bit = false;
instance->var_data = 0;
instance->var_bits = 0;
}
static ManchesterEvent level_and_duration_to_event(bool level, uint32_t duration) {
bool is_long = false;
if(DURATION_DIFF(duration, oregon2_const.te_long) < oregon2_const.te_delta) {
is_long = true;
} else if(DURATION_DIFF(duration, oregon2_const.te_short) < oregon2_const.te_delta) {
is_long = false;
} else {
return ManchesterEventReset;
}
if(level)
return is_long ? ManchesterEventLongHigh : ManchesterEventShortHigh;
else
return is_long ? ManchesterEventLongLow : ManchesterEventShortLow;
}
// From sensor id code return amount of bits in variable section
static uint8_t oregon2_sensor_id_var_bits(uint16_t sensor_id) {
if(sensor_id == 0xEC40) return 16;
return 0;
}
void subghz_protocol_decoder_oregon2_feed(void* context, bool level, uint32_t duration) {
furi_assert(context);
SubGhzProtocolDecoderOregon2* instance = context;
// oregon v2.1 signal is inverted
ManchesterEvent event = level_and_duration_to_event(!level, duration);
bool data;
// low-level bit sequence decoding
if(event == ManchesterEventReset) {
instance->decoder.parser_step = Oregon2DecoderStepReset;
instance->have_bit = false;
instance->decoder.decode_data = 0UL;
instance->decoder.decode_count_bit = 0;
}
if(manchester_advance(instance->manchester_state, event, &instance->manchester_state, &data)) {
if(instance->have_bit) {
if(!instance->prev_bit && data) {
subghz_protocol_blocks_add_bit(&instance->decoder, 1);
} else if(instance->prev_bit && !data) {
subghz_protocol_blocks_add_bit(&instance->decoder, 0);
} else {
subghz_protocol_decoder_oregon2_reset(context);
}
instance->have_bit = false;
} else {
instance->prev_bit = data;
instance->have_bit = true;
}
}
switch(instance->decoder.parser_step) {
case Oregon2DecoderStepReset:
// waiting for fixed oregon2 preamble
if(instance->decoder.decode_count_bit >= OREGON2_PREAMBLE_BITS &&
((instance->decoder.decode_data & OREGON2_PREAMBLE_MASK) == OREGON2_PREAMBLE)) {
instance->decoder.parser_step = Oregon2DecoderStepFoundPreamble;
instance->decoder.decode_count_bit = 0;
instance->decoder.decode_data = 0UL;
}
break;
case Oregon2DecoderStepFoundPreamble:
// waiting for fixed oregon2 data
if(instance->decoder.decode_count_bit == 32) {
instance->generic.data = instance->decoder.decode_data;
instance->generic.data_count_bit = instance->decoder.decode_count_bit;
instance->decoder.decode_data = 0UL;
instance->decoder.decode_count_bit = 0;
// reverse nibbles in decoded data
instance->generic.data = (instance->generic.data & 0x55555555) << 1 |
(instance->generic.data & 0xAAAAAAAA) >> 1;
instance->generic.data = (instance->generic.data & 0x33333333) << 2 |
(instance->generic.data & 0xCCCCCCCC) >> 2;
instance->var_bits =
oregon2_sensor_id_var_bits(OREGON2_SENSOR_ID(instance->generic.data));
if(!instance->var_bits) {
// sensor is not supported, stop decoding, but showing the decoded fixed part
instance->decoder.parser_step = Oregon2DecoderStepReset;
if(instance->base.callback)
instance->base.callback(&instance->base, instance->base.context);
} else {
instance->decoder.parser_step = Oregon2DecoderStepVarData;
}
}
break;
case Oregon2DecoderStepVarData:
// waiting for variable (sensor-specific data)
if(instance->decoder.decode_count_bit == instance->var_bits + OREGON2_CHECKSUM_BITS) {
instance->var_data = instance->decoder.decode_data & 0xFFFFFFFF;
// reverse nibbles in var data
instance->var_data = (instance->var_data & 0x55555555) << 1 |
(instance->var_data & 0xAAAAAAAA) >> 1;
instance->var_data = (instance->var_data & 0x33333333) << 2 |
(instance->var_data & 0xCCCCCCCC) >> 2;
instance->decoder.parser_step = Oregon2DecoderStepReset;
if(instance->base.callback)
instance->base.callback(&instance->base, instance->base.context);
}
break;
}
}
uint8_t subghz_protocol_decoder_oregon2_get_hash_data(void* context) {
furi_assert(context);
SubGhzProtocolDecoderOregon2* instance = context;
return subghz_protocol_blocks_get_hash_data(
&instance->decoder, (instance->decoder.decode_count_bit / 8) + 1);
}
bool subghz_protocol_decoder_oregon2_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
furi_assert(context);
SubGhzProtocolDecoderOregon2* instance = context;
if(!subghz_block_generic_serialize(&instance->generic, flipper_format, preset)) return false;
uint32_t temp = instance->var_bits;
if(!flipper_format_write_uint32(flipper_format, "VarBits", &temp, 1)) {
FURI_LOG_E(TAG, "Error adding VarBits");
return false;
}
if(!flipper_format_write_hex(
flipper_format,
"VarData",
(const uint8_t*)&instance->var_data,
sizeof(instance->var_data))) {
FURI_LOG_E(TAG, "Error adding VarData");
return false;
}
return true;
}
bool subghz_protocol_decoder_oregon2_deserialize(void* context, FlipperFormat* flipper_format) {
furi_assert(context);
SubGhzProtocolDecoderOregon2* instance = context;
bool ret = false;
uint32_t temp_data;
do {
if(!subghz_block_generic_deserialize(&instance->generic, flipper_format)) {
break;
}
if(!flipper_format_read_uint32(flipper_format, "VarBits", &temp_data, 1)) {
FURI_LOG_E(TAG, "Missing VarLen");
break;
}
instance->var_bits = (uint8_t)temp_data;
if(!flipper_format_read_hex(
flipper_format,
"VarData",
(uint8_t*)&instance->var_data,
sizeof(instance->var_data))) {
FURI_LOG_E(TAG, "Missing VarData");
break;
}
if(instance->generic.data_count_bit != oregon2_const.min_count_bit_for_found) {
FURI_LOG_E(TAG, "Wrong number of bits in key: %d", instance->generic.data_count_bit);
break;
}
ret = true;
} while(false);
return ret;
}
// append string of the variable data
static void
oregon2_var_data_append_string(uint16_t sensor_id, uint32_t var_data, FuriString* output) {
uint32_t val;
if(sensor_id == 0xEC40) {
val = ((var_data >> 4) & 0xF) * 10 + ((var_data >> 8) & 0xF);
furi_string_cat_printf(
output,
"Temp: %s%ld.%ld C\r\n",
(var_data & 0xF) ? "-" : "+",
val,
(uint32_t)(var_data >> 12) & 0xF);
}
}
static void oregon2_append_check_sum(uint32_t fix_data, uint32_t var_data, FuriString* output) {
uint8_t sum = fix_data & 0xF;
uint8_t ref_sum = var_data & 0xFF;
var_data >>= 8;
for(uint8_t i = 1; i < 8; i++) {
fix_data >>= 4;
var_data >>= 4;
sum += (fix_data & 0xF) + (var_data & 0xF);
}
// swap calculated sum nibbles
sum = (((sum >> 4) & 0xF) | (sum << 4)) & 0xFF;
if(sum == ref_sum)
furi_string_cat_printf(output, "Sum ok: 0x%hhX", ref_sum);
else
furi_string_cat_printf(output, "Sum err: 0x%hhX vs 0x%hhX", ref_sum, sum);
}
void subghz_protocol_decoder_oregon2_get_string(void* context, FuriString* output) {
furi_assert(context);
SubGhzProtocolDecoderOregon2* instance = context;
uint16_t sensor_id = OREGON2_SENSOR_ID(instance->generic.data);
furi_string_cat_printf(
output,
"%s\r\n"
"ID: 0x%04lX, ch: %ld%s, rc: 0x%02lX\r\n",
instance->generic.protocol_name,
(uint32_t)sensor_id,
(uint32_t)(instance->generic.data >> 12) & 0xF,
((instance->generic.data & OREGON2_FLAG_BAT_LOW) ? ", low bat" : ""),
(uint32_t)(instance->generic.data >> 4) & 0xFF);
if(instance->var_bits > 0) {
oregon2_var_data_append_string(
sensor_id, instance->var_data >> OREGON2_CHECKSUM_BITS, output);
oregon2_append_check_sum((uint32_t)instance->generic.data, instance->var_data, output);
}
}
const SubGhzProtocolDecoder subghz_protocol_oregon2_decoder = {
.alloc = subghz_protocol_decoder_oregon2_alloc,
.free = subghz_protocol_decoder_oregon2_free,
.feed = subghz_protocol_decoder_oregon2_feed,
.reset = subghz_protocol_decoder_oregon2_reset,
.get_hash_data = subghz_protocol_decoder_oregon2_get_hash_data,
.serialize = subghz_protocol_decoder_oregon2_serialize,
.deserialize = subghz_protocol_decoder_oregon2_deserialize,
.get_string = subghz_protocol_decoder_oregon2_get_string,
};
const SubGhzProtocol subghz_protocol_oregon2 = {
.name = SUBGHZ_PROTOCOL_OREGON2_NAME,
.type = SubGhzProtocolTypeStatic,
.flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable |
SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save,
.decoder = &subghz_protocol_oregon2_decoder,
};
-5
View File
@@ -1,5 +0,0 @@
#pragma once
#include "base.h"
#define SUBGHZ_PROTOCOL_OREGON2_NAME "Oregon2"
extern const SubGhzProtocol subghz_protocol_oregon2;
+1 -1
View File
@@ -296,7 +296,7 @@ uint8_t subghz_protocol_decoder_phoenix_v2_get_hash_data(void* context) {
bool subghz_protocol_decoder_phoenix_v2_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderPhoenix_V2* instance = context;
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
+2 -2
View File
@@ -83,13 +83,13 @@ uint8_t subghz_protocol_decoder_phoenix_v2_get_hash_data(void* context);
* Serialize data SubGhzProtocolDecoderPhoenix_V2.
* @param context Pointer to a SubGhzProtocolDecoderPhoenix_V2 instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_phoenix_v2_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderPhoenix_V2.
+1 -1
View File
@@ -349,7 +349,7 @@ uint8_t subghz_protocol_decoder_power_smart_get_hash_data(void* context) {
bool subghz_protocol_decoder_power_smart_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderPowerSmart* instance = context;
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
+2 -2
View File
@@ -83,13 +83,13 @@ uint8_t subghz_protocol_decoder_power_smart_get_hash_data(void* context);
* Serialize data SubGhzProtocolDecoderPowerSmart.
* @param context Pointer to a SubGhzProtocolDecoderPowerSmart instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_power_smart_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderPowerSmart.
+1 -1
View File
@@ -312,7 +312,7 @@ uint8_t subghz_protocol_decoder_princeton_get_hash_data(void* context) {
bool subghz_protocol_decoder_princeton_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderPrinceton* instance = context;
bool res = subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
+2 -2
View File
@@ -83,13 +83,13 @@ uint8_t subghz_protocol_decoder_princeton_get_hash_data(void* context);
* Serialize data SubGhzProtocolDecoderPrinceton.
* @param context Pointer to a SubGhzProtocolDecoderPrinceton instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_princeton_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderPrinceton.
@@ -1,6 +1,6 @@
#include "registry.h"
#include "protocol_items.h"
const SubGhzProtocol* subghz_protocol_registry[] = {
const SubGhzProtocol* 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,
@@ -11,26 +11,10 @@ const SubGhzProtocol* subghz_protocol_registry[] = {
&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_magellen, &subghz_protocol_intertechno_v3,
&subghz_protocol_clemsa, &subghz_protocol_oregon2};
&subghz_protocol_honeywell_wdb, &subghz_protocol_magellan, &subghz_protocol_intertechno_v3,
&subghz_protocol_clemsa,
};
const SubGhzProtocol* subghz_protocol_registry_get_by_name(const char* name) {
for(size_t i = 0; i < subghz_protocol_registry_count(); i++) {
if(strcmp(name, subghz_protocol_registry[i]->name) == 0) {
return subghz_protocol_registry[i];
}
}
return NULL;
}
const SubGhzProtocol* subghz_protocol_registry_get_by_index(size_t index) {
if(index < subghz_protocol_registry_count()) {
return subghz_protocol_registry[index];
} else {
return NULL;
}
}
size_t subghz_protocol_registry_count() {
return COUNT_OF(subghz_protocol_registry);
}
const SubGhzProtocolRegistry subghz_protocol_registry = {
.items = subghz_protocol_registry_items,
.size = COUNT_OF(subghz_protocol_registry_items)};
@@ -1,6 +1,5 @@
#pragma once
#include "../types.h"
#include "../registry.h"
#include "princeton.h"
#include "keeloq.h"
@@ -33,27 +32,8 @@
#include "doitrand.h"
#include "phoenix_v2.h"
#include "honeywell_wdb.h"
#include "magellen.h"
#include "magellan.h"
#include "intertechno_v3.h"
#include "clemsa.h"
#include "oregon2.h"
/**
* Registration by name SubGhzProtocol.
* @param name Protocol name
* @return SubGhzProtocol* pointer to a SubGhzProtocol instance
*/
const SubGhzProtocol* subghz_protocol_registry_get_by_name(const char* name);
/**
* Registration protocol by index in array SubGhzProtocol.
* @param index Protocol by index in array
* @return SubGhzProtocol* pointer to a SubGhzProtocol instance
*/
const SubGhzProtocol* subghz_protocol_registry_get_by_index(size_t index);
/**
* Getting the number of registered protocols.
* @return Number of protocols
*/
size_t subghz_protocol_registry_count();
extern const SubGhzProtocolRegistry subghz_protocol_registry;
+12 -2
View File
@@ -32,6 +32,7 @@ struct SubGhzProtocolDecoderRAW {
FuriString* file_name;
size_t sample_write;
bool last_level;
bool pause;
};
struct SubGhzProtocolEncoderRAW {
@@ -84,7 +85,7 @@ const SubGhzProtocol subghz_protocol_raw = {
bool subghz_protocol_raw_save_to_file_init(
SubGhzProtocolDecoderRAW* instance,
const char* dev_name,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(instance);
instance->storage = furi_record_open(RECORD_STORAGE);
@@ -158,6 +159,7 @@ bool subghz_protocol_raw_save_to_file_init(
instance->upload_raw = malloc(SUBGHZ_DOWNLOAD_MAX_SIZE * sizeof(int32_t));
instance->file_is_open = RAWFileIsOpenWrite;
instance->sample_write = 0;
instance->pause = false;
init = true;
} while(0);
@@ -199,6 +201,14 @@ void subghz_protocol_raw_save_to_file_stop(SubGhzProtocolDecoderRAW* instance) {
instance->file_is_open = RAWFileIsOpenClose;
}
void subghz_protocol_raw_save_to_file_pause(SubGhzProtocolDecoderRAW* instance, bool pause) {
furi_assert(instance);
if(instance->pause != pause) {
instance->pause = pause;
}
}
size_t subghz_protocol_raw_get_sample_write(SubGhzProtocolDecoderRAW* instance) {
return instance->sample_write + instance->ind_write;
}
@@ -234,7 +244,7 @@ void subghz_protocol_decoder_raw_feed(void* context, bool level, uint32_t durati
furi_assert(context);
SubGhzProtocolDecoderRAW* instance = context;
if(instance->upload_raw != NULL) {
if(!instance->pause && (instance->upload_raw != NULL)) {
if(duration > subghz_protocol_raw_const.te_short) {
if(instance->last_level != level) {
instance->last_level = (level ? true : false);
+9 -2
View File
@@ -21,13 +21,13 @@ extern const SubGhzProtocol subghz_protocol_raw;
* Open file for writing
* @param instance Pointer to a SubGhzProtocolDecoderRAW instance
* @param dev_name File name
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_raw_save_to_file_init(
SubGhzProtocolDecoderRAW* instance,
const char* dev_name,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Stop writing file to flash
@@ -103,6 +103,13 @@ void subghz_protocol_encoder_raw_free(void* context);
*/
void subghz_protocol_encoder_raw_stop(void* context);
/**
* pause writing to flash.
* @param context Pointer to a SubGhzProtocolEncoderRAW instance
* @param pause pause writing
*/
void subghz_protocol_raw_save_to_file_pause(SubGhzProtocolDecoderRAW* instance, bool pause);
/**
* Set callback on completion of file transfer.
* @param instance Pointer to a SubGhzProtocolEncoderRAW instance
+1 -1
View File
@@ -251,7 +251,7 @@ uint8_t subghz_protocol_decoder_scher_khan_get_hash_data(void* context) {
bool subghz_protocol_decoder_scher_khan_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderScherKhan* instance = context;
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
+2 -2
View File
@@ -49,13 +49,13 @@ 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, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_scher_khan_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderScherKhan.
+1 -1
View File
@@ -519,7 +519,7 @@ uint8_t subghz_protocol_decoder_secplus_v1_get_hash_data(void* context) {
bool subghz_protocol_decoder_secplus_v1_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderSecPlus_v1* instance = context;
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
+2 -2
View File
@@ -82,13 +82,13 @@ uint8_t subghz_protocol_decoder_secplus_v1_get_hash_data(void* context);
* Serialize data SubGhzProtocolDecoderSecPlus_v1.
* @param context Pointer to a SubGhzProtocolDecoderSecPlus_v1 instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_secplus_v1_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderSecPlus_v1.
+2 -2
View File
@@ -592,7 +592,7 @@ bool subghz_protocol_secplus_v2_create_data(
uint32_t serial,
uint8_t btn,
uint32_t cnt,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolEncoderSecPlus_v2* instance = context;
instance->generic.serial = serial;
@@ -759,7 +759,7 @@ uint8_t subghz_protocol_decoder_secplus_v2_get_hash_data(void* context) {
bool subghz_protocol_decoder_secplus_v2_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderSecPlus_v2* instance = context;
bool res = subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
+4 -4
View File
@@ -52,7 +52,7 @@ LevelDuration subghz_protocol_encoder_secplus_v2_yield(void* context);
* @param btn Button number, 8 bit
* @param cnt Container value, 28 bit
* @param manufacture_name Name of manufacturer's key
* @param preset Modulation, SubGhzPresetDefinition
* @param preset Modulation, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_secplus_v2_create_data(
@@ -61,7 +61,7 @@ bool subghz_protocol_secplus_v2_create_data(
uint32_t serial,
uint8_t btn,
uint32_t cnt,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Allocate SubGhzProtocolDecoderSecPlus_v2.
@@ -101,13 +101,13 @@ uint8_t subghz_protocol_decoder_secplus_v2_get_hash_data(void* context);
* Serialize data SubGhzProtocolDecoderSecPlus_v2.
* @param context Pointer to a SubGhzProtocolDecoderSecPlus_v2 instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_secplus_v2_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderSecPlus_v2.
+1 -1
View File
@@ -382,7 +382,7 @@ uint8_t subghz_protocol_decoder_somfy_keytis_get_hash_data(void* context) {
bool subghz_protocol_decoder_somfy_keytis_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderSomfyKeytis* instance = context;
bool res = subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
+2 -2
View File
@@ -49,13 +49,13 @@ uint8_t subghz_protocol_decoder_somfy_keytis_get_hash_data(void* context);
* Serialize data SubGhzProtocolDecoderSomfyKeytis.
* @param context Pointer to a SubGhzProtocolDecoderSomfyKeytis instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_somfy_keytis_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderSomfyKeytis.
+1 -1
View File
@@ -339,7 +339,7 @@ uint8_t subghz_protocol_decoder_somfy_telis_get_hash_data(void* context) {
bool subghz_protocol_decoder_somfy_telis_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderSomfyTelis* instance = context;
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
+2 -2
View File
@@ -49,13 +49,13 @@ uint8_t subghz_protocol_decoder_somfy_telis_get_hash_data(void* context);
* Serialize data SubGhzProtocolDecoderSomfyTelis.
* @param context Pointer to a SubGhzProtocolDecoderSomfyTelis instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_somfy_telis_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderSomfyTelis.
+1 -1
View File
@@ -319,7 +319,7 @@ uint8_t subghz_protocol_decoder_star_line_get_hash_data(void* context) {
bool subghz_protocol_decoder_star_line_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderStarLine* instance = context;
subghz_protocol_star_line_check_remote_controller(
+2 -2
View File
@@ -49,13 +49,13 @@ 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, SubGhzPresetDefinition
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool subghz_protocol_decoder_star_line_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);
/**
* Deserialize data SubGhzProtocolDecoderStarLine.
+7 -4
View File
@@ -1,6 +1,7 @@
#include "receiver.h"
#include "protocols/registry.h"
#include "registry.h"
#include "protocols/protocol_items.h"
#include <m-array.h>
@@ -22,9 +23,12 @@ struct SubGhzReceiver {
SubGhzReceiver* subghz_receiver_alloc_init(SubGhzEnvironment* environment) {
SubGhzReceiver* instance = malloc(sizeof(SubGhzReceiver));
SubGhzReceiverSlotArray_init(instance->slots);
const SubGhzProtocolRegistry* protocol_registry_items =
subghz_environment_get_protocol_registry(environment);
for(size_t i = 0; i < subghz_protocol_registry_count(); ++i) {
const SubGhzProtocol* protocol = subghz_protocol_registry_get_by_index(i);
for(size_t i = 0; i < subghz_protocol_registry_count(protocol_registry_items); ++i) {
const SubGhzProtocol* protocol =
subghz_protocol_registry_get_by_index(protocol_registry_items, i);
if(protocol->decoder && protocol->decoder->alloc) {
SubGhzReceiverSlot* slot = SubGhzReceiverSlotArray_push_new(instance->slots);
@@ -34,7 +38,6 @@ SubGhzReceiver* subghz_receiver_alloc_init(SubGhzEnvironment* environment) {
instance->callback = NULL;
instance->context = NULL;
return instance;
}
+30
View File
@@ -0,0 +1,30 @@
#include "registry.h"
const SubGhzProtocol* subghz_protocol_registry_get_by_name(
const SubGhzProtocolRegistry* protocol_registry,
const char* name) {
furi_assert(protocol_registry);
for(size_t i = 0; i < subghz_protocol_registry_count(protocol_registry); i++) {
if(strcmp(name, protocol_registry->items[i]->name) == 0) {
return protocol_registry->items[i];
}
}
return NULL;
}
const SubGhzProtocol* subghz_protocol_registry_get_by_index(
const SubGhzProtocolRegistry* protocol_registry,
size_t index) {
furi_assert(protocol_registry);
if(index < subghz_protocol_registry_count(protocol_registry)) {
return protocol_registry->items[index];
} else {
return NULL;
}
}
size_t subghz_protocol_registry_count(const SubGhzProtocolRegistry* protocol_registry) {
furi_assert(protocol_registry);
return protocol_registry->size;
}
+39
View File
@@ -0,0 +1,39 @@
#pragma once
#include "types.h"
typedef struct SubGhzEnvironment SubGhzEnvironment;
typedef struct SubGhzProtocolRegistry SubGhzProtocolRegistry;
struct SubGhzProtocolRegistry {
const SubGhzProtocol** items;
const size_t size;
};
/**
* Registration by name SubGhzProtocol.
* @param protocol_registry SubGhzProtocolRegistry
* @param name Protocol name
* @return SubGhzProtocol* pointer to a SubGhzProtocol instance
*/
const SubGhzProtocol* subghz_protocol_registry_get_by_name(
const SubGhzProtocolRegistry* protocol_registry,
const char* name);
/**
* Registration protocol by index in array SubGhzProtocol.
* @param protocol_registry SubGhzProtocolRegistry
* @param index Protocol by index in array
* @return SubGhzProtocol* pointer to a SubGhzProtocol instance
*/
const SubGhzProtocol* subghz_protocol_registry_get_by_index(
const SubGhzProtocolRegistry* protocol_registry,
size_t index);
/**
* Getting the number of registered protocols.
* @param protocol_registry SubGhzProtocolRegistry
* @return Number of protocols
*/
size_t subghz_protocol_registry_count(const SubGhzProtocolRegistry* protocol_registry);
+568
View File
@@ -0,0 +1,568 @@
#include "subghz_setting.h"
#include "types.h"
//#include "subghz_i.h"
#include <furi.h>
#include <m-list.h>
#include "furi_hal_subghz_configs.h"
#define TAG "SubGhzSetting"
#define SUBGHZ_SETTING_FILE_TYPE "Flipper SubGhz Setting File"
#define SUBGHZ_SETTING_FILE_VERSION 1
#define FREQUENCY_FLAG_DEFAULT (1 << 31)
#define FREQUENCY_MASK (0xFFFFFFFF ^ FREQUENCY_FLAG_DEFAULT)
/* Default */
static const uint32_t subghz_frequency_list[] = {
/* 300 - 348 */
300000000,
303875000,
304250000,
310000000,
315000000,
318000000,
/* 387 - 464 */
390000000,
418000000,
433075000, /* LPD433 first */
433420000,
433920000 | FREQUENCY_FLAG_DEFAULT, /* LPD433 mid */
434420000,
434775000, /* LPD433 last channels */
438900000,
/* 779 - 928 */
868350000,
915000000,
925000000,
0,
};
static const uint32_t subghz_hopper_frequency_list[] = {
310000000,
315000000,
318000000,
390000000,
433920000,
868350000,
0,
};
/* Europe and Russia */
static const uint32_t subghz_frequency_list_region_eu_ru[] = {
/* 300 - 348 */
300000000,
303875000,
304250000,
310000000,
315000000,
318000000,
/* 387 - 464 */
390000000,
418000000,
433075000, /* LPD433 first */
433420000,
433920000 | FREQUENCY_FLAG_DEFAULT, /* LPD433 mid */
434420000,
434775000, /* LPD433 last channels */
438900000,
/* 779 - 928 */
868350000,
915000000,
925000000,
0,
};
static const uint32_t subghz_hopper_frequency_list_region_eu_ru[] = {
310000000,
315000000,
318000000,
390000000,
433920000,
868350000,
0,
};
/* Region 0 */
static const uint32_t subghz_frequency_list_region_us_ca_au[] = {
/* 300 - 348 */
300000000,
303875000,
304250000,
310000000,
315000000,
318000000,
/* 387 - 464 */
390000000,
418000000,
433075000, /* LPD433 first */
433420000,
433920000 | FREQUENCY_FLAG_DEFAULT, /* LPD433 mid */
434420000,
434775000, /* LPD433 last channels */
438900000,
/* 779 - 928 */
868350000,
915000000,
925000000,
0,
};
static const uint32_t subghz_hopper_frequency_list_region_us_ca_au[] = {
310000000,
315000000,
318000000,
390000000,
433920000,
868350000,
0,
};
static const uint32_t subghz_frequency_list_region_jp[] = {
/* 300 - 348 */
300000000,
303875000,
304250000,
310000000,
315000000,
318000000,
/* 387 - 464 */
390000000,
418000000,
433075000, /* LPD433 first */
433420000,
433920000 | FREQUENCY_FLAG_DEFAULT, /* LPD433 mid */
434420000,
434775000, /* LPD433 last channels */
438900000,
/* 779 - 928 */
868350000,
915000000,
925000000,
0,
};
static const uint32_t subghz_hopper_frequency_list_region_jp[] = {
310000000,
315000000,
318000000,
390000000,
433920000,
868350000,
0,
};
typedef struct {
FuriString* custom_preset_name;
uint8_t* custom_preset_data;
size_t custom_preset_data_size;
} SubGhzSettingCustomPresetItem;
ARRAY_DEF(SubGhzSettingCustomPresetItemArray, SubGhzSettingCustomPresetItem, M_POD_OPLIST)
#define M_OPL_SubGhzSettingCustomPresetItemArray_t() \
ARRAY_OPLIST(SubGhzSettingCustomPresetItemArray, M_POD_OPLIST)
LIST_DEF(FrequencyList, uint32_t)
#define M_OPL_FrequencyList_t() LIST_OPLIST(FrequencyList)
typedef struct {
SubGhzSettingCustomPresetItemArray_t data;
} SubGhzSettingCustomPresetStruct;
struct SubGhzSetting {
FrequencyList_t frequencies;
FrequencyList_t hopper_frequencies;
SubGhzSettingCustomPresetStruct* preset;
};
SubGhzSetting* subghz_setting_alloc(void) {
SubGhzSetting* instance = malloc(sizeof(SubGhzSetting));
FrequencyList_init(instance->frequencies);
FrequencyList_init(instance->hopper_frequencies);
instance->preset = malloc(sizeof(SubGhzSettingCustomPresetStruct));
SubGhzSettingCustomPresetItemArray_init(instance->preset->data);
return instance;
}
static void subghz_setting_preset_reset(SubGhzSetting* instance) {
for
M_EACH(item, instance->preset->data, SubGhzSettingCustomPresetItemArray_t) {
furi_string_free(item->custom_preset_name);
free(item->custom_preset_data);
}
SubGhzSettingCustomPresetItemArray_reset(instance->preset->data);
}
void subghz_setting_free(SubGhzSetting* instance) {
furi_assert(instance);
FrequencyList_clear(instance->frequencies);
FrequencyList_clear(instance->hopper_frequencies);
for
M_EACH(item, instance->preset->data, SubGhzSettingCustomPresetItemArray_t) {
furi_string_free(item->custom_preset_name);
free(item->custom_preset_data);
}
SubGhzSettingCustomPresetItemArray_clear(instance->preset->data);
free(instance->preset);
free(instance);
}
static void subghz_setting_load_default_preset(
SubGhzSetting* instance,
const char* preset_name,
const uint8_t* preset_data,
const uint8_t preset_pa_table[8]) {
furi_assert(instance);
furi_assert(preset_data);
uint32_t preset_data_count = 0;
SubGhzSettingCustomPresetItem* item =
SubGhzSettingCustomPresetItemArray_push_raw(instance->preset->data);
item->custom_preset_name = furi_string_alloc();
furi_string_set(item->custom_preset_name, preset_name);
while(preset_data[preset_data_count]) {
preset_data_count += 2;
}
preset_data_count += 2;
item->custom_preset_data_size = sizeof(uint8_t) * preset_data_count + sizeof(uint8_t) * 8;
item->custom_preset_data = malloc(item->custom_preset_data_size);
//load preset register
memcpy(&item->custom_preset_data[0], &preset_data[0], preset_data_count);
//load pa table
memcpy(&item->custom_preset_data[preset_data_count], &preset_pa_table[0], 8);
}
static void subghz_setting_load_default_region(
SubGhzSetting* instance,
const uint32_t frequencies[],
const uint32_t hopper_frequencies[]) {
furi_assert(instance);
FrequencyList_reset(instance->frequencies);
FrequencyList_reset(instance->hopper_frequencies);
subghz_setting_preset_reset(instance);
while(*frequencies) {
FrequencyList_push_back(instance->frequencies, *frequencies);
frequencies++;
}
while(*hopper_frequencies) {
FrequencyList_push_back(instance->hopper_frequencies, *hopper_frequencies);
hopper_frequencies++;
}
subghz_setting_load_default_preset(
instance,
"AM270",
(uint8_t*)furi_hal_subghz_preset_ook_270khz_async_regs,
furi_hal_subghz_preset_ook_async_patable);
subghz_setting_load_default_preset(
instance,
"AM650",
(uint8_t*)furi_hal_subghz_preset_ook_650khz_async_regs,
furi_hal_subghz_preset_ook_async_patable);
subghz_setting_load_default_preset(
instance,
"FM238",
(uint8_t*)furi_hal_subghz_preset_2fsk_dev2_38khz_async_regs,
furi_hal_subghz_preset_2fsk_async_patable);
subghz_setting_load_default_preset(
instance,
"FM476",
(uint8_t*)furi_hal_subghz_preset_2fsk_dev47_6khz_async_regs,
furi_hal_subghz_preset_2fsk_async_patable);
}
void subghz_setting_load_default(SubGhzSetting* instance) {
switch(furi_hal_version_get_hw_region()) {
case FuriHalVersionRegionEuRu:
subghz_setting_load_default_region(
instance,
subghz_frequency_list_region_eu_ru,
subghz_hopper_frequency_list_region_eu_ru);
break;
case FuriHalVersionRegionUsCaAu:
subghz_setting_load_default_region(
instance,
subghz_frequency_list_region_us_ca_au,
subghz_hopper_frequency_list_region_us_ca_au);
break;
case FuriHalVersionRegionJp:
subghz_setting_load_default_region(
instance, subghz_frequency_list_region_jp, subghz_hopper_frequency_list_region_jp);
break;
default:
subghz_setting_load_default_region(
instance, subghz_frequency_list, subghz_hopper_frequency_list);
break;
}
}
void subghz_setting_load(SubGhzSetting* instance, const char* file_path) {
furi_assert(instance);
Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* fff_data_file = flipper_format_file_alloc(storage);
FuriString* temp_str;
temp_str = furi_string_alloc();
uint32_t temp_data32;
bool temp_bool;
subghz_setting_load_default(instance);
if(file_path) {
do {
if(!flipper_format_file_open_existing(fff_data_file, file_path)) {
FURI_LOG_I(TAG, "File is not used %s", file_path);
break;
}
if(!flipper_format_read_header(fff_data_file, temp_str, &temp_data32)) {
FURI_LOG_E(TAG, "Missing or incorrect header");
break;
}
if((!strcmp(furi_string_get_cstr(temp_str), SUBGHZ_SETTING_FILE_TYPE)) &&
temp_data32 == SUBGHZ_SETTING_FILE_VERSION) {
} else {
FURI_LOG_E(TAG, "Type or version mismatch");
break;
}
// Standard frequencies (optional)
temp_bool = true;
flipper_format_read_bool(fff_data_file, "Add_standard_frequencies", &temp_bool, 1);
if(!temp_bool) {
FURI_LOG_I(TAG, "Removing standard frequencies");
FrequencyList_reset(instance->frequencies);
FrequencyList_reset(instance->hopper_frequencies);
} else {
FURI_LOG_I(TAG, "Keeping standard frequencies");
}
// Load frequencies
if(!flipper_format_rewind(fff_data_file)) {
FURI_LOG_E(TAG, "Rewind error");
break;
}
while(flipper_format_read_uint32(
fff_data_file, "Frequency", (uint32_t*)&temp_data32, 1)) {
if(furi_hal_subghz_is_frequency_valid(temp_data32)) {
FURI_LOG_I(TAG, "Frequency loaded %lu", temp_data32);
FrequencyList_push_back(instance->frequencies, temp_data32);
} else {
FURI_LOG_E(TAG, "Frequency not supported %lu", temp_data32);
}
}
// Load hopper frequencies
if(!flipper_format_rewind(fff_data_file)) {
FURI_LOG_E(TAG, "Rewind error");
break;
}
while(flipper_format_read_uint32(
fff_data_file, "Hopper_frequency", (uint32_t*)&temp_data32, 1)) {
if(furi_hal_subghz_is_frequency_valid(temp_data32)) {
FURI_LOG_I(TAG, "Hopper frequency loaded %lu", temp_data32);
FrequencyList_push_back(instance->hopper_frequencies, temp_data32);
} else {
FURI_LOG_E(TAG, "Hopper frequency not supported %lu", temp_data32);
}
}
// Default frequency (optional)
if(!flipper_format_rewind(fff_data_file)) {
FURI_LOG_E(TAG, "Rewind error");
break;
}
if(flipper_format_read_uint32(fff_data_file, "Default_frequency", &temp_data32, 1)) {
for
M_EACH(frequency, instance->frequencies, FrequencyList_t) {
*frequency &= FREQUENCY_MASK;
if(*frequency == temp_data32) {
*frequency |= FREQUENCY_FLAG_DEFAULT;
}
}
}
// custom preset (optional)
if(!flipper_format_rewind(fff_data_file)) {
FURI_LOG_E(TAG, "Rewind error");
break;
}
while(flipper_format_read_string(fff_data_file, "Custom_preset_name", temp_str)) {
FURI_LOG_I(TAG, "Custom preset loaded %s", furi_string_get_cstr(temp_str));
subghz_setting_load_custom_preset(
instance, furi_string_get_cstr(temp_str), fff_data_file);
}
} while(false);
}
furi_string_free(temp_str);
flipper_format_free(fff_data_file);
furi_record_close(RECORD_STORAGE);
if(!FrequencyList_size(instance->frequencies) ||
!FrequencyList_size(instance->hopper_frequencies)) {
FURI_LOG_E(TAG, "Error loading user settings, loading default settings");
subghz_setting_load_default(instance);
}
}
size_t subghz_setting_get_frequency_count(SubGhzSetting* instance) {
furi_assert(instance);
return FrequencyList_size(instance->frequencies);
}
size_t subghz_setting_get_hopper_frequency_count(SubGhzSetting* instance) {
furi_assert(instance);
return FrequencyList_size(instance->hopper_frequencies);
}
size_t subghz_setting_get_preset_count(SubGhzSetting* instance) {
furi_assert(instance);
return SubGhzSettingCustomPresetItemArray_size(instance->preset->data);
}
const char* subghz_setting_get_preset_name(SubGhzSetting* instance, size_t idx) {
furi_assert(instance);
SubGhzSettingCustomPresetItem* item =
SubGhzSettingCustomPresetItemArray_get(instance->preset->data, idx);
return furi_string_get_cstr(item->custom_preset_name);
}
int subghz_setting_get_inx_preset_by_name(SubGhzSetting* instance, const char* preset_name) {
furi_assert(instance);
size_t idx = 0;
for
M_EACH(item, instance->preset->data, SubGhzSettingCustomPresetItemArray_t) {
if(strcmp(furi_string_get_cstr(item->custom_preset_name), preset_name) == 0) {
return idx;
}
idx++;
}
furi_crash("SubGhz: No name preset.");
return -1;
}
bool subghz_setting_load_custom_preset(
SubGhzSetting* instance,
const char* preset_name,
FlipperFormat* fff_data_file) {
furi_assert(instance);
furi_assert(preset_name);
uint32_t temp_data32;
SubGhzSettingCustomPresetItem* item =
SubGhzSettingCustomPresetItemArray_push_raw(instance->preset->data);
item->custom_preset_name = furi_string_alloc();
furi_string_set(item->custom_preset_name, preset_name);
do {
if(!flipper_format_get_value_count(fff_data_file, "Custom_preset_data", &temp_data32))
break;
if(!temp_data32 || (temp_data32 % 2)) {
FURI_LOG_E(TAG, "Integrity error Custom_preset_data");
break;
}
item->custom_preset_data_size = sizeof(uint8_t) * temp_data32;
item->custom_preset_data = malloc(item->custom_preset_data_size);
if(!flipper_format_read_hex(
fff_data_file,
"Custom_preset_data",
item->custom_preset_data,
item->custom_preset_data_size)) {
FURI_LOG_E(TAG, "Missing Custom_preset_data");
break;
}
return true;
} while(true);
return false;
}
bool subghz_setting_delete_custom_preset(SubGhzSetting* instance, const char* preset_name) {
furi_assert(instance);
furi_assert(preset_name);
SubGhzSettingCustomPresetItemArray_it_t it;
SubGhzSettingCustomPresetItemArray_it_last(it, instance->preset->data);
while(!SubGhzSettingCustomPresetItemArray_end_p(it)) {
SubGhzSettingCustomPresetItem* item = SubGhzSettingCustomPresetItemArray_ref(it);
if(strcmp(furi_string_get_cstr(item->custom_preset_name), preset_name) == 0) {
furi_string_free(item->custom_preset_name);
free(item->custom_preset_data);
SubGhzSettingCustomPresetItemArray_remove(instance->preset->data, it);
return true;
}
SubGhzSettingCustomPresetItemArray_previous(it);
}
return false;
}
uint8_t* subghz_setting_get_preset_data(SubGhzSetting* instance, size_t idx) {
furi_assert(instance);
SubGhzSettingCustomPresetItem* item =
SubGhzSettingCustomPresetItemArray_get(instance->preset->data, idx);
return item->custom_preset_data;
}
size_t subghz_setting_get_preset_data_size(SubGhzSetting* instance, size_t idx) {
furi_assert(instance);
SubGhzSettingCustomPresetItem* item =
SubGhzSettingCustomPresetItemArray_get(instance->preset->data, idx);
return item->custom_preset_data_size;
}
uint8_t* subghz_setting_get_preset_data_by_name(SubGhzSetting* instance, const char* preset_name) {
furi_assert(instance);
SubGhzSettingCustomPresetItem* item = SubGhzSettingCustomPresetItemArray_get(
instance->preset->data, subghz_setting_get_inx_preset_by_name(instance, preset_name));
return item->custom_preset_data;
}
uint32_t subghz_setting_get_frequency(SubGhzSetting* instance, size_t idx) {
furi_assert(instance);
uint32_t* ret = FrequencyList_get(instance->frequencies, idx);
if(ret) {
return (*ret) & FREQUENCY_MASK;
} else {
return 0;
}
}
uint32_t subghz_setting_get_hopper_frequency(SubGhzSetting* instance, size_t idx) {
furi_assert(instance);
uint32_t* ret = FrequencyList_get(instance->hopper_frequencies, idx);
if(ret) {
return *ret;
} else {
return 0;
}
}
uint32_t subghz_setting_get_frequency_default_index(SubGhzSetting* instance) {
furi_assert(instance);
for(size_t i = 0; i < FrequencyList_size(instance->frequencies); i++) {
uint32_t frequency = *FrequencyList_get(instance->frequencies, i);
if(frequency & FREQUENCY_FLAG_DEFAULT) {
return i;
}
}
return 0;
}
uint32_t subghz_setting_get_default_frequency(SubGhzSetting* instance) {
furi_assert(instance);
return subghz_setting_get_frequency(
instance, subghz_setting_get_frequency_default_index(instance));
}
+56
View File
@@ -0,0 +1,56 @@
#pragma once
#include <math.h>
#include <furi.h>
#include <furi_hal.h>
#include <lib/flipper_format/flipper_format.h>
#ifdef __cplusplus
extern "C" {
#endif
#define SUBGHZ_SETTING_DEFAULT_PRESET_COUNT 4
typedef struct SubGhzSetting SubGhzSetting;
SubGhzSetting* subghz_setting_alloc(void);
void subghz_setting_free(SubGhzSetting* instance);
void subghz_setting_load(SubGhzSetting* instance, const char* file_path);
size_t subghz_setting_get_frequency_count(SubGhzSetting* instance);
size_t subghz_setting_get_hopper_frequency_count(SubGhzSetting* instance);
size_t subghz_setting_get_preset_count(SubGhzSetting* instance);
const char* subghz_setting_get_preset_name(SubGhzSetting* instance, size_t idx);
int subghz_setting_get_inx_preset_by_name(SubGhzSetting* instance, const char* preset_name);
uint8_t* subghz_setting_get_preset_data(SubGhzSetting* instance, size_t idx);
size_t subghz_setting_get_preset_data_size(SubGhzSetting* instance, size_t idx);
uint8_t* subghz_setting_get_preset_data_by_name(SubGhzSetting* instance, const char* preset_name);
bool subghz_setting_load_custom_preset(
SubGhzSetting* instance,
const char* preset_name,
FlipperFormat* fff_data_file);
bool subghz_setting_delete_custom_preset(SubGhzSetting* instance, const char* preset_name);
uint32_t subghz_setting_get_frequency(SubGhzSetting* instance, size_t idx);
uint32_t subghz_setting_get_hopper_frequency(SubGhzSetting* instance, size_t idx);
uint32_t subghz_setting_get_frequency_default_index(SubGhzSetting* instance);
uint32_t subghz_setting_get_default_frequency(SubGhzSetting* instance);
#ifdef __cplusplus
}
#endif
+7 -3
View File
@@ -1,7 +1,8 @@
#include "transmitter.h"
#include "protocols/base.h"
#include "protocols/registry.h"
#include "registry.h"
#include "protocols/protocol_items.h"
struct SubGhzTransmitter {
const SubGhzProtocol* protocol;
@@ -11,14 +12,17 @@ struct SubGhzTransmitter {
SubGhzTransmitter*
subghz_transmitter_alloc_init(SubGhzEnvironment* environment, const char* protocol_name) {
SubGhzTransmitter* instance = NULL;
const SubGhzProtocol* protocol = subghz_protocol_registry_get_by_name(protocol_name);
const SubGhzProtocolRegistry* protocol_registry_items =
subghz_environment_get_protocol_registry(environment);
const SubGhzProtocol* protocol =
subghz_protocol_registry_get_by_name(protocol_registry_items, protocol_name);
if(protocol && protocol->encoder && protocol->encoder->alloc) {
instance = malloc(sizeof(SubGhzTransmitter));
instance->protocol = protocol;
instance->protocol_instance = instance->protocol->encoder->alloc(environment);
}
return instance;
}

Some files were not shown because too many files have changed in this diff Show More