Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added examples on how to write or read NDEF messages using nfccard-tool #31

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

somq
Copy link

@somq somq commented Jan 8, 2018

  • Edited the readme to add explanations on how to use
  • Added an example for reading and writing NDEF messages containg NDEF records (supported by the lib).
  • Works partly with TT2 spec.

@chris-hinds
Copy link

Hi, trying to get this working myself locally, but getting errors on reading the card running this example.

Can you provide steps on how you got this work?

@somq
Copy link
Author

somq commented Feb 2, 2018

What kind of errors do you get ?
What type of tag do you use ?
What type of NDEF message are you trying to read ?

git clone https://github.com/somq/nfc-pcsc.git
cd nfc-pcsc
npm i && npm run example-ndef

@somq somq mentioned this pull request Feb 3, 2018
@chris-hinds
Copy link

Currently just trying to write a card and getting this error when I guess reading the header:

card detected { atr: <Buffer 3b 8f 80 01 80 4f 0c a0 00 00 03 06 03 00 03 00 00 00 00 68>,
  standard: 'TAG_ISO_14443_3',
  type: 'TAG_ISO_14443_3',
  uid: '043c513a003e80' }
error when reading data TypeError: Cannot read property 'getBytes' of undefined
    at NdefLibrary.NdefTextRecord.ndefTextRecord.assemblePayload (/Users/xxxxx/workspace/personal/nfc-pcsc/node_modules/ndef-lib/dist/ndeflibrary.js:1333:32)
    at NdefLibrary.NdefTextRecord.ndefTextRecord.setText (/Users/xxxxx/workspace/personal/nfc-pcsc/node_modules/ndef-lib/dist/ndeflibrary.js:1295:14)
    at nfcCardTool.prepareNDEFMessage (/Users/xxxxx/workspace/personal/nfc-pcsc/node_modules/nfccard-tool/lib/nfccard-tool.js:403:26)
    at nfcCardTool.prepareBytesToWrite (/Users/xxxxx/workspace/personal/nfc-pcsc/node_modules/nfccard-tool/lib/nfccard-tool.js:468:28)
    at ACR122Reader.<anonymous> (/Users/xxxxx/workspace/personal/nfc-pcsc/examples/ndef.js:50:36)
    at Generator.next (<anonymous>)
    at step (/Users/xxxxx/workspace/personal/nfc-pcsc/examples/ndef.js:16:191)
    at /Users/xxxxx/workspace/personal/nfc-pcsc/examples/ndef.js:16:361
    at <anonymous>

@somq
Copy link
Author

somq commented Feb 3, 2018

You are getting this error because you are trying to write/read a type 3 tag, which is not implemented yet in this library (it only supports type 2 tags for now).
Here are the docs with tech specs to understand the difference: https://github.com/somq/nfccard-tool/tree/master/docs

Feel free to fork and push a PR...

@XavierMallat
Copy link

I don't have any problem with type 3 tag :

ACS ACR122U PICC Interface 0  device attached
card detected {atr: Uint8Array(20), standard: "TAG_ISO_14443_3", type: "TAG_ISO_14443_3", uid: "04064ab2824981"}
tag info: {"headerValues":{"raw":{"Lock":{"LOCK0":0,"LOCK1":0},"capabilityContainer":{"MAGIC_NUMBER":225,"SPEC_VERSION":16,"MAX_NDEF_LENGTH":109,"READ_ACCESS":0,"WRITE_ACCESS":0},"NDEFMessageHeader":{"HAS_NDEF":3,"MESSAGE_LENGTH":79}},"string":{"Lock":{"LOCK0":"0","LOCK1":"0"},"capabilityContainer":{"MAGIC_NUMBER":"E1","SPEC_VERSION":"10","MAX_NDEF_LENGTH":"6D","READ_ACCESS":"0","WRITE_ACCESS":"0"},"NDEFMessageHeader":{"HAS_NDEF":"3","MESSAGE_LENGTH":"4F"}}},"parsedHeader":{"isFormatedAsNDEF":true,"type2SpecVersion":"1.0","maxNDEFMessageSize":872,"hasReadPermissions":true,"getReadPermissionsType":"HAS_READ_ACCESS","hasWritePermissions":true,"writePermissionsType":"HAS_WRITE_ACCESS","hasNDEFMessage":true,"NDEFMessageLength":79,"lengthToReadFromBlock4":81}}
NDEFMessage: (3) [{…}, {…}, {…}]

Your code works perfectly ! Nice lib and PR !

@somq
Copy link
Author

somq commented Jun 12, 2018

Thanks @XavierMallat
Too bad this PR has not been merged yet so...

README.md Show resolved Hide resolved
@somq
Copy link
Author

somq commented Aug 13, 2019

@pokusew Will you review this one at one point ?

@SuneethaYamani
Copy link

I am trying to use this code.but i am getting error
error when reading data { ReadError: Read operation failed: Status code: 0x6300
at ACR122Reader.read (\nfc-pcsc\src/Reader.js:554:10) name: 'ReadError', code: 'operation_failed' }
error when reading data { ReadError: Read operation failed: Status code: 0x6300
at ACR122Reader.read \nfc-pcsc\src/Reader.js:554:10) name: 'ReadError', code: 'operation_failed' }

@matrad
Copy link

matrad commented Nov 26, 2019

@pokusew any reason why this PR is still open? It seems to be finished?

@hasanbasri1993
Copy link

I am trying to use this code.but i am getting error error when reading data { ReadError: Read operation failed: Status code: 0x6300 at ACR122Reader.read (\nfc-pcsc\src/Reader.js:554:10) name: 'ReadError', code: 'operation_failed' } error when reading data { ReadError: Read operation failed: Status code: 0x6300 at ACR122Reader.read \nfc-pcsc\src/Reader.js:554:10) name: 'ReadError', code: 'operation_failed' }

same issue, have u get solution ?

@somq
Copy link
Author

somq commented Nov 12, 2022

@hasanbasri1993 Your error is related to the reader as far as I can understand
Maybe your hardware or driver has some issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants