Read complete scene
Signed-off-by: Markus Birth <markus@birth-online.de>
This commit is contained in:
@@ -3,3 +3,6 @@ Sonicare Brush Head ID
|
||||
|
||||
NTAG213
|
||||
ISO 14443-3 (NFC-A)
|
||||
|
||||
|
||||
NFC Password algorithm by [atc1441](https://github.com/atc1441): https://gist.github.com/atc1441/41af75048e4c22af1f5f0d4c1d94bb56
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ App(
|
||||
apptype=FlipperAppType.EXTERNAL,
|
||||
entry_point="sonicare_app",
|
||||
stack_size=2 * 1024,
|
||||
fap_category="RFID",
|
||||
fap_category="NFC",
|
||||
# Optional values
|
||||
requires=["gui"],
|
||||
fap_version="0.1",
|
||||
|
||||
@@ -2,11 +2,14 @@
|
||||
#include "core/core_defines.h"
|
||||
#include "gui/scene_manager.h"
|
||||
#include "gui/view_dispatcher.h"
|
||||
#include "nfc/nfc.h"
|
||||
#include "nfc/nfc_scanner.h"
|
||||
#include "notification/notification.h"
|
||||
#include <nfc/nfc.h>
|
||||
#include <nfc/nfc_device.h>
|
||||
#include <nfc/nfc_scanner.h>
|
||||
#include <nfc/protocols/nfc_protocol.h>
|
||||
#include <nfc/protocols/iso14443_3a/iso14443_3a_poller.h>
|
||||
#include <nfc/protocols/mf_ultralight/mf_ultralight_poller.h>
|
||||
#include <notification/notification.h>
|
||||
#include <notification/notification_messages.h>
|
||||
#include <dolphin/dolphin.h>
|
||||
//#include <nfc/helpers/protocol_support/nfc_protocol_support_common.h>
|
||||
|
||||
@@ -28,6 +31,7 @@ NfcCommand nfc_scene_poller_callback(NfcGenericEvent event, void* context) {
|
||||
const Iso14443_3aPollerEvent* ev = event.event_data;
|
||||
|
||||
if (ev->type == Iso14443_3aPollerEventTypeReady) {
|
||||
nfc_device_set_data(app->nfc_device, NfcProtocolIso14443_3a, nfc_poller_get_data(app->poller));
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, NfcCustomEventWorkerExit);
|
||||
return NfcCommandStop;
|
||||
}
|
||||
@@ -47,6 +51,7 @@ void sonicare_scene_read_on_enter(void* context) {
|
||||
|
||||
//nfc_detected_protocols_reset(app->detected_protocols);
|
||||
app->nfc = nfc_alloc();
|
||||
app->nfc_device = nfc_device_alloc();
|
||||
// we probably don't need to "scan" but can instead directly "poll" for NTAG213 (ISO 14443-3a) data
|
||||
//app->scanner = nfc_scanner_alloc(app->nfc);
|
||||
//nfc_scanner_start(app->scanner, nfc_scene_detect_scan_callback, app);
|
||||
@@ -62,9 +67,11 @@ bool sonicare_scene_read_on_event(void* context, SceneManagerEvent event) {
|
||||
if (event.event == NfcCustomEventWorkerExit) {
|
||||
//if (nfc_detected_protocols_get_num(app->detected_protocols) > 1) {
|
||||
if (true) {
|
||||
notification_message(app->notifications, &sequence_single_vibro);
|
||||
//notification_message(app->notifications, &sequence_single_vibro);
|
||||
notification_message(app->notifications, &sequence_success);
|
||||
scene_manager_next_scene(app->scene_manager, SonicareSceneReadComplete);
|
||||
} else {
|
||||
notification_message(app->notifications, &sequence_error);
|
||||
scene_manager_next_scene(app->scene_manager, SonicareSceneReadComplete);
|
||||
}
|
||||
consumed = true;
|
||||
@@ -82,6 +89,7 @@ void sonicare_scene_read_on_exit(void* context) {
|
||||
nfc_poller_free(app->poller);
|
||||
//nfc_scanner_stop(app->scanner);
|
||||
//nfc_scanner_free(app->scanner);
|
||||
nfc_device_free(app->nfc_device);
|
||||
nfc_free(app->nfc);
|
||||
popup_reset(app->popup);
|
||||
}
|
||||
|
||||
@@ -1,24 +1,61 @@
|
||||
#include "../uk_mbirth_sonicare.h"
|
||||
#include "gui/canvas.h"
|
||||
#include "gui/modules/widget.h"
|
||||
#include "gui/modules/widget_elements/widget_element.h"
|
||||
#include "gui/scene_manager.h"
|
||||
#include "gui/view_dispatcher.h"
|
||||
#include <nfc/nfc_device.h>
|
||||
#include <nfc/protocols/nfc_protocol.h>
|
||||
#include <nfc/protocols/iso14443_3a/iso14443_3a.h>
|
||||
#include <uk_mbirth_sonicare_icons.h>
|
||||
#include <dolphin/dolphin.h>
|
||||
|
||||
void sonicare_scene_read_complete_widget_callback(GuiButtonType result, InputType type, void* context) {
|
||||
furi_assert(context);
|
||||
Sonicare* app = context;
|
||||
if (type == InputTypeShort) {
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, result);
|
||||
}
|
||||
}
|
||||
|
||||
void sonicare_scene_read_complete_on_enter(void* context) {
|
||||
Sonicare* app = context;
|
||||
Widget* widget = app->widget;
|
||||
|
||||
widget_reset(widget);
|
||||
|
||||
const NfcDevice* nfc_device = app->nfc_device;
|
||||
const Iso14443_3aData* nfc_data = nfc_device_get_data(nfc_device, NfcProtocolIso14443_3a);
|
||||
|
||||
widget_add_icon_element(widget, 128-17, 0, &I_sonicare_brush);
|
||||
widget_add_string_element(widget, 0, 0, AlignLeft, AlignTop, FontPrimary, "Sonicare Brush ID");
|
||||
widget_add_string_element(widget, 0, 12, AlignLeft, AlignTop, FontSecondary, "by mbirth.uk");
|
||||
widget_add_icon_element(widget, 8, 35, &I_sonicare_qr);
|
||||
UNUSED(nfc_data);
|
||||
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
|
||||
furi_string_cat_printf(temp_str, "\e#%s\n", nfc_device_get_name(nfc_device, NfcDeviceNameTypeFull));
|
||||
|
||||
widget_add_text_scroll_element(widget, 0, 0, 128, 64, furi_string_get_cstr(temp_str));
|
||||
|
||||
furi_string_free(temp_str);
|
||||
|
||||
widget_add_button_element(widget, GuiButtonTypeRight, "Change", sonicare_scene_read_complete_widget_callback, app);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SonicareViewWidget);
|
||||
}
|
||||
|
||||
bool sonicare_scene_read_complete_on_event(void* context, SceneManagerEvent event) {
|
||||
UNUSED(context);
|
||||
UNUSED(event);
|
||||
|
||||
bool consumed = false;
|
||||
|
||||
if (event.type == SceneManagerEventTypeCustom) {
|
||||
if (event.event == GuiButtonTypeRight) {
|
||||
// switch to edit screen
|
||||
consumed = true;
|
||||
}
|
||||
} else if (event.type == SceneManagerEventTypeBack) {
|
||||
// Back button pressed
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <nfc/nfc_poller.h>
|
||||
#include <nfc/nfc_scanner.h>
|
||||
#include <nfc/nfc_listener.h>
|
||||
#include <nfc/nfc_device.h>
|
||||
|
||||
typedef struct Sonicare Sonicare;
|
||||
|
||||
@@ -52,6 +53,7 @@ struct Sonicare {
|
||||
NfcPoller* poller;
|
||||
NfcScanner* scanner;
|
||||
NfcListener* listener;
|
||||
NfcDevice* nfc_device;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
@@ -62,6 +64,7 @@ typedef enum {
|
||||
SonicareViewTextInput,
|
||||
SonicareViewByteInput,
|
||||
SonicareViewRead,
|
||||
SonicareViewReadComplete,
|
||||
} SonicareView;
|
||||
|
||||
typedef enum {
|
||||
|
||||
Reference in New Issue
Block a user