Skip to content

Commit

Permalink
upd findmyflipper
Browse files Browse the repository at this point in the history
  • Loading branch information
xMasterX committed May 1, 2024
1 parent 5ab0b9e commit e025802
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 23 deletions.
2 changes: 1 addition & 1 deletion base_pack/find_my_flipper/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ App(
fap_category="Bluetooth",
fap_author="@MatthewKuKanich",
fap_weburl="https://github.com/MatthewKuKanich/FindMyFlipper",
fap_version="3.0",
fap_version="3.5",
fap_description="BLE FindMy Location Beacon",
)
12 changes: 6 additions & 6 deletions base_pack/find_my_flipper/findmy_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,17 @@ bool findmy_state_load(FindMyState* out_state) {
if(!flipper_format_read_uint32(file, "transmit_power", &tmp, 1)) break;
state.transmit_power = tmp;

if(!flipper_format_read_bool(file, "show_mac", &state.show_mac, 1)) {
// Support migrating from old config
state.show_mac = false;
if(!flipper_format_read_uint32(file, "tag_type", &tmp, 1)) {
tmp = FindMyTypeApple;
flipper_format_rewind(file);
}
state.tag_type = tmp;

if(!flipper_format_read_uint32(file, "tag_type", &tmp, 1)) {
if(!flipper_format_read_bool(file, "show_mac", &state.show_mac, 1)) {
// Support migrating from old config
tmp = FindMyTypeApple;
state.show_mac = false;
flipper_format_rewind(file);
}
state.tag_type = tmp;

if(!flipper_format_read_hex(file, "mac", state.mac, sizeof(state.mac))) break;

Expand Down Expand Up @@ -162,6 +161,7 @@ void findmy_state_save(FindMyState* state) {
if(!flipper_format_write_uint32(file, "transmit_power", &tmp, 1)) break;

tmp = state->tag_type;
FURI_LOG_E("tag_type at save", "%ld", tmp);
if(!flipper_format_write_uint32(file, "tag_type", &tmp, 1)) break;

if(!flipper_format_write_bool(file, "show_mac", &state->show_mac, 1)) break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ void findmy_scene_config_import_result_on_enter(void* context) {
popup_set_timeout(popup, 1500);
popup_set_context(popup, app);
popup_set_callback(popup, findmy_scene_config_import_result_callback);
findmy_main_update_active(app->findmy_main, furi_hal_bt_extra_beacon_is_active());
findmy_main_update_mac(app->findmy_main, app->state.mac);
findmy_main_update_type(app->findmy_main, app->state.tag_type);

view_dispatcher_switch_to_view(app->view_dispatcher, FindMyViewPopup);
}

Expand Down
33 changes: 20 additions & 13 deletions base_pack/find_my_flipper/scenes/findmy_scene_main.c
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
#include "../findmy_i.h"

void findmy_scene_main_callback(FindMyMainEvent event, void* context) {
void findmy_scene_main_callback(FindMyMainEvent event, void *context)
{
furi_assert(context);
FindMy* app = context;
FindMy *app = context;
view_dispatcher_send_custom_event(app->view_dispatcher, event);
}

void findmy_scene_main_on_enter(void* context) {
FindMy* app = context;
void findmy_scene_main_on_enter(void *context)
{
FindMy *app = context;

findmy_main_set_callback(app->findmy_main, findmy_scene_main_callback, app);

view_dispatcher_switch_to_view(app->view_dispatcher, FindMyViewMain);
}

bool findmy_scene_main_on_event(void* context, SceneManagerEvent event) {
FindMy* app = context;
bool findmy_scene_main_on_event(void *context, SceneManagerEvent event)
{
FindMy *app = context;
bool consumed = false;

if(event.type == SceneManagerEventTypeCustom) {
if (event.type == SceneManagerEventTypeCustom)
{
consumed = true;
switch(event.event) {
switch (event.event)
{
case FindMyMainEventToggle:
findmy_toggle_beacon(app);
break;
case FindMyMainEventBackground:
app->state.beacon_active = true;
findmy_state_save(&app->state);
if(!furi_hal_bt_extra_beacon_is_active()) {
if (!furi_hal_bt_extra_beacon_is_active())
{
furi_check(furi_hal_bt_extra_beacon_start());
}
view_dispatcher_stop(app->view_dispatcher);
Expand All @@ -44,7 +49,8 @@ bool findmy_scene_main_on_event(void* context, SceneManagerEvent event) {
case FindMyMainEventQuit:
app->state.beacon_active = false;
findmy_state_save(&app->state);
if(furi_hal_bt_extra_beacon_is_active()) {
if (furi_hal_bt_extra_beacon_is_active())
{
furi_check(furi_hal_bt_extra_beacon_stop());
}
break;
Expand All @@ -57,7 +63,8 @@ bool findmy_scene_main_on_event(void* context, SceneManagerEvent event) {
return consumed;
}

void findmy_scene_main_on_exit(void* context) {
FindMy* app = context;
void findmy_scene_main_on_exit(void *context)
{
FindMy *app = context;
UNUSED(app);
}

0 comments on commit e025802

Please sign in to comment.