1818#include <zephyr/bluetooth/conn.h>
1919#include <zephyr/bluetooth/hci.h>
2020
21+ #if !IS_ENABLED (CONFIG_BT_POWER_PROFILING_NFC_DISABLED )
2122#include <nfc_t2t_lib.h>
22-
23+ #endif /* !IS_ENABLED(CONFIG_BT_POWER_PROFILING_NFC_DISABLED) */
2324#include <nfc/ndef/msg.h>
2425#include <nfc/ndef/record.h>
2526#include <nfc/ndef/ch.h>
5859
5960#define NFC_BUFFER_SIZE 1024
6061
62+
6163static struct bt_le_oob oob_local ;
6264static uint8_t tk_local [NFC_NDEF_LE_OOB_REC_TK_LEN ];
65+ #if !IS_ENABLED (CONFIG_BT_POWER_PROFILING_NFC_DISABLED )
6366static uint8_t nfc_buffer [NFC_BUFFER_SIZE ];
67+ static void adv_work_handler (struct k_work * work );
68+ static K_WORK_DEFINE (adv_work , adv_work_handler ) ;
69+ #endif /* !IS_ENABLED(CONFIG_BT_POWER_PROFILING_NFC_DISABLED) */
6470
6571static struct bt_le_ext_adv * adv_set ;
6672
6773static void system_off_work_handler (struct k_work * work );
6874static void key_generation_work_handler (struct k_work * work );
69- static void adv_work_handler (struct k_work * work );
7075static void notify_work_handler (struct k_work * work );
7176static void notify_timeout_handler (struct k_work * work );
7277
7378static K_WORK_DELAYABLE_DEFINE (system_off_work , system_off_work_handler ) ;
7479static K_WORK_DEFINE (key_generate_work , key_generation_work_handler ) ;
75- static K_WORK_DEFINE (adv_work , adv_work_handler ) ;
7680static K_WORK_DELAYABLE_DEFINE (notify_work , notify_work_handler ) ;
7781static K_WORK_DELAYABLE_DEFINE (notify_timeout , notify_timeout_handler ) ;
7882
@@ -149,6 +153,7 @@ static int set_led_off(uint8_t led_idx)
149153 }
150154}
151155
156+ #if !IS_ENABLED (CONFIG_BT_POWER_PROFILING_NFC_DISABLED )
152157static void nfc_callback (void * context , nfc_t2t_event_t event , const uint8_t * data ,
153158 size_t data_length )
154159{
@@ -184,6 +189,7 @@ static void nfc_callback(void *context, nfc_t2t_event_t event, const uint8_t *da
184189 break ;
185190 }
186191}
192+ #endif /* !IS_ENABLED(CONFIG_BT_POWER_PROFILING_NFC_DISABLED) */
187193
188194static void connected (struct bt_conn * conn , uint8_t conn_err )
189195{
@@ -486,6 +492,7 @@ static void key_generation_work_handler(struct k_work *work)
486492 pairing_key_generate ();
487493}
488494
495+ #if !IS_ENABLED (CONFIG_BT_POWER_PROFILING_NFC_DISABLED )
489496static void adv_work_handler (struct k_work * work )
490497{
491498 int err ;
@@ -518,6 +525,7 @@ static void adv_work_handler(struct k_work *work)
518525 printk ("Connectable advertising started\n" );
519526 }
520527}
528+ #endif /* !IS_ENABLED(CONFIG_BT_POWER_PROFILING_NFC_DISABLED) */
521529
522530static void notify_work_handler (struct k_work * work )
523531{
@@ -559,6 +567,7 @@ static void notify_timeout_handler(struct k_work *work)
559567 }
560568}
561569
570+ #if !IS_ENABLED (CONFIG_BT_POWER_PROFILING_NFC_DISABLED )
562571static int nfc_oob_data_setup (size_t * size )
563572{
564573 static const uint8_t ndef_record_count = 2 ;
@@ -599,9 +608,11 @@ static int nfc_oob_data_setup(size_t *size)
599608
600609 return nfc_ndef_msg_encode (& NFC_NDEF_MSG (ndef_msg ), nfc_buffer , size );
601610}
611+ #endif /* !IS_ENABLED(CONFIG_BT_POWER_PROFILING_NFC_DISABLED) */
602612
603613static int nfc_init (void )
604614{
615+ #if !IS_ENABLED (CONFIG_BT_POWER_PROFILING_NFC_DISABLED )
605616 int err ;
606617 size_t nfc_buffer_size = sizeof (nfc_buffer );
607618
@@ -629,6 +640,9 @@ static int nfc_init(void)
629640 }
630641
631642 return err ;
643+ #else
644+ return 0 ;
645+ #endif /* !IS_ENABLED(CONFIG_BT_POWER_PROFILING_NFC_DISABLED) */
632646}
633647
634648static void reset_reason_print (void )
@@ -637,10 +651,12 @@ static void reset_reason_print(void)
637651
638652 reason = nrfx_reset_reason_get ();
639653
640- if (reason & NRFX_RESET_REASON_NFC_MASK ) {
641- printk ("Wake up by NFC field detected\n" );
642- } else if (reason & NRFX_RESET_REASON_OFF_MASK ) {
654+ if (reason & NRFX_RESET_REASON_OFF_MASK ) {
643655 printk ("Wake up by the advertising start buttons\n" );
656+ #if !IS_ENABLED (CONFIG_BT_POWER_PROFILING_NFC_DISABLED )
657+ } else if (reason & NRFX_RESET_REASON_NFC_MASK ) {
658+ printk ("Wake up by NFC field detected\n" );
659+ #endif /* !IS_ENABLED(CONFIG_BT_POWER_PROFILING_NFC_DISABLED) */
644660#if defined(NRF_RESETINFO )
645661 } else if (reason & NRFX_RESET_REASON_LOCAL_SREQ_MASK ) {
646662 printk ("Application soft reset detected\n" );
@@ -774,7 +790,7 @@ int main(void)
774790 return 0 ;
775791 }
776792
777- if (!IS_ENABLED (BT_POWER_PROFILING_NFC_DISABLED )) {
793+ if (!IS_ENABLED (CONFIG_BT_POWER_PROFILING_NFC_DISABLED )) {
778794 err = nfc_init ();
779795 if (err ) {
780796 printk ("Failed to initialize NFC (err %d)\n" , err );
0 commit comments