为什么我不能读ST M24LR64与Android的NFC NDEF消息 [英] Why I can't read ST M24LR64 as NDEF messages with Android NFC

查看:541
本文介绍了为什么我不能读ST M24LR64与Android的NFC NDEF消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从意法半导体的M24LR64 IC支持ISO 15693协议,也被称为NfcV在Android的NFC。当我把我的歌Nexus S手机(Android的4.0.4)接近我的原型标签板,我能听到蜂鸣声,看到了logcat的发射的消息:

M24LR64 IC from STMicroelectronics supports ISO 15693 protocol, also called NfcV in Android NFC. When I placed my Nexus S phone (Android 4.0.4) near to my prototype tag board, I could hear a beep, and saw a message fired by the logcat:

no tag fallback activity found for Intent { act = android.nfc.action.TAG_DISCOVERED}

我不知道为什么在Android派出ACTION_TAG_DISCOVERED的意图,而不是ACTION_NDEF_DISCOVERED,因为我已经构造了以下的ST应用笔记的NDEF格式的邮件。我可以读取称为NfcV阅读器的ST自己的阅读器软件的NDEF消息。

I wondered why the android dispatched the ACTION_TAG_DISCOVERED intent, not the ACTION_NDEF_DISCOVERED, because I had constructured the ndef format messages following the ST application note. And I can read the NDEF message with the ST own reader software called NfcV-Reader.

然后我在android系统组成的演示程序,以确认问题。当我注册的意图与此的Andr​​oidManifest.xml

Then I composed a demo program in android to verify the problem. When I registered intent with this AndroidManifest.xml

<intent-filter>
    <action android:name="android.nfc.action.NDEF_DISCOVERED" />
    <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

我无法接收NFC消息。当我修改这个
    
        
        
    

I can't receive the NFC message. When I modified with this

我可以接收来自Android系统的NFC消息。
但是,当我检查了NDEF消息与前pression

I can receive the NFC message from Android system. But when I checked the NDEF message with the expression

Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);

rawMsgs 变量
所以,我回顾了ST NfcV阅读器源$ C ​​$ C,并发现它已经从加工EEPROM M24LR64所有的数据与读取的块。这意味着原始数据的读取,不要使用过的,现成的工具,从Android的NFC和NDEF。

the rawMsgs variable is null! So I reviewed the ST NfcV-Reader source code, and found that it had processed all the data from M24LR64 EEPROM with read block. That means raw data read, do not use off-the-shelf utility from Android NFC and NDEF.

protected Void doInBackground(Void... params)
{
    DataDevice dataDevice = (DataDevice)getApplication();
    fullNdefMessage = null;
    byte[] resultBlock0 = new byte[4];
    byte[] resultBlock1 = new byte[8];
    cpt = 0;

    resultBlock0 = null;
    while ((resultBlock0 == null || resultBlock0[0] == 1)&& cpt<1500)
    {
        resultBlock0 = NFCCommand.SendReadSingleBlockCommand(dataDevice.getCurrentTag(), new byte[]{0x00,0x00}, dataDevice);
        cpt ++;
        Log.v("CPT ", " CPT Read Block 0 ===> " + String.valueOf(cpt));
    }

    //if CC0 = E1h & CC1 = right version
    if(resultBlock0[0]==(byte)0x00 && resultBlock0[1]==(byte)0xE1 && resultBlock0[2]==(byte)0x40)
    {
        //NDEF TAG Format valid
        cpt = 0;
        resultBlock1 = null;

        while ((resultBlock1 == null || resultBlock1[0] == 1) && cpt < 10)
        {
            resultBlock1 = NFCCommand.SendReadMultipleBlockCommand(dataDevice.getCurrentTag(),new byte[]{0x00,0x01}, (byte)0x02, dataDevice);
        }
        if(resultBlock1[1]==(byte)0x03 && resultBlock1[6]==(byte)0x54) // Text message
        {
            if(resultBlock1[5]<0)
                numberOfBlockToRead = ((resultBlock1[5] + 256 + 14)/4);
            else
                numberOfBlockToRead = ((resultBlock1[5] + 14)/4);
        }
        else if(resultBlock1[1]==(byte)0x03 && resultBlock1[6]==(byte)0x55) // URL message
        {
            if(resultBlock1[1]<0)
                numberOfBlockToRead = ((resultBlock1[2] + 256 + 12)/4);
            else
                numberOfBlockToRead = ((resultBlock1[2] + 12)/4);
        }
    }
    else
    {
        //Not NDEF TAG Format
        numberOfBlockToRead = 0;
    }

    bNumberOfBlock = Helper.ConvertIntTo2bytesHexaFormat(numberOfBlockToRead);

    cpt = 0;
    if(numberOfBlockToRead <32)
    {
        while ((fullNdefMessage == null || fullNdefMessage[0] == 1) && cpt < 10 && numberOfBlockToRead != 0)
        {
            fullNdefMessage = NFCCommand.SendReadMultipleBlockCommandCustom(dataDevice.getCurrentTag(),new byte[]{0x00,0x00}, bNumberOfBlock[1], dataDevice);
            cpt++;
        }
    }
    else
    {
        while ((fullNdefMessage == null || fullNdefMessage[0] == 1) && cpt < 10 && numberOfBlockToRead != 0)
        {
            fullNdefMessage = NFCCommand.SendReadMultipleBlockCommandCustom2(dataDevice.getCurrentTag(),new byte[]{0x00,0x00}, bNumberOfBlock, dataDevice);
            cpt++;
            Log.i("CPT ", "***** " + String.valueOf(cpt));
        }
    }

    return null;
}

我的问题是我是否能使用android NDEF设施,但没有原始块的读写处理我的NFC标签符合ISO 15693?我怎样才能在M24LR64 EEPROM格式化我的数据?

My question is whether I can use the android NDEF facility but not raw block read and write to process my NFC tag with ISO 15693? How can I format my data in M24LR64 EEPROM?

推荐答案

的M24LR64和类似LRiS64K芯片不支持标准ISO 15693读取命令。 (他们可以轻松地从他们的标签ID识别,虽然。)ST定义和<一个href=\"http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/APPLICATION_NOTE/DM00029842.pdf\"相对=nofollow>公布最近的方式来存储这样的标签NDEF消息。这在某种程度上非常相似,它是如何在NXP我code SLI标签完成,为此,Android提供支持完成。但是,目前,在Android中的NFC软件栈提供了ST NfcV标签NDEF的支持。

The M24LR64 and the similar LRiS64K chips do not support the standard ISO 15693 read commands. (They can easily be recognized from their tag ID, though.) ST has defined and published recently a way to store NDEF messages on such tags. This is done in a way quite similar to how it is done on NXP ICODE SLI tags, for which Android provides support. However, currently, the NFC software stack in Android provides no support for NDEF on ST NfcV tags.

更新:

Nexus的4现在有上除了NXP I code其他 NfcV 标签NDEF存储支持。现在有对TI的Tag-它HF-I标签和ST标签,如LRI2K NDEF存储支持。

The Nexus 4 now has support for NDEF storage on other NfcV tags besides NXP ICODE. There is now support for NDEF storage on TI Tag-it HF-I tags and ST tags like LRi2K.

这篇关于为什么我不能读ST M24LR64与Android的NFC NDEF消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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