flipperzero-firmware/lib/subghz/types.h
Skorpionm 9a9abd59e9
[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>
2022-10-20 02:27:26 +09:00

103 lines
2.7 KiB
C

#pragma once
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include <lib/flipper_format/flipper_format.h>
#include <lib/toolbox/level_duration.h>
#include "environment.h"
#include <furi.h>
#include <furi_hal.h>
#define SUBGHZ_APP_FOLDER ANY_PATH("subghz")
#define SUBGHZ_RAW_FOLDER EXT_PATH("subghz")
#define SUBGHZ_APP_EXTENSION ".sub"
#define SUBGHZ_KEY_FILE_VERSION 1
#define SUBGHZ_KEY_FILE_TYPE "Flipper SubGhz Key File"
#define SUBGHZ_RAW_FILE_VERSION 1
#define SUBGHZ_RAW_FILE_TYPE "Flipper SubGhz RAW File"
// 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, SubGhzRadioPreset* preset);
typedef bool (*SubGhzDeserialize)(void* context, FlipperFormat* flipper_format);
// Decoder specific
typedef void (*SubGhzDecoderFeed)(void* decoder, bool level, uint32_t duration);
typedef void (*SubGhzDecoderReset)(void* decoder);
typedef uint8_t (*SubGhzGetHashData)(void* decoder);
typedef void (*SubGhzGetString)(void* decoder, FuriString* output);
// Encoder specific
typedef void (*SubGhzEncoderStop)(void* encoder);
typedef LevelDuration (*SubGhzEncoderYield)(void* context);
typedef struct {
SubGhzAlloc alloc;
SubGhzFree free;
SubGhzDecoderFeed feed;
SubGhzDecoderReset reset;
SubGhzGetHashData get_hash_data;
SubGhzGetString get_string;
SubGhzSerialize serialize;
SubGhzDeserialize deserialize;
} SubGhzProtocolDecoder;
typedef struct {
SubGhzAlloc alloc;
SubGhzFree free;
SubGhzDeserialize deserialize;
SubGhzEncoderStop stop;
SubGhzEncoderYield yield;
} SubGhzProtocolEncoder;
typedef enum {
SubGhzProtocolTypeUnknown = 0,
SubGhzProtocolTypeStatic,
SubGhzProtocolTypeDynamic,
SubGhzProtocolTypeRAW,
SubGhzProtocolWeatherStation,
SubGhzProtocolCustom,
} SubGhzProtocolType;
typedef enum {
SubGhzProtocolFlag_RAW = (1 << 0),
SubGhzProtocolFlag_Decodable = (1 << 1),
SubGhzProtocolFlag_315 = (1 << 2),
SubGhzProtocolFlag_433 = (1 << 3),
SubGhzProtocolFlag_868 = (1 << 4),
SubGhzProtocolFlag_AM = (1 << 5),
SubGhzProtocolFlag_FM = (1 << 6),
SubGhzProtocolFlag_Save = (1 << 7),
SubGhzProtocolFlag_Load = (1 << 8),
SubGhzProtocolFlag_Send = (1 << 9),
} SubGhzProtocolFlag;
typedef struct {
const char* name;
SubGhzProtocolType type;
SubGhzProtocolFlag flag;
const SubGhzProtocolEncoder* encoder;
const SubGhzProtocolDecoder* decoder;
} SubGhzProtocol;