Tizen Native API
4.0
|
API provides access to MIFARE specific I/O operations on a Tag.
#include <nfc.h>
MIFARE Classic is also known as MIFARE Standard.
MIFARE Classic tags are divided into sectors, and each sector is sub-divided into blocks. Block size is always 16 bytes.
MIFARE Classic Mini are 320 bytes (SIZE_MINI), with 5 sectors each of 4 blocks.
MIFARE Classic 1k are 1024 bytes (SIZE_1K), with 16 sectors each of 4 blocks.
MIFARE Classic 2k are 2048 bytes (SIZE_2K), with 32 sectors each of 4 blocks.
MIFARE Classic 4k are 4096 bytes (SIZE_4K). The first 32 sectors contain 4 blocks and the last 8 sectors contain 16 blocks.
MIFARE Classic tags require authentication on a per-sector basis before any other I/O operations on that sector can be performed.
There are two keys per sector, and ACL bits determine what I/O operations are allowed on that sector after authenticating with a key
This API is related with the following features:
It is recommended to design feature related codes in your application for reliability.
You can check if a device supports the related features for this API by using System Information, thereby controlling the procedure of your application.
To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.
More details on featuring your application can be found from Feature Element.
Functions | |
int | nfc_mifare_authenticate_with_keyA (nfc_tag_h tag, int sector_index, unsigned char *auth_key, nfc_mifare_authenticate_with_keyA_completed_cb callback, void *user_data) |
Authenticates a sector with key A. | |
int | nfc_mifare_authenticate_with_keyB (nfc_tag_h tag, int sector_index, unsigned char *auth_key, nfc_mifare_authenticate_with_keyB_completed_cb callback, void *user_data) |
Authenticates a sector with key B. | |
int | nfc_mifare_read_block (nfc_tag_h tag, int block_index, nfc_mifare_read_block_completed_cb callback, void *user_data) |
Reads a 16-byte block. | |
int | nfc_mifare_read_page (nfc_tag_h tag, int page_index, nfc_mifare_read_page_completed_cb callback, void *user_data) |
Reads 4 pages(16 bytes). | |
int | nfc_mifare_write_block (nfc_tag_h tag, int block_index, unsigned char *buffer, int buffer_size, nfc_mifare_write_block_completed_cb callback, void *user_data) |
Writes block (16 byte) of data to the tag at a given block index. | |
int | nfc_mifare_write_page (nfc_tag_h tag, int page_index, unsigned char *buffer, int buffer_size, nfc_mifare_write_page_completed_cb callback, void *user_data) |
Writes a page (4 bytes) of data to the tag at a given page index. | |
int | nfc_mifare_increment (nfc_tag_h tag, int block_index, int value, nfc_mifare_increment_completed_cb callback, void *user_data) |
Increases a value block, storing the result in the temporary block on the tag. | |
int | nfc_mifare_decrement (nfc_tag_h tag, int block_index, int value, nfc_mifare_decrement_completed_cb callback, void *user_data) |
Decreases a value block, storing the result in the temporary block on the tag. | |
int | nfc_mifare_transfer (nfc_tag_h tag, int block_index, nfc_mifare_transfer_completed_cb callback, void *user_data) |
Copy from the temporary block to the specified block. | |
int | nfc_mifare_restore (nfc_tag_h tag, int block_index, nfc_mifare_restore_completed_cb callback, void *user_data) |
Copy from a value block to the temporary block. | |
Typedefs | |
typedef void(* | nfc_mifare_authenticate_with_keyA_completed_cb )(nfc_error_e result, void *user_data) |
Called after nfc_mifare_authenticate_with_keyA() has completed. | |
typedef void(* | nfc_mifare_authenticate_with_keyB_completed_cb )(nfc_error_e result, void *user_data) |
Called after nfc_mifare_authenticate_with_keyB() has completed. | |
typedef void(* | nfc_mifare_write_block_completed_cb )(nfc_error_e result, void *user_data) |
Called after nfc_mifare_write_block() has completed. | |
typedef void(* | nfc_mifare_write_page_completed_cb )(nfc_error_e result, void *user_data) |
Called after nfc_mifare_write_page() has completed. | |
typedef void(* | nfc_mifare_read_block_completed_cb )(nfc_error_e result, unsigned char *buffer, int bufer_size, void *user_data) |
Called after nfc_mifare_read_block() has completed. | |
typedef void(* | nfc_mifare_read_page_completed_cb )(nfc_error_e result, unsigned char *buffer, int bufer_size, void *user_data) |
Called after nfc_mifare_read_page() has completed. | |
typedef void(* | nfc_mifare_increment_completed_cb )(nfc_error_e result, void *user_data) |
Called after nfc_mifare_increment() has completed. | |
typedef void(* | nfc_mifare_decrement_completed_cb )(nfc_error_e result, void *user_data) |
Called after nfc_mifare_decrement() has completed. | |
typedef void(* | nfc_mifare_transfer_completed_cb )(nfc_error_e result, void *user_data) |
Called after nfc_mifare_transfer() has completed. | |
typedef void(* | nfc_mifare_restore_completed_cb )(nfc_error_e result, void *user_data) |
Called after nfc_mifare_restore() has completed. |
typedef void(* nfc_mifare_authenticate_with_keyA_completed_cb)(nfc_error_e result, void *user_data) |
Called after nfc_mifare_authenticate_with_keyA() has completed.
[in] | result | The result of nfc_mifare_authenticate_with_keyA() |
[in] | user_data | The user data passed from nfc_mifare_authenticate_with_keyA() |
typedef void(* nfc_mifare_authenticate_with_keyB_completed_cb)(nfc_error_e result, void *user_data) |
Called after nfc_mifare_authenticate_with_keyB() has completed.
[in] | result | The result of function call |
[in] | user_data | The user data passed from nfc_mifare_authenticate_with_keyB() |
typedef void(* nfc_mifare_decrement_completed_cb)(nfc_error_e result, void *user_data) |
Called after nfc_mifare_decrement() has completed.
[in] | result | The result of nfc_mifare_decrement() |
[in] | user_data | The user data passed from nfc_mifare_decrement() |
typedef void(* nfc_mifare_increment_completed_cb)(nfc_error_e result, void *user_data) |
Called after nfc_mifare_increment() has completed.
[in] | result | The result of nfc_mifare_increment() |
[in] | user_data | The user data passed from nfc_mifare_increment() |
typedef void(* nfc_mifare_read_block_completed_cb)(nfc_error_e result, unsigned char *buffer, int bufer_size, void *user_data) |
Called after nfc_mifare_read_block() has completed.
[in] | result | The result of function call |
[in] | buffer | The read buffer |
[in] | size | The size of buffer in bytes |
[in] | user_data | The user data passed from nfc_mifare_read_block() |
typedef void(* nfc_mifare_read_page_completed_cb)(nfc_error_e result, unsigned char *buffer, int bufer_size, void *user_data) |
Called after nfc_mifare_read_page() has completed.
[in] | result | The result of nfc_mifare_read_page() |
[in] | buffer | The read buffer |
[in] | size | The size of read buffer in bytes |
[in] | user_data | The user data passed from nfc_mifare_read_page() |
typedef void(* nfc_mifare_restore_completed_cb)(nfc_error_e result, void *user_data) |
Called after nfc_mifare_restore() has completed.
[in] | result | The result of nfc_mifare_restore() |
[in] | user_data | The user data passed from nfc_mifare_restore() |
typedef void(* nfc_mifare_transfer_completed_cb)(nfc_error_e result, void *user_data) |
Called after nfc_mifare_transfer() has completed.
[in] | result | The result of nfc_mifare_transfer() |
[in] | user_data | The user data passed from nfc_mifare_transfer() |
typedef void(* nfc_mifare_write_block_completed_cb)(nfc_error_e result, void *user_data) |
Called after nfc_mifare_write_block() has completed.
[in] | result | The result of nfc_mifare_write_block() |
[in] | user_data | The user data passed from nfc_mifare_write_block() |
typedef void(* nfc_mifare_write_page_completed_cb)(nfc_error_e result, void *user_data) |
Called after nfc_mifare_write_page() has completed.
[in] | result | The result of function call |
[in] | user_data | The user data passed from nfc_mifare_write_page() |
int nfc_mifare_authenticate_with_keyA | ( | nfc_tag_h | tag, |
int | sector_index, | ||
unsigned char * | auth_key, | ||
nfc_mifare_authenticate_with_keyA_completed_cb | callback, | ||
void * | user_data | ||
) |
Authenticates a sector with key A.
[in] | tag | The handle to NFC tag |
[in] | sector_index | The index of sector to authenticate with key A, starting from 0 |
[in] | auth_key | 6-byte authentication key |
[in] | callback | The callback function to invoke after this function has completed It can be null if notification is not required |
[in] | user_data | The user data to be passed to the callback function |
NFC_ERROR_NONE | Successful |
NFC_ERROR_NOT_SUPPORTED | Not supported NFC |
NFC_ERROR_NOT_INITIALIZED | Not initialized NFC |
NFC_ERROR_OUT_OF_MEMORY | Out of memory |
NFC_ERROR_INVALID_PARAMETER | Invalid parameter |
NFC_ERROR_DEVICE_BUSY | Device is too busy to handle your request |
NFC_ERROR_TIMED_OUT | Timeout is reached while communicating with tag |
NFC_ERROR_NOT_ACTIVATED | NFC is not activated |
NFC_ERROR_OPERATION_FAILED | Operation failed |
int nfc_mifare_authenticate_with_keyB | ( | nfc_tag_h | tag, |
int | sector_index, | ||
unsigned char * | auth_key, | ||
nfc_mifare_authenticate_with_keyB_completed_cb | callback, | ||
void * | user_data | ||
) |
Authenticates a sector with key B.
[in] | tag | The handle to NFC tag |
[in] | sector_index | The index of sector to authenticate with key B, starting from 0 |
[in] | auth_key | 6-byte authentication key |
[in] | callback | The callback function to invoke after this function has completed It can be null if notification is not required |
[in] | user_data | The user data to be passed to the callback function |
NFC_ERROR_NONE | Successful |
NFC_ERROR_NOT_SUPPORTED | Not supported NFC |
NFC_ERROR_NOT_INITIALIZED | Not initialized NFC |
NFC_ERROR_OUT_OF_MEMORY | Out of memory |
NFC_ERROR_INVALID_PARAMETER | Invalid parameter |
NFC_ERROR_DEVICE_BUSY | Device is too busy to handle your request |
NFC_ERROR_TIMED_OUT | Timeout is reached while communicating with tag |
NFC_ERROR_NOT_ACTIVATED | NFC is not activated |
NFC_ERROR_OPERATION_FAILED | Operation failed |
int nfc_mifare_decrement | ( | nfc_tag_h | tag, |
int | block_index, | ||
int | value, | ||
nfc_mifare_decrement_completed_cb | callback, | ||
void * | user_data | ||
) |
Decreases a value block, storing the result in the temporary block on the tag.
[in] | tag | The handle to NFC tag |
[in] | block_index | The index of block to decrease, starting from 0 |
[in] | value | non-negative to decrement by |
[in] | callback | The callback function to invoke after this function has completed It can be null if notification is not required |
[in] | user_data | The user data to be passed to the callback function |
NFC_ERROR_NONE | Successful |
NFC_ERROR_NOT_SUPPORTED | Not supported NFC |
NFC_ERROR_NOT_INITIALIZED | Not initialized NFC |
NFC_ERROR_OUT_OF_MEMORY | Out of memory |
NFC_ERROR_INVALID_PARAMETER | Invalid parameter |
NFC_ERROR_DEVICE_BUSY | Device is too busy to handle your request |
NFC_ERROR_TIMED_OUT | Timeout is reached while communicating with tag |
NFC_ERROR_NOT_ACTIVATED | NFC is not activated |
NFC_ERROR_OPERATION_FAILED | Operation failed |
int nfc_mifare_increment | ( | nfc_tag_h | tag, |
int | block_index, | ||
int | value, | ||
nfc_mifare_increment_completed_cb | callback, | ||
void * | user_data | ||
) |
Increases a value block, storing the result in the temporary block on the tag.
[in] | tag | The handle to NFC tag |
[in] | block_index | The index of block to increase, starting from 0 |
[in] | value | Non-negative to increment by |
[in] | callback | The callback function to invoke after this function has completed It can be null if notification is not required |
[in] | user_data | The user data to be passed to the callback function |
NFC_ERROR_NONE | Successful |
NFC_ERROR_NOT_SUPPORTED | Not supported NFC |
NFC_ERROR_NOT_INITIALIZED | Not initialized NFC |
NFC_ERROR_OUT_OF_MEMORY | Out of memory |
NFC_ERROR_INVALID_PARAMETER | Invalid parameter |
NFC_ERROR_NOT_INITIALIZED | Not initialized |
NFC_ERROR_DEVICE_BUSY | Device is too busy to handle your request |
NFC_ERROR_TIMED_OUT | Timeout is reached while communicating with tag |
NFC_ERROR_NOT_ACTIVATED | NFC is not activated |
NFC_ERROR_OPERATION_FAILED | Operation failed |
int nfc_mifare_read_block | ( | nfc_tag_h | tag, |
int | block_index, | ||
nfc_mifare_read_block_completed_cb | callback, | ||
void * | user_data | ||
) |
Reads a 16-byte block.
[in] | tag | The handle to NFC tag |
[in] | block_index | The block or starting page number |
[in] | callback | The callback function to invoke after this function has completed It can be null if notification is not required |
[in] | user_data | The user data to be passed to the callback function |
NFC_ERROR_NONE | Successful |
NFC_ERROR_NOT_SUPPORTED | Not supported NFC |
NFC_ERROR_NOT_INITIALIZED | Not initialized NFC |
NFC_ERROR_OUT_OF_MEMORY | Out of memory |
NFC_ERROR_INVALID_PARAMETER | Invalid parameter |
NFC_ERROR_DEVICE_BUSY | Device is too busy to handle your request |
NFC_ERROR_TIMED_OUT | Timeout is reached while communicating with tag |
NFC_ERROR_NOT_ACTIVATED | NFC is not activated |
NFC_ERROR_OPERATION_FAILED | Operation failed |
int nfc_mifare_read_page | ( | nfc_tag_h | tag, |
int | page_index, | ||
nfc_mifare_read_page_completed_cb | callback, | ||
void * | user_data | ||
) |
Reads 4 pages(16 bytes).
[in] | tag | The handle to NFC tag |
[in] | page_index | The index of page to read, starting from 0 |
[in] | callback | The callback function to invoke after this function has completed It can be null if notification is not required |
[in] | user_data | The user data to be passed to the callback function |
NFC_ERROR_NONE | Successful |
NFC_ERROR_NOT_SUPPORTED | Not supported NFC |
NFC_ERROR_NOT_INITIALIZED | Not initialized NFC |
NFC_ERROR_OUT_OF_MEMORY | Out of memory |
NFC_ERROR_INVALID_PARAMETER | Invalid parameter |
NFC_ERROR_DEVICE_BUSY | Device is too busy to handle your request |
NFC_ERROR_TIMED_OUT | Timeout is reached while communicating with tag |
NFC_ERROR_NOT_ACTIVATED | NFC is not activated |
NFC_ERROR_OPERATION_FAILED | Operation failed |
int nfc_mifare_restore | ( | nfc_tag_h | tag, |
int | block_index, | ||
nfc_mifare_restore_completed_cb | callback, | ||
void * | user_data | ||
) |
Copy from a value block to the temporary block.
[in] | tag | The handle to NFC tag |
[in] | block_index | The index of block to copy from, starting from 0 |
[in] | callback | The callback function to invoke after this function has completed It can be null if notification is not required |
[in] | user_data | The user data to be passed to the callback function |
NFC_ERROR_NONE | Successful |
NFC_ERROR_NOT_SUPPORTED | Not supported NFC |
NFC_ERROR_NOT_INITIALIZED | Not initialized NFC |
NFC_ERROR_OUT_OF_MEMORY | Out of memory |
NFC_ERROR_INVALID_PARAMETER | Invalid parameter |
NFC_ERROR_DEVICE_BUSY | Device is too busy to handle your request |
NFC_ERROR_TIMED_OUT | Timeout is reached while communicating with tag |
NFC_ERROR_NOT_ACTIVATED | NFC is not activated |
NFC_ERROR_OPERATION_FAILED | Operation failed |
int nfc_mifare_transfer | ( | nfc_tag_h | tag, |
int | block_index, | ||
nfc_mifare_transfer_completed_cb | callback, | ||
void * | user_data | ||
) |
Copy from the temporary block to the specified block.
[in] | tag | The handle to NFC tag |
[in] | block_index | The index of block to copy to, starting from 0 |
[in] | callback | The callback function to invoke after this function has completed It can be null if notification is not required |
[in] | user_data | The user data to be passed to the callback function |
NFC_ERROR_NONE | Successful |
NFC_ERROR_NOT_SUPPORTED | Not supported NFC |
NFC_ERROR_NOT_INITIALIZED | Not initialized NFC |
NFC_ERROR_OUT_OF_MEMORY | Out of memory |
NFC_ERROR_INVALID_PARAMETER | Invalid parameter |
NFC_ERROR_DEVICE_BUSY | Device is too busy to handle your request |
NFC_ERROR_TIMED_OUT | Timeout is reached while communicating with tag |
NFC_ERROR_NOT_ACTIVATED | NFC is not activated |
NFC_ERROR_OPERATION_FAILED | Operation failed |
int nfc_mifare_write_block | ( | nfc_tag_h | tag, |
int | block_index, | ||
unsigned char * | buffer, | ||
int | buffer_size, | ||
nfc_mifare_write_block_completed_cb | callback, | ||
void * | user_data | ||
) |
Writes block (16 byte) of data to the tag at a given block index.
[in] | tag | The handle to NFC tag |
[in] | block_index | The index of block to read, starting from 0 |
[in] | buffer | 16 bytes of data to write |
[in] | buffer_size | The size of buffer in bytes |
[in] | callback | The callback function to invoke after this function has completed It can be null if notification is not required |
[in] | user_data | The user data to be passed to the callback function |
NFC_ERROR_NONE | Successful |
NFC_ERROR_NOT_SUPPORTED | Not supported NFC |
NFC_ERROR_NOT_INITIALIZED | Not initialized NFC |
NFC_ERROR_OUT_OF_MEMORY | Out of memory |
NFC_ERROR_INVALID_PARAMETER | Invalid parameter |
NFC_ERROR_NOT_INITIALIZED | Not initialized |
NFC_ERROR_DEVICE_BUSY | Device is too busy to handle your request |
NFC_ERROR_TIMED_OUT | Timeout is reached while communicating with tag |
NFC_ERROR_NOT_ACTIVATED | NFC is not activated |
NFC_ERROR_OPERATION_FAILED | Operation failed |
int nfc_mifare_write_page | ( | nfc_tag_h | tag, |
int | page_index, | ||
unsigned char * | buffer, | ||
int | buffer_size, | ||
nfc_mifare_write_page_completed_cb | callback, | ||
void * | user_data | ||
) |
Writes a page (4 bytes) of data to the tag at a given page index.
[in] | tag | The handle to NFC tag |
[in] | page_index | The index of page to write, starting from 0 |
[in] | buffer | 4 bytes of data to write |
[in] | buffer_size | The size of buffer in bytes |
[in] | callback | The callback function to invoke after this function has completed It can be null if notification is not required |
[in] | user_data | The user data to be passed to the callback function |
NFC_ERROR_NONE | Successful |
NFC_ERROR_NOT_SUPPORTED | Not supported NFC |
NFC_ERROR_NOT_INITIALIZED | Not initialized NFC |
NFC_ERROR_OUT_OF_MEMORY | Out of memory |
NFC_ERROR_INVALID_PARAMETER | Invalid parameter |
NFC_ERROR_DEVICE_BUSY | Device is too busy to handle your request |
NFC_ERROR_TIMED_OUT | Timeout is reached while communicating with tag |
NFC_ERROR_NOT_ACTIVATED | NFC is not activated |
NFC_ERROR_OPERATION_FAILED | Operation failed |
const unsigned char NFC_TAG_MIFARE_KEY_APPLICATION_DIRECTORY[6] |
The well-known key for tags formatted according to the MIFARE Application Directory (MAD) specification.
The key is 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5
const unsigned char NFC_TAG_MIFARE_KEY_DEFAULT[6] |
The default factory key.
The key is 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
const unsigned char NFC_TAG_MIFARE_KEY_NFC_FORUM[6] |
The well-known key for tags formatted according to the NDEF on Mifare Classic specification.
The key is 0xD3, 0xF7, 0xD3, 0xF7, 0xD3, 0xF7