NFC的Mifare标签超轻写作 [英] NFC Mifare Ultralight tags writing

查看:165
本文介绍了NFC的Mifare标签超轻写作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何教程如何在超轻的Mifare标签写的?

Any tutorial for how to write on Mifare Ultralight tags ?

我一直在寻找了一段时间

I have been searching for a while

推荐答案

MifareUltraLight标签包含16页,每页包含4个字节。它的第一个4页包含制造商信息,OTP和锁定字节。
越来越标签后,您可以使用此得到MifareUltralight类:

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"));

下面的 PAGENUMBER是你想要写页数据的页面是你想要写数据。 pageData必须等于4个字节和页面数必须小于16。
完整code是在这里:

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();
        }
    }

}

您还可以看到code样品从我的仓库

You can also see the code sample From my repository

这篇关于NFC的Mifare标签超轻写作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆