Closed Devofure closed 6 years ago
This plugin deals with NFC at the NDEF level so it can handle many tag technologies with the same API.
If you want to read raw Mifare Classic bytes, you're better off using the Android's MifareClassic.
You could make a PhoneGap plugin to access MifareClassic from JavaScript, but I think that makes sense as a separate plugin.
If you're dealing with NDEF data, you're getting the same data using phonegap-nfc as you would reading the tag directly. If you're dealing with non-NDEF data or non-standard sector keys, it could make sense to deal directly with MifareClassic.
Ok thanks, Im not an expert with the NFC technology but the data is written with a non-NDEF format so I will try to do a plugin, thank you again for the answer.
I suggest writing a small native app first then converting it to a plugin.
hi! i have the same problem but i am new in phonegap. How can i converting in to a plugin?
@valemunoz the suggestion is to write a small native app to solve your problem first then think about bringing it into PG. Do you already have a native solution?
@JohnMcLear yes i have a read and write solution
So if you look at a basic Phonegap plugin example you will be able to see how it returns values.. For example.. http://devgirl.org/2013/07/17/tutorial-how-to-write-a-phonegap-plugin-for-android/
If I was you I would fork @don's phonegap-nfc project and add the relevant Mifare hooks. I don't know if @don wants to add native Mifare support, imho he should but that's up to him.
One thing to try and do is keep the same async/callback style that Don uses.. Callbacks in Javascript are your friend.
@don fwiw I'm +1 native Mifare support and also support for locking tags. Saying that though, there are huge bugs/inconsistencies we need to fix first before implementing new features...
@JohnMcLear Locking tags is supported. (Might be Android only) https://github.com/chariotsolutions/phonegap-nfc#nfcmakereadonly
@JohnMcLear @valemunoz @erickChavez What sort of stuff do you guys want to do with raw Mifare? I don't have a good use case. I'm concerned that adding Mifare will complicate the API even more. I'd rather see separate plugins for Mifare and IsoDep unless someone comes up with a really clean API.
@JohnMcLear @don What I need is to be read sectors and blocks of a mifare Classic card. Now I have the native code in android and I am trying to create a plugin but so far only bugs :)
@JohnMcLear I did it! ... I change the nfc plugin and add 2 functions one who reads and returns the data from all sectors and the other reads a sector specific block. code so no more optimal for the moment but it works :) if anyone needs it let me know
@valemunoz submit it as a pull request so we can see the changes, it wont be merged but at least it's there as a point of reference.
oki doki... but how i do that? :)
Fork this plugin then clone your plugin
Make your changes
Add & Commit your changes git add . && git commit -m "my changes
push your changes to your fork (using git) git push
Then click Pull request in the Github interface, select this repository as the destination and your repository as the source.
ok!! sorry but my English is not very good and i did not understand before :/
now is ready(i think).
@valemunoz, @don, i need to read sectors and blocks too. where line on NfcPlugin.java that need to change? btw, i dont know java programming.
@sutriadi there are 2 pull requests #155 and #156 that have code for reading mifare. I haven't had time to review and clean up before merging. Give them a try and see if it works for you.
Hi, I try the code for reading mifare but it's not working for me. Someone have a sample code ?
@JohnMcLear I did it! ... I change the nfc plugin and add 2 functions one who reads and returns the data from all sectors and the other reads a sector specific block. code so no more optimal for the moment but it works :) if anyone needs it let me know
@valemunoz, where do i find this plugin code? We are trying to do a similar read from Ionic stack, to read bytes / values from all blocks / sectors and they dont follow NDEF formats. Please help to get a walk through on this solution you did..
Hi, Im trying to read from a Mifare Card with you plugin, in Android the Mifare Class is used to connect and read the data, but if I get the tag as a Json from your plugin, How could I read the data as this: mifareClassic.connect(); mifareClassic.authenticateSectorWithKeyA(); mifareClassic.getBlockCountInSector(); mifareClassic.readBlock();
Is it possible to do that with javaScript? Im using a Android mobile that can read Mifare.