Mbed OS Reference
Loading...
Searching...
No Matches
NFCController Class Reference

This class represents a NFC Controller. More...

#include <NFCController.h>

Inheritance diagram for NFCController:
NFCControllerDriver::Delegate

Data Structures

struct  Delegate
 The NFCController delegate. More...
 

Public Member Functions

 NFCController (NFCControllerDriver *driver, events::EventQueue *queue, const Span< uint8_t > &ndef_buffer)
 Construct a NFCController instance. More...
 
nfc_err_t initialize ()
 Initialize the NFC controller. More...
 
void set_delegate (Delegate *delegate)
 Set the delegate that will receive events generated by this controller. More...
 
nfc_rf_protocols_bitmask_t get_supported_rf_protocols () const
 Get the list of RF protocols supported by this controller. More...
 
nfc_err_t configure_rf_protocols (nfc_rf_protocols_bitmask_t rf_protocols)
 Set the list of RF protocols to look for during discovery. More...
 
nfc_err_t start_discovery ()
 Start the discovery process using the protocols configured previously. More...
 
nfc_err_t cancel_discovery ()
 Cancel/stop a running discovery process. More...
 

Detailed Description

This class represents a NFC Controller.

A controller can be in one of three different states:

  • Idle/sleep state
  • Discovery state: The controller tries to discover a remote endpoint (initiator or target)
  • Connected state: The controller exchanges data with an endpoint (initiator or target)

A NFCController instance needs to be initialized with a NFCControllerDriver instance which abstracts the specific controller being used. A delegate needs to be set by the user to receive discovery events.

Definition at line 55 of file NFCController.h.

Constructor & Destructor Documentation

◆ NFCController()

NFCController ( NFCControllerDriver driver,
events::EventQueue queue,
const Span< uint8_t > &  ndef_buffer 
)

Construct a NFCController instance.

Parameters
[in]drivera pointer to a NFCControllerDriver instance
[in]queuea pointer to the events queue to use
[in]ndef_buffera bytes array used to store NDEF messages

Member Function Documentation

◆ initialize()

nfc_err_t initialize ( )

Initialize the NFC controller.

This method must be called before any other method call.

Returns
NFC_OK, or an error.

◆ set_delegate()

void set_delegate ( Delegate delegate)

Set the delegate that will receive events generated by this controller.

Parameters
[in]delegatethe delegate instance to use

◆ get_supported_rf_protocols()

nfc_rf_protocols_bitmask_t get_supported_rf_protocols ( ) const

Get the list of RF protocols supported by this controller.

Returns
a bitmask of RF protocols supported by the controller

◆ configure_rf_protocols()

nfc_err_t configure_rf_protocols ( nfc_rf_protocols_bitmask_t  rf_protocols)

Set the list of RF protocols to look for during discovery.

Parameters
[in]rf_protocolsthe relevant bitmask
Returns
NFC_OK on success, or NFC_ERR_UNSUPPORTED if a protocol is not supported by the controller, NFC_ERR_BUSY if the discovery process is already running

◆ start_discovery()

nfc_err_t start_discovery ( )

Start the discovery process using the protocols configured previously.

If remote endpoints are connected when this is called, they will be disconnected.

Returns
NFC_OK on success, or NFC_ERR_BUSY if the discovery process is already running

◆ cancel_discovery()

nfc_err_t cancel_discovery ( )

Cancel/stop a running discovery process.

Returns
NFC_OK