Android Question use the acs reader NFC API

dannythevii

Member
Licensed User
hi to all

i want to read/write a nfc ntag or mifare ultralight with an acs external reader.

this code work well, but i don't understant how to read/write cards

someone can help me with an axample or a little demo ?

please :oops:

tanks
 

dannythevii

Member
Licensed User
mr. Erel,
initialy tanks.
i already do this, i used the code of mr. JTMartins, but it not read/write the fields of card
in this moment i try to understand the acs evk but for me is very hard :(

I had seen that many posts on forum works correctly on internal nfc reader op bluethoot , not on usb; on various post like https://www.b4x.com/android/forum/threads/nfc-tagwriter-and-ibeacon-libraries-for-free.42137/

when the procedure comes to .EnableForegroundDispatch there is an exception if the lector is external usb, nothing if internal.

tanks for all your help
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I'm not sure that this library supports writing
It does Support writing. But only "SmartAccess"-Cards. These Cards have 3 Strings stored. Name, Company and Position.
You are not able to create userdefined NFC-Card-Content with the ACSSMC Lib.
Except if you write new Classes to Write/Read the Content of the Cards presented to the Reader.

I did a recompile of their SmartAccess-App to look at the sources.

There are a few methods to read or write to a specific Card (Mifare, Acos3). But all of them will create/read just the Cards with those 3 Strings.
Name, Company and Position.

Based on the code of these Methods one should be able to create specific mthods for any Kind of Data. I guess. I´m not sure if i would able as i did not understand the code completely

Example (note that is a source based on a decompiled APK)
B4X:
    public void writeMifareCard() {
        this._receiveDataList = new ArrayList();
        this._commandApduList = new ArrayList();
        this._receiveCount = 0;
        resetAll();
        try {
            this._commandType = COMMAND_TYPE.UPDATE_BLOCK;
            byte[] dataToWrite = new byte[16];
            System.arraycopy(Helper.stringToByteArray("SMARTACCESSAPP", 14), 0, dataToWrite, 0, 14);
            this._mifare.updateBinaryBlock((byte) 4, dataToWrite, (byte) 16);
            this._commandApduList.add(0, this._mifare.get_apdu().getCommand(false));
            dataToWrite = new byte[32];
            System.arraycopy(this._name, 0, dataToWrite, 0, this._name.length);
            this._mifare.updateBinaryBlock((byte) 5, dataToWrite, (byte) 32);
            this._commandApduList.add(1, this._mifare.get_apdu().getCommand(false));
            this._acr1255.authenticate((byte) 8, KEYTYPES.ACR1281_KEYTYPE_A, (byte) 0);
            this._commandApduList.add(2, this._acr1255.get_apdu().getCommand(false));
            dataToWrite = new byte[16];
            System.arraycopy(this._organization, 0, dataToWrite, 0, this._organization.length);
            this._mifare.updateBinaryBlock((byte) 8, dataToWrite, (byte) 16);
            this._commandApduList.add(3, this._mifare.get_apdu().getCommand(false));
            dataToWrite = new byte[16];
            System.arraycopy(this._position, 0, dataToWrite, 0, this._position.length);
            this._mifare.updateBinaryBlock((byte) 9, dataToWrite, (byte) 16);
            this._commandApduList.add(4, this._mifare.get_apdu().getCommand(false));
            startCommandExecution();
        } catch (Exception e) {
        }
    }

The problem is one needs to know how these "APDU"-Commands/Protocol works... Honestly i did not read much in the documentation... just the source :)

I´ll be probably able to provide a lib which can read/write such Cards (working on it). Not sure if i get success with it.
 
Upvote 0

dannythevii

Member
Licensed User
Thanks mr. Manfred, very kind and competent.
Also because I did not think to decompile an apk or a library ! ;)

I asked to acs help for low level commands, if they answer me... i place it here ! Maybe we can make a universal library.

Now understand why there are so many NFC apps on android ... why if one can do a program like that ... ALL MUST KNOW !!! :D:D:D

But maybe some other friend can help us ... please :oops::oops:

Thanks and compliments
Daniele
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Additionally to the ACSSMC lib there is a Lib for the Reader itself (without methods to read/write SmartAccess cards).

This library is able to execute APDU-Commands and to receive the Answer to the call.
So, one have the rigth tools to communicate with the reader and send commands to read/write. But i dont know how the APDU must look like.
I may be able to find out with reverse engeneering the ACS App.

I have a wrap working for my ACR1522-J1. You can find it here

But: I guess we need to have a cmbination of both. The reader and the SMC lib. I´m working on it.
 
Upvote 0

dannythevii

Member
Licensed User
dear DonManfred

i had seen that library usbserial -> deviceinfo() see all info of reader ... i think is a good start.
your is a great work but only for bluethooth

i think a good idea is also to "sniff" the output of a serial reader (now i search to my friends) so we can see all traffit to/from reader.

but ... if i understant ... you have changed a java library in b4a library ?? great work !!!

regards and tanks for now


p.s. More hard the way ... more sweet the victory !!
 
Last edited:
Upvote 0

dannythevii

Member
Licensed User
I'm sorry to have annoyed asking help, but this problem is very important to me.

mr. DonManfred ... thank's for your attempts to help me

best regards
 
Upvote 0
Top