Following DLL functions are available.
unsigned char AvailablePorts(char ports[256][8]);
Auto detects avialable serial ports and copies them into the two dimensional array.
Parameters:
ports: com port name array. Must be of size 256 x 8 or a single dimension array of 2048.
Example: ports[0] = “COM4”, ports[1] = “COM7”, etc
Returns: 1 on success.
unsigned char OpenPort(unsigned char* port);
Opens a COM port
Parameters:
port: com port name. Example “COM4”, etch
Returns: 1 on success.
void ClosePort();
Closes COM port that was opened. Otherwise does nothing.
unsigned char Scan(unsigned char* uid, unsigned char *size, unsigned char retries)
Scans for Card. If found, the UID of the card is saved into the supplied uid parameter and its size is stored in size parameter. The size of uid array should be sufficiently large, for example, 16 bytes.
Parameters:
uid: saves UID of the card.
size: saves array of UID.
Returns: 1 on success.
unsigned char Keys(unsigned char* keyA, unsigned char* keyB)
Set access keys for the card.
Parameters:
keyA : access key A. For MIFARE 1k, this is usually 6 bytes.
keyB : access key B. For MIFARE 1k, this is usually 6 bytes.
Returns : 1 on success.
unsigned char Read(int block, unsigned char *data, int *size, unsigned char keyB)
Reads a block. Allocate sufficiently large array to hold the read data. The data read must equal the block or page size of the card.
Parameters:
data: stores the read data into the array.
size: stores the number of bytes read. This is equal to the block size.
Returns: 1 on success.
unsigned char Write(int block, unsigned char* data, int size, unsigned char keyB)
Writes a block of data into Card. Data size must equal or bigger than the block or page size. If array passed is smaller, random values would be written. Zero fill the array if data is small. All data may not be written if size > block/page size.
Parameters:
data: array of data to be written. Array size must equal block or page size.
size: size in bytes of data to be written.
Returns: 1 on success.
unsigned char CardType()
Reads the card type.
Parameters: none
Returns: card type as integer.
char *CardName()
Returns card name, e.g, MIFARE, NTAG, etc.
Parameters: none
Returns: card name as string. This string corresponds to the card type.
unsigned char NdefFormat()
NDEF format the card. A card must be detected before calling this method.
Parameters: none. Operates on the currently detected card.
Returns: 1 if NDEF format was successful. If no card found, will return 0.
unsigned char NdefAddUri(char* uri)
Adds NDEF URI record.
Parameters: URI to be added.
Returns: 1 if command was successful. If no card found, will return 0.
unsigned char NdefAddText(char* text)
Adds NDEF Text record.
Parameters: Text to be added.
Returns: 1 if command was successful. If no card found, will return 0.
unsigned char NdefErase()
Erases record on the card.
Parameters: none.
Returns: 1 if command was successful. If no card found, will return 0.
int NdefRead()
Reads record on the card.
Parameters: none.
Returns: Number of records read, if command was successful. If no card found or no record found, will return -1.
unsigned char NdefGetRecord(int i, char* type, char* id, char* encoding, char* payload, int* size)
Reads the i-th record. i must be 0 to (number of records – 1). Record type is stored in type.
Parameters:
i – zero based record index. Must be valid. The should be to 0 to the number returned by NdefRead() – 1.
type – record type. Pass at lease a character array of 64 byte.
id – record id. Pass at lease a character array of 64 byte.
encoding – the encoding used in the payload. Pass at lease a character array of 64 byte.
payload – record payload. Pass sufficiently large character array. 1024 byte recommended.
size – payload size. The actual size of the payload is stored here.
Returns: 1 if command was successful. If no card found, will return 0.
int BlockCount()
Returns number of blocks in the card memory. This method must be called after scan operation.
Parameters: none.
Returns: Number of blocks in card memory as integer.Parameters: none.
int BlockSize()
Returns block size of the card memory. This method must be called after scan operation. Blocks size indicates number of bytes that has to be written into or read from the card in a single write or read operation. Individual bytes could not be read or written, but only blocks can be read or written.
Parameters: none.
Returns: Block size of the card memory as integer.
unsigned char Format()
Formats and attempts to reset the tag to factory setting. This operation will reset all data to ZEROs. If the tag is password protected, reset to default password before calling this method.
Parameters: none.
Returns: Resets all data in the card to ZEROs.
unsigned char IsNdef()
Call this method to find out if the tag is NDEF formatted. A brand new card is not NDEF formatted. Calling this method after a scan operation would return 0 on a brand new card. This method should return 1 after the card is NDEF formatted using NdefFormat() method.
Parameters: none.
Returns: 1 if the tag is NDEF formatted.
unsigned char NdefReadBlock(int block, unsigned char *data, int *size)
This is a helper function to read raw NDEF blocks directly from memory for debugging purposes. Those developers who are planning to use Java NDEF library instead of the library provided by the driver may use this method to read raw blocks and display them.
Parameters:
block: zero based block number to read.
data: an array of unsigned char of at least size returned by BlockSize() method.
size: Actually number of bytes copied. Usually equal to BlockSize() value.
Returns: 1, if successful.
unsigned char UserMemory(int *start, int *end)
For the card under scan, retrieves the user memory range.
Parameters:
start: pointer to integer that will store the beginning of the block.
end: pointer to integer that will store the ending block.
Returns: 1, if successful.
unsigned char Sync()
If the card under scan gets out of sync, call this method to sync the card. A card may go out of sync if any read or write operation fails. After any of the failure, this method must be called to make the card in sync with the software.
Parameters: none.
Returns: 1, if successful.
unsigned char EmulateInit(unsigned char *uid, int buffsize, unsigned char writeable)
Setup device for card emulation but does not enters into emulation mode. This method must be called before you can begin card emulation. This methods allocates space for UID and sets up internal buffer size for card emulation.
Parameters:
uid: a three byte array with non zero UID. For example: {0x3A, 0x46, 0xf2}.
buffsize: card memory size in bytes. Maximum allowed is 128 bytes.
writeable: If cards need to be writeable, pass one. Otherwise cards will be emulated as read-only.
Returns: 1, if successful.
unsigned char EmulateStart(int timeout)
This is a blocking operation, so choose timeout in milliseconds during which time the device will emulate as card. Do not use a large timeout. This may hang the software.
Parameters:
timeout: time out in milli seconds.
Returns: 1, if a card received a write. For read only operation, the return value will always be zero.
unsigned char EmulateStop()
Stops emulation mode. Once stopped, to restart emulation, first call EmulateInit method to initialize then call EmulateStart. This method de-allocates memory that was initialized by EmulateInit.
Parameters: none
Returns: 1, if successful.