| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- #include <inttypes.h>
- #include <lib/flipper_format/flipper_format_i.h>
- #include <furi/core/string.h>
- #include <lib/subghz/registry.h>
- #include <lib/subghz/protocols/base.h>
- #include "app_buffer.h"
- #define TAG "PROTOVIEW-protocol"
- const SubGhzProtocol subghz_protocol_protoview;
- /* The feed() method puts data in the RawSamples global (protected by
- * a mutex). */
- extern RawSamplesBuffer *RawSamples;
- /* This is totally dummy: we just define the decoder base for the async
- * system to work but we don't really use it if not to collect raw
- * data via the feed() method. */
- typedef struct SubGhzProtocolDecoderprotoview {
- SubGhzProtocolDecoderBase base;
- } SubGhzProtocolDecoderprotoview;
- void* subghz_protocol_decoder_protoview_alloc(SubGhzEnvironment* environment) {
- UNUSED(environment);
- SubGhzProtocolDecoderprotoview* instance =
- malloc(sizeof(SubGhzProtocolDecoderprotoview));
- instance->base.protocol = &subghz_protocol_protoview;
- return instance;
- }
- void subghz_protocol_decoder_protoview_free(void* context) {
- furi_assert(context);
- SubGhzProtocolDecoderprotoview* instance = context;
- free(instance);
- }
- void subghz_protocol_decoder_protoview_reset(void* context) {
- furi_assert(context);
- }
- /* That's the only thig we really use of the protocol decoder
- * implementation. */
- void subghz_protocol_decoder_protoview_feed(void* context, bool level, uint32_t duration) {
- furi_assert(context);
- UNUSED(context);
- /* Add data to the circular buffer. */
- raw_samples_add(RawSamples, level, duration);
- // FURI_LOG_E(TAG, "FEED: %d %d", (int)level, (int)duration);
- return;
- }
- /* The only scope of this method is to avoid duplicated messages in the
- * Subghz history, which we don't use. */
- uint8_t subghz_protocol_decoder_protoview_get_hash_data(void* context) {
- furi_assert(context);
- return 123;
- }
- bool subghz_protocol_decoder_protoview_serialize(
- void* context,
- FlipperFormat* flipper_format,
- SubGhzRadioPreset* preset)
- {
- UNUSED(context);
- UNUSED(flipper_format);
- UNUSED(preset);
- return false;
- }
- bool subghz_protocol_decoder_protoview_deserialize(void* context, FlipperFormat* flipper_format)
- {
- UNUSED(context);
- UNUSED(flipper_format);
- return false;
- }
- void subhz_protocol_decoder_protoview_get_string(void* context, FuriString* output)
- {
- furi_assert(context);
- furi_string_cat_printf(output, "Protoview");
- }
- const SubGhzProtocolDecoder subghz_protocol_protoview_decoder = {
- .alloc = subghz_protocol_decoder_protoview_alloc,
- .free = subghz_protocol_decoder_protoview_free,
- .reset = subghz_protocol_decoder_protoview_reset,
- .feed = subghz_protocol_decoder_protoview_feed,
- .get_hash_data = subghz_protocol_decoder_protoview_get_hash_data,
- .serialize = subghz_protocol_decoder_protoview_serialize,
- .deserialize = subghz_protocol_decoder_protoview_deserialize,
- .get_string = subhz_protocol_decoder_protoview_get_string,
- };
- const SubGhzProtocol subghz_protocol_protoview = {
- .name = "Protoview",
- .type = SubGhzProtocolTypeStatic,
- .flag = SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable,
- .decoder = &subghz_protocol_protoview_decoder,
- };
- const SubGhzProtocol* protoview_protocol_registry_items[] = {
- &subghz_protocol_protoview,
- };
- const SubGhzProtocolRegistry protoview_protocol_registry = {
- .items = protoview_protocol_registry_items,
- .size = COUNT_OF(protoview_protocol_registry_items)
- };
|