diff --git a/applications/debug/unit_tests/resources/unit_tests/subghz/dickert_mahs.sub b/applications/debug/unit_tests/resources/unit_tests/subghz/dickert_mahs.sub new file mode 100644 index 0000000000..9737b71a69 --- /dev/null +++ b/applications/debug/unit_tests/resources/unit_tests/subghz/dickert_mahs.sub @@ -0,0 +1,7 @@ +Filetype: Flipper SubGhz Key File +Version: 1 +Frequency: 433920000 +Preset: FuriHalSubGhzPresetOok650Async +Protocol: Dickert_MAHS +Bit: 36 +Key: 00 00 00 01 55 57 55 15 diff --git a/applications/debug/unit_tests/resources/unit_tests/subghz/dickert_raw.sub b/applications/debug/unit_tests/resources/unit_tests/subghz/dickert_raw.sub new file mode 100644 index 0000000000..544fc7a1d2 --- /dev/null +++ b/applications/debug/unit_tests/resources/unit_tests/subghz/dickert_raw.sub @@ -0,0 +1,7 @@ +Filetype: Flipper SubGhz RAW File +Version: 1 +Frequency: 433920000 +Preset: FuriHalSubGhzPresetOok650Async +Protocol: RAW +RAW_Data: 112254 -62882 64 -8912 798 -844 416 -418 806 -850 396 -45206 440 -428 794 -442 804 -422 822 -810 414 -414 824 -832 412 -416 808 -848 376 -446 792 -846 382 -448 816 -828 410 -416 810 -844 382 -416 834 -818 410 -414 810 -856 408 -810 412 -836 384 -442 808 -814 402 -844 414 -834 378 -436 808 -844 396 -422 798 -844 416 -416 814 -404 812 -440 810 -842 396 -422 798 -840 414 -414 806 -850 398 -45210 450 -420 796 -436 780 -446 802 -848 380 -434 806 -846 400 -422 800 -840 410 -408 836 -812 414 -410 826 -840 378 -440 804 -848 396 -426 812 -810 426 -394 826 -844 414 -810 420 -834 378 -442 808 -832 412 -812 416 -830 410 -406 810 -844 400 -420 832 -810 414 -416 800 -446 798 -440 812 -808 426 -410 800 -836 412 -414 806 -836 412 -45216 450 -420 798 -434 806 -414 802 -846 382 -438 814 -832 410 -410 838 -834 396 -430 810 -842 394 -392 826 -840 414 -414 802 -850 396 -428 812 -842 394 -394 828 -842 414 -810 424 -812 392 -434 812 -844 398 -848 380 -844 408 -416 820 -810 414 -406 816 -836 412 -416 836 -414 816 -398 816 -840 420 -410 802 -844 416 -416 804 -824 410 -45232 446 -400 802 -442 810 -432 804 -842 396 -392 826 -842 410 -410 834 -818 378 -442 804 -854 406 -408 806 -838 408 -428 804 -844 396 -392 826 -840 410 -410 834 -810 414 -832 408 -834 380 -440 802 -826 410 -836 412 -838 396 -424 796 -842 414 -414 804 -848 396 -426 812 -412 814 -414 824 -832 410 -416 806 -848 382 -420 834 -814 422 -45228 416 -422 802 -446 810 -420 790 -846 382 -448 818 -828 408 -416 808 -848 382 -418 830 -816 410 -412 812 -856 410 -382 834 -846 382 -418 832 -818 408 -412 812 -856 408 -814 414 -838 396 -428 810 -808 424 -836 380 -844 404 -416 802 -840 424 -394 826 -840 414 -382 836 -412 822 -436 812 -806 424 -394 826 -844 416 -382 838 -816 402 -45228 438 -430 796 -444 806 -424 822 -810 412 -416 822 -832 412 -416 804 -844 408 -414 824 -812 412 -408 812 -834 410 -414 804 -848 408 -412 802 -840 424 -412 802 -834 412 -842 384 -848 396 -426 814 -808 424 -816 392 -866 382 -414 838 -816 414 -428 792 -846 380 -440 810 -438 812 -412 802 -846 380 -438 826 -840 380 -416 838 -814 404 -45226 450 -404 820 -408 806 -452 792 -848 382 -440 814 -832 410 -416 810 -846 378 -450 792 -846 380 -446 816 -830 410 -386 836 -846 376 -410 828 -846 380 -446 814 -828 410 -814 414 -836 396 -428 810 -842 394 -816 410 -836 406 -430 812 -810 426 -394 826 -838 +RAW_Data: 414 -414 808 -416 826 -438 814 -816 420 -414 834 -814 418 -418 808 -848 398 -45218 412 -438 824 -412 812 -418 832 -852 378 -446 782 -862 410 -386 838 -848 384 -420 836 -820 418 -414 814 -854 408 -388 838 -814 418 -422 836 -816 394 -434 812 -846 398 -850 380 -848 410 -418 822 -812 416 -850 368 -854 412 -418 810 -850 384 -422 834 -820 416 -414 812 -428 836 -412 804 -848 382 -450 818 -828 412 -418 808 -850 380 -45228 452 -420 798 -434 806 -416 834 -818 384 -440 810 -820 404 -420 834 -814 416 -418 834 -824 386 -442 810 -818 404 -420 834 -814 416 -418 834 -820 410 -414 810 -850 406 -812 414 -816 404 -420 818 -838 386 -848 394 -828 414 -414 838 -814 406 -420 820 -842 384 -446 794 -438 810 -412 802 -848 394 -432 812 -842 394 -392 830 -842 414 -105578 64 -1760 130 -196 130 -832 160 -128 62 -1278 194 -1316 230 -96 362 -64 64 -398 diff --git a/applications/debug/unit_tests/tests/subghz/subghz_test.c b/applications/debug/unit_tests/tests/subghz/subghz_test.c index 90e6d429b2..ac14bce6a3 100644 --- a/applications/debug/unit_tests/tests/subghz/subghz_test.c +++ b/applications/debug/unit_tests/tests/subghz/subghz_test.c @@ -665,6 +665,13 @@ MU_TEST(subghz_decoder_mastercode_test) { "Test decoder " SUBGHZ_PROTOCOL_MASTERCODE_NAME " error\r\n"); } +MU_TEST(subghz_decoder_dickert_test) { + mu_assert( + subghz_decoder_test( + EXT_PATH("unit_tests/subghz/dickert_raw.sub"), SUBGHZ_PROTOCOL_DICKERT_MAHS_NAME), + "Test decoder " SUBGHZ_PROTOCOL_DICKERT_MAHS_NAME " error\r\n"); +} + //test encoders MU_TEST(subghz_encoder_princeton_test) { mu_assert( @@ -822,6 +829,12 @@ MU_TEST(subghz_encoder_mastercode_test) { "Test encoder " SUBGHZ_PROTOCOL_MASTERCODE_NAME " error\r\n"); } +MU_TEST(subghz_encoder_dickert_test) { + mu_assert( + subghz_encoder_test(EXT_PATH("unit_tests/subghz/dickert_mahs.sub")), + "Test encoder " SUBGHZ_PROTOCOL_DICKERT_MAHS_NAME " error\r\n"); +} + MU_TEST(subghz_random_test) { mu_assert(subghz_decode_random_test(TEST_RANDOM_DIR_NAME), "Random test error\r\n"); } @@ -873,6 +886,7 @@ MU_TEST_SUITE(subghz) { MU_RUN_TEST(subghz_decoder_nice_one_test); MU_RUN_TEST(subghz_decoder_kinggates_stylo4k_test); MU_RUN_TEST(subghz_decoder_mastercode_test); + MU_RUN_TEST(subghz_decoder_dickert_test); MU_RUN_TEST(subghz_encoder_princeton_test); MU_RUN_TEST(subghz_encoder_came_test); @@ -900,6 +914,7 @@ MU_TEST_SUITE(subghz) { MU_RUN_TEST(subghz_encoder_holtek_ht12x_test); MU_RUN_TEST(subghz_encoder_dooya_test); MU_RUN_TEST(subghz_encoder_mastercode_test); + MU_RUN_TEST(subghz_encoder_dickert_test); MU_RUN_TEST(subghz_random_test); subghz_test_deinit(); diff --git a/lib/subghz/protocols/dickert_mahs.c b/lib/subghz/protocols/dickert_mahs.c new file mode 100644 index 0000000000..4691e3423c --- /dev/null +++ b/lib/subghz/protocols/dickert_mahs.c @@ -0,0 +1,385 @@ +#include "dickert_mahs.h" + +#include "../blocks/const.h" +#include "../blocks/decoder.h" +#include "../blocks/encoder.h" +#include "../blocks/generic.h" +#include "../blocks/math.h" + +#include +#include +#include + +#define TAG "SubGhzProtocolDicketMAHS" + +static const SubGhzBlockConst subghz_protocol_dickert_mahs_const = { + .te_short = 400, + .te_long = 800, + .te_delta = 100, + .min_count_bit_for_found = 36, +}; + +struct SubGhzProtocolDecoderDickertMAHS { + SubGhzProtocolDecoderBase base; + + SubGhzBlockDecoder decoder; + SubGhzBlockGeneric generic; + + uint32_t tmp[2]; + uint8_t tmp_cnt; +}; + +struct SubGhzProtocolEncoderDickertMAHS { + SubGhzProtocolEncoderBase base; + + SubGhzProtocolBlockEncoder encoder; + SubGhzBlockGeneric generic; +}; + +typedef enum { + DickertMAHSDecoderStepReset = 0, + DickertMAHSDecoderStepInitial, + DickertMAHSDecoderStepRecording, +} DickertMAHSDecoderStep; + +const SubGhzProtocolDecoder subghz_protocol_dickert_mahs_decoder = { + .alloc = subghz_protocol_decoder_dickert_mahs_alloc, + .free = subghz_protocol_decoder_dickert_mahs_free, + + .feed = subghz_protocol_decoder_dickert_mahs_feed, + .reset = subghz_protocol_decoder_dickert_mahs_reset, + + .get_hash_data = subghz_protocol_decoder_dickert_mahs_get_hash_data, + .serialize = subghz_protocol_decoder_dickert_mahs_serialize, + .deserialize = subghz_protocol_decoder_dickert_mahs_deserialize, + .get_string = subghz_protocol_decoder_dickert_mahs_get_string, +}; + +const SubGhzProtocolEncoder subghz_protocol_dickert_mahs_encoder = { + .alloc = subghz_protocol_encoder_dickert_mahs_alloc, + .free = subghz_protocol_encoder_dickert_mahs_free, + + .deserialize = subghz_protocol_encoder_dickert_mahs_deserialize, + .stop = subghz_protocol_encoder_dickert_mahs_stop, + .yield = subghz_protocol_encoder_dickert_mahs_yield, +}; + +const SubGhzProtocol subghz_protocol_dickert_mahs = { + .name = SUBGHZ_PROTOCOL_DICKERT_MAHS_NAME, + .type = SubGhzProtocolTypeStatic, + .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | + SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save | SubGhzProtocolFlag_Send, + + .decoder = &subghz_protocol_dickert_mahs_decoder, + .encoder = &subghz_protocol_dickert_mahs_encoder, +}; + +static void subghz_protocol_encoder_dickert_mahs_parse_buffer( + SubGhzProtocolDecoderDickertMAHS* instance, + FuriString* output) { + // We assume we have only decodes < 64 bit! + uint64_t data = instance->generic.data; + uint8_t bits[36] = {}; + + // Convert uint64_t into bit array + for(int i = 35; i >= 0; i--) { + if(data & 1) { + bits[i] = 1; + } + data >>= 1; + } + + // Decode symbols + FuriString* code = furi_string_alloc(); + for(size_t i = 0; i < 35; i += 2) { + uint8_t dip = (bits[i] << 1) + bits[i + 1]; + // PLUS = 3, // 0b11 + // ZERO = 1, // 0b01 + // MINUS = 0, // 0x00 + if(dip == 0x01) { + furi_string_cat(code, "0"); + } else if(dip == 0x00) { + furi_string_cat(code, "-"); + } else if(dip == 0x03) { + furi_string_cat(code, "+"); + } else { + furi_string_cat(code, "?"); + } + } + + FuriString* user_dips = furi_string_alloc(); + FuriString* fact_dips = furi_string_alloc(); + furi_string_set_n(user_dips, code, 0, 10); + furi_string_set_n(fact_dips, code, 10, 8); + + furi_string_cat_printf( + output, + "%s\r\n" + "User-Dips:\t%s\r\n" + "Fac-Code:\t%s\r\n", + instance->generic.protocol_name, + furi_string_get_cstr(user_dips), + furi_string_get_cstr(fact_dips)); + furi_string_free(user_dips); + furi_string_free(fact_dips); + furi_string_free(code); +} + +void* subghz_protocol_encoder_dickert_mahs_alloc(SubGhzEnvironment* environment) { + UNUSED(environment); + SubGhzProtocolEncoderDickertMAHS* instance = malloc(sizeof(SubGhzProtocolEncoderDickertMAHS)); + + instance->base.protocol = &subghz_protocol_dickert_mahs; + instance->generic.protocol_name = instance->base.protocol->name; + + instance->encoder.repeat = 10; + instance->encoder.size_upload = 128; + instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); + instance->encoder.is_running = false; + return instance; +} + +void subghz_protocol_encoder_dickert_mahs_free(void* context) { + furi_assert(context); + SubGhzProtocolEncoderDickertMAHS* instance = context; + free(instance->encoder.upload); + free(instance); +} + +/** + * Generating an upload from data. + * @param instance Pointer to a SubGhzProtocolEncoderDickertMAHS instance + * @return true On success + */ +static bool + subghz_protocol_encoder_dickert_mahs_get_upload(SubGhzProtocolEncoderDickertMAHS* instance) { + furi_assert(instance); + size_t index = 0; + size_t size_upload = (instance->generic.data_count_bit * 2) + 2; + if(size_upload > instance->encoder.size_upload) { + FURI_LOG_E(TAG, "Size upload exceeds allocated encoder buffer."); + return false; + } else { + instance->encoder.size_upload = size_upload; + } + + instance->encoder.upload[index++] = + level_duration_make(false, (uint32_t)subghz_protocol_dickert_mahs_const.te_short * 112); + // Send start bit + instance->encoder.upload[index++] = + level_duration_make(true, (uint32_t)subghz_protocol_dickert_mahs_const.te_short); + + //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(false, (uint32_t)subghz_protocol_dickert_mahs_const.te_long); + instance->encoder.upload[index++] = + level_duration_make(true, (uint32_t)subghz_protocol_dickert_mahs_const.te_short); + } else { + //send bit 0 + instance->encoder.upload[index++] = + level_duration_make(false, (uint32_t)subghz_protocol_dickert_mahs_const.te_short); + instance->encoder.upload[index++] = + level_duration_make(true, (uint32_t)subghz_protocol_dickert_mahs_const.te_long); + } + } + + return true; +} + +SubGhzProtocolStatus + subghz_protocol_encoder_dickert_mahs_deserialize(void* context, FlipperFormat* flipper_format) { + furi_assert(context); + SubGhzProtocolEncoderDickertMAHS* instance = context; + SubGhzProtocolStatus ret = SubGhzProtocolStatusError; + do { + ret = subghz_block_generic_deserialize(&instance->generic, flipper_format); + if(ret != SubGhzProtocolStatusOk) { + break; + } + + // Allow for longer keys (<) instead of != + if((instance->generic.data_count_bit < + subghz_protocol_dickert_mahs_const.min_count_bit_for_found)) { + FURI_LOG_E(TAG, "Wrong number of bits in key"); + ret = SubGhzProtocolStatusErrorValueBitCount; + break; + } + //optional parameter parameter + flipper_format_read_uint32( + flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); + + if(!subghz_protocol_encoder_dickert_mahs_get_upload(instance)) { + ret = SubGhzProtocolStatusErrorEncoderGetUpload; + break; + } + instance->encoder.is_running = true; + } while(false); + + return ret; +} + +void subghz_protocol_encoder_dickert_mahs_stop(void* context) { + SubGhzProtocolEncoderDickertMAHS* instance = context; + instance->encoder.is_running = false; +} + +LevelDuration subghz_protocol_encoder_dickert_mahs_yield(void* context) { + SubGhzProtocolEncoderDickertMAHS* instance = context; + + if(instance->encoder.repeat == 0 || !instance->encoder.is_running) { + instance->encoder.is_running = false; + return level_duration_reset(); + } + + LevelDuration ret = instance->encoder.upload[instance->encoder.front]; + + if(++instance->encoder.front == instance->encoder.size_upload) { + instance->encoder.repeat--; + instance->encoder.front = 0; + } + + return ret; +} + +void* subghz_protocol_decoder_dickert_mahs_alloc(SubGhzEnvironment* environment) { + UNUSED(environment); + SubGhzProtocolDecoderDickertMAHS* instance = malloc(sizeof(SubGhzProtocolDecoderDickertMAHS)); + instance->base.protocol = &subghz_protocol_dickert_mahs; + instance->generic.protocol_name = instance->base.protocol->name; + instance->tmp_cnt = 0; + + return instance; +} + +void subghz_protocol_decoder_dickert_mahs_free(void* context) { + furi_assert(context); + SubGhzProtocolDecoderDickertMAHS* instance = context; + free(instance); +} + +void subghz_protocol_decoder_dickert_mahs_reset(void* context) { + furi_assert(context); + SubGhzProtocolDecoderDickertMAHS* instance = context; + instance->decoder.parser_step = DickertMAHSDecoderStepReset; +} + +void subghz_protocol_decoder_dickert_mahs_feed(void* context, bool level, uint32_t duration) { + furi_assert(context); + SubGhzProtocolDecoderDickertMAHS* instance = context; + + switch(instance->decoder.parser_step) { + case DickertMAHSDecoderStepReset: + // Check if done + if(instance->decoder.decode_count_bit >= + subghz_protocol_dickert_mahs_const.min_count_bit_for_found) { + instance->generic.serial = 0x0; + instance->generic.btn = 0x0; + + instance->generic.data = instance->decoder.decode_data; + instance->generic.data_count_bit = instance->decoder.decode_count_bit; + + if(instance->base.callback) + instance->base.callback(&instance->base, instance->base.context); + + instance->decoder.decode_data = 0; + instance->decoder.decode_count_bit = 0; + } + + if((!level) && (duration > 10 * subghz_protocol_dickert_mahs_const.te_short)) { + //Found header DICKERT_MAHS + instance->decoder.parser_step = DickertMAHSDecoderStepInitial; + } + break; + case DickertMAHSDecoderStepInitial: + if(!level) { + break; + } else if( + DURATION_DIFF(duration, subghz_protocol_dickert_mahs_const.te_short) < + subghz_protocol_dickert_mahs_const.te_delta) { + //Found start bit DICKERT_MAHS + instance->decoder.parser_step = DickertMAHSDecoderStepRecording; + instance->decoder.decode_data = 0; + instance->decoder.decode_count_bit = 0; + } else { + instance->decoder.parser_step = DickertMAHSDecoderStepReset; + } + break; + case DickertMAHSDecoderStepRecording: + if((!level && instance->tmp_cnt == 0) || (level && instance->tmp_cnt == 1)) { + instance->tmp[instance->tmp_cnt] = duration; + + instance->tmp_cnt++; + + if(instance->tmp_cnt == 2) { + if(DURATION_DIFF(instance->tmp[0] + instance->tmp[1], 1200) < + subghz_protocol_dickert_mahs_const.te_delta) { + if(DURATION_DIFF(instance->tmp[0], subghz_protocol_dickert_mahs_const.te_long) < + subghz_protocol_dickert_mahs_const.te_delta) { + subghz_protocol_blocks_add_bit(&instance->decoder, 1); + } else if( + DURATION_DIFF( + instance->tmp[0], subghz_protocol_dickert_mahs_const.te_short) < + subghz_protocol_dickert_mahs_const.te_delta) { + subghz_protocol_blocks_add_bit(&instance->decoder, 0); + } + + instance->tmp_cnt = 0; + } else { + instance->tmp_cnt = 0; + instance->decoder.parser_step = DickertMAHSDecoderStepReset; + } + } + } else { + instance->tmp_cnt = 0; + instance->decoder.parser_step = DickertMAHSDecoderStepReset; + } + + break; + } +} + +uint8_t subghz_protocol_decoder_dickert_mahs_get_hash_data(void* context) { + furi_assert(context); + SubGhzProtocolDecoderDickertMAHS* instance = context; + return subghz_protocol_blocks_get_hash_data( + &instance->decoder, (instance->decoder.decode_count_bit / 8) + 1); +} + +SubGhzProtocolStatus subghz_protocol_decoder_dickert_mahs_serialize( + void* context, + FlipperFormat* flipper_format, + SubGhzRadioPreset* preset) { + furi_assert(context); + SubGhzProtocolDecoderDickertMAHS* instance = context; + return subghz_block_generic_serialize(&instance->generic, flipper_format, preset); +} + +SubGhzProtocolStatus + subghz_protocol_decoder_dickert_mahs_deserialize(void* context, FlipperFormat* flipper_format) { + furi_assert(context); + SubGhzProtocolDecoderDickertMAHS* instance = context; + SubGhzProtocolStatus ret = SubGhzProtocolStatusError; + do { + ret = subghz_block_generic_deserialize(&instance->generic, flipper_format); + if(ret != SubGhzProtocolStatusOk) { + break; + } + + // Allow for longer keys (<) instead of != + if((instance->generic.data_count_bit < + subghz_protocol_dickert_mahs_const.min_count_bit_for_found)) { + FURI_LOG_E(TAG, "Wrong number of bits in key"); + ret = SubGhzProtocolStatusErrorValueBitCount; + break; + } + } while(false); + return ret; +} + +void subghz_protocol_decoder_dickert_mahs_get_string(void* context, FuriString* output) { + furi_assert(context); + subghz_protocol_encoder_dickert_mahs_parse_buffer(context, output); +} diff --git a/lib/subghz/protocols/dickert_mahs.h b/lib/subghz/protocols/dickert_mahs.h new file mode 100644 index 0000000000..3f682cee09 --- /dev/null +++ b/lib/subghz/protocols/dickert_mahs.h @@ -0,0 +1,120 @@ +#pragma once + +#include "base.h" + +#define SUBGHZ_PROTOCOL_DICKERT_MAHS_NAME "Dickert_MAHS" + +typedef struct SubGhzProtocolDecoderDickertMAHS SubGhzProtocolDecoderDickertMAHS; +typedef struct SubGhzProtocolEncoderDickertMAHS SubGhzProtocolEncoderDickertMAHS; + +extern const SubGhzProtocolDecoder subghz_protocol_dickert_mahs_decoder; +extern const SubGhzProtocolEncoder subghz_protocol_dickert_mahs_encoder; +extern const SubGhzProtocol subghz_protocol_dickert_mahs; + +/** Allocate SubGhzProtocolEncoderDickertMAHS. + * + * @param environment Pointer to a SubGhzEnvironment instance + * + * @return pointer to a SubGhzProtocolEncoderDickertMAHS instance + */ +void* subghz_protocol_encoder_dickert_mahs_alloc(SubGhzEnvironment* environment); + +/** Free SubGhzProtocolEncoderDickertMAHS. + * + * @param context Pointer to a SubGhzProtocolEncoderDickertMAHS instance + */ +void subghz_protocol_encoder_dickert_mahs_free(void* context); + +/** Deserialize and generating an upload to send. + * + * @param context Pointer to a SubGhzProtocolEncoderDickertMAHS + * instance + * @param flipper_format Pointer to a FlipperFormat instance + * + * @return status + */ +SubGhzProtocolStatus + subghz_protocol_encoder_dickert_mahs_deserialize(void* context, FlipperFormat* flipper_format); + +/** Forced transmission stop. + * + * @param context Pointer to a SubGhzProtocolEncoderDickertMAHS instance + */ +void subghz_protocol_encoder_dickert_mahs_stop(void* context); + +/** Getting the level and duration of the upload to be loaded into DMA. + * + * @param context Pointer to a SubGhzProtocolEncoderDickertMAHS instance + * + * @return LevelDuration + */ +LevelDuration subghz_protocol_encoder_dickert_mahs_yield(void* context); + +/** Allocate SubGhzProtocolDecoderDickertMAHS. + * + * @param environment Pointer to a SubGhzEnvironment instance + * + * @return pointer to a SubGhzProtocolDecoderDickertMAHS instance + */ +void* subghz_protocol_decoder_dickert_mahs_alloc(SubGhzEnvironment* environment); + +/** Free SubGhzProtocolDecoderDickertMAHS. + * + * @param context Pointer to a SubGhzProtocolDecoderDickertMAHS instance + */ +void subghz_protocol_decoder_dickert_mahs_free(void* context); + +/** Reset decoder SubGhzProtocolDecoderDickertMAHS. + * + * @param context Pointer to a SubGhzProtocolDecoderDickertMAHS instance + */ +void subghz_protocol_decoder_dickert_mahs_reset(void* context); + +/** Parse a raw sequence of levels and durations received from the air. + * + * @param context Pointer to a SubGhzProtocolDecoderDickertMAHS instance + * @param level Signal level true-high false-low + * @param duration Duration of this level in, us + */ +void subghz_protocol_decoder_dickert_mahs_feed(void* context, bool level, uint32_t duration); + +/** Getting the hash sum of the last randomly received parcel. + * + * @param context Pointer to a SubGhzProtocolDecoderDickertMAHS instance + * + * @return hash Hash sum + */ +uint8_t subghz_protocol_decoder_dickert_mahs_get_hash_data(void* context); + +/** Serialize data SubGhzProtocolDecoderDickertMAHS. + * + * @param context Pointer to a SubGhzProtocolDecoderDickertMAHS + * instance + * @param flipper_format Pointer to a FlipperFormat instance + * @param preset The modulation on which the signal was received, + * SubGhzRadioPreset + * + * @return status + */ +SubGhzProtocolStatus subghz_protocol_decoder_dickert_mahs_serialize( + void* context, + FlipperFormat* flipper_format, + SubGhzRadioPreset* preset); + +/** Deserialize data SubGhzProtocolDecoderDickertMAHS. + * + * @param context Pointer to a SubGhzProtocolDecoderDickertMAHS + * instance + * @param flipper_format Pointer to a FlipperFormat instance + * + * @return status + */ +SubGhzProtocolStatus + subghz_protocol_decoder_dickert_mahs_deserialize(void* context, FlipperFormat* flipper_format); + +/** Getting a textual representation of the received data. + * + * @param context Pointer to a SubGhzProtocolDecoderDickertMAHS instance + * @param output Resulting text + */ +void subghz_protocol_decoder_dickert_mahs_get_string(void* context, FuriString* output); diff --git a/lib/subghz/protocols/protocol_items.c b/lib/subghz/protocols/protocol_items.c index e50d52ac1d..0d9c2a088b 100644 --- a/lib/subghz/protocols/protocol_items.c +++ b/lib/subghz/protocols/protocol_items.c @@ -44,6 +44,7 @@ const SubGhzProtocol* subghz_protocol_registry_items[] = { &subghz_protocol_kinggates_stylo_4k, &subghz_protocol_bin_raw, &subghz_protocol_mastercode, + &subghz_protocol_dickert_mahs, }; const SubGhzProtocolRegistry subghz_protocol_registry = { diff --git a/lib/subghz/protocols/protocol_items.h b/lib/subghz/protocols/protocol_items.h index c5a090e993..ae531c3f9b 100644 --- a/lib/subghz/protocols/protocol_items.h +++ b/lib/subghz/protocols/protocol_items.h @@ -45,3 +45,4 @@ #include "kinggates_stylo_4k.h" #include "bin_raw.h" #include "mastercode.h" +#include "dickert_mahs.h"