javax.bluetooth
Class LocalDevice

java.lang.Object
  extended by javax.bluetooth.LocalDevice

public class LocalDevice
extends Object

Singleton class representing a local NXT Bluetooth device. Most methods are standard, except you can also set the friendly name with this class.

Author:
BB

Method Summary
 String getBluetoothAddress()
          Returns the local Bluetooth address of NXT brick.
 DeviceClass getDeviceClass()
          The Bluetooth device class for the LEGO NXT brick.
 int getDiscoverable()
          Indicates whether the NXT brick is visible to other devices
 DiscoveryAgent getDiscoveryAgent()
          Returns the discovery agent for this device.
 String getFriendlyName()
          Returns the friendly name of a Bluetooth device.
static LocalDevice getLocalDevice()
           
static String getProperty(String property)
          UNIMPLEMENTED! Returns null always.
static boolean isPowerOn()
          Power state of the Bluecore 4 chip in the NXT brick.
 boolean setDiscoverable(int mode)
          Normally the mode values are found in javax.bluetooth.DiscoveryAgent.
 boolean setFriendlyName(String name)
          Changes the friendly name of the NXT brick.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getLocalDevice

public static LocalDevice getLocalDevice()
                                  throws BluetoothStateException
Throws:
BluetoothStateException

getDiscoveryAgent

public DiscoveryAgent getDiscoveryAgent()
Returns the discovery agent for this device. Multiple calls to this method will return the same object. This method will never return null.

Returns:
the discovery agent for the local device

getFriendlyName

public String getFriendlyName()
Returns the friendly name of a Bluetooth device. NOTE: If you want to set the friendly name, it can be done through the LCP class or using the NXJExplorer program on your personal computer.

Returns:
the friendly name

setFriendlyName

public boolean setFriendlyName(String name)
Changes the friendly name of the NXT brick. NOTE: This method is not part of the standard JSR 82 API because not all Bluetooth devices can change their friendly name. This method does not work. Technically this should be done through LCP so USB can also change it.

Parameters:
name - new friendly name
Returns:
true = success, false = failed

getDeviceClass

public DeviceClass getDeviceClass()
The Bluetooth device class for the LEGO NXT brick. The Lego Bluecore code can't retrieve this from the chip. Always returns hardcoded 0x3e0100 DeviceClass Untested if this is correct device class or not.

Returns:
the device class

setDiscoverable

public boolean setDiscoverable(int mode)
                        throws BluetoothStateException
Normally the mode values are found in javax.bluetooth.DiscoveryAgent. We don't have this yet in NXJ so use 0 for invisible, any other value for visible.

Parameters:
mode - 0 = invisible, all other = visible.
Returns:
true if successful, false if unsuccessful
Throws:
BluetoothStateException

isPowerOn

public static boolean isPowerOn()
Power state of the Bluecore 4 chip in the NXT brick.

Returns:
the power state

getDiscoverable

public int getDiscoverable()
Indicates whether the NXT brick is visible to other devices

Returns:
0 = not discoverable, all other = discoverable

getProperty

public static String getProperty(String property)
UNIMPLEMENTED! Returns null always. Returns various properties about the bluetooth implementation such as version, whether master/slave switch allowed, etc.. Possibly use Properties class in implementation.

Parameters:
property -
Returns:
null

getBluetoothAddress

public String getBluetoothAddress()
Returns the local Bluetooth address of NXT brick.

Returns:
the address