Show UID and serial#
Signed-off-by: Markus Birth <markus@birth-online.de>
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
#include "../uk_mbirth_sonicare.h"
|
||||
#include "core/core_defines.h"
|
||||
#include "gui/scene_manager.h"
|
||||
#include "gui/view_dispatcher.h"
|
||||
#include <nfc/nfc.h>
|
||||
@@ -36,11 +35,11 @@ NfcCommand nfc_scene_poller_callback(NfcGenericEvent event, void* context) {
|
||||
//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;
|
||||
|
||||
mf_ultralight_copy(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);
|
||||
|
||||
@@ -11,6 +11,13 @@
|
||||
#include <uk_mbirth_sonicare_icons.h>
|
||||
#include <dolphin/dolphin.h>
|
||||
|
||||
|
||||
void format_bytes(FuriString* str, const uint8_t* data, size_t size) {
|
||||
for(size_t i = 0; i < size; i++) {
|
||||
furi_string_cat_printf(str, " %02X", data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void sonicare_scene_read_complete_widget_callback(GuiButtonType result, InputType type, void* context) {
|
||||
furi_assert(context);
|
||||
Sonicare* app = context;
|
||||
@@ -29,14 +36,24 @@ void sonicare_scene_read_complete_on_enter(void* context) {
|
||||
FURI_LOG_D("sonicare_scene_read_complete", "Pulling Mifare Ultralight data from NFC device");
|
||||
const MfUltralightData* ul_data = app->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));
|
||||
furi_string_cat_printf(temp_str, "UID:");
|
||||
format_bytes(temp_str, ul_data->iso14443_3a_data->uid, ul_data->iso14443_3a_data->uid_len);
|
||||
furi_string_cat_printf(temp_str, "\n");
|
||||
|
||||
furi_string_cat_str(temp_str, "Ser#: ");
|
||||
FuriString* serial_no = furi_string_alloc();
|
||||
furi_string_cat_str(serial_no, (char*)(ul_data->page[0x21].data));
|
||||
// furi_string_right(serial_no, 10);
|
||||
|
||||
furi_string_cat(temp_str, serial_no);
|
||||
|
||||
widget_add_text_scroll_element(widget, 0, 0, 128, 64, furi_string_get_cstr(temp_str));
|
||||
|
||||
furi_string_free(temp_str);
|
||||
furi_string_free(serial_no);
|
||||
|
||||
widget_add_button_element(widget, GuiButtonTypeRight, "Change", sonicare_scene_read_complete_widget_callback, app);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SonicareViewWidget);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "uk_mbirth_sonicare.h"
|
||||
#include <nfc/protocols/mf_ultralight/mf_ultralight.h>
|
||||
#include <dolphin/dolphin.h>
|
||||
|
||||
/* generated by fbt from .png files in images folder */
|
||||
@@ -47,11 +48,15 @@ static Sonicare* sonicare_alloc(void) {
|
||||
app->popup = popup_alloc();
|
||||
view_dispatcher_add_view(app->view_dispatcher, SonicareViewPopup, popup_get_view(app->popup));
|
||||
|
||||
app->nfc_data = mf_ultralight_alloc();
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
static void sonicare_free(Sonicare* app) {
|
||||
furi_assert(app);
|
||||
|
||||
mf_ultralight_free(app->nfc_data);
|
||||
|
||||
// Popup
|
||||
view_dispatcher_remove_view(app->view_dispatcher, SonicareViewPopup);
|
||||
|
||||
@@ -55,7 +55,7 @@ struct Sonicare {
|
||||
NfcScanner* scanner;
|
||||
NfcListener* listener;
|
||||
NfcDevice* nfc_device;
|
||||
const MfUltralightData* nfc_data;
|
||||
MfUltralightData* nfc_data;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
|
||||
Reference in New Issue
Block a user