Register an AID for Host Card Emulation (HCE)


#include "nfc/nfc.h"
NFC_API nfc_result_t nfc_hce_register_aid(const uint8_t *aid,                 
                                          size_t aid_len,                 
                                          app_category_type_t category,                 
                                          const char *invoke_target)


BlackBerry 10.3.0



Pointer to the buffer containing the AID.


Length of the AID.


The purpose of the emulating application. This is used to help the user choose an application when an AID conflict occurs between two or more applications.


The target ID in a null-terminated string. When an NFC reader selects the registered AID, the NFC system includes this target ID in the invocation message it sends. When registering a wildcard AID, set this parameter to NULL.


libnfc (For the qcc command, use the -l nfc option to link against this library)


An application that wants to perform HCE as defined in ISO-DEP (ISO/IEC 14443-4) can use this function to register an application identifier (AID) according to ISO/IEC 7816-5. When an NFC reader issues a SELECT command with the registered AID, the application is notified through the Invocation Framework using the invoke_target that the application has provided.

An application can register a specific AID or a wildcard AID. When it registers a specific AID, the AID stays registered (that is, the emulation is active) until the application calls nfc_hce_unregister_aid() or until the application is uninstalled from the system. This means that the emulation remains active regardless of whether the application is running (either in the foreground or in the background) or terminated.

An application can register a specific AID only once, but can register more than one AID. The registration of the same AID by more than one application leads to a routing conflict in the system. When the NFC service receives the first SELECT command with the conflicting AID, it prompts the user to resolve the conflict.

An application can register a wildcard AID by setting the parameters aid to NULL and aid_len to 0. A wildcard AID allows the application to receive all ISO 14443-4 commands when it runs in the foreground; however, when it's running in the background or gets terminated, no HCE commands are routed to the application.

An application also needs to register itself as an invocation target in order to be invoked to handle AID routing and transactions. This can be done in the <invoke-target> of the bar-descriptor.xml file.

During emulation, the following events can occur:

Feature set 1 doesn't support this function. When called in feature set 1, the function returns NFC_RESULT_UNSUPPORTED_API.


NFC_RESULT_SUCCESS, or one of the following:

Last modified: 2015-07-24

Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus