NFC Mifare Ultralight tags writing [closed]

别来无恙 提交于 2019-12-12 11:17:31

问题


Any tutorial for how to write on Mifare Ultralight tags ?

I have been searching for a while


回答1:


MifareUltraLight tags it contains 16 page and each page contains 4 bytes. Its first 4 page contains manufacturer info , OTP and locking bytes. After getting The Tag you can get MifareUltralight class using this:

MifareUltralight mifare = MifareUltralight.get(tag);

When you get the tag then before read and write into a page you must have to connect. When Connect successfully then using this Command you can write:

 mifare.writePage(pageNumber, pageData.getBytes("US-ASCII"));

here pageNumber is the page where you want to write and page data is Data that you want to write. pageData must be equals 4 bytes and page Number must less than 16. The Complete Code is here:

public void writeOnMifareUltralightC( Tag tag,
        String pageData, int pageNumber) {
    MifareUltralight mifare = null;

    try {
        mifare = MifareUltralight.get(tag);
        mifare.connect();
        mifare.writePage(pageNumber, pageData.getBytes("US-ASCII"));

    } catch (Exception ex) {
        ex.printStackTrace();
    } finally {
        try {
            mifare.close();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

}

You can also see the code sample From my repository




回答2:


You might want to look at this StackOverflow question:

Writing NFC tags using a Nexus S

Also, if you haven't done so already, read through the NFC Basics document on the Android developers' site:

http://developer.android.com/guide/topics/nfc/nfc.html

(Admittedly, there's not much documentation out there on this yet. If you get this working, I'd encourage you to write a technical blog post on your experiences!)



来源:https://stackoverflow.com/questions/7368206/nfc-mifare-ultralight-tags-writing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!