Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

NFC
Started by Michael W. May 26 2016 02:52 PM

32 replies to this topic
release android
[TOPIC CONTROLS]
Page 1 of 2 1 2
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Michael W.

[GLOBAL: userInfoPane.html]
Michael W.
  • Contributor

  • 276 posts
  • Alumni

NFC

by Spiral Code Studio


View and activate on the Corona Store


The NFC plugin enables your application to read NFC tags. NFC stands for Near Field Communication. At the moment the plugin only supports reading NDEF tags.

Documentation
  • springmorning likes this

[TOPIC: post.html]
#2

alexey.beljakov

[GLOBAL: userInfoPane.html]
alexey.beljakov
  • Observer

  • 7 posts
  • Corona SDK

Hi there!
How to get byte array of tag.id?
If i convert string to bytes by string:byte, i get wrong results.

example: 
original tag.id: 194 24 120 63
from plugin, after convertation: 239 191 189 24 120 63



[TOPIC: post.html]
#3

Lerg

[GLOBAL: userInfoPane.html]
Lerg
  • Contributor

  • 533 posts
  • Corona Staff

alexey.beljakov, hi. Can you see what's in event.id and event.tag.toString?



[TOPIC: post.html]
#4

alexey.beljakov

[GLOBAL: userInfoPane.html]
alexey.beljakov
  • Observer

  • 7 posts
  • Corona SDK

event.id is string with special symbols, part of them are not display on device.

json.encode(event.id)

result: \ufffd\u0018x?

original id is: C7:18:78:3F (hex) 

 

 

event.tag.toString: TAG: Tech [android.nfc.tech.NfcA]



[TOPIC: post.html]
#5

alexey.beljakov

[GLOBAL: userInfoPane.html]
alexey.beljakov
  • Observer

  • 7 posts
  • Corona SDK

it will be nice, if event.tag.id returns hexstring



[TOPIC: post.html]
#6

Lerg

[GLOBAL: userInfoPane.html]
Lerg
  • Contributor

  • 533 posts
  • Corona Staff

Can you print out event.id using the same string:byte() approach?
In the plugin code I am converting a byte array (tag id) directly into a Lua string, so that really should be working.
Are you sure the ID you are providing as "correct" is truly correct? Can you try a few other NFC readers?



[TOPIC: post.html]
#7

alexey.beljakov

[GLOBAL: userInfoPane.html]
alexey.beljakov
  • Observer

  • 7 posts
  • Corona SDK

string.byte(event.id,1,10)

 

result: 239 191 189 24 120 63

original: 199 24 120 63

another card:

result: 4 108 232 146 170 65 239 191 189

original: 4 108 232 146 170 65 128

 

wrong part is 239 191 189 in both cases

 

i read it by android app "NFC Tools" and by windows pcsc cardreader(ACR1251) original id is the same in both cases



[TOPIC: post.html]
#8

Lerg

[GLOBAL: userInfoPane.html]
Lerg
  • Contributor

  • 533 posts
  • Corona Staff

Thanks, I think I know what's going on. Will try fixing it soon.



[TOPIC: post.html]
#9

alexey.beljakov

[GLOBAL: userInfoPane.html]
alexey.beljakov
  • Observer

  • 7 posts
  • Corona SDK

very nice! thank you very much 

спасибо большое!)



[TOPIC: post.html]
#10

Lerg

[GLOBAL: userInfoPane.html]
Lerg
  • Contributor

  • 533 posts
  • Corona Staff

Just pushed a fix. Please try again when the repo updates.



[TOPIC: post.html]
#11

alexey.beljakov

[GLOBAL: userInfoPane.html]
alexey.beljakov
  • Observer

  • 7 posts
  • Corona SDK

i pull update, result is other, but still wrong(

 

plugin: 4 108 195 168 194 146 194 170 65 194 128

original: 4 108 232 146 170 65 128

 

plugin: 195 135 24 120 63

original: 199 24 120 63



[TOPIC: post.html]
#12

Lerg

[GLOBAL: userInfoPane.html]
Lerg
  • Contributor

  • 533 posts
  • Corona Staff

Pushed another fix. Try again soon.



[TOPIC: post.html]
#13

alexey.beljakov

[GLOBAL: userInfoPane.html]
alexey.beljakov
  • Observer

  • 7 posts
  • Corona SDK

bingo! works good! 

thank you for quick fixes!



[TOPIC: post.html]
#14

runewinse

[GLOBAL: userInfoPane.html]
runewinse
  • Contributor

  • 485 posts
  • Corona SDK

I feel a bit stupid, but how do you stop the app receiving NCS events?

 

Can you call setListener with nil like this?

nfc.setListener(nil)

[TOPIC: post.html]
#15

Lerg

[GLOBAL: userInfoPane.html]
Lerg
  • Contributor

  • 533 posts
  • Corona Staff

Hah, never thought about that. Will add nfc.removeListener() soon.
setListener(nil) won't work.



[TOPIC: post.html]
#16

Lerg

[GLOBAL: userInfoPane.html]
Lerg
  • Contributor

  • 533 posts
  • Corona Staff

runewinse, added.



[TOPIC: post.html]
#17

runewinse

[GLOBAL: userInfoPane.html]
runewinse
  • Contributor

  • 485 posts
  • Corona SDK

Thanks a bunch!  :)



[TOPIC: post.html]
#18

Lerg

[GLOBAL: userInfoPane.html]
Lerg
  • Contributor

  • 533 posts
  • Corona Staff

A heads up. The plugin will become paid on Wednesday (Oct. 12).
Launch sale for $14.99 for a week and $19.99 after that. Subscription.



[TOPIC: post.html]
#19

gjaman

[GLOBAL: userInfoPane.html]
gjaman
  • Enthusiast

  • 35 posts
  • Corona SDK

I"m looking to read/write raw data for ISO 15693 chips like a M24LR04E-R, which is a NFC/EE

 

My understanding is I'd need access to NfcV transceive() 

https://developer.android.com/reference/android/nfc/tech/NfcV.html#transceive(byte[])

 

Is this supported or any thoughts of adding support for this?



[TOPIC: post.html]
#20

max.srdk

[GLOBAL: userInfoPane.html]
max.srdk
  • Enthusiast

  • 41 posts
  • Corona SDK

I've got the same problem with reading event.tag.id string.

The original tag id is 0bfa3930, but incoming value is \u000bú90.

Seems like \u000b string is the utf line break.

 

The whole json is:

{  "id":"\u000bú90",
  "name":"nfc",
  "tag":{
    "id":"\u000bú90",
    "techs":["android.nfc.tech.NfcA","android.nfc.tech.MifareClassic","android.nfc.tech.NdefFormatable"],
    "toString":"TAG: Tech [android.nfc.tech.NfcA, android.nfc.tech.MifareClassic, android.nfc.tech.NdefFormatable]"
  },
  "type":"tag",
  "isError":false
}

Can you please look.



[TOPIC: post.html]
#21

Lerg

[GLOBAL: userInfoPane.html]
Lerg
  • Contributor

  • 533 posts
  • Corona Staff

gjaman, working on writing feature at the moment.

max.srdk, it's becoming \u000bú90 when you convert to JSON. You can convert the bytes representation to hexadecimal when you get the Lua table with the event.
If you convert the \u000bú90 value back to HEX you would get 000B 00FA 0039 0030, which is your starting value, but with extra zero bytes because of the unicode conversion.


  • gjaman likes this

[TOPIC: post.html]
#22

codeasysdk

[GLOBAL: userInfoPane.html]
codeasysdk
  • Enthusiast

  • 52 posts
  • Corona SDK

Hi,

 

Any chance to get NFCA support ?

 

{  "id":"Gx[Ä",

  "name":"nfc",
  "tag":{
    "id":"Gx[Ä",

    "toString":"TAG: Tech [android.nfc.tech.NfcA]",
    "techs":["android.nfc.tech.NfcA"]
  },
  "type":"tag",
  "isError":false
}

 


Best regards.


[TOPIC: post.html]
#23

shohoku-boy

[GLOBAL: userInfoPane.html]
shohoku-boy
  • Observer

  • 8 posts
  • Corona SDK

Can I use it for write tag ?



[TOPIC: post.html]
#24

Lerg

[GLOBAL: userInfoPane.html]
Lerg
  • Contributor

  • 533 posts
  • Corona Staff

shohoku-boy, yes, please see http://docs.spiralcodestudio.com/plugin/nfc/writeTag/



[TOPIC: post.html]
#25

shohoku-boy

[GLOBAL: userInfoPane.html]
shohoku-boy
  • Observer

  • 8 posts
  • Corona SDK

I have problem when init nfc plugin
runtime error with java.lang.NullPointerException
run on android version 4.2.2
 

https://drive.google.com/open?id=0B3Ve3AAODG0MRXoxZlFIX3JENFk




[topic_controls]
Page 1 of 2 1 2
 
[/topic_controls]

Also tagged with one or more of these keywords: release, android