|
|
@@ -1,17 +1,13 @@
|
|
|
#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;
|
|
|
- // FURI_LOG_E("verify", "UHFWorkerEventSuccess");
|
|
|
- // FURI_LOG_E("verify", "%d", verify_success);
|
|
|
- } else {
|
|
|
- // FURI_LOG_E("verify", "UHFWorkerEventFail");
|
|
|
- }
|
|
|
+ if(event == UHFWorkerEventSuccess) verify_success = true;
|
|
|
+
|
|
|
view_dispatcher_send_custom_event(uhf_app->view_dispatcher, UHFCustomEventVerifyDone);
|
|
|
}
|
|
|
|
|
|
@@ -28,6 +24,8 @@ 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) {
|
|
|
@@ -39,35 +37,76 @@ bool uhf_scene_verify_on_event(void* ctx, SceneManagerEvent event) {
|
|
|
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) {
|
|
|
- // FuriString* temp_str = furi_string_alloc();
|
|
|
- // UHFResponseData* response_data = uhf_app->worker->data;
|
|
|
- // UHFData* software_version = uhf_response_data_get_uhf_data(response_data, 0);
|
|
|
-
|
|
|
+ widget_reset(uhf_app->widget);
|
|
|
+ furi_string_reset(temp_str);
|
|
|
+ UHFResponseData* response_data = uhf_app->worker->data;
|
|
|
+ UHFData* hardware_version = uhf_response_data_get_uhf_data(response_data, 0);
|
|
|
+ UHFData* software_version = uhf_response_data_get_uhf_data(response_data, 1);
|
|
|
+ UHFData* manufacturer = uhf_response_data_get_uhf_data(response_data, 2);
|
|
|
+ uint offset = 6;
|
|
|
widget_add_string_element(
|
|
|
uhf_app->widget, 64, 5, AlignCenter, AlignCenter, FontPrimary, "Module Info");
|
|
|
- // furi_string_cat_str(temp_str, "Software Version: ");
|
|
|
- // for(int i = 0; i < 10; i++) {
|
|
|
- // furi_string_cat_printf(temp_str, "%c ", software_version->data[6 + i]);
|
|
|
- // }
|
|
|
- // widget_add_string_element(
|
|
|
- // uhf_app->widget,
|
|
|
- // 3,
|
|
|
- // 10,
|
|
|
- // AlignLeft,
|
|
|
- // AlignBottom,
|
|
|
- // FontSecondary,
|
|
|
- // furi_string_get_cstr(temp_str));
|
|
|
+ // 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, 64, 5, AlignCenter, AlignCenter, FontPrimary, "Module Info");
|
|
|
+ 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);
|
|
|
- // furi_string_free(temp_str);
|
|
|
} else {
|
|
|
widget_add_string_element(
|
|
|
uhf_app->widget,
|
|
|
@@ -77,6 +116,18 @@ bool uhf_scene_verify_on_event(void* ctx, SceneManagerEvent event) {
|
|
|
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);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -85,9 +136,11 @@ bool uhf_scene_verify_on_event(void* ctx, SceneManagerEvent event) {
|
|
|
|
|
|
void uhf_scene_verify_on_exit(void* ctx) {
|
|
|
UHFApp* uhf_app = ctx;
|
|
|
- // // Stop worker
|
|
|
+ // Clear string
|
|
|
+ furi_string_free(temp_str);
|
|
|
+ // Stop worker
|
|
|
uhf_worker_stop(uhf_app->worker);
|
|
|
- // // Clear view
|
|
|
+ // Clear view
|
|
|
// popup_reset(uhf_app->popup);
|
|
|
// clear widget
|
|
|
widget_reset(uhf_app->widget);
|