#ifndef DLLMODULENAME
#define DLLMODULENAME_LIB_API extern "C" __declspec(dllexport)
#else
#define DLLMODULENAME_LIB_API __declspec(dllimport)
#endif
#define DTCALL_CONVENTION __stdcall

typedef void (__stdcall*RFIDBlockCallback) (const TCHAR* pszBlockArray, unsigned int nCount);
// connect RFID,
// return handle ID >=0 Success to connect RFID. <0 failed
//DLLMODULENAME_LIB_API int connect();


// return >0 success, <=0 failed
//DLLMODULENAME_LIB_API int DisConnect( int Handle );

// return ==0 success, ==-1 failed
DLLMODULENAME_LIB_API int RFID_GetBlockData(TCHAR *rpt,int m_BlockNum);
// return >0 the number of bytes written, ==0 Write overflow, ==-1 failed
DLLMODULENAME_LIB_API int RFID_WriteBlockData(TCHAR *rpt,int m_BlockNum);
// return >0 the number of bytes written, ==0 Write overflow, ==-1 failed
DLLMODULENAME_LIB_API int RFID_AddOrClrWriteBlockData(TCHAR *rpt,int flag);
// return ==0 success, ==-1 failed
//DLLMODULENAME_LIB_API int RFID_GetAllBlockData(TCHAR *rpt);
// return ==0 success, ==-1 failed
DLLMODULENAME_LIB_API int RFID_GetBlockinfo(int& mBlocknum, int& mBlocksize);

DLLMODULENAME_LIB_API int DTCALL_CONVENTION RFID_SetBlockReceiverCallback(RFIDBlockCallback pBlockFun);
DLLMODULENAME_LIB_API int DTCALL_CONVENTION RFID_StartReadBlock(void);
DLLMODULENAME_LIB_API int DTCALL_CONVENTION RFID_StopReadBlock(void);
DLLMODULENAME_LIB_API int DTCALL_CONVENTION RFID_GetUID(TCHAR* WstrUidDataBuf);

/*	 
* Callback function.When a valid rfid card is detected, this function will be called.
* @Param[IN] pszUidArray: A zero ended ASCII string. This string contains an array of 
*            uid and type pair. For example: "4EFA178A:ISO1443A, 33FA178B: ISO1443A "
*            ":" is used between uid and its type. "," is used between different Uid:Type pairs.
* @Param[IN] nCount:The total number of RFIDs were found.
*/
typedef void (*RFIDUidCallback) (const TCHAR* pszUidArray, unsigned int nCount);

/*
* This function is not thread safe.
* Connect to a RFID device.
* @Param[IN] port: Serial port used to connect to RFID reader.
* @Return: 0 Failed.
*			1 Successful.
*/	
DLLMODULENAME_LIB_API int DTCALL_CONVENTION RFID_Connect(int port);

/*
* This function is not thread safe.
* Disconnect from a connected RFID device.
* @Return: 0 Failed.
*			1 Successful.
*/
DLLMODULENAME_LIB_API int DTCALL_CONVENTION RFID_Disconnect(void);

/*
* This function is not thread safe.
* Specify a callback function.
* @Param[IN] pUidFun: Callback function that will be called when a RFID card is detected.
* @Return: 0 Failed.
*			1 Successful.
*/
DLLMODULENAME_LIB_API int DTCALL_CONVENTION RFID_SetUidReceiverCallback(RFIDUidCallback pUidFun);

/*
* This function is not thread safe.
* Read data from a block.
* @Param[IN] pszUid: The uid of the RFID card which will be read. Only zero ended ASCII string is valid.
* @Param[IN] pszPassword: BlockĄ¯s password. Only zero ended ASCII string is valid. 
* @Param[IN] nBlkIdx: Block's index.
* @Param[OUT] pBuf: Point to a buffer to receive the block data from a RFID card.
* @Param[IN/OUT] pBufSize: When in, this variable contains the buffer size of parameter lpBuffer. 
*                When out, this variable contains returned data size.
* @Return: 0 Failed.
*			1 Successful.
*/
DLLMODULENAME_LIB_API int DTCALL_CONVENTION RFID_ReadBlockData(const TCHAR* pszUid, 
														const TCHAR* pszPassword, 
														unsigned int nBlkIdx,
														unsigned char* pBuf, 
														unsigned int* pBufSize);
/*
* This function is not thread safe.
* Set the parameter of the sound.
* @Param[IN] iEnableSound: 1 Enable the sound. When a valid rfid card is detected the sound will be played. 
*                          0 Disable the sound..
* @Param[IN] pszSoundPath: Pointer to a null-terminated string that specifies the sound to play. If this parameter is NULL the function will use
*                          a default sound.
* @Return: 0 Failed.
*			1 Successful.
*/
DLLMODULENAME_LIB_API int DTCALL_CONVENTION RFID_SoundSetting(int iEnableSound, const TCHAR* pszSoundPath );