Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javax.bluetooth
Class LocalDevice

    java.lang.Object
      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
`protected char[]` | `convertBytesToChars(byte[] byteArray)`
`protected byte[]` | `convertCharsToBytes(char[] charArray, int length)`
`String` | `getBluetoothAddress()` Returns the local Bluetooth address of NXT brick.
`DeviceClass` | `getDeviceClass()` The Lego Bluecore code can't retrieve this from the chip.
`int` | `getDiscoverable()` Indicates whether the NXT brick is visible to other devices
`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
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait`

Method Detail

### getLocalDevice

    public static LocalDevice getLocalDevice()
                                      throws BluetoothStateException

  Throws:
    `BluetoothStateException`

### 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.

  Returns:
    true = success, false = failed

### convertCharsToBytes

    protected byte[] convertCharsToBytes(char[] charArray,
                                         int length)

### convertBytesToChars

    protected char[] convertBytesToChars(byte[] byteArray)

### getDeviceClass

    public DeviceClass getDeviceClass()

  The Lego Bluecore code can't retrieve this from the chip. Always returns hardcoded 0x3e0100 DeviceClass Untested if this is correct.

  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

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD