[FL-2904, FL-2900, FL-2890] WS: add app WeatherStation (#1833)

* WeatherStation: start
* SubGhz: rename protocol magellen -> magellan
* WeatherStation: err Unresolved symbols: {'subghz_protocol_decoder_base_get_string'}
* WeatherStation: fix Unresolved symbols: {'subghz_protocol_decoder_base_get_string'}
* Subghz: add set protocol_items
* WeatherStation: adding your protocols
* WS: add Infactory protocol
* WS: add history
* WS: add setting
* WS: add lock
* WS: add hopper frequency
* WS: fix history
* WS fix string_t -> FuriString*
* WS: add images
* WS: history record update when receiving data from the sensor again
* WS: add receiver info, delete extra code
* WS: add protocol ThermoPRO_TX4
* [FL-2900] SubGhz: Move icons in Sub-GHz
* WS: add Notification
* [FL-2890] SubGhz: Rename *_user files in resources to _user.example
* WS: add about scene
* WS: removing redundant code
* WS: add  protocol Nexus-TH
* WS: add protocol GT_WT03
* WS: fix notification and rename "Weather Station" -> "Read Weather Station"
* SubGhz: partial unit tests fix
* SubGhz: fix unit_test
* SubGhz: remove dead code
* SubGhz: rename SubGhzPresetDefinition into SubGhzRadioPreset, cleanup subghz types.

Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
Skorpionm
2022-10-19 21:27:26 +04:00
committed by GitHub
parent 79c3040629
commit 9a9abd59e9
143 changed files with 4677 additions and 458 deletions
+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
+8
View File
@@ -4,6 +4,10 @@
#include <stdint.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct SubGhzBlockDecoder SubGhzBlockDecoder;
struct SubGhzBlockDecoder {
@@ -26,3 +30,7 @@ void subghz_protocol_blocks_add_bit(SubGhzBlockDecoder* decoder, uint8_t bit);
* @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
+65
View File
@@ -14,4 +14,69 @@ uint8_t subghz_protocol_blocks_get_parity(uint64_t key, uint8_t count_bit) {
parity += bit_read(key, i);
}
return parity & 0x01;
}
uint8_t subghz_protocol_blocks_crc4(
uint8_t const message[],
unsigned nBytes,
uint8_t polynomial,
uint8_t init) {
unsigned remainder = init << 4; // LSBs are unused
unsigned poly = polynomial << 4;
unsigned bit;
while(nBytes--) {
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[],
unsigned nBytes,
uint8_t polynomial,
uint8_t init) {
unsigned remainder = init << 1; // LSB is unused
unsigned poly = polynomial << 1;
unsigned byte, bit;
for(byte = 0; byte < nBytes; ++byte) {
remainder ^= message[byte];
for(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[],
unsigned nBytes,
uint8_t polynomial,
uint8_t init) {
uint8_t remainder = init;
unsigned byte, bit;
for(byte = 0; byte < nBytes; ++byte) {
remainder ^= message[byte];
for(bit = 0; bit < 8; ++bit) {
if(remainder & 0x80) {
remainder = (remainder << 1) ^ polynomial;
} else {
remainder = (remainder << 1);
}
}
}
return remainder;
}
+52
View File
@@ -9,7 +9,11 @@
#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))
#ifdef __cplusplus
extern "C" {
#endif
/**
* Flip the data bitwise.
* @param key In data
@@ -25,3 +29,51 @@ uint64_t subghz_protocol_blocks_reverse_key(uint64_t key, uint8_t count_bit);
* @return parity
*/
uint8_t subghz_protocol_blocks_get_parity(uint64_t key, uint8_t count_bit);
/**
* CRC-4.
* @param message array of bytes to check
* @param nBytes 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[],
unsigned nBytes,
uint8_t polynomial,
uint8_t init);
/**
* CRC-7.
* @param message array of bytes to check
* @param nBytes 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[],
unsigned nBytes,
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 nBytes 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[],
unsigned nBytes,
uint8_t polynomial,
uint8_t init);
#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.
+1 -1
View File
@@ -295,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);
+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.
+1 -1
View File
@@ -193,7 +193,7 @@ uint8_t subghz_protocol_decoder_oregon2_get_hash_data(void* context) {
bool subghz_protocol_decoder_oregon2_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(context);
SubGhzProtocolDecoderOregon2* instance = context;
if(!subghz_block_generic_serialize(&instance->generic, flipper_format, preset)) return false;
+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,9 @@ 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_honeywell_wdb, &subghz_protocol_magellan, &subghz_protocol_intertechno_v3,
&subghz_protocol_clemsa, &subghz_protocol_oregon2};
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,9 @@
#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;
+1 -1
View File
@@ -84,7 +84,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);
+2 -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
+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;
}
+11 -8
View File
@@ -10,7 +10,6 @@
#include "environment.h"
#include <furi.h>
#include <furi_hal.h>
#include <subghz/helpers/subghz_types.h>
#define SUBGHZ_APP_FOLDER ANY_PATH("subghz")
#define SUBGHZ_RAW_FOLDER EXT_PATH("subghz")
@@ -22,19 +21,21 @@
#define SUBGHZ_RAW_FILE_VERSION 1
#define SUBGHZ_RAW_FILE_TYPE "Flipper SubGhz RAW File"
//
// Abstract method types
//
// Radio Preset
typedef struct {
FuriString* name;
uint32_t frequency;
uint8_t* data;
size_t data_size;
} SubGhzRadioPreset;
// Allocator and Deallocator
typedef void* (*SubGhzAlloc)(SubGhzEnvironment* environment);
typedef void (*SubGhzFree)(void* context);
// Serialize and Deserialize
typedef bool (*SubGhzSerialize)(
void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
typedef bool (
*SubGhzSerialize)(void* context, FlipperFormat* flipper_format, SubGhzRadioPreset* preset);
typedef bool (*SubGhzDeserialize)(void* context, FlipperFormat* flipper_format);
// Decoder specific
@@ -74,6 +75,8 @@ typedef enum {
SubGhzProtocolTypeStatic,
SubGhzProtocolTypeDynamic,
SubGhzProtocolTypeRAW,
SubGhzProtocolWeatherStation,
SubGhzProtocolCustom,
} SubGhzProtocolType;
typedef enum {