Mif command group

With this command group, you can access MIFARE cards in low-level mode.

Whenever a card enters the HF field, it will be in idle state. From the idle state, a card switches to the requested state as soon as the Mif.Request command is executed. Cards in requested state participate in the anti-collision sequence, controlled by the Mif.Anticoll command, resulting in an unambiguous serial number belonging to one of the cards in the HF field. The card with this serial number may now be selected with the Mif.Select command. All other cards will fall back to idle state again and wait for the next call of the Mif.Request command. The selected card, however, changes from requested state to selected state.

The Mif.Anticoll and Mif.Select commands can only process serial numbers with a length of 4 bytes. Since 2010, however, MIFARE cards with a 7-byte serial number are available. Please use the ISO 14443-3 (Type A) command group to select and process cards with 7-byte serial numbers.

When a card is in selected state, communication with the card is possible. Nevertheless, it is necessary to be authenticated before a sector of the card can be accessed. Authentication can be performed either with the Mif.AuthE2 command or with the Mif.AuthUser command. Both commands send a key to the currently selected card along with information regarding whether this key should be compared to key A or key B on the card. If the given key matches the corresponding sector's key (either key A or key B, as specified in the command's parameters), then access according to the access conditions of the desired sector will be granted.

Finally, a card that is in select state can be set to halt state. A card in halt state will not respond to any command unless a specially parameterized Mif.Request command is called, or when it leaves and then re-enters the HF field of the reader's antenna. The halt state is helpful when it is necessary to deal with multiple cards present in the reader's antenna HF field.

The Mif.Read and Mif.Write commands can be use to read/write data from/to a certain block. Additionally, a data sector may be turned into a special value sector (also called value block ), which is initialized with a specific starting value and can then only be changed by means of increment and decrement operations using the ChangeValue or ChangeValueBackup commands. Value sectors are very useful in some scenarios, such as for cash-based applications. To create a value sector, it is simply required to write specially formatted data to it:

Each increment and decrement operation has to be followed by a transfer operation, using the Mif.TransferBlock command, in order to make the increment/decrement persistent. This feature guarantees that no data will be lost during a recalculation of the value on the card.

WARNING: This command set is not available in all Baltech reader firmware variants.

Status codes

BRP status BRP Library Error Code Mnemonic Description
0x01 0x1001 (4097) Mif.ErrNoTag There's no card in the HF field, or the card doesn't respond.
0x02 0x1002 (4098) Mif.ErrCrc The response frame is invalid, e.g. it may contain an invalid CRC checksum. Please rerun the command.
0x04 0x1004 (4100) Mif.ErrAuth Card authentication has failed.
0x05 0x1005 (4101) Mif.ErrParity Legacy error code: The parity bits don't match the transmitted data. Authentication has been lost. Please reauthenticate and rerun the commands.
0x06 0x1006 (4102) Mif.ErrCode The card behaves in an unspecified way. Please rerun the command or reselect the card.
0x08 0x1008 (4104) Mif.ErrSnr Legacy error code: The serial number is wrong.
0x09 0x1009 (4105) Mif.ErrKey The key in the SAM/crypto memory is invalid or missing.
0x0A 0x100A (4106) Mif.ErrNotauth Card authentication has failed. The current configuration/state doesn't allow the requested command.
0x0B 0x100B (4107) Mif.ErrBitcount Legacy error code: HF data transition error. The number of received bits is invalid.
0x0C 0x100C (4108) Mif.ErrBytecount Legacy error code: HF data transition error. The number of received bytes is invalid.
0x0E 0x100E (4110) Mif.VcsAndProxCheckError The proximity check has timed out. Please reselect the card.
0x0F 0x100F (4111) Mif.ErrWrite Writing to the card has failed. Please rerun the command or check the access conditions.
0x10 0x1010 (4112) Mif.ErrInc Legacy error code: Increment couldn't be performed.
0x11 0x1011 (4113) Mif.ErrDecr Legacy error code: Decrement couldn't be performed.
0x12 0x1012 (4114) Mif.ErrRead Reading data from the card has failed. Please rerun the command or check the access conditions.
0x13 0x1013 (4115) Mif.ErrOvfl Legacy error code: An overflow occurred during decrement or increment.
0x15 0x1015 (4117) Mif.ErrFraming The response frame is invalid, e.g. it may contain an invalid number of bits. Please rerun the command.
0x16 0x1016 (4118) Mif.ErrBreak The command has been aborted because the HF interface has been requested by another task or command. Please reselect the card. This error only occurs when you combine VHL and low-level commands. We highly recommend you avoid that combination as these 2 command sets will interfere with each other's card states.
0x17 0x1017 (4119) Mif.ErrCmd The specified command or parameters are unknown.
0x18 0x1018 (4120) Mif.ErrColl An error occurred in the anti-collision sequence. Please reselect the card.
0x1A 0x101A (4122) Mif.ErrReaderChipCommunication Communication with the reader's HF interface has failed. Please reset the HF interface with Sys.HFReset and check the reader status with Sys.GetBootStatus.
0x1D 0x101D (4125) Mif.ErrFirmwareNotSupported This command isn't supported by the reader firmware.
0x1E 0x101E (4126) Mif.ErrVal A value operation, e.g. increment or decrement, has failed. This may have several reasons, e.g. an invalid value format, or the value to manipulate doesn't exist on the card.
0x1F 0x101F (4127) Mif.ErrIntegrity Secure messaging error: The CRC or MAC checksum doesn't match the transmitted data. Authentication has been lost. Please reauthenticate and rerun the commands, or check the security conditions.
0x20 0x1020 (4128) Mif.CondNotvalid Card error as per MIFARE specification: Condition of use not satisfied.
0x21 0x1021 (4129) Mif.ErrHwNotSupported This command isn't supported by the reader hardware, i.e. by the SAM or reader chip.
0x22 0x1022 (4130) Mif.ErrSamUnlock Unlocking/authenticating with the SAM has failed. Please check the SamAVx configuration values.
0x23 0x1023 (4131) Mif.ErrSamCommunication Communication with the SAM has failed. This may have several reasons, e.g. the wrong SAM type or a failure to activate the SAM. Please check the SAM status and reset the reader with Sys.Reset.