Skip to content
This repository has been archived by the owner on Jul 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1 from frux-c/init_fixes
Browse files Browse the repository at this point in the history
Init_fixes
  • Loading branch information
frux-c authored Aug 2, 2023
2 parents 4ac5b0f + fb2f25e commit 0102dc1
Show file tree
Hide file tree
Showing 15 changed files with 298 additions and 86 deletions.
22 changes: 15 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ This repository contains a UHF RFID application developed for FlipperZero, a ver

## Features

- [ ] Read UHF RFID tags.
- [x] Write UHF RFID tags.
- [x] Read UHF RFID tags.
- [ ] Write UHF RFID tags.
- [ ] Communicate with the YRM100 module to perform UHF RFID operations.
- [ ] Easy-to-use interface on FlipperZero's display.

Expand All @@ -22,8 +22,14 @@ To run this application on FlipperZero, you will need:

## Installation

1. Ensure you have set up your FlipperZero device with the YRM100 module properly.
2. Clone this repository to your FlipperZero using (add the specific instructions or link to the tool used for this).
1. Ensure you have set up your FlipperZero device with the YRM100 module properly. You can also read more about how to setup the module from the [Md5Stack Docs page](http://docs.m5stack.com/en/unit/uhf_rfid).
![wiring diagram](https://static-cdn.m5stack.com/resource/docs/products/unit/uhf_rfid/uhf_rfid_sch_01.webp)
2. Clone this repository to the `applications_user` folder of your flipper firmware of your choice
3. If you have VSCode setup with your flipper firmware.
- ### Windows
1. Press `Ctrl+Shift+B` on vscode while in the uhf_app folder
2. Select the `Launch App on Flipper` option. And watch as the app launches on your flipper
- If you don't have vscode setup you can use the cli command `./fbt COMPACT=1 DEBUG=0 launch APPSRC=applications_user\uhf_rfid`

## Usage

Expand All @@ -45,12 +51,14 @@ This project is licensed under the [MIT License](link_to_license_file). -->
- Use it at your own risk.
- I am not responsible for any damage or loss caused by the usage of this app.

## Extra Resources

- [MagicRF M100&QM100_Firmware_manual_en.pdf](assets/res/MagicRF_M100&QM100_Firmware_manual_en.pdf)

## Contact

For any inquiries or support, you can reach out to us at :

- Personal Email : [[email protected]](mailto:[email protected])
- Discord Server: [Flipper Zero Tutorial-Unoffical by @jamisonderek](https://discord.gg/REunuAnTX9)
- Discord User: [frux.c]()



Binary file not shown.
25 changes: 8 additions & 17 deletions scenes/uhf_scene_card_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,18 @@ enum SubmenuIndex {
SubmenuIndexChangeKey,
};

void uhf_scene_card_menu_submenu_callback(void* context, uint32_t index) {
UHFApp* uhf_app = context;
void uhf_scene_card_menu_submenu_callback(void* ctx, uint32_t index) {
UHFApp* uhf_app = ctx;
view_dispatcher_send_custom_event(uhf_app->view_dispatcher, index);
}

void uhf_scene_card_menu_on_enter(void* context) {
UHFApp* uhf_app = context;
void uhf_scene_card_menu_on_enter(void* ctx) {
UHFApp* uhf_app = ctx;

Submenu* submenu = uhf_app->submenu;

submenu_add_item(
submenu, "Save", SubmenuIndexSave, uhf_scene_card_menu_submenu_callback, uhf_app);
// if(picopass->dev->dev_data.pacs.record.valid) {
// submenu_add_item(
// submenu,
// "Save as LF",
// SubmenuIndexSaveAsLF,
// picopass_scene_card_menu_submenu_callback,
// picopass);
// }
submenu_add_item(
submenu,
"Change Key",
Expand All @@ -38,12 +30,11 @@ void uhf_scene_card_menu_on_enter(void* context) {
view_dispatcher_switch_to_view(uhf_app->view_dispatcher, UHFViewMenu);
}

bool uhf_scene_card_menu_on_event(void* context, SceneManagerEvent event) {
UHFApp* uhf_app = context;
bool uhf_scene_card_menu_on_event(void* ctx, SceneManagerEvent event) {
UHFApp* uhf_app = ctx;
bool consumed = false;

if(event.type == SceneManagerEventTypeCustom) {
FURI_LOG_E("LOG", "%lu", event.event);
if(event.event == SubmenuIndexSave) {
scene_manager_set_scene_state(
uhf_app->scene_manager, UHFSceneCardMenu, SubmenuIndexSave);
Expand All @@ -64,8 +55,8 @@ bool uhf_scene_card_menu_on_event(void* context, SceneManagerEvent event) {
return consumed;
}

void uhf_scene_card_menu_on_exit(void* context) {
UHFApp* uhf_app = context;
void uhf_scene_card_menu_on_exit(void* ctx) {
UHFApp* uhf_app = ctx;

submenu_reset(uhf_app->submenu);
}
1 change: 1 addition & 0 deletions scenes/uhf_scene_config.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ADD_SCENE(uhf, verify, Verify)
ADD_SCENE(uhf, start, Start)
ADD_SCENE(uhf, read_tag, ReadTag)
ADD_SCENE(uhf, read_tag_success, ReadTagSuccess)
Expand Down
5 changes: 2 additions & 3 deletions scenes/uhf_scene_read_tag.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ void uhf_read_tag_worker_callback(UHFWorkerEvent event, void* ctx) {
}

void uhf_scene_read_tag_on_enter(void* ctx) {
// FURI_LOG_E("33", "uhf_scene_read_tag_on_enter was called!");
UHFApp* uhf_app = ctx;
dolphin_deed(DolphinDeedNfcRead);

Expand All @@ -23,7 +22,8 @@ void uhf_scene_read_tag_on_enter(void* ctx) {

// Start worker
view_dispatcher_switch_to_view(uhf_app->view_dispatcher, UHFViewPopup);
uhf_worker_start(uhf_app->worker, UHFWorkerStateDetect, uhf_read_tag_worker_callback, uhf_app);
uhf_worker_start(
uhf_app->worker, UHFWorkerStateDetectSingle, uhf_read_tag_worker_callback, uhf_app);

uhf_blink_start(uhf_app);
}
Expand All @@ -33,7 +33,6 @@ bool uhf_scene_read_tag_on_event(void* ctx, SceneManagerEvent event) {
UHFApp* uhf_app = ctx;
bool consumed = false;
if(event.event == UHFCustomEventWorkerExit) {
FURI_LOG_E("uhf_scene_read_tag_on_event", "event was registered");
scene_manager_next_scene(uhf_app->scene_manager, UHFSceneReadTagSuccess);
consumed = true;
}
Expand Down
6 changes: 2 additions & 4 deletions scenes/uhf_scene_read_tag_success.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ void uhf_scene_read_card_success_widget_callback(GuiButtonType result, InputType
}

void uhf_scene_read_tag_success_on_enter(void* ctx) {
// UNUSED(ctx);
UHFApp* uhf_app = ctx;

const uint8_t* read_data = uhf_app->worker->data->data->data;
const uint8_t* read_data = uhf_app->worker->response_data->head->data;

widget_add_string_element(
uhf_app->widget, 32, 5, AlignLeft, AlignCenter, FontPrimary, "Read Success");
Expand Down Expand Up @@ -78,7 +77,6 @@ bool uhf_scene_read_tag_success_on_event(void* ctx, SceneManagerEvent event) {
UHFApp* uhf_app = ctx;
bool consumed = false;
if(event.event == SceneManagerEventTypeBack) {
// FURI_LOG_E("36", "Back button was pressed");
uhf_app->worker->state = UHFWorkerStateStop;
}
if(event.type == SceneManagerEventTypeCustom) {
Expand All @@ -101,7 +99,7 @@ void uhf_scene_read_tag_success_on_exit(void* ctx) {
UHFApp* uhf_app = ctx;

// // Stop worker
// uhf_worker_stop(uhf_app->worker);
uhf_worker_stop(uhf_app->worker);
// Clear view
popup_reset(uhf_app->popup);
// clear widget
Expand Down
4 changes: 2 additions & 2 deletions scenes/uhf_scene_save_name.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ void uhf_scene_save_name_on_enter(void* context) {

bool uhf_scene_save_name_on_event(void* context, SceneManagerEvent event) {
UHFApp* uhf_app = context;
UHFResponseData* uhf_data_save = uhf_app->worker->data;
UHFResponseData* uhf_data_save = uhf_app->worker->response_data;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == UHFCustomEventTextInputDone) {
if(uhf_save_data(uhf_data_save, uhf_app->storage, uhf_app->text_store)) {
if(uhf_save_read_data(uhf_data_save, uhf_app->storage, uhf_app->text_store)) {
scene_manager_next_scene(uhf_app->scene_manager, UHFSceneSaveSuccess);
consumed = true;
} else {
Expand Down
1 change: 0 additions & 1 deletion scenes/uhf_scene_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ bool uhf_scene_start_on_event(void* ctx, SceneManagerEvent event) {
UHFApp* uhf_app = ctx;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
// FURI_LOG_E("scene_start_on_event", "%lu", event.event);
if(event.event == SubmenuIndexRead) {
scene_manager_set_scene_state(uhf_app->scene_manager, UHFSceneStart, SubmenuIndexRead);
scene_manager_next_scene(uhf_app->scene_manager, UHFSceneReadTag);
Expand Down
147 changes: 147 additions & 0 deletions scenes/uhf_scene_verify.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
#include "../uhf_app_i.h"

bool verify_success = false;
FuriString* temp_str;

void uhf_scene_verify_callback_event(UHFWorkerEvent event, void* ctx) {
UNUSED(ctx);
UHFApp* uhf_app = ctx;
if(event == UHFWorkerEventSuccess) verify_success = true;

view_dispatcher_send_custom_event(uhf_app->view_dispatcher, UHFCustomEventVerifyDone);
}

void uhf_scene_verify_widget_callback(GuiButtonType result, InputType type, void* ctx) {
furi_assert(ctx);
UHFApp* uhf_app = ctx;

if(type == InputTypeShort) {
view_dispatcher_send_custom_event(uhf_app->view_dispatcher, result);
}
}

void uhf_scene_verify_on_enter(void* ctx) {
UHFApp* uhf_app = ctx;
uhf_worker_start(
uhf_app->worker, UHFWorkerStateVerify, uhf_scene_verify_callback_event, uhf_app);
temp_str = furi_string_alloc();
view_dispatcher_switch_to_view(uhf_app->view_dispatcher, UHFViewWidget);
}

bool uhf_scene_verify_on_event(void* ctx, SceneManagerEvent event) {
UHFApp* uhf_app = ctx;
bool consumed = false;
if(event.event == SceneManagerEventTypeBack) {
uhf_app->worker->state = UHFWorkerStateStop;
} else if(event.type == SceneManagerEventTypeCustom) {
if(event.event == GuiButtonTypeRight) {
scene_manager_next_scene(uhf_app->scene_manager, UHFSceneStart);
consumed = true;
} else if(event.event == GuiButtonTypeLeft) {
if(!verify_success) {
widget_reset(uhf_app->widget);
furi_string_reset(temp_str);
uhf_worker_stop(uhf_app->worker);
uhf_worker_start(
uhf_app->worker,
UHFWorkerStateVerify,
uhf_scene_verify_callback_event,
uhf_app);
}
} else if(event.event == UHFCustomEventVerifyDone) {
if(verify_success) {
widget_reset(uhf_app->widget);
furi_string_reset(temp_str);
UHFResponseData* uhf_response_data = uhf_app->worker->response_data;
UHFData* hardware_version = uhf_response_data_get_uhf_data(uhf_response_data, 0);
UHFData* software_version = uhf_response_data_get_uhf_data(uhf_response_data, 1);
UHFData* manufacturer = uhf_response_data_get_uhf_data(uhf_response_data, 2);
uint offset = 6;
widget_add_string_element(
uhf_app->widget, 64, 5, AlignCenter, AlignCenter, FontPrimary, "Module Info");
// hardware info
furi_string_cat_str(temp_str, "HW Version: ");
for(int i = 0; i < 10; i++) {
furi_string_cat_printf(temp_str, "%c", hardware_version->data[offset + i]);
}
widget_add_string_element(
uhf_app->widget,
1,
15,
AlignLeft,
AlignCenter,
FontSecondary,
furi_string_get_cstr(temp_str));
furi_string_reset(temp_str);
// software info
furi_string_cat_str(temp_str, "SW Version: ");
for(int i = 0; i < 10; i++) {
furi_string_cat_printf(temp_str, "%c", software_version->data[offset + i]);
}
widget_add_string_element(
uhf_app->widget,
1,
27,
AlignLeft,
AlignCenter,
FontSecondary,
furi_string_get_cstr(temp_str));
furi_string_reset(temp_str);
// manufacturer info
furi_string_cat_str(temp_str, "Manufacturer: ");
for(int i = 0; i < 10; i++) {
furi_string_cat_printf(temp_str, "%c", manufacturer->data[offset + i]);
}
widget_add_string_element(
uhf_app->widget,
1,
39,
AlignLeft,
AlignCenter,
FontSecondary,
furi_string_get_cstr(temp_str));

widget_add_button_element(
uhf_app->widget,
GuiButtonTypeRight,
"Continue",
uhf_scene_verify_widget_callback,
uhf_app);
} else {
widget_add_string_element(
uhf_app->widget,
64,
5,
AlignCenter,
AlignCenter,
FontPrimary,
"No UHF Module found");
widget_add_button_element(
uhf_app->widget,
GuiButtonTypeLeft,
"Retry",
uhf_scene_verify_widget_callback,
uhf_app);
widget_add_button_element(
uhf_app->widget,
GuiButtonTypeRight,
"Skip",
uhf_scene_verify_widget_callback,
uhf_app);
}
}
}
return consumed;
}

void uhf_scene_verify_on_exit(void* ctx) {
UHFApp* uhf_app = ctx;
// Clear string
furi_string_free(temp_str);
// Stop worker
uhf_worker_stop(uhf_app->worker);
// Clear view
// popup_reset(uhf_app->popup);
// clear widget
widget_reset(uhf_app->widget);
}
Loading

0 comments on commit 0102dc1

Please sign in to comment.