BALTECH Docs |
C API for BALTECH SDK
|
brp_errcode brp_VHL_Setup | ( | brp_protocol | protocol, |
brp_CardType | ConsideredCardType, | ||
brp_buf | MifareKey, | ||
bool | AsKeyA, | ||
unsigned | MadId, | ||
unsigned | AppId, | ||
brp_DesfireFileDescription | DesfireFileDesc, | ||
brp_buf | Key, | ||
size_t | Key_len, | ||
brp_buf | SegmentInfo, | ||
size_t | SegmentInfo_len, | ||
bool | EnStamp, | ||
brp_VHL_Setup_AdrMode | AdrMode, | ||
unsigned | FirstBlock, | ||
unsigned | BlockCount, | ||
brp_VHL_Setup_OptionFlag | OptionFlag, | ||
unsigned | BlockSize, | ||
unsigned | SelectFileCmdListLen, | ||
brp_VHL_Setup_SelectFileCmdList_Entry * | SelectFileCmdList, | ||
size_t | SelectFileCmdList_len, | ||
unsigned | FileLen, | ||
unsigned | ApduTimeout | ||
) |
This command creates a VHL file dynamically and transfers it to the reader's RAM.
The VHL file specifies the card-specific memory structure required to call brp_VHL_Read() or brp_VHL_Write(). You need to run VHL.Setup if you don't want to configure the readers with a static VHL file ( learn more).
To run brp_VHL_Format() , you cannot use a dynamic VHL file. In this case, you have to follow thestandard VHL implementation with a static VHL file.
To describe the memory structure, provide a list of parameters depending on the card type (see optional fields in the Parameters table below). If you omit a parameter, the reader will use the default value. To fill in the parameter values, please refer to the card specification. For LEGIC or MIFARE cards, you can also analyze the card structure using BALTECH ID-engine Explorer.
In principle, it is possible to mix dynamic VHL files and static VHL files (as part of the reader configuration for the VHL & Autoread). However, please note that the dynamic VHL file is lost as soon as you run brp_VHL_Read() or brp_VHL_Write() with a static VHL file. Thus, if you later want to run VHL.Read or VHL.Write with the dynamic VHL file again, you first need to rerun VHL.Setup to recreate the dynamic VHL file.
[in] | protocol | used to execute the command |
[in] | ConsideredCardType | Type of card to consider. The default value is 0x00, i.e. the reader will use the card type detected by brp_VHL_Select(). To handle the card as a different type (e.g. handle a DESFire card as an inter-industry ISO 14443-4 card), set this value to the desired card type. Not all card types support all VHL commands. For details, see our overview ofsupported commands |
[in] | MifareKey | Encryption key to access the card. |
[in] | AsKeyA | If true , Key A is used to access the card. If false , Key B is used. |
[in] | MadId | 2-byte application ID (AID) that identifies the sectors to access. If specified, only the payload of that application will be accessed. If not specified, the payload of all sectors will be accessed. All sector trailer blocks and block 0 will be omitted, i.e. the following block order is used: 1,2,4,5,6,8, etc. (0,3,7, etc. are omitted). |
[in] | AppId | Application ID, ranging from 0 to 0x00FFFFFF (big-endian) |
[in] | DesfireFileDesc | |
[in] | Key | Key with preceding crypto byte. Please refer to Device / CryptoKey SubKey for more details. |
[in] | Key_len | |
[in] | SegmentInfo | Either segment number or stamp, as defined in the EnStamp parameter. By default, the first segment will be accessed using its segment number. |
[in] | SegmentInfo_len | |
[in] | EnStamp | If true , SegmentInfo contains a stamp, i.e. the identifier of the application. If false , it contains a segment number. This parameter will only be evaluated if SegmentInfo has a length of 1. In this case, the reader can't distinguish between ID and stamp as a valid segment number always has length 1. |
[in] | AdrMode | Specifies the addressing mode. This parameter is only available on readers supporting LEGIC advant. LEGIC prime readers ignore it. To allow for backward compatibility with LEGIC prime readers, omitting this parameter will not result in the default value, but in the following behavior: VHL address 0 is mapped to protocol header address 25 , starting with the first data byte after the longest possible LEGIC prime stamp. |
[in] | FirstBlock | First block of the application data Firmware versions 1100 2.07.00 and above also support a 16-bit length value. This is not explicitly documented. |
[in] | BlockCount | Number of blocks occupied by the application data Firmware versions 1100 2.07.00 and above also support a 16-bit length value. This is not explicitly documented. |
[in] | OptionFlag | Option flag value for read/write operations |
[in] | BlockSize | Block size in bytes |
[in] | SelectFileCmdListLen | Length of SelectFileCmdList (including the following "Length of SelectFileCmdList" field) in bytes |
[in] | SelectFileCmdList | |
[in] | SelectFileCmdList_len | |
[in] | FileLen | File length in bytes |
[in] | ApduTimeout | Timeout for APDU command execution in ms. The default value is 2500 ms. Keep in mind that this timeout may add up several times in the scope of a single read or write access as file selection usually requires multiple APDUs to be executed. |