@@ -1,17 +1,13 @@
|
||||
#include "../uk_mbirth_sonicare.h"
|
||||
#include "gui/scene_manager.h"
|
||||
#include "gui/view_dispatcher.h"
|
||||
#include <gui/scene_manager.h>
|
||||
#include <gui/view_dispatcher.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.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>
|
||||
|
||||
void nfc_scene_detect_scan_callback(NfcScannerEvent event, void* context) {
|
||||
furi_assert(context);
|
||||
@@ -25,14 +21,10 @@ 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 == NfcProtocolMfUltralight);
|
||||
|
||||
Sonicare* app = context;
|
||||
//const Iso14443_3aPollerEvent* ev = event.event_data;
|
||||
|
||||
const MfUltralightPollerEvent* ev = event.event_data;
|
||||
|
||||
//if (ev->type == Iso14443_3aPollerEventTypeReady) {
|
||||
if (event.protocol == NfcProtocolMfUltralight && ev->type == MfUltralightPollerEventTypeReadSuccess) {
|
||||
FURI_LOG_I("sonicare_scene_read", "NFC Poller reports Read Success");
|
||||
nfc_device_set_data(app->nfc_device, NfcProtocolMfUltralight, nfc_poller_get_data(app->poller));
|
||||
@@ -63,13 +55,6 @@ void sonicare_scene_read_on_enter(void* context) {
|
||||
//popup_set_icon(app->popup, 0, 8, &I_NFC_manual_60x50);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SonicareViewPopup);
|
||||
|
||||
//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);
|
||||
//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);
|
||||
}
|
||||
@@ -80,7 +65,6 @@ bool sonicare_scene_read_on_event(void* context, SceneManagerEvent event) {
|
||||
|
||||
if (event.type == SceneManagerEventTypeCustom) {
|
||||
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_success);
|
||||
@@ -102,9 +86,5 @@ void sonicare_scene_read_on_exit(void* context) {
|
||||
|
||||
nfc_poller_stop(app->poller);
|
||||
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,15 +1,10 @@
|
||||
#include "../uk_mbirth_sonicare.h"
|
||||
#include "../sonicare_password.h"
|
||||
#include "core/string.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 <nfc/protocols/mf_ultralight/mf_ultralight.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 <uk_mbirth_sonicare_icons.h>
|
||||
#include <dolphin/dolphin.h>
|
||||
|
||||
@@ -90,7 +85,7 @@ void sonicare_scene_read_complete_on_enter(void* context) {
|
||||
|
||||
// NFC password
|
||||
uint32_t unlock_pwd_big = get_sonicare_password((uint8_t*)ul_data->iso14443_3a_data->uid, (uint8_t*)furi_string_get_cstr(serial_no));
|
||||
FURI_LOG_D("sonicare_scene_read_complete", "NFC unlock password: %04lx", unlock_pwd_big);
|
||||
FURI_LOG_D("sonicare_scene_read_complete", "NFC unlock password: 0x%08lx", unlock_pwd_big);
|
||||
uint8_t unlock_pwd[4];
|
||||
memcpy(unlock_pwd, &unlock_pwd_big, sizeof(unlock_pwd_big));
|
||||
furi_string_cat_printf(temp_str, "NFC pwd:");
|
||||
@@ -103,7 +98,7 @@ void sonicare_scene_read_complete_on_enter(void* context) {
|
||||
furi_string_free(temp_str);
|
||||
furi_string_free(serial_no);
|
||||
|
||||
widget_add_button_element(widget, GuiButtonTypeRight, "Change", sonicare_scene_read_complete_widget_callback, app);
|
||||
// TODO: widget_add_button_element(widget, GuiButtonTypeRight, "Change", sonicare_scene_read_complete_widget_callback, app);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SonicareViewWidget);
|
||||
}
|
||||
|
||||
|
||||
+6
-7
@@ -1,8 +1,7 @@
|
||||
// Thanks to atc1441
|
||||
// https://gist.github.com/atc1441/41af75048e4c22af1f5f0d4c1d94bb56
|
||||
|
||||
#include "uk_mbirth_sonicare.h"
|
||||
#include <dolphin/dolphin.h>
|
||||
#include <furi.h>
|
||||
|
||||
uint16_t CRC16(uint16_t crc, uint8_t *buffer, int len) // Default CRC16 Algo
|
||||
{
|
||||
@@ -27,19 +26,19 @@ uint16_t CRC16(uint16_t crc, uint8_t *buffer, int len) // Default CRC16 Algo
|
||||
|
||||
uint32_t get_sonicare_password(uint8_t nfctag_uid[], uint8_t nfc_second[]) {
|
||||
for (uint16_t i=0; i<7; i++) {
|
||||
FURI_LOG_D("sonicare_password", "Input UID byte %i: %02x", i, nfctag_uid[i]);
|
||||
FURI_LOG_D("sonicare_password", "Input UID byte %i: 0x%02x", i, nfctag_uid[i]);
|
||||
}
|
||||
for (uint16_t i=0; i<10; i++) {
|
||||
FURI_LOG_D("sonicare_password", "Input MFG byte %i: %02x", i, nfc_second[i]);
|
||||
FURI_LOG_D("sonicare_password", "Input MFG byte %i: 0x%02x", i, nfc_second[i]);
|
||||
}
|
||||
uint32_t crc_calc = CRC16(0x49A3, nfctag_uid, 7); // Calculate the NTAG UID CRC
|
||||
FURI_LOG_D("sonicare_password", "CRC16 of UID: %04lx", crc_calc);
|
||||
FURI_LOG_D("sonicare_password", "CRC16 of UID: 0x%08lx", crc_calc);
|
||||
|
||||
crc_calc = crc_calc | (CRC16(crc_calc, nfc_second, 10) << 16); // Calculate the MFG CRC
|
||||
FURI_LOG_D("sonicare_password", "CRC16 with MFG: %04lx", crc_calc);
|
||||
FURI_LOG_D("sonicare_password", "CRC16 with MFG: 0x%08lx", crc_calc);
|
||||
|
||||
crc_calc = ((crc_calc >> 8) & 0x00FF00FF) | ((crc_calc << 8) & 0xFF00FF00); // Rotate the uin16_t bytes
|
||||
FURI_LOG_D("sonicare_password", "Final CRC16: %04lx", crc_calc);
|
||||
FURI_LOG_D("sonicare_password", "Final NFC password: 0x%08lx", crc_calc);
|
||||
|
||||
return crc_calc;
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
#include <dolphin/dolphin.h>
|
||||
#include <furi.h>
|
||||
|
||||
uint32_t get_sonicare_password(uint8_t nfctag_uid[], uint8_t nfc_second[]);
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include "uk_mbirth_sonicare.h"
|
||||
#include "nfc/nfc.h"
|
||||
#include "nfc/nfc_device.h"
|
||||
#include <nfc/protocols/mf_ultralight/mf_ultralight.h>
|
||||
#include <dolphin/dolphin.h>
|
||||
|
||||
@@ -48,6 +50,9 @@ static Sonicare* sonicare_alloc(void) {
|
||||
app->popup = popup_alloc();
|
||||
view_dispatcher_add_view(app->view_dispatcher, SonicareViewPopup, popup_get_view(app->popup));
|
||||
|
||||
// NFC
|
||||
app->nfc = nfc_alloc();
|
||||
app->nfc_device = nfc_device_alloc();
|
||||
app->nfc_data = mf_ultralight_alloc();
|
||||
|
||||
return app;
|
||||
@@ -56,7 +61,10 @@ static Sonicare* sonicare_alloc(void) {
|
||||
static void sonicare_free(Sonicare* app) {
|
||||
furi_assert(app);
|
||||
|
||||
// NFC
|
||||
mf_ultralight_free(app->nfc_data);
|
||||
nfc_device_free(app->nfc_device);
|
||||
nfc_free(app->nfc);
|
||||
|
||||
// Popup
|
||||
view_dispatcher_remove_view(app->view_dispatcher, SonicareViewPopup);
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include "scenes/sonicare_scene.h"
|
||||
|
||||
#include <nfc/nfc_poller.h>
|
||||
#include <nfc/nfc_scanner.h>
|
||||
#include <nfc/nfc_listener.h>
|
||||
#include <nfc/nfc_device.h>
|
||||
#include <nfc/protocols/mf_ultralight/mf_ultralight.h>
|
||||
@@ -52,7 +51,6 @@ struct Sonicare {
|
||||
// NFC
|
||||
Nfc* nfc;
|
||||
NfcPoller* poller;
|
||||
NfcScanner* scanner;
|
||||
NfcListener* listener;
|
||||
NfcDevice* nfc_device;
|
||||
MfUltralightData* nfc_data;
|
||||
|
||||
Reference in New Issue
Block a user