//This DLL can open 10 reader on one computer



#ifndef _EXPORT_FUNCTION_H_
#define _EXPORT_FUNCTION_H_



//Open reader
//para: port, serial port number£¬e.g."com1"
//      addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//return: seccuss return true£¬else return false
DECLDIR BOOL _stdcall gConnReader(char *port, int addr=0);



//Close reader
//para: addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//return: seccuss return true£¬else return false
DECLDIR BOOL _stdcall gDiscReader(int addr=0);



//Set serial port communication wait time
//para: time, timeout, ms unit 
//      addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//return: seccuss return true£¬else return false
DECLDIR BOOL _stdcall gSetTimeOut(int time, int addr=0);



//Set serial port communication baudrate
//para: baud, serial port baudrate
//      addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//return: seccuss return true£¬else return false
DECLDIR BOOL _stdcall gSetBaud(DWORD baud, int addr=0);



//Get reader model
//para: model->return reader model
//      len  ->return model length
//      addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//return: seccuss return true£¬else return false
DECLDIR BOOL _stdcall gGetModel(BYTE *model, int *len, int addr=0);



//Set beep
//para: time->beep time£¬unit is 5MS 
//      addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//return: seccuss return true£¬else return false
DECLDIR BOOL _stdcall gSetBeep(BYTE time, int addr=0);



//Set LED color
//para: color->0x00 = LED off
//             0x01 = LED red
//             0x02 = LED green
//      addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//return: seccuss return true£¬else return false
DECLDIR BOOL _stdcall gSetLED(BYTE color, int addr=0);



//Power down reader, wake up reader by any function
//para: addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//return: seccuss return true£¬else return false
DECLDIR BOOL _stdcall gSleepReader(int addr=0);



//Read FDX-A card
//para: ID ->return card number£¬5 BYTES
//      addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//success return 1, read error return 2, communication error return 3
DECLDIR int _stdcall gReadFDXA(BYTE *ID, int addr=0);



//Read FDX-B£¨ISO11784/85£©card
//para: nation ->return national code£¬5 BYTES
//      country->return country code£¬2 BYTES
//      trailer->return user data 3 BYTES
//      addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//success return 1, read error return 2, communication error return 3
DECLDIR int _stdcall gReadFDXB(BYTE *nation, BYTE *country, BYTE *trailer, int addr=0);



//Read EM4100 card
//para: ID ->return card number£¬5 BYTES
//      addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//success return 1, read error return 2, communication error return 3
DECLDIR int _stdcall gReadEM4100(BYTE *ID, int addr=0);



//Read HID card
//para: hid ->return card number£¬3 BYTES
//      addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//success return 1, read error return 2, communication error return 3
DECLDIR int _stdcall gReadHID(BYTE *hid, int addr=0);


//Read reader EEPROM
//para: eeprom_data->return EEPROM data£¬max is 64 BYTES
//      addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//return data lenght
DECLDIR int _stdcall gReadEeprom(BYTE *eeprom_data, int addr=0);



//Write reader EEPROM
//para: eeprom_data->EEPROM data
//      len        ->EEPROM data length£¬max is 64 bytes
//      addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//return: seccuss return true£¬else return false
DECLDIR BOOL _stdcall gWriteEeprom(BYTE *eeprom_data, BYTE len, int addr=0);



//Send and get reader frame directe
//para: cmd     ->reader command
//      para    ->command data
//      para_len->comand data length
//      resp    ->respone data
//      resp_len->respone data length
//      addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//success return 1, read error return 2, communication error return 3
DECLDIR int _stdcall gDirecteAccess(WORD cmd, BYTE *para, int para_len, BYTE *resp, int *resp_len, int addr=0);



//=============================================================================
//ATA5567 Function
//=============================================================================


//Write card
//para: page      ->page address£¬start from 0
//      block     ->block address£¬maybe you need look at T5577 EEPROM map
//      lock      ->0x00 = unlock block
//                  0x01 = lock block
//      block_data->block data£¬4 BYTES
//      addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//Return true means communication success£¬return false means communication error
//Call ATA_Read to read data, and compare with before write in data if write successful.
DECLDIR BOOL _stdcall ATA_StandWrite(BYTE page, BYTE block, BYTE lock, BYTE *block_data, int addr=0);



//Write card with password
//para: page      ->page address£¬start from 0
//      block     ->block address£¬maybe you need look at T5577 EEPROM map
//      lock      ->0x00 = unlock block
//                  0x01 = lock block
//      block_data->block data£¬4 BYTES
//      password  ->card password, it is block 7 data
//      addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//Return true means communication success£¬return false means communication error
//Call ATA_Read to read data, and compare with before write in data to see if write successful.
DECLDIR BOOL _stdcall ATA_ProteWrite(BYTE page, BYTE block, BYTE lock, BYTE *block_data, BYTE* password, int addr=0);



//Wake up card
//para: password  ->card password, it is block 7 data
//      addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//Return true means communication success£¬return false means communication error
//Call ATA_Read to read data to see if write successful.
DECLDIR BOOL _stdcall ATA_WakeUp(BYTE *password, int addr=0);



//Set block to return data
//para: page      ->page address£¬start from 0
//      block     ->block address£¬maybe you need look at T5577 EEPROM map
//      addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//Return true means communication success£¬return false means communication error
//Call ATA_Read to read data to see if write successful.
DECLDIR BOOL _stdcall ATA_Access(BYTE page, BYTE block, int addr=0);



//Set block to return data, if the card has need password has to use this function,
//otherwise don't use this function
//para: page      ->page address£¬start from 0
//      block     ->block address£¬maybe you need look at T5577 EEPROM map
//      password  ->card password, it is block 7 data
//      addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//Return true means communication success£¬return false means communication error
//Call ATA_Read to read data to see if write successful.
DECLDIR BOOL _stdcall ATA_AccessPWD(BYTE page, BYTE block, BYTE* password, int addr=0);



//Select page to ruturn data
//para: page, age address£¬start from 0
//      addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//Return true means communication success£¬return false means communication error
//Call ATA_Read to read data to see if write successful.
DECLDIR BOOL _stdcall ATA_SelectPage(BYTE page, int addr=0);



//Reset card
//para: addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//Return true means communication success£¬return false means communication error
//Call ATA_Read to read data to see if write successful.
DECLDIR BOOL _stdcall ATA_Reset(int addr=0);



//Read card with Manchester RF/32
//para: data_card->return data
//      data_len ->return data length
//      addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//success return 1, read error return 2, communication error return 3
DECLDIR int _stdcall ATA_ReadCardRF32(BYTE *data_card, int *data_len, int addr=0);



//Read card with Manchester RF/64
//para: data_card->return data
//      data_len ->return data length
//      addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//success return 1, read error return 2, communication error return 3
DECLDIR int _stdcall ATA_ReadCardRF64(BYTE *data_card, int *data_len, int addr=0);



//Set T5577 to FDX-A 
//para: ID  ->FDX-A number£¬5 BYTES
//      addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//Return true means communication success£¬return false means communication error
//Call gReadFDXA to see if write successful
DECLDIR BOOL _stdcall ATA_WriteFDXA(BYTE *ID, int addr=0);



//Set ATA5567 to HID 
//para: hid  ->HID number£¬3 BYTES
//      addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//Return true means communication success£¬return false means communication error
//Call gReadHID to see if write successful
DECLDIR BOOL _stdcall ATA_WriteHID(BYTE *hid, int addr=0);



//Set ATA5567 to FDX_B
//para: nation ->national code£¬38 bits
//      country->country code£¬10 bits
//      trailer->user data 3 BYTES
//      lock->1 lock card, 0 unlock
//      old_pw->4 BYTES old password£¬default password is 00000000
//      new_pw->4 BYTES new password
//      addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//Return true means communication success£¬return false means communication error
//Call gReadFDXB to see if write successful
DECLDIR BOOL _stdcall ATA_WriteFDXB(BYTE *nation, BYTE *country, BYTE *trailer, BYTE lock, BYTE *old_pw, BYTE *new_pw, int addr=0);



//Set T5557 to EM4100
//para: ID  ->EM4100 number£¬5 BYTES
//      lock->1 lock card, 0 unlock
//      old_pw->4 BYTES old password£¬default password is 00000000
//      new_pw->4 BYTES new password
//      addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//Return true means communication success£¬return false means communication error
//Call gReadEM4100 to see if write successful
DECLDIR BOOL _stdcall ATA_WriteEM4100(BYTE *ID, BYTE lock, BYTE *old_pw, BYTE *new_pw, int addr=0);



//=============================================================================
//EM4305 Function
//=============================================================================


//Write card
//para: word_addr->card address, you need study EM4305 EEPROM map
//      word_data->word data£¬4 bytes
//      addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//success return 0, error return 1, communication error return 2
DECLDIR int _stdcall EM_WriteWord(BYTE word_addr, BYTE *word_data, int addr=0);



//Read card
//para: word_addr->card address, you need study EM4305 EEPROM map
//      word_data->word data£¬4 bytes
//      addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//success return 0, error return 1, communication error return 2
DECLDIR int _stdcall EM_ReadWord(BYTE word_addr, BYTE *word_data, int addr=0);



//Check card password
//para: password->4 bytes card password
//      addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//success return 0, error return 1, communication error return 2
DECLDIR int _stdcall EM_Login(BYTE *password, int addr=0);



//Lock card
//para: array_addr->an address array
//      array_size->array length
//      addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//Remark£ºif lock it can not unlock
//success return 0, error return 1, communication error return 2
DECLDIR int _stdcall EM_Protect(BYTE *array_addr, int array_size, int addr=0);


//Power down card
//para: addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//success return 0, error return 1, communication error return 2
DECLDIR int _stdcall EM_Disable(int addr=0);



//Set reader mode adapt to card
//para: mode-> 0 = Manchester RF/64
//             1 = Manchester RF/32
//             2 = Bi-phase RF/32
//      addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//return: seccuss return true£¬else return false
DECLDIR BOOL _stdcall EM_SetCardMode(BYTE mode, int addr=0);



//Set EM4305 to FDX-B 
//para: nation ->national code£¬38 bits
//      country->country code£¬10 bits
//      trailer->user data 3 BYTES
//      lock->1 lock card, 0 unlock
//      old_pw->4 BYTES old password£¬default password is 00000000
//      new_pw->4 BYTES new password
//      addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//success return 0, error return 1, communication error return 2
DECLDIR int _stdcall EM_WriteFDXB(BYTE *nation, BYTE *country, BYTE *trailer, BYTE lock, BYTE *old_pw, BYTE *new_pw, int addr=0);



//Set EM4305 to EM4100
//para: ID  ->EM4100 number£¬5 BYTES
//      lock->1 lock card, 0 unlock
//      old_pw->4 BYTES old password£¬default password is 00000000
//      new_pw->4 BYTES new password
//      addr, assign address for reader£¬range 0 to 9, 
//            use default value 0 when you use only one reader in your system
//success return 0, error return 1, communication error return 2
DECLDIR int _stdcall EM_WriteEM4100(BYTE *ID, BYTE lock, BYTE *old_pw, BYTE *new_pw, int addr=0);



#endif