capella-ben / LUA_RC522

MFRC522 RFID reader/writer for the NodeMCU
28 stars 22 forks source link

Getting null when taking card out of the antenna range #2

Open Netoperz opened 7 years ago

Netoperz commented 7 years ago

Ben could you show me how to manage to show the UUID only ones per initialization of tag ?

So if tag persists in antenna range of the reader, you only get UUID ones.

Right now you get the same UUID over and over again, as long as the card is initialized. And i've noticed that sometimes when you are taking the card out of the reader range you get null number printed because the lib is not getting full UID, that should not happened.

for example you get

8734658037 8734658037 8734658037 8734658037 8734658037 0 <== this is last value of the UID when the card is taken out of the range , we should filter that garbage, since the UID of the tag is always 7 bytes,

http://www.tagnfc.com/en/info/11-nfc-tags-specs

We should filter out everything that is not = 7bytes

I think that best way would be sending UID only ones if it is not reinitialized. that will solve the problem with timers.

Waiting for your reply mate.

capella-ben commented 7 years ago

Hi,

The demo code uses a repeating timer to continue to read any card in the vicinity. You will have to modify the main code to your needs. The timer runs every 100ms and when it detects a card, it pauses so that it has time to read all of the data on the card. It does this with the tmr.stop(0) and tmr.start(0) lines.

To stop it from looping you can simply remove the tmr.start(0) on line 486.

Not sure what you mean my the UUID. Each card has a serial number and a certain amount of flash memory. You need to find the datasheet for your card to understand the way the flash memory is organised. This code assumes that you are using a S50 tag which has a specific flash structure, but the code can be changed to other structures. The S50 seems to be a pretty common card type.

Hope this helps.

Ben ..

Netoperz commented 7 years ago

Yes Ben that helped, i'll try to play with timers.

I'm new in LUA, but as it is similar in construction of the code to C/C++ , than it is quite clear to understand for me, but lack of knowlegde about function naming and other stuff related to actual coding makes my questions a bit silly , and in "kindergarden style" so Im sorry for that and I do thank You for your time.

UUID/UID means unique ID so in short words it is Serial number as you said. Just my friends were using UID/UUID commonly for serial numer and I used to name it same way :)

S50 Are fine, byt they have some little problem... Those tags are not compatible with all devices. Some time ago i was designing a card reader that can read S50 S70 and banking cards serial number for use as loyality card. And those cards should be used also on mobile devices with build in reader if they have one, for example in smartphone. And in testing we have had an issues with S50...

And S50 are not "open" they are properitary standard of NXP, and they work only with readers that do have NXP made NFC reader.

If the reader is made by qualacomm or other vendor, it cannot read the S50, not that it is impossible , but the licence for S50 standard is properitary and owned by NXP (Philips) .

So if someone wants to implement universal system that is platform independent it should not be focused on using S50.

Any other Types of tags that are compilant with NFC Forum standard are compatible with every reader on the market. S50 only with NXP genuine hardware.

So i might want to implement other types (just serial number will be fine at the start) just to be able to use one standard that is multiplatform and vendor independent. That is just quick info for you if you didn't know that already.

If i'll make some useful changes i'll push the code for you to consider adding stuff to your lib.

Cheers mate.

capella-ben commented 7 years ago

Cool.

One think about the nodeMCU LUA is that it is event based. You shodul not use loops with delays like what is commonly done in Arduino. Hence why I use timers.

One thing to be aware of is that this code uses up a lot of memory on the EPS8266 nodeMCU firmware. Functions (oddly) are bad for memory usage, so that is why I have put the init in the main code.

What I/we should really do is create a LUA module. Will look into that when I get some free time.

Happy to update based on your changes. Thanks!

Ben ..

Netoperz commented 7 years ago

Ok, so we will keep in touch, right now i'm implementing your code to work with mqqt ,and after that i'll start to look in to the other tag types.

LUA module for this reader would be a sensation in lua world, Right now there was no ready to go support for NFC in LUA, Your port made the developing more easy for folks like me.

Thank You :D and I'm waiting for module like child for christmas 🗡