|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object lejos.nxt.comm.NXTCommDevice lejos.nxt.comm.Bluetooth
public class Bluetooth
Provides Bluetooth communications. Allows inbound and outbound connections. Provides access to to device registration.
Fields inherited from class lejos.nxt.comm.NXTCommDevice |
---|
ADDRESS_LEN, cs, NAME, NAME_LEN, SERIAL_NO |
Method Summary | |
---|---|
static boolean |
addDevice(RemoteDevice d)
Add device to known devices |
static void |
btDisable()
|
static void |
btEnable()
|
static int |
btGetBC4CmdMode()
Low-level method to get the BC4 chip mode |
static int |
btPending()
Low-Level method to access the Bluetooth interface. |
static int |
btRead(byte[] buf,
int off,
int len)
Low-level method to read BT data |
static void |
btReceive(byte[] buf)
Low-level method to receive BT replies or data |
static void |
btSend(byte[] buf,
int len)
Low-level method to send a BT command or data |
static void |
btSetArmCmdMode(int mode)
Low-level method to switch BC4 chip between command and data (stream) mode. |
static void |
btSetCmdMode(int mode)
Set the BC4 mode, and wait for that mode to be confirmed by the chip. |
static void |
btSetResetHigh()
Low-level method to take the BC4 reset line high |
static void |
btSetResetLow()
Low-level method to take the BC4 reset line low |
static void |
btStartADConverter()
Low-level method to start ADC converter |
static int |
btWrite(byte[] buf,
int off,
int len)
Low-level method to write BT data |
static boolean |
cancelInquiry()
Cancel a Bluetooth inquiry process that has been started using startInquire |
static int |
closeConnection(byte handle)
Close an open connection |
static byte[] |
closePort()
Closes the port to disallow incoming connections. |
static BTConnection |
connect(RemoteDevice remoteDevice)
Connects to a remote device. |
static BTConnection |
connect(String target,
int mode)
Connect to the specified device, either by name or address |
static BTConnection |
connect(String target,
int mode,
byte[] pin)
Connect to the specified device, either by name or address |
static byte[] |
getConnectionStatus()
Get the status of all connections |
static NXTCommConnector |
getConnector()
Provides access to the singleton connection object. |
static String |
getFriendlyName()
Get the friendly name of the local device |
static RemoteDevice |
getKnownDevice(String fName)
Gets a Device of the BC4-Chips internal list of known Devices (those who have been paired before) into the BTDevice Object. |
static Vector |
getKnownDevicesList()
The internal Chip has a list of already paired Devices. |
static String |
getLocalAddress()
get the Bluetooth address of the local device |
static int |
getOperatingMode()
Get the operating mode (stream breaking or not) |
static byte[] |
getPin()
Return the pin to be used for pairing/connecting to the system |
static int |
getPortOpen()
Get the port open status, i.e whether connections are being accepted |
static boolean |
getPower()
Return the current state of the module power |
static int |
getResetCount()
|
static int |
getSignalStrength(byte handle)
Get the Bluetooth signal strength (link quality) Higher values mean stronger signal. |
static int |
getStatus()
Get the persistent status value from the BC4 chip |
static byte[] |
getVersion()
Get the major and minor version of the BlueCore code |
static int |
getVisibility()
Get the visibility (discoverable) status of the device |
static Vector |
inquire(int maxDevices,
int timeout,
byte[] cod)
Start a Bluetooth inquiry process |
static void |
inquireNotify(int maxDevices,
int timeout,
DiscoveryListener listy)
Start a Bluetooth inquiry process and notify listener of each device found. |
static void |
loadSettings()
|
static String |
lookupName(String addr)
Look up the name of a device using its address |
static byte[] |
openPort()
Opens the port to allow incoming connections. |
static int |
readPacket(byte[] buf,
int len)
Read a packet from the stream. |
static boolean |
removeDevice(RemoteDevice d)
Remove device from known devices |
static void |
reset()
Force a reset of the Bluetooth module. |
static void |
sendPacket(byte[] buf,
int bufLen)
Send a data packet. |
static int |
setFactorySettings()
Reset the settings of the BC4 chip to the factory defaults. |
static boolean |
setFriendlyName(String strName)
Set the name of the local device |
static int |
setOperatingMode(byte mode)
Set the operating mode |
static void |
setPin(byte[] newPin)
Set the pin to be used for pairing/connecting to the system |
static void |
setPower(boolean on)
Set the power to the module |
static int |
setStatus(int status)
Set the persistent status byte for the BC4 chip |
static int |
setVisibility(byte visible)
Set Bluetooth visibility (discoverable) on or off for the local device |
static BTConnection |
waitForConnection()
Uses the current default PIN |
static BTConnection |
waitForConnection(int timeout,
int mode)
Uses the current default PIN |
static BTConnection |
waitForConnection(int timeout,
int mode,
byte[] pin)
Wait for a remote device to connect. |
Methods inherited from class lejos.nxt.comm.NXTCommDevice |
---|
addressToString, getAddress, getName, isAddress, nameToString, setAddress, setName, stringToAddress, stringToName |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final byte MSG_BEGIN_INQUIRY
public static final byte MSG_CANCEL_INQUIRY
public static final byte MSG_CONNECT
public static final byte MSG_OPEN_PORT
public static final byte MSG_LOOKUP_NAME
public static final byte MSG_ADD_DEVICE
public static final byte MSG_REMOVE_DEVICE
public static final byte MSG_DUMP_LIST
public static final byte MSG_CLOSE_CONNECTION
public static final byte MSG_ACCEPT_CONNECTION
public static final byte MSG_PIN_CODE
public static final byte MSG_OPEN_STREAM
public static final byte MSG_START_HEART
public static final byte MSG_HEARTBEAT
public static final byte MSG_INQUIRY_RUNNING
public static final byte MSG_INQUIRY_RESULT
public static final byte MSG_INQUIRY_STOPPED
public static final byte MSG_LOOKUP_NAME_RESULT
public static final byte MSG_LOOKUP_NAME_FAILURE
public static final byte MSG_CONNECT_RESULT
public static final byte MSG_RESET_INDICATION
public static final byte MSG_REQUEST_PIN_CODE
public static final byte MSG_REQUEST_CONNECTION
public static final byte MSG_LIST_RESULT
public static final byte MSG_LIST_ITEM
public static final byte MSG_LIST_DUMP_STOPPED
public static final byte MSG_CLOSE_CONNECTION_RESULT
public static final byte MSG_PORT_OPEN_RESULT
public static final byte MSG_SET_DISCOVERABLE
public static final byte MSG_CLOSE_PORT
public static final byte MSG_CLOSE_PORT_RESULT
public static final byte MSG_PIN_CODE_ACK
public static final byte MSG_SET_DISCOVERABLE_ACK
public static final byte MSG_SET_FRIENDLY_NAME
public static final byte MSG_SET_FRIENDLY_NAME_ACK
public static final byte MSG_GET_LINK_QUALITY
public static final byte MSG_LINK_QUALITY_RESULT
public static final byte MSG_SET_FACTORY_SETTINGS
public static final byte MSG_SET_FACTORY_SETTINGS_ACK
public static final byte MSG_GET_LOCAL_ADDR
public static final byte MSG_GET_LOCAL_ADDR_RESULT
public static final byte MSG_GET_FRIENDLY_NAME
public static final byte MSG_GET_DISCOVERABLE
public static final byte MSG_GET_PORT_OPEN
public static final byte MSG_GET_FRIENDLY_NAME_RESULT
public static final byte MSG_GET_DISCOVERABLE_RESULT
public static final byte MSG_GET_PORT_OPEN_RESULT
public static final byte MSG_GET_VERSION
public static final byte MSG_GET_VERSION_RESULT
public static final byte MSG_GET_BRICK_STATUSBYTE_RESULT
public static final byte MSG_SET_BRICK_STATUSBYTE_RESULT
public static final byte MSG_GET_BRICK_STATUSBYTE
public static final byte MSG_SET_BRICK_STATUSBYTE
public static final byte MSG_GET_OPERATING_MODE
public static final byte MSG_SET_OPERATING_MODE
public static final byte MSG_OPERATING_MODE_RESULT
public static final byte MSG_GET_CONNECTION_STATUS
public static final byte MSG_CONNECTION_STATUS_RESULT
public static final byte MSG_GOTO_DFU_MODE
public static final byte MSG_ANY
public static final byte BT_PENDING_INPUT
public static final byte BT_PENDING_OUTPUT
public static final String PIN
Method Detail |
---|
public static int btWrite(byte[] buf, int off, int len)
buf
- the buffer to sendoff
- the offset to start the write from.len
- the number of bytes to send
public static int btRead(byte[] buf, int off, int len)
buf
- the buffer to read data intooff
- the offset at which to start the transferlen
- the number of bytes to read
public static int btPending()
public static void btSetArmCmdMode(int mode)
mode
- 0=data mode, 1=command modepublic static int btGetBC4CmdMode()
public static void btStartADConverter()
public static void btSetResetLow()
public static void btSetResetHigh()
public static void btSend(byte[] buf, int len)
buf
- the buffer to sendlen
- the number of bytes to sendpublic static void btReceive(byte[] buf)
buf
- the buffer to receive data inpublic static void btEnable()
public static void btDisable()
public static void setPin(byte[] newPin)
newPin
- the new pin codepublic static byte[] getPin()
public static int closeConnection(byte handle)
handle
- the handle for the connection
public static byte[] openPort()
public static byte[] closePort()
public static BTConnection waitForConnection(int timeout, int mode, byte[] pin)
timeout
- time in ms to wait for connection, 0 == wait for evermode
- the I/O mode to be used for this connection. NXTConnection.RAW, .LCP, or .PACKET
pin
- the pin to use, null use current default
public static BTConnection waitForConnection()
public static BTConnection waitForConnection(int timeout, int mode)
timeout
- time in ms to wait for connection, 0 == wait for evermode
- the I/O mode to be used for this connection. NXTConnection.RAW, .LCP, or .PACKET
public static BTConnection connect(RemoteDevice remoteDevice)
remoteDevice
- remote device
public static BTConnection connect(String target, int mode, byte[] pin)
target
- String name or addressmode
- I/O mode for this connection. NXTConnection.RAW, .LCP, or .PACKET
pin
- The pin to use for this connection
public static BTConnection connect(String target, int mode)
target
- String name or addressmode
- I/O mode for this connection. NXTConnection.RAW, .LCP, or .PACKET
public static int getSignalStrength(byte handle)
handle
- The handle/channel of the connection
public static String getFriendlyName()
public static boolean setFriendlyName(String strName)
strName
- the friendly name for the device
public static String getLocalAddress()
public static Vector getKnownDevicesList()
public static RemoteDevice getKnownDevice(String fName)
fName
- Friendly-Name of the device
public static boolean addDevice(RemoteDevice d)
d
- Remote Device
public static boolean removeDevice(RemoteDevice d)
d
- Remote Device
public static boolean cancelInquiry()
public static void inquireNotify(int maxDevices, int timeout, DiscoveryListener listy)
maxDevices
- the maximum number of devices to discovertimeout
- the timeout value in units of 1.28 secondslisty
- The listener to notifypublic static Vector inquire(int maxDevices, int timeout, byte[] cod)
maxDevices
- the maximum number of devices to discovertimeout
- the timeout value in units of 1.28 secondscod
- the class of device to look for
public static String lookupName(String addr)
addr
- device address
public static byte[] getConnectionStatus()
public static byte[] getVersion()
public static int getStatus()
public static int setStatus(int status)
status
- the byte status value
public static int getVisibility()
public static int getPortOpen()
public static int getOperatingMode()
public static int setVisibility(byte visible)
visible
- true to set visibility on, false to set it off
public static int setFactorySettings()
public static int setOperatingMode(byte mode)
mode
- 0 = Stream breaking, 1 don't break stream
public static void reset()
public static void setPower(boolean on)
on
- power on or offpublic static boolean getPower()
public static int getResetCount()
public static void loadSettings()
public static int readPacket(byte[] buf, int len)
buf
- Buffer to read data into.len
- Number of bytes to read.
public static void sendPacket(byte[] buf, int bufLen)
buf
- the data to sendbufLen
- the number of bytes to sendpublic static void btSetCmdMode(int mode)
mode
- the requested mode 1 == Command mode 0 == Stream modepublic static NXTCommConnector getConnector()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |