diff options
author | Sylvain Fonteneau <sylvain.fonteneau@trusted-logic.com> | 2010-11-24 05:16:35 -0800 |
---|---|---|
committer | Android Partner Code Review <android-gerrit-partner@google.com> | 2010-11-24 05:16:35 -0800 |
commit | 78fe74b1207f1afe88e6df4fe5b629c41c667b6b (patch) | |
tree | ce9503deb62a2de0b94df4c364ca998afad14699 /src/com | |
parent | 2be7931d6e3be031a3e046d445b52e379ba1a1d5 (diff) | |
parent | bcccb386fe1dc20401b88ab0b0e493a8dbe7615c (diff) | |
download | packages_apps_nfc-78fe74b1207f1afe88e6df4fe5b629c41c667b6b.zip packages_apps_nfc-78fe74b1207f1afe88e6df4fe5b629c41c667b6b.tar.gz packages_apps_nfc-78fe74b1207f1afe88e6df4fe5b629c41c667b6b.tar.bz2 |
Merge "Enabled sending of large messages in MyTagClient." into gingerbread-nfc
Diffstat (limited to 'src/com')
-rwxr-xr-x | src/com/android/nfc/mytag/MyTagClient.java | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/com/android/nfc/mytag/MyTagClient.java b/src/com/android/nfc/mytag/MyTagClient.java index d515f88..b42fb99 100755 --- a/src/com/android/nfc/mytag/MyTagClient.java +++ b/src/com/android/nfc/mytag/MyTagClient.java @@ -37,6 +37,7 @@ import java.io.IOException; */ public class MyTagClient extends BroadcastReceiver { private static final String TAG = "MyTagClient"; + private static final int MIU = 128; private static final boolean DBG = true; public MyTagClient(Context context) { @@ -69,17 +70,29 @@ public class MyTagClient extends BroadcastReceiver { public Void doInBackground(NdefMessage... msgs) { NfcService service = NfcService.getInstance(); NdefMessage msg = msgs[0]; + byte[] buffer = msg.toByteArray(); + byte[] tmpBuffer = new byte[MIU]; + int offset = 0; try { if (DBG) Log.d(TAG, "about to create socket"); // Connect to the my tag server on the remote side - LlcpSocket sock = service.createLlcpSocket(0, 128, 1, 1024); + LlcpSocket sock = service.createLlcpSocket(0, MIU, 1, 1024); if (DBG) Log.d(TAG, "about to connect"); // sock.connect(MyTagServer.SERVICE_NAME); sock.connect(0x20); - // Push the local NDEF message to the server - if (DBG) Log.d(TAG, "about to send"); - sock.send(msg.toByteArray()); + if (DBG) Log.d(TAG, "about to send a " + buffer.length + "-bytes message"); + while (offset < buffer.length) { + int length = buffer.length - offset; + if (length > tmpBuffer.length) { + length = tmpBuffer.length; + } + System.arraycopy(buffer, offset, tmpBuffer, 0, length); + if (DBG) Log.d(TAG, "about to send a " + length + "-bytes packet"); + sock.send(tmpBuffer); + offset += length; + } + if (DBG) Log.d(TAG, "about to close"); sock.close(); |