Loading...
Searching...
No Matches
types.h
1#pragma once
2
3#include <stdbool.h>
4#include <stdint.h>
5#include <stddef.h>
6
8#include <lib/toolbox/level_duration.h>
9
10#include "environment.h"
11#include <furi.h>
12#include <furi_hal.h>
13
14#define SUBGHZ_APP_FOLDER EXT_PATH("subghz")
15#define SUBGHZ_RAW_FOLDER EXT_PATH("subghz")
16#define SUBGHZ_APP_FILENAME_PREFIX "SubGHz"
17#define SUBGHZ_APP_FILENAME_EXTENSION ".sub"
18
19#define SUBGHZ_KEY_FILE_VERSION 1
20#define SUBGHZ_KEY_FILE_TYPE "Flipper SubGhz Key File"
21
22#define SUBGHZ_RAW_FILE_VERSION 1
23#define SUBGHZ_RAW_FILE_TYPE "Flipper SubGhz RAW File"
24
25#define SUBGHZ_KEYSTORE_DIR_NAME EXT_PATH("subghz/assets/keeloq_mfcodes")
26#define SUBGHZ_KEYSTORE_DIR_USER_NAME EXT_PATH("subghz/assets/keeloq_mfcodes_user")
27#define SUBGHZ_CAME_ATOMO_DIR_NAME EXT_PATH("subghz/assets/came_atomo")
28#define SUBGHZ_NICE_FLOR_S_DIR_NAME EXT_PATH("subghz/assets/nice_flor_s")
29#define SUBGHZ_ALUTECH_AT_4N_DIR_NAME EXT_PATH("subghz/assets/alutech_at_4n")
30
33
34// Radio Preset
35typedef struct {
36 FuriString* name;
37 uint32_t frequency;
38 uint8_t* data;
39 size_t data_size;
41
42typedef enum {
43 SubGhzProtocolStatusOk = 0,
44 // Errors
45 SubGhzProtocolStatusError = (-1),
46 // Serialize/De-serialize
47 SubGhzProtocolStatusErrorParserHeader = (-2),
48 SubGhzProtocolStatusErrorParserFrequency = (-3),
49 SubGhzProtocolStatusErrorParserPreset = (-4),
50 SubGhzProtocolStatusErrorParserCustomPreset = (-5),
51 SubGhzProtocolStatusErrorParserProtocolName = (-6),
52 SubGhzProtocolStatusErrorParserBitCount = (-7),
53 SubGhzProtocolStatusErrorParserKey = (-8),
54 SubGhzProtocolStatusErrorParserTe = (-9),
55 SubGhzProtocolStatusErrorParserOthers = (-10),
56 // Invalid data
57 SubGhzProtocolStatusErrorValueBitCount = (-11),
58 // Encoder issue
59 SubGhzProtocolStatusErrorEncoderGetUpload = (-12),
60 // Special Values
61 SubGhzProtocolStatusErrorProtocolNotFound = (-13),
62 SubGhzProtocolStatusReserved = 0x7FFFFFFF,
63} SubGhzProtocolStatus;
64
65// Allocator and Deallocator
66typedef void* (*SubGhzAlloc)(SubGhzEnvironment* environment);
67typedef void (*SubGhzFree)(void* context);
68
69// Serialize and Deserialize
70typedef SubGhzProtocolStatus (
71 *SubGhzSerialize)(void* context, FlipperFormat* flipper_format, SubGhzRadioPreset* preset);
72typedef SubGhzProtocolStatus (*SubGhzDeserialize)(void* context, FlipperFormat* flipper_format);
73
74// Decoder specific
75typedef void (*SubGhzDecoderFeed)(void* decoder, bool level, uint32_t duration);
76typedef void (*SubGhzDecoderReset)(void* decoder);
77typedef uint8_t (*SubGhzGetHashData)(void* decoder);
78typedef void (*SubGhzGetString)(void* decoder, FuriString* output);
79
80// Encoder specific
81typedef void (*SubGhzEncoderStop)(void* encoder);
82typedef LevelDuration (*SubGhzEncoderYield)(void* context);
83
84typedef struct {
85 SubGhzAlloc alloc;
86 SubGhzFree free;
87
88 SubGhzDecoderFeed feed;
89 SubGhzDecoderReset reset;
90
91 SubGhzGetHashData get_hash_data;
92 SubGhzGetString get_string;
93 SubGhzSerialize serialize;
94 SubGhzDeserialize deserialize;
96
97typedef struct {
98 SubGhzAlloc alloc;
99 SubGhzFree free;
100
101 SubGhzDeserialize deserialize;
102 SubGhzEncoderStop stop;
103 SubGhzEncoderYield yield;
105
106typedef enum {
107 SubGhzProtocolTypeUnknown = 0,
108 SubGhzProtocolTypeStatic,
109 SubGhzProtocolTypeDynamic,
110 SubGhzProtocolTypeRAW,
111 SubGhzProtocolWeatherStation,
112 SubGhzProtocolCustom,
113} SubGhzProtocolType;
114
115typedef enum {
116 SubGhzProtocolFlag_RAW = (1 << 0),
117 SubGhzProtocolFlag_Decodable = (1 << 1),
118 SubGhzProtocolFlag_315 = (1 << 2),
119 SubGhzProtocolFlag_433 = (1 << 3),
120 SubGhzProtocolFlag_868 = (1 << 4),
121 SubGhzProtocolFlag_AM = (1 << 5),
122 SubGhzProtocolFlag_FM = (1 << 6),
123 SubGhzProtocolFlag_Save = (1 << 7),
124 SubGhzProtocolFlag_Load = (1 << 8),
125 SubGhzProtocolFlag_Send = (1 << 9),
126 SubGhzProtocolFlag_BinRAW = (1 << 10),
127} SubGhzProtocolFlag;
128
130 const char* name;
131 SubGhzProtocolType type;
132 SubGhzProtocolFlag flag;
133
134 const SubGhzProtocolEncoder* encoder;
135 const SubGhzProtocolDecoder* decoder;
136};
Flipper File Format helper library.
Furi HAL API.
Definition flipper_format.c:12
Definition string.c:4
Definition level_duration.h:15
Definition environment.c:4
Definition types.h:84
Definition types.h:97
Definition types.h:129
Definition registry.h:14
Definition types.h:35