ST_RFID_CfgStruct_BaltechMifVHLFile

[available from library v.1.2.4]

TYPE ST_RFID_CfgStruct_BaltechMifVHLFile :
STRUCT
    iVHLFile        : USINT     := 1;           (* nr. of VHL file to configure *)
    iNrOfKeys       : USINT(1..8)   := 1;
    iNrOfSectors    : USINT(1..56)  := 16;          (* default: 16 sectors -> 1024 bytes mifare card with 752 bytes user data *)
    iRC500EEPOffset : USINT     := 16#FF;
    arrKeyList      : ARRAY [0..7] OF T_RFID_MifareKey;         (* up to 8 keys, 6 byte each *)
    arrSectorList   : ARRAY [0..55] OF BYTE         (* up to 56 sectors accessible *)
                    := 0,1,2,3,4,5,6,7,8,9,10,      (* default: 16 sectors -> 1024 bytes mifare card with 752 bytes user data *)
                    11,12,13,14,15,16,17,18,19,20,
                    21,22,23,24,25,26,27,28,29,30,
                    31,32,33,34,35,36,37,38,39,40,
                    41,42,43,44,45,46,47,48,49,50,
                    51,52,53,54,55;
    arrRdKeyAssign  : ARRAY [0..55] OF BYTE;            (* Key index for each sector *)
    arrWrKeyAssign  : ARRAY [0..55] OF BYTE;            (* Key index for each sector *)
    bMAD_Mode       : BOOL      := FALSE;               (* use MAD AID [default = FALSE] *)
    iMAD_AID        : USINT;
    iReserved       : INT;
END_STRUCT
END_TYPE

The structure is suitable for the writing with the command eRFC_SetConfig. (see command set)
This does not concern the parameterization of the PLC RFID library, but rather the proprietary configuration of the RFID reader.

Structure of a Mifare card (up to 2 KB memory):
a Mifare card with 1 KB memory has 16 sectors of 64 bytes each. Each sector has 4 blocks. Sector 0 consists of blocks 0-3, sector 1 consists of block 4-7, and the following sectors are formed accordingly. In the diagram each column represents a sector, while a box represents a 16-byte block.

0

4

*

*

*

*

*

*

*

*

*

*

*

*

*

*

1

5

*

*

*

*

*

*

*

*

*

*

*

*

*

*

2

6

*

*

*

*

*

*

*

*

*

*

*

*

*

*

3

7

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Only the blocks shown with the asterisk symbol (*) contain usable memory area for the user. The maximum size of the user data is therefore 752 bytes (47 x 16 byte) for a 1024-byte Mifare card.

iVHLFile

iVHLFile is used to specify the number of the VHL file to be configured. The configuration of the RFID device can contain several VHL files side by side.

iNrOfKeys

iNrOfKeys is used to specify the required number of keys. 1 to 8 keys can be defined.

iNrOfSectors

iNrOfSectors is used to specify the number of sectors to be used for user data. A 1 KB Mifare card has 16 sectors (default = 16).
Example: if only sectors 4-6 are to be used, iNrOfSectors=3 is specified.

iRC500EEPOffset

This parameter refers to the internal transfer of the keys within the hardware of the RFID device. The default setting (16#FF) offers enhanced security. It is recommended to leave this setting unchanged.

arrKeyList

All keys are stored in the array arrKeyList. A key is of type T_RFID_MifareKey and consists of 6 bytes.
Example: if two keys are to be used, the respective keys are stored in arrKeyList[0] and arrLeyList[1].
TYPE T_RFID_MifareKey :
ARRAY[0..5] OF BYTE;
END_TYPE

arrSectorList

In the array arrSectorList all sectors are stored which are to be used for user data.
Example: if only sectors 4-6 are to be used, arrSectorList[0]=4, arrSectorList[1]=5, arrSectorList[2]=6.
The array is already initialized with consecutive numbering. In most cases no change is required.

arrRdKeyAssign

In the array arrRdKeyAssign the key index for each used sector is stored.
Example: for a 1 KB Mifare card, all sectors are to be used (iNrOfSectors = 16). Two keys are used (iNrOfKeys = 2) The first half of the sectors on this card should be read with the first key (arrKeyList[0]), the second half with the second key (arrKeyList[1]). In the array arrRdKeyAssign the indices
stCfg:ST_RFID_CfgStruct_BaltechMifVHLFile:=(arrRdKeyAssign:=0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1); must therefore be stored.
If a single key is to be used for all sectors, it is the key index 0 for all sectors. The array is already initialized with 0. In this case no change is required.

arrWrKeyAssign

In the array arrWrKeyAssign the key index for each used sector is stored.
Example: for a 1 KB Mifare card, all sectors are to be used (iNrOfSectors = 16). Two keys are used (iNrOfKeys = 2) The first half of the sectors on this card should be written with the first key (arrKeyList[0]), the second half with the second key (arrKeyList[1]). The array arrWrKeyAssign must therefore contain the indices
stCfg:ST_RFID_CfgStruct_BaltechMifVHLFile:=(arrWrKeyAssign:=0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1);.
If one key is to be used for all sectors, it is the key index 0 for all sectors. The array is already initialized with 0. In this case no change is required.

bMAD_Mode

If MAD (Mifare Application Directory) with AIDS (Application Identifiers) is to be used instead of the sector allocation, bMAD_Mode must be set (TRUE). The sector allocation is used as standard (default = FALSE).

iMAD_AID

The input is only required if MAD (Mifare Application Directory) is used (bMAD_mode = TRUE). At the configuration input iMAD_AID the MAD AID (Application Identifier) for the VHL file is specified.

Further information regarding the RFID reader configuration can be found in chapter Configuration.

More detailed information on VHL files and configuration of Baltech RFID devices can be found in the documentation provided by the manufacturer (files Mifare.pdf and ConfigurationValues.pdf).