-
-
Notifications
You must be signed in to change notification settings - Fork 184
/
flipper_settings.hexpat
258 lines (224 loc) · 7.7 KB
/
flipper_settings.hexpat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
/*!
This pattern can be used to parse Flipper Zero settings.
It supports SavedStructure based settings and Notification settings.
*/
#pragma author Jan Wiesemann
#pragma description Flipper Zero Settings
/**
Infrared
@source https://github.com/flipperdevices/flipperzero-firmware/blob/a403e5f543a5423e39ac1700ae4711e9e489445e/applications/main/infrared/infrared_app.c#L17
*/
#define MAGIC_IR 0x1F
/**
Expansion/UART
@source https://github.com/flipperdevices/flipperzero-firmware/blob/a403e5f543a5423e39ac1700ae4711e9e489445e/applications/services/expansion/expansion_settings.c#L10
*/
#define MAGIC_UART 0xEA
/**
Bluetooth
@source https://github.com/flipperdevices/flipperzero-firmware/blob/a403e5f543a5423e39ac1700ae4711e9e489445e/applications/services/bt/bt_settings.c#L9
*/
#define MAGIC_BT 0x19
/**
Dolphin
@source https://github.com/DarkFlippers/unleashed-firmware/blob/b2305ce5c7a6ab36babc30243a589eccfa9edcb6/applications/services/dolphin/helpers/dolphin_state.c#L14
*/
#define MAGIC_DOLPHIN 0xD0
/**
Desktop
@source https://github.com/flipperdevices/flipperzero-firmware/blob/a403e5f543a5423e39ac1700ae4711e9e489445e/applications/services/desktop/desktop_settings.h#L14
*/
#define MAGIC_DEKTOP 0x17
/* ======= Common structures =======
Flipper datatype aliases
They are added for easyer translatiom from the Flipper soruce into ImHex
*/
using int8_t = u8;
using uint8_t = u8;
using int16_t = u16;
using uint16_t = u16;
using int32_t = s32;
using uint32_t = u32;
using int64_t = s64;
using uint64_t = u64;
/* ======= Common structures ======= */
/**
Header for a saved structure file
@source https://github.com/flipperdevices/flipperzero-firmware/blob/a403e5f543a5423e39ac1700ae4711e9e489445e/lib/toolbox/saved_struct.c#L14
*/
struct SavedStructHeader {
uint8_t magic;
uint8_t version;
uint8_t checksum; //Sum of data-bytes
uint8_t flags; //Not used always 0
uint32_t timestamp; //Not used alwas 0
};
/* ======= Infrared settings '.infrared.settings' ======= */
/*
Lists all avalible outputs for the Infrared appication
@source https://github.com/flipperdevices/flipperzero-firmware/blob/a403e5f543a5423e39ac1700ae4711e9e489445e/targets/furi_hal_include/furi_hal_infrared.h#L23
*/
enum FuriHalInfraredTxPin : uint8_t {
FuriHalInfraredTxPinInternal,
FuriHalInfraredTxPinExtPA7,
FuriHalInfraredTxPinMax
};
/*
Infrared Settings
@source https://github.com/flipperdevices/flipperzero-firmware/blob/a403e5f543a5423e39ac1700ae4711e9e489445e/applications/main/infrared/infrared_app.c#L22
*/
struct InfraredSettings {
FuriHalInfraredTxPin tx_pin;
bool otg_enabled;
};
/* ======= Expansion settings '.expansion.settings' ======= */
/**
???
@source https://github.com/flipperdevices/flipperzero-firmware/blob/a403e5f543a5423e39ac1700ae4711e9e489445e/applications/services/expansion/expansion_settings.h#L23
*/
struct ExpansionSettings {
uint8_t uart_index;
};
/* ======= Bluetooth settings '.bt.settings' ======= */
/**
Bluetooth Settings
@source https://github.com/flipperdevices/flipperzero-firmware/blob/a403e5f543a5423e39ac1700ae4711e9e489445e/applications/services/bt/bt_settings.h#L14
*/
struct BtSettings {
bool enabled;
};
/* ======= Dolphin state '.dolphin.state' ======= */
/**
Lists all avalible Apps, that grand you points
@source https://github.com/flipperdevices/flipperzero-firmware/blob/a403e5f543a5423e39ac1700ae4711e9e489445e/applications/services/dolphin/helpers/dolphin_deed.h#L18
*/
enum DolphinApp : uint16_t {
DolphinAppSubGhz,
DolphinAppRfid,
DolphinAppNfc,
DolphinAppIr,
DolphinAppIbutton,
DolphinAppBadusb,
DolphinAppPlugin,
DolphinAppMAX
};
/**
States for the Dolphin
@source https://github.com/flipperdevices/flipperzero-firmware/blob/a403e5f543a5423e39ac1700ae4711e9e489445e/applications/services/dolphin/helpers/dolphin_state.h#L17
*/
struct DolphinStoreData{
uint8_t icounter_daily_limit[DolphinApp::DolphinAppMAX];
uint8_t butthurt_daily_limit;
uint32_t flags; // Not used always 0
uint32_t icounter;
int32_t butthurt;
uint64_t timestamp;
padding[4];
};
/* ======= Desktop settings '.dektop.settings' ======= */
#define MAX_PIN_SIZE 10
#define MIN_PIN_SIZE 4
#define MAX_APP_LENGTH 128
/**
Represents a Input Key
@source https://github.com/flipperdevices/flipperzero-firmware/blob/a403e5f543a5423e39ac1700ae4711e9e489445e/targets/f7/furi_hal/furi_hal_resources.h#L22
*/
enum InputKey : uint8_t{
InputKeyUp,
InputKeyDown,
InputKeyRight,
InputKeyLeft,
InputKeyOk,
InputKeyBack,
InputKeyMAX, /**< Special value */
};
/**
Stores the Pin-Code
@source https://github.com/flipperdevices/flipperzero-firmware/blob/a403e5f543a5423e39ac1700ae4711e9e489445e/applications/services/desktop/desktop_settings.h#L58
*/
struct PinCode{
InputKey data[MAX_PIN_SIZE];
uint8_t length;
};
/**
Possible buttons for the Shortcut menu
@source https://github.com/flipperdevices/flipperzero-firmware/blob/a403e5f543a5423e39ac1700ae4711e9e489445e/applications/services/desktop/desktop_settings.h#L45
*/
enum FavoriteAppShortcut : uint32_t {
FavoriteAppLeftShort,
FavoriteAppLeftLong,
FavoriteAppRightShort,
FavoriteAppRightLong,
FavoriteAppNumber
};
/**
Possible buttons for the Shortcut menu while using the dummy mode
@source https://github.com/flipperdevices/flipperzero-firmware/blob/a403e5f543a5423e39ac1700ae4711e9e489445e/applications/services/desktop/desktop_settings.h#L53
*/
enum DummyAppShortcut : uint32_t{
DummyAppLeft = 0,
DummyAppRight,
DummyAppDown,
DummyAppOk,
DummyAppNumber,
};
/**
Path or Appname for a Shortcut
@source https://github.com/flipperdevices/flipperzero-firmware/blob/a403e5f543a5423e39ac1700ae4711e9e489445e/applications/services/desktop/desktop_settings.h#L62
*/
struct FavoriteApp {
char name_or_path[MAX_APP_LENGTH];
};
/**
Settings for the Desktop
@source https://github.com/flipperdevices/flipperzero-firmware/blob/a403e5f543a5423e39ac1700ae4711e9e489445e/applications/services/desktop/desktop_settings.h#L71
*/
struct DesktopSettings {
PinCode pin_code;
padding[1];
uint32_t auto_lock_delay_ms;
uint8_t dummy_mode;
uint8_t display_clock;
FavoriteApp favorite_apps[FavoriteAppShortcut::FavoriteAppNumber];
FavoriteApp dummy_apps[DummyAppShortcut::DummyAppNumber];
padding[2];
};
/* ======= Helper======= */
/**
Container for SavedStruct based settings
*/
struct SavedStructure {
SavedStructHeader header;
match(header.magic, sizeof($) - sizeof(SavedStructHeader)) {
(MAGIC_IR, sizeof(InfraredSettings)): InfraredSettings infraredSettings;
(MAGIC_UART, sizeof(ExpansionSettings)): ExpansionSettings expansionSettings;
(MAGIC_BT, sizeof(BtSettings)): BtSettings btSettings;
(MAGIC_DOLPHIN, sizeof(DolphinStoreData)): DolphinStoreData dolphinStoreData;
(MAGIC_DEKTOP, sizeof(DesktopSettings)): DesktopSettings desktopSettings;
}
};
/**
Settings for the LCD and Notifications
@source https://github.com/flipperdevices/flipperzero-firmware/blob/a403e5f543a5423e39ac1700ae4711e9e489445e/applications/services/notification/notification_app.h#L46
*/
struct NotificationSettings {
uint8_t version;
padding[3];
float display_brightness;
float led_brightness;
float speaker_volume;
uint32_t display_off_delay_ms;
int8_t contrast;
bool vibro_on;
padding[2];
};
/**
Wrapper for SavedStructure or Notificaition settings
*/
struct FlipperSettings {
if(sizeof($) == sizeof(NotificationSettings))
NotificationSettings notificationSettings;
else
SavedStructure savedStructure;
};
FlipperSettings flipperSettings @ 0x00;