Skip to content

Commit c310653

Browse files
authored
Merge pull request #7 from chris-bc/data-model-and-packet-changes
Data model and packet changes
2 parents 61b0f8e + cce7cb2 commit c310653

32 files changed

+2777
-2910
lines changed

Flipper/scenes/wendigo_scene.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22

33
// Generate scene on_enter handlers array
44
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter,
5-
void (*const wendigo_scene_on_enter_handlers[])(void*) = {
5+
void (*const wendigo_scene_on_enter_handlers[])(void *) = {
66
#include "wendigo_scene_config.h"
77
};
88
#undef ADD_SCENE
99

1010
// Generate scene on_event handlers array
1111
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_event,
12-
bool (*const wendigo_scene_on_event_handlers[])(void* context, SceneManagerEvent event) = {
12+
bool (*const wendigo_scene_on_event_handlers[])(void *context, SceneManagerEvent event) = {
1313
#include "wendigo_scene_config.h"
1414
};
1515
#undef ADD_SCENE
1616

1717
// Generate scene on_exit handlers array
1818
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_exit,
19-
void (*const wendigo_scene_on_exit_handlers[])(void* context) = {
19+
void (*const wendigo_scene_on_exit_handlers[])(void *context) = {
2020
#include "wendigo_scene_config.h"
2121
};
2222
#undef ADD_SCENE

Flipper/scenes/wendigo_scene.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ extern const SceneManagerHandlers wendigo_scene_handlers;
1919

2020
// Generate scene on_event handlers declaration
2121
#define ADD_SCENE(prefix, name, id) \
22-
bool prefix##_scene_##name##_on_event(void* context, SceneManagerEvent event);
22+
bool prefix##_scene_##name##_on_event(void *context, SceneManagerEvent event);
2323
#include "wendigo_scene_config.h"
2424
#undef ADD_SCENE
2525

2626
// Generate scene on_exit handlers declaration
27-
#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_exit(void* context);
27+
#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_exit(void *context);
2828
#include "wendigo_scene_config.h"
2929
#undef ADD_SCENE
3030

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#include "../wendigo_app_i.h"
22

3-
void wendigo_console_output_handle_rx_data_cb(uint8_t* buf, size_t len, void* context) {
3+
void wendigo_console_output_handle_rx_data_cb(uint8_t *buf, size_t len, void *context) {
44
furi_assert(context);
5-
WendigoApp* app = context;
6-
FuriString* new_str = furi_string_alloc();
5+
WendigoApp *app = context;
6+
FuriString *new_str = furi_string_alloc();
77

8-
if(app->hex_mode) {
9-
while(len--) {
8+
if (app->hex_mode) {
9+
while (len--) {
1010
uint8_t byte = *(buf++);
11-
if(byte == '\0') break;
11+
if (byte == '\0') break;
1212
furi_string_cat_printf(new_str, "%02X ", byte);
1313
}
1414
} else {
@@ -19,7 +19,7 @@ void wendigo_console_output_handle_rx_data_cb(uint8_t* buf, size_t len, void* co
1919
// If text box store gets too big, then truncate it
2020
app->text_box_store_strlen += furi_string_size(new_str);
2121
;
22-
while(app->text_box_store_strlen >= WENDIGO_TEXT_BOX_STORE_SIZE - 1) {
22+
while (app->text_box_store_strlen >= WENDIGO_TEXT_BOX_STORE_SIZE - 1) {
2323
furi_string_right(app->text_box_store, app->text_box_store_strlen / 2);
2424
app->text_box_store_strlen = furi_string_size(app->text_box_store) + len;
2525
}
@@ -31,48 +31,48 @@ void wendigo_console_output_handle_rx_data_cb(uint8_t* buf, size_t len, void* co
3131
}
3232

3333
static uint8_t hex_char_to_byte(const char c) {
34-
if(c >= '0' && c <= '9') {
34+
if (c >= '0' && c <= '9') {
3535
return c - '0';
3636
}
37-
if(c >= 'A' && c <= 'F') {
37+
if (c >= 'A' && c <= 'F') {
3838
return c - 'A' + 10;
3939
}
40-
if(c >= 'a' && c <= 'f') {
40+
if (c >= 'a' && c <= 'f') {
4141
return c - 'a' + 10;
4242
}
4343
return 0;
4444
}
4545

46-
void wendigo_scene_console_output_on_enter(void* context) {
47-
FURI_LOG_T(WENDIGO_TAG, "Start wendigo_scene_console_output_on_enter()\n----------");
48-
WendigoApp* app = context;
46+
void wendigo_scene_console_output_on_enter(void *context) {
47+
FURI_LOG_T(WENDIGO_TAG, "Start wendigo_scene_console_output_on_enter()");
48+
WendigoApp *app = context;
4949
app->current_view = WendigoAppViewConsoleOutput;
5050

51-
TextBox* text_box = app->text_box;
51+
TextBox *text_box = app->text_box;
5252
text_box_reset(app->text_box);
5353
text_box_set_font(text_box, TextBoxFontText);
5454
text_box_set_focus(text_box, TextBoxFocusEnd);
5555

5656
bool need_reinit = false;
5757

5858
//Change baudrate
59-
if(app->BAUDRATE != app->NEW_BAUDRATE && app->NEW_BAUDRATE) {
59+
if (app->BAUDRATE != app->NEW_BAUDRATE && app->NEW_BAUDRATE) {
6060
need_reinit = true;
6161
}
6262

6363
//Change UART port
64-
if(app->uart_ch != app->new_uart_ch) {
64+
if (app->uart_ch != app->new_uart_ch) {
6565
need_reinit = true;
6666
}
6767

68-
if(need_reinit) {
68+
if (need_reinit) {
6969
wendigo_uart_free(app->uart);
7070
app->BAUDRATE = app->NEW_BAUDRATE;
7171
app->uart_ch = app->new_uart_ch;
7272
app->uart = wendigo_uart_init(app);
7373
}
7474

75-
if(app->is_command) {
75+
if (app->is_command) {
7676
furi_string_reset(app->text_box_store);
7777
app->text_box_store_strlen = 0;
7878
}
@@ -87,31 +87,31 @@ void wendigo_scene_console_output_on_enter(void* context) {
8787
wendigo_uart_set_handle_rx_data_cb(
8888
app->uart, wendigo_console_output_handle_rx_data_cb); // setup callback for rx thread
8989

90-
if(app->hex_mode) {
90+
if (app->hex_mode) {
9191
// Send binary packet
92-
if(app->selected_tx_string) {
93-
const char* str = app->selected_tx_string;
92+
if (app->selected_tx_string) {
93+
const char *str = app->selected_tx_string;
9494
uint8_t digit_num = 0;
9595
uint8_t byte = 0;
96-
while(*str) {
96+
while (*str) {
9797
byte |= (hex_char_to_byte(*str) << ((1 - digit_num) * 4));
9898

99-
if(++digit_num == 2) {
99+
if (++digit_num == 2) {
100100
wendigo_uart_tx(app->uart, &byte, 1);
101101
digit_num = 0;
102102
byte = 0;
103103
}
104104
str++;
105105
}
106106

107-
if(digit_num) {
107+
if (digit_num) {
108108
wendigo_uart_tx(app->uart, &byte, 1);
109109
}
110110
}
111111
} else {
112112
// Send command with CR+LF or newline '\n'
113-
if(app->is_command && app->selected_tx_string) {
114-
if(app->TERMINAL_MODE == 1) {
113+
if (app->is_command && app->selected_tx_string) {
114+
if (app->TERMINAL_MODE == 1) {
115115
wendigo_uart_tx(
116116
app->uart,
117117
(uint8_t*)(app->selected_tx_string),
@@ -126,30 +126,30 @@ void wendigo_scene_console_output_on_enter(void* context) {
126126
}
127127
}
128128
}
129-
FURI_LOG_T(WENDIGO_TAG, "----------\nEnd wendigo_scene_console_output_on_enter()");
129+
FURI_LOG_T(WENDIGO_TAG, "End wendigo_scene_console_output_on_enter()");
130130
}
131131

132-
bool wendigo_scene_console_output_on_event(void* context, SceneManagerEvent event) {
133-
FURI_LOG_T(WENDIGO_TAG, "Start wendigo_scene_console_output_on_event()\n----------");
134-
WendigoApp* app = context;
132+
bool wendigo_scene_console_output_on_event(void *context, SceneManagerEvent event) {
133+
FURI_LOG_T(WENDIGO_TAG, "Start wendigo_scene_console_output_on_event()");
134+
WendigoApp *app = context;
135135

136136
bool consumed = false;
137137

138-
if(event.type == SceneManagerEventTypeCustom) {
138+
if (event.type == SceneManagerEventTypeCustom) {
139139
text_box_set_text(app->text_box, furi_string_get_cstr(app->text_box_store));
140140
consumed = true;
141-
} else if(event.type == SceneManagerEventTypeTick) {
141+
} else if (event.type == SceneManagerEventTypeTick) {
142142
consumed = true;
143143
}
144-
FURI_LOG_T(WENDIGO_TAG, "----------\nEnd wendigo_scene_console_output_on_event()");
144+
FURI_LOG_T(WENDIGO_TAG, "End wendigo_scene_console_output_on_event()");
145145
return consumed;
146146
}
147147

148-
void wendigo_scene_console_output_on_exit(void* context) {
149-
FURI_LOG_T(WENDIGO_TAG, "Start wendigo_scene_console_output_on_exit()\n----------");
150-
WendigoApp* app = context;
148+
void wendigo_scene_console_output_on_exit(void *context) {
149+
FURI_LOG_T(WENDIGO_TAG, "Start wendigo_scene_console_output_on_exit()");
150+
WendigoApp *app = context;
151151

152152
// Unregister rx callback
153153
wendigo_uart_set_handle_rx_data_cb(app->uart, NULL);
154-
FURI_LOG_T(WENDIGO_TAG, "----------\nEnd wendigo_scene_console_output_on_exit()");
154+
FURI_LOG_T(WENDIGO_TAG, "End wendigo_scene_console_output_on_exit()");
155155
}

Flipper/scenes/wendigo_scene_device_detail.c

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,49 @@
44
wendigo_device *device = NULL;
55

66
void wendigo_scene_device_detail_set_device(wendigo_device *d) {
7-
FURI_LOG_T(WENDIGO_TAG, "Start wendigo_scene_device_detail_set_device()\n----------");
7+
FURI_LOG_T(WENDIGO_TAG, "Start wendigo_scene_device_detail_set_device()");
88
device = d;
9-
FURI_LOG_T(WENDIGO_TAG, "----------\nEnd wendigo_scene_device_detail_set_device()");
9+
FURI_LOG_T(WENDIGO_TAG, "End wendigo_scene_device_detail_set_device()");
1010
}
1111

12-
static void wendigo_scene_device_detail_var_list_enter_callback(void* context, uint32_t index) {
13-
FURI_LOG_T(WENDIGO_TAG, "Start wendigo_scene_device_detail_var_list_enter_callback()\n----------");
12+
static void wendigo_scene_device_detail_var_list_enter_callback(void *context, uint32_t index) {
13+
FURI_LOG_T(WENDIGO_TAG, "Start wendigo_scene_device_detail_var_list_enter_callback()");
1414
furi_assert(context);
15-
WendigoApp* app = context;
15+
WendigoApp *app = context;
1616

1717
// furi_assert(index < ((display_selected_only) ? bt_selected_devices_count : bt_devices_count));
1818

1919
UNUSED(app); UNUSED(index);
2020

2121
// TODO: something
2222

23-
FURI_LOG_T(WENDIGO_TAG, "----------\nEnd wendigo_scene_device_detail_var_list_enter_callback()");
23+
FURI_LOG_T(WENDIGO_TAG, "End wendigo_scene_device_detail_var_list_enter_callback()");
2424
}
2525

26-
static void wendigo_scene_device_detail_var_list_change_callback(VariableItem* item) {
27-
FURI_LOG_T(WENDIGO_TAG, "Start wendigo_scene_device_detail_var_list_change_callback()\n----------");
26+
static void wendigo_scene_device_detail_var_list_change_callback(VariableItem *item) {
27+
FURI_LOG_T(WENDIGO_TAG, "Start wendigo_scene_device_detail_var_list_change_callback()");
2828
furi_assert(item);
2929

30-
WendigoApp* app = variable_item_get_context(item);
30+
WendigoApp *app = variable_item_get_context(item);
3131
furi_assert(app);
3232

3333
uint8_t item_index = variable_item_get_current_value_index(item);
3434
UNUSED(item_index);
3535

36-
FURI_LOG_T(WENDIGO_TAG, "----------\nEnd wendigo_scene_device_detail_var_list_change_callback()");
36+
FURI_LOG_T(WENDIGO_TAG, "End wendigo_scene_device_detail_var_list_change_callback()");
3737
}
3838

39-
void wendigo_scene_device_detail_on_enter(void* context) {
40-
FURI_LOG_T(WENDIGO_TAG, "Start wendigo_scene_device_detail_on_enter()\n----------");
41-
WendigoApp* app = context;
42-
VariableItemList* var_item_list = app->detail_var_item_list;
39+
void wendigo_scene_device_detail_on_enter(void *context) {
40+
FURI_LOG_T(WENDIGO_TAG, "Start wendigo_scene_device_detail_on_enter()");
41+
WendigoApp *app = context;
42+
VariableItemList *var_item_list = app->detail_var_item_list;
4343
app->current_view = WendigoAppViewDeviceDetail;
4444

4545
variable_item_list_set_enter_callback(
4646
var_item_list, wendigo_scene_device_detail_var_list_enter_callback, app);
4747

4848
variable_item_list_reset(var_item_list);
49-
VariableItem* item;
49+
VariableItem *item;
5050
// TODO: Populate with device details
5151
item = variable_item_list_add(
5252
var_item_list,
@@ -60,16 +60,16 @@ void wendigo_scene_device_detail_on_enter(void* context) {
6060
var_item_list, scene_manager_get_scene_state(app->scene_manager, WendigoSceneDeviceDetail));
6161

6262
view_dispatcher_switch_to_view(app->view_dispatcher, WendigoAppViewDeviceDetail);
63-
FURI_LOG_T(WENDIGO_TAG, "----------\nEnd wendigo_scene_device_detail_on_enter()");
63+
FURI_LOG_T(WENDIGO_TAG, "End wendigo_scene_device_detail_on_enter()");
6464
}
6565

66-
bool wendigo_scene_device_detail_on_event(void* context, SceneManagerEvent event) {
67-
FURI_LOG_T(WENDIGO_TAG, "Start wendigo_scene_device_detail_on_event()\n----------");
68-
WendigoApp* app = context;
66+
bool wendigo_scene_device_detail_on_event(void *context, SceneManagerEvent event) {
67+
FURI_LOG_T(WENDIGO_TAG, "Start wendigo_scene_device_detail_on_event()");
68+
WendigoApp *app = context;
6969
bool consumed = false;
7070
UNUSED(app);
7171

72-
if(event.type == SceneManagerEventTypeCustom) {
72+
if (event.type == SceneManagerEventTypeCustom) {
7373
switch (event.event) {
7474
case Wendigo_EventListDevices:
7575
// scene_manager_set_scene_state(
@@ -81,18 +81,18 @@ bool wendigo_scene_device_detail_on_event(void* context, SceneManagerEvent event
8181
break;
8282
}
8383
consumed = true;
84-
} else if(event.type == SceneManagerEventTypeTick) {
84+
} else if (event.type == SceneManagerEventTypeTick) {
8585
// app->device_detail_selected_menu_index =
8686
// variable_item_list_get_selected_item_index(app->detail_var_item_list);
8787
consumed = true;
8888
}
89-
FURI_LOG_T(WENDIGO_TAG, "----------\nEnd wendigo_scene_device_detail_on_event()");
89+
FURI_LOG_T(WENDIGO_TAG, "End wendigo_scene_device_detail_on_event()");
9090
return consumed;
9191
}
9292

93-
void wendigo_scene_device_detail_on_exit(void* context) {
94-
FURI_LOG_T(WENDIGO_TAG, "Start wendigo_scene_device_detail_on_exit()\n----------");
95-
WendigoApp* app = context;
93+
void wendigo_scene_device_detail_on_exit(void *context) {
94+
FURI_LOG_T(WENDIGO_TAG, "Start wendigo_scene_device_detail_on_exit()");
95+
WendigoApp *app = context;
9696
variable_item_list_reset(app->detail_var_item_list);
97-
FURI_LOG_T(WENDIGO_TAG, "----------\nEnd wendigo_scene_device_detail_on_exit()");
97+
FURI_LOG_T(WENDIGO_TAG, "End wendigo_scene_device_detail_on_exit()");
9898
}

0 commit comments

Comments
 (0)