RFD2000 trigger event blocked by TCP connection?

Good morning,

I'm currently developing a relatively simple RFID reader app for the TC20/RFD2000 using the RFID API3.

Its point is to scan RFIDs and send the tag data to a server application in JSON format via a simple TCP socket.

Now, for some reason I can't figure out, once I run the connection task that creates my TCP client instance and listens for server response, the trigger of the RFD2000 stops working. Checking Logcat I see that instead of the usual

05-25 09:06:58.444 13429-13447/com.saco.mrott.rfidapp I/Android SDK API: Notification_TriggerEvent TRIGGER_PRESS

    Notification_TriggerEvent TRIGGER_RELEASE

I get a lot of

05-25 09:06:54.663 13429-13429/com.saco.mrott.rfidapp D/RFIDAPI3: broadcast: TRIGGERScom.symbol.button.R1

05-25 09:06:54.900 13429-13429/com.saco.mrott.rfidapp D/RFIDAPI3: broadcast: TRIGGERScom.symbol.button.R1

05-25 09:06:55.155 13429-13429/com.saco.mrott.rfidapp D/RFIDAPI3: broadcast: TRIGGERScom.symbol.button.R1

05-25 09:06:56.152 13429-13429/com.saco.mrott.rfidapp D/RFIDAPI3: broadcast: TRIGGERScom.symbol.button.R1

05-25 09:06:56.349 13429-13429/com.saco.mrott.rfidapp D/RFIDAPI3: broadcast: TRIGGERScom.symbol.button.R1

instead.

I'm relatively new to android development, but from what I gather it would appear that the notification event doesn't fire as it's supposed to.

I have no idea why this is, the TCPclient class I wrote has literally nothing to do with the API. What am I doing wrong?

Here's the class:

package com.saco.mrott.rfidapp.home.classes;

import com.saco.mrott.rfidapp.home.application.Interfaces;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.Socket;
import java.util.List;

/**
* Very basic TCP client class that connects to a server on a specified port (port=6666 for testing,
* we will see what port we later need to use) and is able to send and receive messages.

*/

public class TCPclient {

   public static final String SERVER_IP = "192.168.199.103";
  public static final int SERVER_PORT = 6666;

  private String mServerMessage;
  private Interfaces.OnMessageReceived mMessageListener = null;

  private Boolean mRun = false;

  private PrintWriter mBufferOut;
  private BufferedReader mBufferIn;

  public TCPclient (Interfaces.OnMessageReceived listener){

   mMessageListener = listener;
   }

   public void sendMessage (final String message){

  Runnable runnable = new Runnable() {

   @Override
   public void run() {

   if (mBufferOut != null) {

   mBufferOut.println(message + "\r\n");
   mBufferOut.flush();
   }

  }

  };
   Thread thread = new Thread(runnable);
   thread.start();
   }

   public void stopClient() {

   mRun = false;

  if (mBufferOut != null) {

   mBufferOut.flush();
   mBufferOut.close();
   }

   mMessageListener = null;
   mBufferIn = null;
   mBufferOut = null;
   mServerMessage = null;

   }

   public void run() {

   mRun = true;

  try {

  InetAddress serverAddress = InetAddress.getByName(SERVER_IP);
   Socket socket = new Socket(serverAddress, SERVER_PORT);

  try {

   mBufferOut = new PrintWriter(socket.getOutputStream());
   mBufferIn = new BufferedReader(new InputStreamReader(socket.getInputStream()));
  int charsRead = 0;
  char[] buffer = new char[1024];

  while (mRun) {

  charsRead = mBufferIn.read(buffer);
   mServerMessage = new String(buffer).substring(0, charsRead);
  if (mServerMessage != null && mMessageListener != null) {

   mMessageListener.messageReceived(mServerMessage);
   }

   mServerMessage = null;
   }

  } catch (Exception e) {

   // handle this somehow
   } finally {

  socket.close();
   }

  } catch (Exception e) {

   // handle this somehow
   }

  }

}

and the AsyncTask that handles the connection:

public class ConnectTask extends AsyncTask<String, String, TCPclient> {

   @Override
   protected TCPclient doInBackground (String... message) {

   mClient = new TCPclient(new Interfaces.OnMessageReceived() {

   @Override
   public void messageReceived(String message) {

  publishProgress(message);
   }

  });

   mClient.run();

  return null;
   }

   @Override
   protected void onProgressUpdate (String... values) {

   super.onProgressUpdate(values);

   // handle server response here


   }

   @Override
   protected void onCancelled() {

   super.onCancelled();

   mClient.stopClient();
   }

}