ims.devicemanager
Class BluetoothDataManager

java.lang.Object
  extended by ims.devicemanager.BluetoothDataManager

public class BluetoothDataManager
extends java.lang.Object

This class provides the main components that are needed for connecting with a Bluetooth device, hold the connection and to receive and read the input of the device.

Copyright © 2014 by Daniela Blum

This file is part of GPSChildFinder.
GPSChildFinder is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses.

Author:
Daniela Blum

Constructor Summary
BluetoothDataManager(android.bluetooth.BluetoothSocket bluetoothSocket)
          Constructor which calls setupStreamReader() to read the input from the socket.
 
Method Summary
 void close()
          Cleans up this class by closing the stream and reader and setting the BluetoothConnectThread.GETTING_GPS_INPUT to false.
 double getLatitude()
           
 double getLongitude()
           
 void readNMEASentences()
          Is called when the Bluetooth socket is connected to a Bluetooth device.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BluetoothDataManager

public BluetoothDataManager(android.bluetooth.BluetoothSocket bluetoothSocket)
Constructor which calls setupStreamReader() to read the input from the socket.

Parameters:
bluetoothSocket - currently connected Bluetooth socket
Method Detail

readNMEASentences

public void readNMEASentences()
                       throws java.io.IOException
Is called when the Bluetooth socket is connected to a Bluetooth device.
The method reads the sentences send from the device to the phone. When the sentences start with $GPGGA they are GPS NMEA scentences and contain the GPS coordinates of the device, so getCoordinates(String) is called.

Throws:
java.io.IOException - when the connection get lost.

getLatitude

public double getLatitude()
Returns:
the current latitude

getLongitude

public double getLongitude()
Returns:
the current longitude

close

public void close()
Cleans up this class by closing the stream and reader and setting the BluetoothConnectThread.GETTING_GPS_INPUT to false.