开发者

NFC Mifare Ultralight tags writing [closed]

开发者 https://www.devze.com 2023-04-04 01:49 出处:网络
Closed. This question is seeking recommendations for books, tools, software libraries, and more. It does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed. This question is seeking recommendations for books, tools, software libraries, and more. It does not meet Stack Overflow guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 8 years ago.

Improve this question

Any tutorial for how to write on Mifare Ultralight tags开发者_JAVA技巧 ?

I have been searching for a while


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


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!)

0

精彩评论

暂无评论...
验证码 换一张
取 消