ch.aplu.bluetooth
Class BluetoothClient

java.lang.Object
  extended by ch.aplu.bluetooth.BluetoothClient

public class BluetoothClient
extends java.lang.Object

Class to create a client that connects to a server via Bluetooth. The server's Bluetooth name has to be added manually to the known Bluetooth device list using the Lejos command processor. Keep in mind that a server must be up and running before any client can connect.


Constructor Summary
BluetoothClient()
           
BluetoothClient(java.lang.String serverName)
          Creates a BluetoothClient instance for the given server's Bluetooth name that will connect to channel 1.
 
Method Summary
 boolean connect()
          Connects the client to the host.
 void disconnect()
          If connected, closes input and output streams and releases the Bluetooth communication.
 java.io.InputStream getInputStream()
           
 java.io.OutputStream getOutputStream()
           
 int getSignalStrength()
          Get the signal strength of the connection.
 boolean isConnected()
          Returns the connection state.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BluetoothClient

public BluetoothClient()

BluetoothClient

public BluetoothClient(java.lang.String serverName)
Creates a BluetoothClient instance for the given server's Bluetooth name that will connect to channel 1. No connection is established a this time.

Method Detail

connect

public boolean connect()
Connects the client to the host.

Returns:
true, if successful; false, if connection cannot be established because the remote device is not added to the device list

disconnect

public void disconnect()
If connected, closes input and output streams and releases the Bluetooth communication.


isConnected

public boolean isConnected()
Returns the connection state.

Returns:
true, if connected, otherwise false

getInputStream

public java.io.InputStream getInputStream()

getOutputStream

public java.io.OutputStream getOutputStream()

getSignalStrength

public int getSignalStrength()
Get the signal strength of the connection. Returns -1 if not connected. Do not invoke while performing a data transfer because the data stream is closed and reopened.

Returns:
a value from 0 to 255