From a447120cbe2a67457ce3622022d285cae45dfa8c Mon Sep 17 00:00:00 2001 From: Philippe Bonnaz Date: Thu, 31 Aug 2023 13:36:44 +0200 Subject: [PATCH] Remove nfc tag customizatiopn with NDEF message New ifdef to activate feature if needed HAVE_NDEF_SUPPORT --- include/os_io_seproxyhal.h | 8 +++++++- lib_nfc/include/{nfc.h => nfc_ndef.h} | 0 lib_nfc/src/{nfc.c => nfc_ndef.c} | 6 ++++-- src/os_io_seproxyhal.c | 18 ++++++++++++++++-- 4 files changed, 27 insertions(+), 5 deletions(-) rename lib_nfc/include/{nfc.h => nfc_ndef.h} (100%) rename lib_nfc/src/{nfc.c => nfc_ndef.c} (98%) diff --git a/include/os_io_seproxyhal.h b/include/os_io_seproxyhal.h index 940cc1567..e43ce042a 100644 --- a/include/os_io_seproxyhal.h +++ b/include/os_io_seproxyhal.h @@ -31,7 +31,9 @@ #include "os_types.h" #ifdef HAVE_NFC -#include "nfc.h" +#ifdef HAVE_NDEF_SUPPORT +#include "nfc_ndef.h" +#endif #endif #ifdef HAVE_SERIALIZED_NBGL @@ -126,7 +128,11 @@ void io_seproxyhal_send_nbgl_serialized(nbgl_serialized_event_type_e event, nbgl void io_set_timeout(unsigned int timeout); #ifdef HAVE_NFC +#ifdef HAVE_NDEF_SUPPORT void io_seproxyhal_nfc_init(ndef_struct_t *ndef_message, bool async, bool forceInit); +#else // ! HAVE_NDEF_SUPPORT +void io_seproxyhal_nfc_init(bool forceInit); +#endif // HAVE_NDEF_SUPPORT #endif #ifdef HAVE_SE_TOUCH diff --git a/lib_nfc/include/nfc.h b/lib_nfc/include/nfc_ndef.h similarity index 100% rename from lib_nfc/include/nfc.h rename to lib_nfc/include/nfc_ndef.h diff --git a/lib_nfc/src/nfc.c b/lib_nfc/src/nfc_ndef.c similarity index 98% rename from lib_nfc/src/nfc.c rename to lib_nfc/src/nfc_ndef.c index 4ad1dec49..16579b5d6 100644 --- a/lib_nfc/src/nfc.c +++ b/lib_nfc/src/nfc_ndef.c @@ -1,5 +1,6 @@ #ifdef HAVE_NFC -#include "nfc.h" +#ifdef HAVE_NDEF_SUPPORT +#include "nfc_ndef.h" #include "string.h" #include "os_apdu.h" @@ -194,4 +195,5 @@ uint16_t os_ndef_to_string(ndef_struct_t *ndef_message, char * out_string) { } return tot_length; } -#endif +#endif // HAVE_NDEF_SUPPORT +#endif // HAVE_NFC diff --git a/src/os_io_seproxyhal.c b/src/os_io_seproxyhal.c index 11b9ab07a..65a48cc55 100644 --- a/src/os_io_seproxyhal.c +++ b/src/os_io_seproxyhal.c @@ -467,8 +467,11 @@ void io_seproxyhal_play_tune(tune_index_e tune_index) { #endif // HAVE_PIEZO_SOUND #ifdef HAVE_NFC -#include "nfc.h" +#ifdef HAVE_NDEF_SUPPORT + #include "nfc_ndef.h" +#endif +#ifdef HAVE_NDEF_SUPPORT /** * @brief Send a SEPH message to MCU to init NFC * @@ -497,7 +500,18 @@ void io_seproxyhal_nfc_init(ndef_struct_t *ndef_message, bool async, bool forceI io_seproxyhal_spi_send(buffer, 5); io_seproxyhal_spi_send(G_io_seproxyhal_spi_buffer, total_length-2); } -#endif +#else // ! HAVE_NDEF_SUPPORT +void io_seproxyhal_nfc_init(bool forceInit) { + uint8_t buffer[4]; + uint8_t is_nfc_enabled = forceInit?1:(os_setting_get(OS_SETTING_FEATURES, NULL, 0)&OS_SETTING_FEATURES_NFC_ENABLED); + buffer[0] = SEPROXYHAL_TAG_NFC_INIT; + buffer[1] = 0; + buffer[2] = 1; + buffer[3] = is_nfc_enabled; + io_seproxyhal_spi_send(buffer, 4); +} +#endif // HAVE_NDEF_SUPPORT +#endif // HAVE_NFC #ifdef HAVE_SE_TOUCH #ifdef HAVE_TOUCH_READ_DEBUG_DATA_SYSCALL