uk.co.silentsoftware.reader
Class BluetoothGPSReader

java.lang.Object
  extended by uk.co.silentsoftware.reader.BluetoothGPSReader
All Implemented Interfaces:
javax.bluetooth.DiscoveryListener, GPSReader

public class BluetoothGPSReader
extends java.lang.Object
implements GPSReader, javax.bluetooth.DiscoveryListener

Simple class to associate with a Bluetooth GPS and read the NMEA data in, making a call back to the current displayed view


Field Summary
 
Fields inherited from interface javax.bluetooth.DiscoveryListener
INQUIRY_COMPLETED, INQUIRY_ERROR, INQUIRY_TERMINATED, SERVICE_SEARCH_COMPLETED, SERVICE_SEARCH_DEVICE_NOT_REACHABLE, SERVICE_SEARCH_ERROR, SERVICE_SEARCH_NO_RECORDS, SERVICE_SEARCH_TERMINATED
 
Constructor Summary
BluetoothGPSReader(BluetoothListView bluetoothListView)
          Default constructor with a view (data renderer) argument
 
Method Summary
 void deviceDiscovered(javax.bluetooth.RemoteDevice rd, javax.bluetooth.DeviceClass dc)
           
 void discoverGPS()
          Simple method to search for any nearby bluetooth device and initiate connection (if it has a serial port - see inquiryCompleted method)
 java.lang.String getLastDeviceName()
          Returns the BT name of the last GPS that was connected to
 void inquiryCompleted(int discType)
           
 void resetToCleanStatus()
          Resets the Bluetooth discovery transaction id, whether BT is still connected, and blanks the device name in the configuration.
 void selectDevice(int index, java.lang.String name)
          Connect to the chosen BT GPS
 void selectDevice(java.lang.String name)
          Connect to the chosen Bluetooth GPS
 void servicesDiscovered(int transID, javax.bluetooth.ServiceRecord[] sr)
           
 void serviceSearchCompleted(int arg0, int respCode)
           
 void shutdown()
          Flag to shutdown the reader and disconnect the socket
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BluetoothGPSReader

public BluetoothGPSReader(BluetoothListView bluetoothListView)
Default constructor with a view (data renderer) argument

Method Detail

deviceDiscovered

public void deviceDiscovered(javax.bluetooth.RemoteDevice rd,
                             javax.bluetooth.DeviceClass dc)
Specified by:
deviceDiscovered in interface javax.bluetooth.DiscoveryListener

inquiryCompleted

public void inquiryCompleted(int discType)
Specified by:
inquiryCompleted in interface javax.bluetooth.DiscoveryListener

getLastDeviceName

public java.lang.String getLastDeviceName()
Returns the BT name of the last GPS that was connected to

Returns:

servicesDiscovered

public void servicesDiscovered(int transID,
                               javax.bluetooth.ServiceRecord[] sr)
Specified by:
servicesDiscovered in interface javax.bluetooth.DiscoveryListener

resetToCleanStatus

public void resetToCleanStatus()
Resets the Bluetooth discovery transaction id, whether BT is still connected, and blanks the device name in the configuration. Typically used when a GPS connection fails.


serviceSearchCompleted

public void serviceSearchCompleted(int arg0,
                                   int respCode)
Specified by:
serviceSearchCompleted in interface javax.bluetooth.DiscoveryListener

selectDevice

public void selectDevice(int index,
                         java.lang.String name)
Connect to the chosen BT GPS

Parameters:
index -

selectDevice

public void selectDevice(java.lang.String name)
Connect to the chosen Bluetooth GPS

Parameters:
name -

discoverGPS

public void discoverGPS()
Simple method to search for any nearby bluetooth device and initiate connection (if it has a serial port - see inquiryCompleted method)

Specified by:
discoverGPS in interface GPSReader

shutdown

public void shutdown()
Flag to shutdown the reader and disconnect the socket

Specified by:
shutdown in interface GPSReader