Skip to content

Commit

Permalink
add method to retrieve PN532 version
Browse files Browse the repository at this point in the history
  • Loading branch information
andreock committed Jan 2, 2025
1 parent cd532e4 commit 7bb78db
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/UI/navigation/NFC/NFCNavigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,19 @@ void init_nfc_navigation(Gui *_gui) {
}
nfc_initialized = true;
}
}

String get_current_pn532_version() {
String version = "";
#ifndef LILYGO_T_EMBED_CC1101
// Already initialized in setup
Wire.begin(PN532_SDA, PN532_SCL);
#endif
nfc_attacks = new NFCAttacks();
if(nfc_attacks->begin()) {
uint32_t nfc_version = nfc_attacks->get_version();
version = (String)((nfc_version>>16) & 0xFF) + "." + ((nfc_version>>8) & 0xFF);
}
nfc_attacks->power_down();
return version;
}
1 change: 1 addition & 0 deletions lib/UI/navigation/NFC/NFCNavigation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@ void goto_nfc_polling_result_gui(uint8_t *uid, uint8_t len,
const char *tag_name);
void felica_dump();
void nfc_cleanup();
String get_current_pn532_version();
#endif
6 changes: 6 additions & 0 deletions lib/UI/navigation/navigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "SubGHZ/SubGHZNavigation.hpp"
#include "buttons/btn_routines.hpp"
#include "gui.hpp"
#include "Settings/SettingsNavigation.hpp"
#include "wifi/wifi_navigation.hpp"

static Gui *gui;
Expand Down Expand Up @@ -62,6 +63,11 @@ void init_ir_ui() {
goto_ir_gui();
}

void init_settings_ui() {
init_settings_navigation(gui);
goto_settings_ui();
}

/*
ISR routines should be short, since display is slow,
we use a task to control display element selection
Expand Down
1 change: 1 addition & 0 deletions lib/UI/navigation/navigation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ void init_nfc_ui();

void init_ir_ui();

void init_settings_ui();
#endif
3 changes: 3 additions & 0 deletions lib/nfc_attacks/nfc_attacks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ class NFCAttacks {
~NFCAttacks() {};
bool begin();
void power_down() {nfc_framework.power_down();};
uint32_t get_version() {
return nfc_framework.get_version();
}
bool bruteforce();
void read_uid(uint8_t *uid, uint8_t *uid_length);
void read_uid(uint8_t *uid, uint8_t *uid_length, uint16_t *atqa,
Expand Down

0 comments on commit 7bb78db

Please sign in to comment.