OpticonRL

Revision as of 30 April 2012 15:42 by Jleiseth (Comments | Contribs) | (OpticonRL for Mac OS X)

Summary

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.

OpticonRL for Windows

OpticonRL for Windows is a stand-alone executable, with no installation required.

  • Simply download the zipped file here http://ftp.opticonusa.com/OpticonRL/WindowsPC/1.18/OpticonRL_10520I.zip
  • Extract the contents to a convenient location like your desktop.
  • Open the folder and double click on OpticonRL.exe.
  • Select settings.
  • Select the COM port of the device you want to use, and select "Toggle on/off".
  • Adjust the other settings if needed.
  • You have now finished setting up OpticonRL for Windows, so try it!

Are you using an OPL9724 to transmit data in real time to OpticonRL for Windows? Check out the article here.

OpticonRL for Mac OS X

To get setup with OpticonRL for Mac

This section has moved to the Mac OS X platform page.

OpticonRL for Android

OpticonRL for Android should work on any android device capable of bluetooth SPP communication. We have done specific testing with the following devices: Motorolla Droid, Thunderbolt, HTC, Galaxy Tab, Archos 101, Toshiba Thrive, and we have customers using almost every other android device in existence.

  • Download the zipped file from Opticon's FTP - Download
  • For your convenience we made a youtube video that walks you through using OpticonRl for the first time: http://www.youtube.com/watch?v=Qc_Yh9Vacss
  • Using the OPL9724 with the Galaxy Tab or another Android 2.2.1 device? Check out the article here.

OpticonRL for Windows Mobile 6.0, 6.1, and 6.5

Use this version of OpticonRL on our H16, H19, H21 and H22 devices. This file includes installation instructions.

Download

Usage

  1. To connect to a device using OpticonRL, tap on its listing on the Windows Mobile Today Screen, which is the first screen you see when you start up your device.
  2. Tap "Discover." Wait for the operation to be completed. Your device will appear in the list if it is discoverable.
  3. Select your device from the list.
  4. Tap "Connect" to begin connecting to your device. Follow the prompts, and make sure that you enter the correct PIN code. When you are finished your device should be connected to OpticonRL.

OpticonRL for Pocket PC

All versions of Windows Mobile prior to Windows Mobile 6.0 use M2694. Current version is 2694.0A or version 1.10.

OpticonRL for Palm

OpticonRL for BlackBerry

Please see the wiki page dedicated to the BlackBerry platform.

Software Development

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

  • The Android UI is not thread safe, so all connection handles have to be under the thread and the Handler needs to be used to talk to the UI.
  • OpticonRL is similar to Google's example. As a starting point we recommend using this example to see if the device can be connected.
<Android-sdk>/samples/android-7/BluetoothChat
  • If you have a resource busy problem it might be caused by an incorrect UUID. UUIDs do change with different Android devices. Please try several different UUIDs such as:
    • "00001101-0000-1000-8000-00805F9B34FB"
    • "fa87c0d0-afac-11de-8a39-0800200c9a66"

Code Examples

  • The Google example above does not address reconnections. An example of this is below.
Disconnections

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);
            }
        }
    }

Reconnections

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);



Useful links