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}
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.
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>
I can't receive the NFC message. When I modified with this
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);
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;
}
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?