Read Mifare Ultralight data

Signed-off-by: Markus Birth <markus@birth-online.de>
This commit is contained in:
2026-03-28 20:20:21 +00:00
parent eb72af76d8
commit 0d0d8d76b2
3 changed files with 24 additions and 9 deletions
+17 -5
View File
@@ -7,6 +7,7 @@
#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.h>
#include <nfc/protocols/mf_ultralight/mf_ultralight_poller.h>
#include <notification/notification.h>
#include <notification/notification_messages.h>
@@ -25,13 +26,23 @@ void nfc_scene_detect_scan_callback(NfcScannerEvent event, void* context) {
}
NfcCommand nfc_scene_poller_callback(NfcGenericEvent event, void* context) {
furi_assert(event.protocol == NfcProtocolIso14443_3a);
//furi_assert(event.protocol == NfcProtocolIso14443_3a);
furi_assert(event.protocol == NfcProtocolMfUltralight);
Sonicare* app = context;
const Iso14443_3aPollerEvent* ev = event.event_data;
//const Iso14443_3aPollerEvent* ev = event.event_data;
const MfUltralightPollerEvent* ev = event.event_data;
if (ev->type == Iso14443_3aPollerEventTypeReady) {
nfc_device_set_data(app->nfc_device, NfcProtocolIso14443_3a, nfc_poller_get_data(app->poller));
//if (ev->type == Iso14443_3aPollerEventTypeReady) {
if (ev->type == MfUltralightPollerEventTypeReadSuccess) {
FURI_LOG_I("sonicare_scene_read", "NFC Poller reports Read Success");
//nfc_device_set_data(app->nfc_device, NfcProtocolIso14443_3a, nfc_poller_get_data(app->poller));
nfc_device_set_data(app->nfc_device, NfcProtocolMfUltralight, nfc_poller_get_data(app->poller));
FURI_LOG_D("sonicare_scene_read", "Pulling Mifare Ultralight data from poller");
const MfUltralightData* ul_data = nfc_device_get_data(app->nfc_device, NfcProtocolMfUltralight);
app->nfc_data = ul_data;
FURI_LOG_I("sonicare_scene_read", "Dataset has %i of %i pages read from Mifare Ultralight", ul_data->pages_read, ul_data->pages_total);
view_dispatcher_send_custom_event(app->view_dispatcher, NfcCustomEventWorkerExit);
return NfcCommandStop;
}
@@ -55,7 +66,8 @@ void sonicare_scene_read_on_enter(void* context) {
// 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);
app->poller = nfc_poller_alloc(app->nfc, NfcProtocolIso14443_3a);
//app->poller = nfc_poller_alloc(app->nfc, NfcProtocolIso14443_3a);
app->poller = nfc_poller_alloc(app->nfc, NfcProtocolMfUltralight);
nfc_poller_start(app->poller, nfc_scene_poller_callback, app);
}
+5 -4
View File
@@ -7,6 +7,7 @@
#include <nfc/nfc_device.h>
#include <nfc/protocols/nfc_protocol.h>
#include <nfc/protocols/iso14443_3a/iso14443_3a.h>
#include "nfc/protocols/mf_ultralight/mf_ultralight.h"
#include <uk_mbirth_sonicare_icons.h>
#include <dolphin/dolphin.h>
@@ -25,14 +26,14 @@ void sonicare_scene_read_complete_on_enter(void* context) {
widget_reset(widget);
const NfcDevice* nfc_device = app->nfc_device;
const Iso14443_3aData* nfc_data = nfc_device_get_data(nfc_device, NfcProtocolIso14443_3a);
FURI_LOG_D("sonicare_scene_read_complete", "Pulling Mifare Ultralight data from NFC device");
const MfUltralightData* ul_data = app->nfc_data;
UNUSED(nfc_data);
UNUSED(ul_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);
@@ -53,7 +54,7 @@ bool sonicare_scene_read_complete_on_event(void* context, SceneManagerEvent even
}
} else if (event.type == SceneManagerEventTypeBack) {
// Back button pressed
consumed = true;
//consumed = true;
}
return consumed;
+2
View File
@@ -29,6 +29,7 @@
#include <nfc/nfc_scanner.h>
#include <nfc/nfc_listener.h>
#include <nfc/nfc_device.h>
#include <nfc/protocols/mf_ultralight/mf_ultralight.h>
typedef struct Sonicare Sonicare;
@@ -54,6 +55,7 @@ struct Sonicare {
NfcScanner* scanner;
NfcListener* listener;
NfcDevice* nfc_device;
const MfUltralightData* nfc_data;
};
typedef enum {