NFC ZigBee 3.0 Modules and Libraries: ntag_nwk.h File Reference

NFC ZigBee 3.0

NFC ZigBee 3.0 Modules and Libraries
NFC Commissioning using ZigBee Installation Codes
ntag_nwk.h File Reference

NTAG Network NDEF reading and writing (interface) More...

#include <jendefs.h> #include "nfc_nwk.h"

Go to the source code of this file.

Enumerations

enum  teNtagNwkStatus {
  E_NTAG_NWK_IDLE, E_NTAG_NWK_READING, E_NTAG_NWK_READ_FAIL, E_NTAG_NWK_READ_OK,
  E_NTAG_NWK_WRITING, E_NTAG_NWK_WRITE_FAIL, E_NTAG_NWK_WRITE_OK
}
 

Functions

PUBLIC teNtagNwkStatus NTAG_NWK_eRead (uint32 *pu32ReadAddress, tsNfcNwkPayload *psNfcNwkPayloadStart)
 Requests read of NTAG NWK NDEF data. More...
 
PUBLIC teNtagNwkStatus NTAG_NWK_eWrite (uint32 *pu32WriteAddress, tsNfcNwkPayload *psNfcNwkPayloadStart)
 Requests write of NTAG NWK NDEF data. More...
 
PUBLIC teNtagNwkStatus NTAG_NWK_eStop (void)
 Stops processing of NTAG NWK NDEF data. More...
 
PUBLIC teNtagNwkStatus NTAG_NWK_eStatus (void)
 Returns the status of the NTAG NWK NDEF processing. More...
 
PUBLIC teNtagNwkStatus NTAG_NWK_eTick (uint32 u32TickMs)
 Timer function to drive NTAG NWK NDEF processing. More...
 

Detailed Description

NTAG Network NDEF reading and writing (interface)

ntag_nwk.h contains high level APIs for reading and writing a network NDEF to the NTAG suitable for use in commissioning devices into an IEEE 802.15.4 network.

The typical set up sequence is the same for the data APIs (described in ntag.h).

A typical sequence to read data is shown below. It is recommended that data is read when the NTAG is removed from a field (as the data in the NTAG may have been altered whilst in the field) in response to the E_NTAG_EVENT_ABSENT event.

  • NTAG_vTick() is called by the application
  • APP_NtagCbEvent(E_NTAG_EVENT_ABSENT) is called in the application
  • NTAG_NWK_eRead() is called by the application, handing control of the low-level data APIs over to the NDEF data module. A pointer to be filled in with the address of the read and a pointer to store the NDEF payload is provided. This function call will return E_NTAG_NWK_READING if the request is successful.
  • NTAG_NWK_eTick() should then be called regularly by the application (replacing the calls to NTAG_vTick()).
  • If NTAG_NWK_eTick() returns E_NTAG_NWK_READ_OK the read was successful. The NDEF payload and the address of the read will have been placed into the pointers provided in the NTAG_NWK_eRead() call.
  • If NTAG_NWK_eTick() returns E_NTAG_NWK_READ_FAIL the read was unsuccessful.
  • If the interaction with the NDEF data is finished NTAG_NWK_eStop() should be called followed by a call to NTAG_vRegCbEvent() to reclaim the NTAG event callback, followed by regular calls to NTAG_vTick().

A typical sequence to write the NDEF payload data is shown below. It is recommended that data is written when the NTAG is not in a field (as a reader may be writing whilst in the field). Data may also be written following a successful read as shown below:

  • NTAG_NWK_eTick() returns E_NTAG_NWK_READ_OK indicating a successful read.
  • The NDEF payload contents are updated for writing.
  • NTAG_NWK_eWrite() is called by the application, handing control of the low-level data APIs over to the NDEF data module. A pointer with the address of the write and a pointer to NDEF payload data to be written is provided. This function call will return E_NTAG_NWK_WRITING if the request is successful.
  • NTAG_NWK_eTick() should then be called regularly by the application (continuing to replace the calls to NTAG_vTick()).
  • If NTAG_NWK_eTick() returns E_NTAG_NWK_WRITE_OK the write was successful.
  • If NTAG_NWK_eTick() returns E_NTAG_NWK_WRITE_FAIL the write was unsuccessful.
  • If the interaction with the NDEF data is finished NTAG_NWK_eStop() should be called followed by a call to NTAG_vRegCbEvent() to reclaim the NTAG event callback, followed by regular calls to NTAG_vTick().

The message sequence chart below shows a sequence of function calls for initialisation, an NDEF read and an NDEF write:

msc_inline_mscgraph_4

Enumeration Type Documentation

◆ teNtagNwkStatus

NTAG NWK status type

Enumerator
E_NTAG_NWK_IDLE 

NTAG NWK processing is idle

E_NTAG_NWK_READING 

NTAG NWK is reading data

E_NTAG_NWK_READ_FAIL 

NTAG NWK read has failed

E_NTAG_NWK_READ_OK 

NTAG NWK read was successful

E_NTAG_NWK_WRITING 

NTAG NWK is writing data

E_NTAG_NWK_WRITE_FAIL 

NTAG NWK write has failed

E_NTAG_NWK_WRITE_OK 

NTAG NWK write was successful

Function Documentation

◆ NTAG_NWK_eRead()

PUBLIC teNtagNwkStatus NTAG_NWK_eRead ( uint32 *  pu32ReadAddress,
tsNfcNwkPayload psNfcNwkPayloadStart 
)

Requests read of NTAG NWK NDEF data.

If the request is successful the final outcome of the read request is returned by NTAG_NWK_eTick() returning a status of E_NTAG_NWK_READ_OK. The byte address the NTAG NWK NDEF was read from is placed in the pu32ReadAddress pointer and the payload data in the psNfcNwkPayloadStart pointer.

When the request is accepted the NTAG event callback function, set by NTAG_vRegCbEvent(), is overridden to allow the NTAG NWK code to process NTAG events. When the request completes NTAG_NWK_eStop() should be called to end the processing and the NTAG event callback function can be reclaimed by the application.

Return values
E_NTAG_NWK_READINGRequest accepted
E_NTAG_NWK_READ_FAILRequest failed
Parameters
pu32ReadAddressPointer where byte address of NTAG NWK NDEF is placed if successful
psNfcNwkPayloadStartPointer where NTAG NWK NDEF payload data is placed if successful

◆ NTAG_NWK_eWrite()

PUBLIC teNtagNwkStatus NTAG_NWK_eWrite ( uint32 *  pu32WriteAddress,
tsNfcNwkPayload psNfcNwkPayloadStart 
)

Requests write of NTAG NWK NDEF data.

If the request is successful the final outcome of the write request is returned by NTAG_NWK_eTick() returning a status of E_NTAG_NWK_WRITE_OK. The byte address to write NTAG NWK NDEF should be in the pu32ReadAddress pointer and the payload data in the psNfcNwkPayloadStart pointer.

When the request is accepted the NTAG event callback function, set by NTAG_vRegCbEvent(), is overridden to allow the NTAG NWK code to process NTAG events. When the request completes NTAG_NWK_eStop() should be called to end the processing and the NTAG event callback function can be reclaimed by the application.

Return values
E_NTAG_NWK_WRITINGRequest accepted
E_NTAG_NWK_WRITE_FAILRequest failed
Parameters
pu32WriteAddressPointer to byte address to write data
psNfcNwkPayloadStartPointer to payload to write

◆ NTAG_NWK_eStop()

PUBLIC teNtagNwkStatus NTAG_NWK_eStop ( void  )

Stops processing of NTAG NWK NDEF data.

This function should be called when the processing of the NTAG NWK NDEF data is complete, the NTAG event callback function can be reclaimed by the application after calling NTAG_NWK_eStop().

Return values
E_NTAG_NWK_IDLENTAG_NWK NDEF processing is idle

◆ NTAG_NWK_eStatus()

PUBLIC teNtagNwkStatus NTAG_NWK_eStatus ( void  )

Returns the status of the NTAG NWK NDEF processing.

Returns
Status of NTAG NWK NDEF processing

◆ NTAG_NWK_eTick()

PUBLIC teNtagNwkStatus NTAG_NWK_eTick ( uint32  u32TickMs)

Timer function to drive NTAG NWK NDEF processing.

Should be called regularly, every 5ms is recommended.

Warning
This function calls NTAG_bTick() internally, there is no need to call NTAG_bTick() from the application when NTAG NWK NDEF processing is taking place.
Returns
Status of NTAG NWK NDEF processing
Parameters
u32TickMsTime in ms since previous call
Generated by   doxygen 1.8.13