Ejemplo n.º 1
0
    */  uint8_t WaspRFID::init(uint8_t *UID , uint8_t *ATQ)   //! Request InListPassive 
	{
		USB.flush();

		delay(_delay);
		digitalWrite(MUX_USB_XBEE, HIGH); 
		delay(_delay);
		dataTX[0] = 0x04; // Length
		lengthCheckSum(dataTX); // Length Checksum
		dataTX[2] = HOSTTOPN532;
		dataTX[3] = INLISTPASSIVETARGET; // Code
		dataTX[4] = 0x01; //MaxTarget
		dataTX[5] = 0x00; //BaudRate = 106Kbps
		dataTX[6] = 0x00; // Clear checkSum position
		checkSum(dataTX); 
		
		sendTX(dataTX , 7 ,23);	
		
		for (int i = 17; i < (21) ; i++)
		{
			_UID[i-17] = dataRX[i];
		     UID[i-17] = _UID[i-17];
		}
		
		ATQ[0] = dataRX[13];
		ATQ[1] = dataRX[14];
		
		if ((dataRX[9]== 0xD5) & (dataRX[10] == 0x4B) & (dataRX[11] == 0x01)) {		 
			return 0;       
		} else {
			return 1;
		}
	}
Ejemplo n.º 2
0
//**********************************************************************
//!Write 16 bytes in address .
uint8_t writeData(uint8_t address, uint8_t *blockData)  //!Writing
{
	Serial.print("                ");
	dataTX[0] = 0x15;
	lengthCheckSum(dataTX); // Length Checksum
	dataTX[2] = 0xD4;
	dataTX[3] = 0x40;//inDataEchange CODE
	dataTX[4] = 0x01;//Number of targets
	dataTX[5] = 0xA0;//Write Command
	dataTX[6] = address; //Address		

	for (int i = 0; i < 16; i++) {
		dataTX[i+7] = blockData[i];
	}

	dataTX[23] = 0x00;
	checkSum(dataTX);
	sendTX(dataTX , 24 ,14);		

	if ((dataRX[9]== 0xD5) & (dataRX[10] == 0x41) & (dataRX[11] == 0x00)) {
		return 0;
	} else {
		return 1;
	}
}
Ejemplo n.º 3
0
//**********************************************************************
//!The goal of this command is to detect as many targets (maximum MaxTg)
// as possible in passive mode.
uint8_t init(uint8_t *UID , uint8_t *ATQ)   //! Request InListPassive
{
  Serial.flush();

	dataTX[0] = 0x04; // Length
	lengthCheckSum(dataTX); // Length Checksum
	dataTX[2] = 0xD4;
	dataTX[3] = 0x4A; // Code
	dataTX[4] = 0x01; //MaxTarget
	dataTX[5] = 0x00; //BaudRate = 106Kbps
	dataTX[6] = 0x00; // Clear checkSum position
	checkSum(dataTX); 

	sendTX(dataTX , 7 ,23);

	for (int i = 17; i < (21) ; i++){
		_UID[i-17] = dataRX[i];
	UID[i-17] = _UID[i-17];
	}

	ATQ[0] = dataRX[13];
	ATQ[1] = dataRX[14];

	if ((dataRX[9]== 0xD5) & (dataRX[10] == 0x4B) & (dataRX[11] == 0x01)) {
		return 0;
	} else {
		return 1;
	}
}
Ejemplo n.º 4
0
    */ 	uint8_t WaspRFID::write(uint8_t address, uint8_t *blockData)  //!Writing 
	{
		delay(_delay);
		digitalWrite(MUX_USB_XBEE, HIGH); 
		delay(2);
		printString("                ", _uart);		

		dataTX[0] = 0x15;
		lengthCheckSum(dataTX); // Length Checksum
		dataTX[2] = HOSTTOPN532;
		dataTX[3] = 0x40;  //inDataEchange CODE
		dataTX[4] = 0x01;  //Number of targets
		dataTX[5] = MIFARE_WRITE; //Write Command
		dataTX[6] = address; //Address		
		
		for (int i = 0; i<16; i++) {
			dataTX[i+7] = blockData[i];
		}
		
		dataTX[23] = 0x00; 
		checkSum(dataTX);
		sendTX(dataTX , 24 ,14);  		


         if ((dataRX[9]== 0xD5) & (dataRX[10] == 0x41) & (dataRX[11] == 0x00)) {
		 	return 0;
         } else {
            return 1;
         }
	}
Ejemplo n.º 5
0
    */ 	uint8_t WaspRFID::read(uint8_t address, uint8_t *readData) //!Reading 
	{
		delay(2);
		digitalWrite(MUX_USB_XBEE, HIGH); 
		delay(2);
		printString("                ", _uart);		
		
		dataTX[0] = 0x05;
		lengthCheckSum(dataTX); // Length Checksum
		dataTX[2] = HOSTTOPN532; // Code
		dataTX[3] = INDATAEXCHANGE; // Code
		dataTX[4] = 0x01; // Number of targets
		dataTX[5] = MIFARE_READ; //ReadCode
		dataTX[6] = address;  //Read address
		dataTX[7] = 0x00;
		checkSum(dataTX);

		sendTX(dataTX , 8, 30);  
		memset(readData, 0x00, 16);  

		if ((dataRX[9]== 0xD5) & (dataRX[10] == 0x41) & (dataRX[11] == 0x00)) {             
			for (int i = 12; i < 28; i++) {
				readData[i-12] = dataRX[i];
			}
		  	 return 0;
        } else { 
			 return 1;
        }
	}	
Ejemplo n.º 6
0
    */   bool WaspRFID::getFirmware(void)  //! It is needed to launch a simple command to sycnchronize
  	{
		delay(_delay);
		digitalWrite(MUX_USB_XBEE, HIGH); 
		delay(_delay);
		printString("                  ", _uart);		
		
		memset(dataTX, 0x00, 35);  
		dataTX[0] = 0x02; // Length
		lengthCheckSum(dataTX); // Length Checksum
		dataTX[2] = HOSTTOPN532; // CODE
		dataTX[3] = 0x02; //TFI
		checkSum(dataTX); //0x2A; //Checksum   
 
		sendTX(dataTX , 5 , 17);  
		
		USB.print("Your Firmware version is : ");
		
		for (int i = 11; i < (15) ; i++)
		{
			USB.printHex(dataRX[i]);
			USB.print(" ");
		}
			USB.print("\n"); 
	}
Ejemplo n.º 7
0
    */	 uint8_t WaspRFID::authenticate(uint8_t *UID, uint8_t blockAddress, uint8_t *keyAccess)
	{
		delay(_delay);
		digitalWrite(MUX_USB_XBEE, HIGH); 
		delay(_delay);
		
		dataTX[0] = 0x0F;
		lengthCheckSum(dataTX);
		dataTX[2] = HOSTTOPN532;
		dataTX[3] = INDATAEXCHANGE; // inDataEchange
		dataTX[4] = 0x01; //Number of targets
		dataTX[5] = AUTH_WITH_KEYA; // Authentication code
		dataTX[6] = blockAddress;

		for (int i = 0; i<6 ; i++) {
			dataTX[i + 7] = keyAccess[i];
		}
 
		dataTX[13] = UID[0];  dataTX[14] = UID[1];
		dataTX[15] = UID[2];  dataTX[16] = UID[3]; 
 
		dataTX[17] = 0x00;
		checkSum(dataTX);
		
			sendTX(dataTX , 18 ,14);
			
		if ((dataRX[9]== 0xD5) & (dataRX[10] == 0x41) & (dataRX[11] == 0x00)) {		 
			return 0;       
		} else {
			return 1;        
		}
	}	         
Ejemplo n.º 8
0
bool XBeeRemote::tick()
{
    if(_safeSendMap.empty())
        return false;
    auto it = _safeSendMap.begin();
    sendTX(it->second);
    _safeSendMap.erase(it);
    return true;
}
Ejemplo n.º 9
0
//**********************************************************************
//!This command is used to set internal parameters of the PN532,
bool configureSAM(void)//! Configure the SAM
{
	Serial.print("               ");
	dataTX[0] = 0x05; //Length
	lengthCheckSum(dataTX); // Length Checksum
	dataTX[2] = 0xD4;
	dataTX[3] = 0x14;
	dataTX[4] = 0x01; // Normal mode
	dataTX[5] = 0x14; // TimeOUT
	dataTX[6] = 0x00; // IRQ
	dataTX[7] = 0x00; // Clean checkSum position
	checkSum(dataTX);

	sendTX(dataTX , 8, 13);
}
Ejemplo n.º 10
0
//**********************************************************************
//!The PN532 sends back the version of the embedded firmware.
bool getFirmware(void)  //! It is needed to launch a simple command to sycnchronize
{
	Serial.print("                ");
	memset(dataTX, 0x00, 35);
	dataTX[0] = 0x02; // Length
	lengthCheckSum(dataTX); // Length Checksum
	dataTX[2] = 0xD4; // CODE
	dataTX[3] = 0x02; //TFI
	checkSum(dataTX); //0x2A; //Checksum   

	sendTX(dataTX , 5 , 17);
	fprintf(stderr,"\nYour Firmware version is : ");

	for (int i = 11; i < (15) ; i++){
		fprintf(stderr,"%x",dataRX[i]);
		fprintf(stderr," ");
	}
	fprintf(stderr,"\n");
}
Ejemplo n.º 11
0
    */   bool  WaspRFID::configureSAM(void)  //! Configure the SAM 
	{
		delay(_delay);
		digitalWrite(MUX_USB_XBEE, HIGH); 
		delay(_delay);
		printString("               ", _uart);		
		
		dataTX[0] = 0x05; //Length 
		lengthCheckSum(dataTX); // Length Checksum
		dataTX[2] = HOSTTOPN532;
		dataTX[3] = SAMCONFIGURATION;
		dataTX[4] = 0x01; //Normal mode
		dataTX[5] = 0x14; // TimeOUT
		dataTX[6] = 0x00; // IRQ
		dataTX[7] = 0x00; // Clean checkSum position
		checkSum(dataTX);
		
				sendTX(dataTX , 8, 13);  
	}
Ejemplo n.º 12
0
//**********************************************************************
//!Read 16 bytes from  address .
uint8_t readData(uint8_t address, uint8_t *readData) //!Reading
{
	Serial.print("                ");
	dataTX[0] = 0x05;
	lengthCheckSum(dataTX); // Length Checksum
	dataTX[2] = 0xD4; // Code
	dataTX[3] = 0x40; // Code
	dataTX[4] = 0x01; // Number of targets
	dataTX[5] = 0x30; //ReadCode
	dataTX[6] = address;  //Read address
	dataTX[7] = 0x00;
	checkSum(dataTX);
	sendTX(dataTX , 8, 30);
	memset(readData, 0x00, 16);  

	if ((dataRX[9]== 0xD5) & (dataRX[10] == 0x41) & (dataRX[11] == 0x00)) {
		for (int i = 12; i < 28; i++) {
			readData[i-12] = dataRX[i];
		}
		return 0;
	} else {
		return 1;
	}
}
Ejemplo n.º 13
0
//**********************************************************************
//!A block must be authenticated before read and write operations
uint8_t authenticate(uint8_t *UID, uint8_t blockAddress, uint8_t *keyAccess)
{
	dataTX[0] = 0x0F;
	lengthCheckSum(dataTX);
	dataTX[2] = 0xD4;
	dataTX[3] = 0x40; // inDataEchange
	dataTX[4] = 0x01; //Number of targets
	dataTX[5] = 0x60; // Authentication code
	dataTX[6] = blockAddress;
	for (int i = 0; i < 6 ; i++) {
		dataTX[i + 7] = keyAccess[i];
	}
	dataTX[13] = UID[0];  dataTX[14] = UID[1];
	dataTX[15] = UID[2];  dataTX[16] = UID[3];
	dataTX[17] = 0x00;
	checkSum(dataTX);
	sendTX(dataTX , 18 ,14);

	if ((dataRX[9]== 0xD5) & (dataRX[10] == 0x41) & (dataRX[11] == 0x00)) {
		return 0;
	} else {
		return 1;
	}
}
Ejemplo n.º 14
0
    */ 	uint8_t WaspRFID::powerDown(void)
	{
		delay(2);
		digitalWrite(MUX_USB_XBEE, HIGH); 
		delay(2);		
		printString("                ", _uart);	
		
		dataTX[0] = 0x03;
		lengthCheckSum(dataTX);  // Length Checksum
		dataTX[2] = HOSTTOPN532; // Code
		dataTX[3] = POWERDOWN;   // Code
		dataTX[4] = 0x10; 	     // Wake UP mode HFU.
		dataTX[5] = 0x00; 	     // Clear checkSum byte. 

		checkSum(dataTX);

		sendTX(dataTX , 6, 12); 
		
		if ((dataRX[9]== 0xD5) & (dataRX[10] == 0x17) & (dataRX[11] == 0x00)) {		 
			return 1;       
		} else {
            return 0;        
		}
	}
Ejemplo n.º 15
0
void XBeeRemote::sendMsg(XBEE_MSG_TYPE type, const HexData &data)
{
    sendTX(prepareMsg(type, data));
}
Ejemplo n.º 16
0
/*! \brief SerialDevice::syncRX Is the serial interface's implementation of syncRX.
 * Same functionality as sendTX.
 */
void SerialDevice::syncTX()
{
    sendTX();
}