I am trying to send a long NDEF message from ACR1252 to an android application. i'm using C# to develop the application. it is possible to send a message with length smaller than 256 bytes and also the android app receives the message completely, but for larger messages i use the MI (multiple information) bit in the PFB field to send the message in fragments. i get ack for each message but the android app enters the NFC receive page but does not receive anything at the end.
this is the code that i use to send the message:
sentIndex = 0;
do
{
int tempLen = Min(474, sSNEPMessage_.Length - sentIndex);
int index = 0;
bool firstPacket = sentIndex == 0 ? true : false;
bool lastPacket = (sSNEPMessage_.Length == sentIndex + tempLen) ? true : false;
int iByteLength = 6 + 6 + tempLen / 2;
uSendBuffer = new byte[iByteLength];
uSendBuffer[index++] = 0x11;
if (lastPacket == true)
uSendBuffer[index++] = (byte)(0x00 | (uPNI_ & 0x03)); // PFB
else
uSendBuffer[index++] = (byte)(0x10 | (uPNI_ & 0x03)); // PFB
uSendBuffer[index++] = (byte)(tempLen / 2 + 3 + 6);
uSendBuffer[index++] = (byte)(((uDSAP_ << 2) & 0xFC) | 0x03); // I1
uSendBuffer[index++] = (byte)(uSSAP_ & 0x3F); // I2
uSendBuffer[index++] = (byte)(((uSendSeq_++ << 4) & 0xF0) | (uRecSeq_ & 0x0F)); // Seq
uSendBuffer[index++] = 0x10;
uSendBuffer[index++] = 0x02;
uSendBuffer[index++] = 0x00;
uSendBuffer[index++] = 0x00;
uSendBuffer[index++] = 0x00;
uSendBuffer[index++] = (byte)(tempLen / 2);
for (int i = 0; i < (tempLen / 2); i++)
uSendBuffer[index + i] = Convert.ToByte(sSNEPMessage_.Substring(sentIndex + i * 2, 2), 16);
iSendCnt = 6 + 6 + tempLen / 2;
iConnectComplete_ = 0x00;
uApduResponse = peerToPeer_.depExchange(uSendBuffer, iSendCnt);
sentIndex += tempLen;
uPNI_++;
} while (sentIndex != sSNEPMessage_.Length);
and depExchange is :
public byte[] depExchange(byte[] uDep, int iSendDep)
{
Apdu apdu = new Apdu();
apdu.lengthExpected = 20;
apdu.data = new byte[5];
apdu.data[0] = 0xE0;
apdu.data[1] = 0x00;
apdu.data[2] = 0x00;
apdu.data[3] = 0x43;
apdu.data[4] = (byte)(iSendDep);
apdu.data = Helper.appendArrays(apdu.data, uDep);
apduCommand = apdu;
sendCardControl(ref apdu, operationControlCode);
return apduCommand.response;
}
sendCardControl uses SCardControl to send apdu.
i use the following code to create NDEF message:
void encodeToNdefMessage(String msgToSend)
{
NdefMessage ndefMessage;
NdefRecord tmpRecord;
byte uStatusByte = 0;
byte[] uBuffer;
if (RadioButtonUtf16.Checked)
uStatusByte = 0x80;
uStatusByte |= (byte)msgToSend.Length;
tmpRecord = new NdefRecord(new NdefRecordType(TypeNameFormat.NfcFormWellKnownType, "T"));
tmpRecord.messageBegin = true;
tmpRecord.messageEnd = true;
tmpRecord.payLoad = new byte[] { uStatusByte };
tmpRecord.payLoad = Helper.appendArrays(tmpRecord.payLoad, ASCIIEncoding.ASCII.GetBytes(ComboBoxTextLanguage.Text));
tmpRecord.payLoad = Helper.appendArrays(tmpRecord.payLoad, ASCIIEncoding.ASCII.GetBytes(msgToSend));
ndefMessage = new NdefMessage();
ndefMessage.appendRecord(tmpRecord);
uBuffer = ndefMessage.toByteArray();
sSNEPMessage_ = Helper.byteAsString(uBuffer, false);
}
public byte[] toByteArray()
{
byte[] buffer = new byte[0];
byte[] tmpArray;
int indx = 0;
for (int i = 0; i < ndefRecords.Count; i++)
{
indx = buffer.Length;
if (i == 0)
ndefRecords[i].messageBegin = true;
if ((i + 1) == ndefRecords.Count)
ndefRecords[i].messageEnd = true;
tmpArray = ndefRecords[i].encodeToNDEF();
//Resize destination array to acoomodate new record
Array.Resize(ref buffer, buffer.Length + tmpArray.Length);
//Copy new ndef record to byte array
Array.Copy(tmpArray, 0, buffer, indx, tmpArray.Length);
}
return buffer;
}
Also this is the log : enter image description here