OpticonRL is an application developed separately for multiple platforms that converts barcode data coming over a serial port into key presses. Since the majority of our products support serial communication in one way or another this can be especially useful. In effect, the barcode data is wedged into whatever application is at the forefront and has text focus, as if it were typed.
This section has moved to the Windows platform page.
This section has moved to the Mac OS X platform page.
This section has moved to the Android platform page. For general information about using Opticon Products with Android devices please see the wiki page dedicated to the Android platform.
Use this version of OpticonRL on our H16, H19, H21 and H22 devices. This file includes installation instructions.
All versions of Windows Mobile prior to Windows Mobile 6.0 use M2694. Current version is 2694.0A or version 1.10.
This section has moved to the Blackberry platform page. For general information about using Opticon Products with BlackBerry please see the wiki page dedicated to the BlackBerry platform.
Since Bluetooth Serial Port data requires an application present on the host device to receive the incoming data Opticon developed it's OpticonRL application. OpticonRL intercepts the serial data and injects it at the cursor. In some cases an application developer may wish to have direct control of the serial data and replace OpticonRL. This section contains a few hints and tips for duplicating the functionality of OpticonRL within your own application.
<Android-sdk>/samples/android-7/BluetoothChat
Once the device is connected, start the ConnectedThread to begin managing a Bluetooth connection.
public synchronized void connected(BluetoothSocket socket, BluetoothDevice device) { // Cancel the thread that completed the connection if (mConnectThread != null) { mConnectThread.cancel(); mConnectThread = null; } // Cancel any thread currently running a connection if (mConnectedThread != null) { mConnectedThread.cancel(); mConnectedThread = null; } // Cancel the accept thread because we only want to connect to one device if (mAcceptThread != null) { mAcceptThread.cancel(); mAcceptThread = null; } // Start the thread to manage the connection and perform transmissions mConnectedThread = new ConnectedThread(socket); mConnectedThread.start(); // Send the name of the connected device back to the UI Activity Message msg = mHandler.obtainMessage(OpticonRL.MESSAGE_DEVICE_NAME); Bundle bundle = new Bundle(); bundle.putString(OpticonRL.DEVICE_NAME, device.getName()); msg.setData(bundle); mHandler.sendMessage(msg); setState(STATE_CONNECTED);
Implement ConnectedThread - When the device is disconnected, IOExceptin is thrown in while roop in run function. Notify to the UI Activity.
/* * * This thread runs during a connection with a remote device. * It handles all incoming and outgoing transmissions. * */ public class ConnectedThread extends Thread { private final BluetoothSocket mmSocket; private final InputStream mmInStream; public ConnectedThread(BluetoothSocket socket) { Log.d(TAG, "create ConnectedThread"); mmSocket = socket; InputStream tmpIn = null; // Get the BluetoothSocket input and output streams try { tmpIn = socket.getInputStream(); } catch (IOException e) { Log.e(TAG, "temp sockets not created", e); } mmInStream = tmpIn; } public void run() { Log.i(TAG, "BEGIN mConnectedThread"); byte[] buffer = new byte[1024]; int bytes; // Keep listening to the InputStream while connected while (true) { try { // Read from the InputStream bytes = mmInStream.read(buffer); // Send the obtained bytes to the UI Activity mHandler.obtainMessage(OpticonRL.MESSAGE_READ, bytes, -1, buffer).sendToTarget(); } catch (IOException e) { Log.e(TAG, "disconnected", e); // Connection is LOST (disconnected from device) break; } } } public void cancel() { try { mmSocket.close(); } catch (IOException e) { Log.e(TAG, "ConnectedThread close()", e); } } }
Override AsyncTask and make an application run background.
private class Reconnect extends AsyncTask<BluetoothDevice, Void, Boolean > { BluetoothService mService = null; boolean stopReconnect = false; public Reconnect(BluetoothService mService){ this.mService = mService; } @Override protected void onCancelled() { } @Override protected Boolean doInBackground(BluetoothDevice... arg0) { // if device is not connected, create timer and keep connecting for certain time. } }
Excecute AsyncTask when device was disconnected.
private Reconnect task = new Reconnect(mService); task.execute(device);