|
@@ -1,4 +1,4 @@
|
|
|
-#include "magellen.h"
|
|
|
|
|
|
|
+#include "magellan.h"
|
|
|
|
|
|
|
|
#include "../blocks/const.h"
|
|
#include "../blocks/const.h"
|
|
|
#include "../blocks/decoder.h"
|
|
#include "../blocks/decoder.h"
|
|
@@ -6,16 +6,16 @@
|
|
|
#include "../blocks/generic.h"
|
|
#include "../blocks/generic.h"
|
|
|
#include "../blocks/math.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_short = 200,
|
|
|
.te_long = 400,
|
|
.te_long = 400,
|
|
|
.te_delta = 100,
|
|
.te_delta = 100,
|
|
|
.min_count_bit_for_found = 32,
|
|
.min_count_bit_for_found = 32,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-struct SubGhzProtocolDecoderMagellen {
|
|
|
|
|
|
|
+struct SubGhzProtocolDecoderMagellan {
|
|
|
SubGhzProtocolDecoderBase base;
|
|
SubGhzProtocolDecoderBase base;
|
|
|
|
|
|
|
|
SubGhzBlockDecoder decoder;
|
|
SubGhzBlockDecoder decoder;
|
|
@@ -23,7 +23,7 @@ struct SubGhzProtocolDecoderMagellen {
|
|
|
uint16_t header_count;
|
|
uint16_t header_count;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-struct SubGhzProtocolEncoderMagellen {
|
|
|
|
|
|
|
+struct SubGhzProtocolEncoderMagellan {
|
|
|
SubGhzProtocolEncoderBase base;
|
|
SubGhzProtocolEncoderBase base;
|
|
|
|
|
|
|
|
SubGhzProtocolBlockEncoder encoder;
|
|
SubGhzProtocolBlockEncoder encoder;
|
|
@@ -31,50 +31,50 @@ struct SubGhzProtocolEncoderMagellen {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
typedef enum {
|
|
typedef enum {
|
|
|
- MagellenDecoderStepReset = 0,
|
|
|
|
|
- MagellenDecoderStepCheckPreambula,
|
|
|
|
|
- MagellenDecoderStepFoundPreambula,
|
|
|
|
|
- MagellenDecoderStepSaveDuration,
|
|
|
|
|
- MagellenDecoderStepCheckDuration,
|
|
|
|
|
-} MagellenDecoderStep;
|
|
|
|
|
-
|
|
|
|
|
-const SubGhzProtocolDecoder subghz_protocol_magellen_decoder = {
|
|
|
|
|
- .alloc = subghz_protocol_decoder_magellen_alloc,
|
|
|
|
|
- .free = subghz_protocol_decoder_magellen_free,
|
|
|
|
|
-
|
|
|
|
|
- .feed = subghz_protocol_decoder_magellen_feed,
|
|
|
|
|
- .reset = subghz_protocol_decoder_magellen_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,
|
|
|
|
|
|
|
+ MagellanDecoderStepReset = 0,
|
|
|
|
|
+ MagellanDecoderStepCheckPreambula,
|
|
|
|
|
+ MagellanDecoderStepFoundPreambula,
|
|
|
|
|
+ MagellanDecoderStepSaveDuration,
|
|
|
|
|
+ MagellanDecoderStepCheckDuration,
|
|
|
|
|
+} MagellanDecoderStep;
|
|
|
|
|
+
|
|
|
|
|
+const SubGhzProtocolDecoder subghz_protocol_magellan_decoder = {
|
|
|
|
|
+ .alloc = subghz_protocol_decoder_magellan_alloc,
|
|
|
|
|
+ .free = subghz_protocol_decoder_magellan_free,
|
|
|
|
|
+
|
|
|
|
|
+ .feed = subghz_protocol_decoder_magellan_feed,
|
|
|
|
|
+ .reset = subghz_protocol_decoder_magellan_reset,
|
|
|
|
|
+
|
|
|
|
|
+ .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,
|
|
.type = SubGhzProtocolTypeStatic,
|
|
|
.flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable |
|
|
.flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable |
|
|
|
SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save | SubGhzProtocolFlag_Send,
|
|
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);
|
|
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->generic.protocol_name = instance->base.protocol->name;
|
|
|
|
|
|
|
|
instance->encoder.repeat = 10;
|
|
instance->encoder.repeat = 10;
|
|
@@ -84,75 +84,75 @@ void* subghz_protocol_encoder_magellen_alloc(SubGhzEnvironment* environment) {
|
|
|
return instance;
|
|
return instance;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void subghz_protocol_encoder_magellen_free(void* context) {
|
|
|
|
|
|
|
+void subghz_protocol_encoder_magellan_free(void* context) {
|
|
|
furi_assert(context);
|
|
furi_assert(context);
|
|
|
- SubGhzProtocolEncoderMagellen* instance = context;
|
|
|
|
|
|
|
+ SubGhzProtocolEncoderMagellan* instance = context;
|
|
|
free(instance->encoder.upload);
|
|
free(instance->encoder.upload);
|
|
|
free(instance);
|
|
free(instance);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Generating an upload from data.
|
|
* Generating an upload from data.
|
|
|
- * @param instance Pointer to a SubGhzProtocolEncoderMagellen instance
|
|
|
|
|
|
|
+ * @param instance Pointer to a SubGhzProtocolEncoderMagellan instance
|
|
|
* @return true On success
|
|
* @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);
|
|
furi_assert(instance);
|
|
|
|
|
|
|
|
size_t index = 0;
|
|
size_t index = 0;
|
|
|
|
|
|
|
|
//Send header
|
|
//Send header
|
|
|
instance->encoder.upload[index++] =
|
|
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++] =
|
|
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++) {
|
|
for(uint8_t i = 0; i < 12; i++) {
|
|
|
instance->encoder.upload[index++] =
|
|
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++] =
|
|
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++] =
|
|
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++] =
|
|
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
|
|
//Send start bit
|
|
|
instance->encoder.upload[index++] =
|
|
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++] =
|
|
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
|
|
//Send key data
|
|
|
for(uint8_t i = instance->generic.data_count_bit; i > 0; i--) {
|
|
for(uint8_t i = instance->generic.data_count_bit; i > 0; i--) {
|
|
|
if(bit_read(instance->generic.data, i - 1)) {
|
|
if(bit_read(instance->generic.data, i - 1)) {
|
|
|
//send bit 1
|
|
//send bit 1
|
|
|
instance->encoder.upload[index++] =
|
|
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++] =
|
|
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 {
|
|
} else {
|
|
|
//send bit 0
|
|
//send bit 0
|
|
|
instance->encoder.upload[index++] =
|
|
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++] =
|
|
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
|
|
//Send stop bit
|
|
|
instance->encoder.upload[index++] =
|
|
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++] =
|
|
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;
|
|
instance->encoder.size_upload = index;
|
|
|
return true;
|
|
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);
|
|
furi_assert(context);
|
|
|
- SubGhzProtocolEncoderMagellen* instance = context;
|
|
|
|
|
|
|
+ SubGhzProtocolEncoderMagellan* instance = context;
|
|
|
bool res = false;
|
|
bool res = false;
|
|
|
do {
|
|
do {
|
|
|
if(!subghz_block_generic_deserialize(&instance->generic, flipper_format)) {
|
|
if(!subghz_block_generic_deserialize(&instance->generic, flipper_format)) {
|
|
@@ -160,7 +160,7 @@ bool subghz_protocol_encoder_magellen_deserialize(void* context, FlipperFormat*
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
if(instance->generic.data_count_bit !=
|
|
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");
|
|
FURI_LOG_E(TAG, "Wrong number of bits in key");
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
@@ -168,7 +168,7 @@ bool subghz_protocol_encoder_magellen_deserialize(void* context, FlipperFormat*
|
|
|
flipper_format_read_uint32(
|
|
flipper_format_read_uint32(
|
|
|
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
|
|
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;
|
|
instance->encoder.is_running = true;
|
|
|
|
|
|
|
|
res = true;
|
|
res = true;
|
|
@@ -177,13 +177,13 @@ bool subghz_protocol_encoder_magellen_deserialize(void* context, FlipperFormat*
|
|
|
return res;
|
|
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;
|
|
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) {
|
|
if(instance->encoder.repeat == 0 || !instance->encoder.is_running) {
|
|
|
instance->encoder.is_running = false;
|
|
instance->encoder.is_running = false;
|
|
@@ -200,27 +200,27 @@ LevelDuration subghz_protocol_encoder_magellen_yield(void* context) {
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void* subghz_protocol_decoder_magellen_alloc(SubGhzEnvironment* environment) {
|
|
|
|
|
|
|
+void* subghz_protocol_decoder_magellan_alloc(SubGhzEnvironment* environment) {
|
|
|
UNUSED(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;
|
|
instance->generic.protocol_name = instance->base.protocol->name;
|
|
|
return instance;
|
|
return instance;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void subghz_protocol_decoder_magellen_free(void* context) {
|
|
|
|
|
|
|
+void subghz_protocol_decoder_magellan_free(void* context) {
|
|
|
furi_assert(context);
|
|
furi_assert(context);
|
|
|
- SubGhzProtocolDecoderMagellen* instance = context;
|
|
|
|
|
|
|
+ SubGhzProtocolDecoderMagellan* instance = context;
|
|
|
free(instance);
|
|
free(instance);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void subghz_protocol_decoder_magellen_reset(void* context) {
|
|
|
|
|
|
|
+void subghz_protocol_decoder_magellan_reset(void* context) {
|
|
|
furi_assert(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;
|
|
uint8_t crc = 0x00;
|
|
|
size_t i, j;
|
|
size_t i, j;
|
|
|
for(i = 0; i < len; i++) {
|
|
for(i = 0; i < len; i++) {
|
|
@@ -235,99 +235,99 @@ uint8_t subghz_protocol_magellen_crc8(uint8_t* data, size_t len) {
|
|
|
return crc;
|
|
return crc;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-static bool subghz_protocol_magellen_check_crc(SubGhzProtocolDecoderMagellen* instance) {
|
|
|
|
|
|
|
+static bool subghz_protocol_magellan_check_crc(SubGhzProtocolDecoderMagellan* instance) {
|
|
|
uint8_t data[3] = {
|
|
uint8_t data[3] = {
|
|
|
instance->decoder.decode_data >> 24,
|
|
instance->decoder.decode_data >> 24,
|
|
|
instance->decoder.decode_data >> 16,
|
|
instance->decoder.decode_data >> 16,
|
|
|
instance->decoder.decode_data >> 8};
|
|
instance->decoder.decode_data >> 8};
|
|
|
return (instance->decoder.decode_data & 0xFF) ==
|
|
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);
|
|
furi_assert(context);
|
|
|
- SubGhzProtocolDecoderMagellen* instance = context;
|
|
|
|
|
|
|
+ SubGhzProtocolDecoderMagellan* instance = context;
|
|
|
|
|
|
|
|
switch(instance->decoder.parser_step) {
|
|
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->decoder.te_last = duration;
|
|
|
instance->header_count = 0;
|
|
instance->header_count = 0;
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
- case MagellenDecoderStepCheckPreambula:
|
|
|
|
|
|
|
+ case MagellanDecoderStepCheckPreambula:
|
|
|
if(level) {
|
|
if(level) {
|
|
|
instance->decoder.te_last = duration;
|
|
instance->decoder.te_last = duration;
|
|
|
} else {
|
|
} 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
|
|
// Found header
|
|
|
instance->header_count++;
|
|
instance->header_count++;
|
|
|
} else if(
|
|
} 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->header_count > 10)) {
|
|
|
- instance->decoder.parser_step = MagellenDecoderStepFoundPreambula;
|
|
|
|
|
|
|
+ instance->decoder.parser_step = MagellanDecoderStepFoundPreambula;
|
|
|
} else {
|
|
} else {
|
|
|
- instance->decoder.parser_step = MagellenDecoderStepReset;
|
|
|
|
|
|
|
+ instance->decoder.parser_step = MagellanDecoderStepReset;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
- case MagellenDecoderStepFoundPreambula:
|
|
|
|
|
|
|
+ case MagellanDecoderStepFoundPreambula:
|
|
|
if(level) {
|
|
if(level) {
|
|
|
instance->decoder.te_last = duration;
|
|
instance->decoder.te_last = duration;
|
|
|
} else {
|
|
} else {
|
|
|
if((DURATION_DIFF(
|
|
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_data = 0;
|
|
|
instance->decoder.decode_count_bit = 0;
|
|
instance->decoder.decode_count_bit = 0;
|
|
|
} else {
|
|
} else {
|
|
|
- instance->decoder.parser_step = MagellenDecoderStepReset;
|
|
|
|
|
|
|
+ instance->decoder.parser_step = MagellanDecoderStepReset;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
- case MagellenDecoderStepSaveDuration:
|
|
|
|
|
|
|
+ case MagellanDecoderStepSaveDuration:
|
|
|
if(level) {
|
|
if(level) {
|
|
|
instance->decoder.te_last = duration;
|
|
instance->decoder.te_last = duration;
|
|
|
- instance->decoder.parser_step = MagellenDecoderStepCheckDuration;
|
|
|
|
|
|
|
+ instance->decoder.parser_step = MagellanDecoderStepCheckDuration;
|
|
|
} else {
|
|
} else {
|
|
|
- instance->decoder.parser_step = MagellenDecoderStepReset;
|
|
|
|
|
|
|
+ instance->decoder.parser_step = MagellanDecoderStepReset;
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
- case MagellenDecoderStepCheckDuration:
|
|
|
|
|
|
|
+ case MagellanDecoderStepCheckDuration:
|
|
|
if(!level) {
|
|
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);
|
|
subghz_protocol_blocks_add_bit(&instance->decoder, 1);
|
|
|
- instance->decoder.parser_step = MagellenDecoderStepSaveDuration;
|
|
|
|
|
|
|
+ instance->decoder.parser_step = MagellanDecoderStepSaveDuration;
|
|
|
} else if(
|
|
} 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);
|
|
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
|
|
//Found stop bit
|
|
|
if((instance->decoder.decode_count_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 = instance->decoder.decode_data;
|
|
|
instance->generic.data_count_bit = instance->decoder.decode_count_bit;
|
|
instance->generic.data_count_bit = instance->decoder.decode_count_bit;
|
|
|
if(instance->base.callback)
|
|
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_data = 0;
|
|
|
instance->decoder.decode_count_bit = 0;
|
|
instance->decoder.decode_count_bit = 0;
|
|
|
- instance->decoder.parser_step = MagellenDecoderStepReset;
|
|
|
|
|
|
|
+ instance->decoder.parser_step = MagellanDecoderStepReset;
|
|
|
} else {
|
|
} else {
|
|
|
- instance->decoder.parser_step = MagellenDecoderStepReset;
|
|
|
|
|
|
|
+ instance->decoder.parser_step = MagellanDecoderStepReset;
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- instance->decoder.parser_step = MagellenDecoderStepReset;
|
|
|
|
|
|
|
+ instance->decoder.parser_step = MagellanDecoderStepReset;
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
@@ -350,7 +350,7 @@ void subghz_protocol_decoder_magellen_feed(void* context, bool level, uint32_t d
|
|
|
* Analysis of received data
|
|
* Analysis of received data
|
|
|
* @param instance Pointer to a SubGhzBlockGeneric* instance
|
|
* @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
|
|
* package 32b data 24b CRC8
|
|
|
* 0x037AE4828 => 001101111010111001001000 00101000
|
|
* 0x037AE4828 => 001101111010111001001000 00101000
|
|
@@ -375,7 +375,7 @@ static void subghz_protocol_magellen_check_remote_controller(SubGhzBlockGeneric*
|
|
|
instance->btn = (data_rev >> 16) & 0xFF;
|
|
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(
|
|
furi_string_cat_printf(
|
|
|
output,
|
|
output,
|
|
|
"%s%s%s%s%s%s%s%s",
|
|
"%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 ? ", ?" : ""));
|
|
((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);
|
|
furi_assert(context);
|
|
|
- SubGhzProtocolDecoderMagellen* instance = context;
|
|
|
|
|
|
|
+ SubGhzProtocolDecoderMagellan* instance = context;
|
|
|
return subghz_protocol_blocks_get_hash_data(
|
|
return subghz_protocol_blocks_get_hash_data(
|
|
|
&instance->decoder, (instance->decoder.decode_count_bit / 8) + 1);
|
|
&instance->decoder, (instance->decoder.decode_count_bit / 8) + 1);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-bool subghz_protocol_decoder_magellen_serialize(
|
|
|
|
|
|
|
+bool subghz_protocol_decoder_magellan_serialize(
|
|
|
void* context,
|
|
void* context,
|
|
|
FlipperFormat* flipper_format,
|
|
FlipperFormat* flipper_format,
|
|
|
- SubGhzPresetDefinition* preset) {
|
|
|
|
|
|
|
+ SubGhzRadioPreset* preset) {
|
|
|
furi_assert(context);
|
|
furi_assert(context);
|
|
|
- SubGhzProtocolDecoderMagellen* instance = context;
|
|
|
|
|
|
|
+ SubGhzProtocolDecoderMagellan* instance = context;
|
|
|
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
|
|
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);
|
|
furi_assert(context);
|
|
|
- SubGhzProtocolDecoderMagellen* instance = context;
|
|
|
|
|
|
|
+ SubGhzProtocolDecoderMagellan* instance = context;
|
|
|
bool ret = false;
|
|
bool ret = false;
|
|
|
do {
|
|
do {
|
|
|
if(!subghz_block_generic_deserialize(&instance->generic, flipper_format)) {
|
|
if(!subghz_block_generic_deserialize(&instance->generic, flipper_format)) {
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
if(instance->generic.data_count_bit !=
|
|
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");
|
|
FURI_LOG_E(TAG, "Wrong number of bits in key");
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
@@ -424,10 +424,10 @@ bool subghz_protocol_decoder_magellen_deserialize(void* context, FlipperFormat*
|
|
|
return ret;
|
|
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);
|
|
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(
|
|
furi_string_cat_printf(
|
|
|
output,
|
|
output,
|
|
|
"%s %dbit\r\n"
|
|
"%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.serial & 0xFF,
|
|
|
instance->generic.btn);
|
|
instance->generic.btn);
|
|
|
|
|
|
|
|
- subghz_protocol_magellen_get_event_serialize(instance->generic.btn, output);
|
|
|
|
|
|
|
+ subghz_protocol_magellan_get_event_serialize(instance->generic.btn, output);
|
|
|
}
|
|
}
|