nfc elechouse ver 2 Library import problem

I’m having problems with importing the nfc.h library for this nfc modual

http://www.elechouse.com/elechouse/index.php?main_page=product_info&cPath=90_93&products_id=2205

I keep getting an “java.util.zip.ZipException: error in opening zip file” when I try to import. Kinda a noob.

Source:

#include <Boards.h>
#include <Firmata.h>

#include <Wire.h>


/**
  @file    nfc_mifare_mf1s50_reader.ino
  @author  www.elechouse.com
  @brief   example of reading mf1s50 card for NFC_MODULE
  
    For this demo, waiting for a MF1S50 card or tag, after reading a card/tag UID,
    then try to read the block 4/5/6/7 ..
  
  @section  HISTORY
  
  V1.0 initial version
  
    Copyright (c) 2012 www.elechouse.com  All right reserved.
*/

/** include library */
#include <nfc.h>

/** define a nfc class */
NFC_Module nfc;

void setup(void)
{
  Serial.begin(9600);
  nfc.begin();
  Serial.println("MF1S50 Reader Demo From Elechouse!");
  
  uint32_t versiondata = nfc.get_version();
  if (! versiondata) {
    Serial.print("Didn't find PN53x board");
    while (1); // halt
  }
  
  // Got ok data, print it out!
  Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX); 
  Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC); 
  Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);
  
  /** Set normal mode, and disable SAM */
  nfc.SAMConfiguration();
}

void loop(void)
{
  u8 buf[32],sta;
  
  
  /** Polling the mifar card, buf[0] is the length of the UID */
  sta = nfc.InListPassiveTarget(buf);
  
  /** check state and UID length */
  if(sta && buf[0] == 4){
    /** the card may be Mifare Classic card, try to read the block */  
    Serial.print("UUID length:");
    Serial.print(buf[0], DEC);
    Serial.println();
    Serial.print("UUID:");
    nfc.puthex(buf+1, buf[0]);
    Serial.println();
    /** factory default KeyA: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF */
    u8 key[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
    u8 blocknum = 4;
    /** Authentication blok 4 */
    sta = nfc.MifareAuthentication(0, blocknum, buf+1, buf[0], key);
    if(sta){
      /** save read block data */
      u8 block[16];
      Serial.println("Authentication success.");
      
      // uncomment following lines for writing data to blok 4
/*      
      strcpy((char*)block, "Elechoues - NFC");
      sta = nfc.MifareWriteBlock(blocknum, block);
      if(sta){
        Serial.println("Write block successfully:");
      }
*/  

      /** read block 4 */
      sta = nfc.MifareReadBlock(blocknum, block);
      if(sta){
        Serial.println("Read block successfully:");
        
        nfc.puthex(block, 16);
        Serial.println();
      }
      
      /** read block 5 */
      sta = nfc.MifareReadBlock(blocknum+1, block);
      if(sta){
        Serial.println("Read block successfully:");
        
        nfc.puthex(block, 16);
        Serial.println();
      }
      
      /** read block 6 */
      sta = nfc.MifareReadBlock(blocknum+2, block);
      if(sta){
        Serial.println("Read block successfully:");
        
        nfc.puthex(block, 16);
        Serial.println();
      }
      
      /** read block 7 */
      sta = nfc.MifareReadBlock(blocknum+3, block);
      if(sta){
        Serial.println("Read block successfully:");
        
        nfc.puthex(block, 16);
        Serial.println();
      }
    }  
  }
}

I keep getting an "java.util.zip.ZipException: error in opening zip file" when I try to import.

On what operating system? The file downloaded and opened in WinZip on Win7 just fine.

It compiles fine for me.

Using the "Library" link on the page you pointed to I downloaded PN532_NFC_elechouse.rar

I expanded the .rar archive.

I moved the NFC folder from the expanded archive to Arduino/libraries/NFC.

I re-started the Arduino IDE.

I verified one of the examples: File->Examples->NFC->examples->nfc_mifare_mf1s50_reader

I copied your code to an empty sketch and verified it without error.

I suspect one of those steps did not happen correctly on your system.

OK just needed to learn how to manual install the library’s. But know I need to know how to grab the data in block one 4 for comparison. I cant seam to find the method. “nfc.puthex(block, 16)” will print whats in block 4 but I need to compare that hex value to another hex value for security reasons.

#include <Wire.h>

#include <twi.h>

#include <nfc.h>

/**
  @file    nfc_mifare_mf1s50_reader.ino
  @author  www.elechouse.com
  @brief   example of reading mf1s50 card for NFC_MODULE
  
    For this demo, waiting for a MF1S50 card or tag, after reading a card/tag UID,
    then try to read the block 4/5/6/7 ..
  
  @section  HISTORY
  
  V1.0 initial version
  
    Copyright (c) 2012 www.elechouse.com  All right reserved.
*/

/** include library */


/** define a nfc class */
NFC_Module nfc;

void setup(void)
{
  Serial.begin(9600);
  nfc.begin();
  Serial.println("MF1S50 Reader Demo From Elechouse!");
  
  uint32_t versiondata = nfc.get_version();
  if (! versiondata) 
  {
    Serial.print("Didn't find PN53x board");
    while (1); // halt
  }
  
  // Got ok data, print it out!
  Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX); 
  Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC); 
  Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);
  
  /** Set normal mode, and disable SAM */
  nfc.SAMConfiguration();
}

void loop(void)
{
  u8 buf[32],sta;
  
  
  /** Polling the mifar card, buf[0] is the length of the UID */
  sta = nfc.InListPassiveTarget(buf);
  
  /** check state and UID length */
  if(sta && buf[0] == 4){
    /** the card may be Mifare Classic card, try to read the block */  
    Serial.print("UUID length:");
    Serial.print(buf[0], DEC);
    Serial.println();
    Serial.print("UUID:");
    nfc.puthex(buf+1, buf[0]);
    Serial.println();
    /** factory default KeyA: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF */
    u8 key[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
    u8 blocknum = 4;
    /** Authentication blok 4 */
    sta = nfc.MifareAuthentication(0, blocknum, buf+1, buf[0], key);
    if(sta)
    {
      /** save read block data */
      u8 block[16];
      Serial.println("Authentication success.");
      
      // uncomment following lines for writing data to blok 4
     
     // strcpy((char*)block, "eE8080474nosaj");
     // sta = nfc.MifareWriteBlock(blocknum, block);
      //if(sta){
     //   Serial.println("Write block successfully:");
     // }
      String strng;

      /** read block 4 */
      sta = nfc.MifareReadBlock(blocknum, block);
      if(sta)
      {
        Serial.println("Read block successfully:");
        
        nfc.puthex(block, 16);
        Serial.println();
      }


    }  
  }



}

"nfc.puthex(block, 16)" will print whats in block 4

No. It prints whatever is in block. If you call it right after reading what is in block 4, then it will print what is in block 4. If you call it right after reading what is in block 28, then it will print what is in block 28.

but I need to compare that hex value to another hex value for security reasons.

What's stopping you? block is an array. Use memcmp() to compare it to another array of the same size and type.

I need to put "block" in to a local string variable. how can I do that

I need to put "block" in to a local string variable.

Why?

how can I do that

memcpy()

Could you give me an example of how to use it

http://www.cplusplus.com/reference/cstring/memcmp/

How do I download these Librarys

it is already included