|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.avetana.bluetooth.stack.BlueZ
public class BlueZ
This class provides the methods to access the underlying BlueZ functions. All native methods defined in this class are implemented via the Java Native Interface (JNI) in C/C++. See the bluez.cpp file and associated comments for full details. All methods are static. This way of defining a common access to the stack avoids the user and the developper to repeatedly create a new instance of the BlueZ class.
| Field Summary | |
|---|---|
static PooledExecutor |
executor
|
static int |
m_transactionId
|
static ConnectionFactory |
myFactory
|
| Constructor Summary | |
|---|---|
BlueZ()
|
|
| Method Summary | |
|---|---|
static void |
addService(int transID,
ServiceRecord rec)
|
static void |
addService(int transID,
ServiceRecord[] rec)
Callback method, which notifies the discovering a new service. |
static int |
authenticate(int handle,
java.lang.String deviceAddr,
java.lang.String pin)
Authenticates the remote device |
static int |
authenticate(java.lang.String deviceAddr,
java.lang.String pin)
Authenticates the remote device |
static void |
cancelInquiry()
|
static boolean |
cancelServiceSearch(int transID)
|
static void |
closeConnectionS(int fid)
Closes an existing connection. |
static void |
connectionClosed(int fid)
Called from the native side, when the connection is beeing closed |
static boolean |
connectionEstablished(int fid,
int channel,
int protocol,
java.lang.String jaddr)
Method called by the C-Code in order to notify the establishment of a new connection. |
static boolean |
connectionEstablished(int fid,
int channel,
int protocol,
java.lang.String jaddr,
int recMTU,
int transMTU)
|
static boolean[] |
connectionOptions(int handle,
java.lang.String deviceAddr)
Retrieves the connection options |
java.lang.Class |
createClass(java.lang.String name)
|
static int |
createService(LocalServiceRecord service)
Stores a new Service record in the BCC. |
static void |
deviceDiscovered(RemoteDevice d)
The following method is called by some Stacks to notify of RemoteDevices that have been found. |
static void |
disposeLocalRecord(long recordHandle)
Deletes the service record identified by the record handle given as parameter. |
static int |
encrypt(int handle,
java.lang.String deviceAddr,
boolean enable)
Turns on/off the encryption of an ACL link |
static void |
flush(int fd)
Used for Widcomm to wait for the RFCommBuffer to be drained |
static int |
getAccessMode(int device)
Gets the access mode of the local device |
static int |
getDeviceClass(int dev_id)
Gets the device class of the local device number "dev_id" |
static int |
getLinkQuality(java.lang.String bdaddr)
Retrieves the current quality of the physical bluetooth connection to the specified device. |
static int |
getMaxConnectedDevices()
Returns the maximum number of connected devices allowed by the stack This number may be greater than 7 if the implementation handles parked connections. |
static int |
getRssi(java.lang.String adr)
Provides an estimation of the strength of the signal received from another specified bluetooth-device. |
protected static void |
hciCloseDevice(int dd)
Close the HCI device. |
static BTAddress |
hciDevBTAddress(int hciDevID)
Gets the Bluetooth device address for a specified local HCI device. |
static int |
hciDeviceID(BTAddress bdaddr)
Gets the device ID for a specified local HCI device. |
static int |
hciDeviceID(java.lang.String bdaddr)
Gets the device ID for a specified local HCI device. |
static boolean |
hciInquiry(int hciDevID,
DiscoveryAgent agent)
Performs an HCI inquiry to discover remote Bluetooth devices. |
static boolean |
hciInquiry(int hciDevID,
int len,
int max_num_rsp,
long flags,
DiscoveryAgent agent)
Performs an HCI inquiry to discover remote Bluetooth devices. |
static java.lang.String |
hciLocalName(int dd)
Gets the name of a local device. |
static java.lang.String |
hciLocalName(int dd,
int timeOut)
Gets the name of a local device. |
static int |
hciOpenDevice(int hciDevID,
BlueZ ref)
Opens the HCI device. |
static java.lang.String |
hciRemoteName(int dd,
BTAddress bdaddr)
Gets the name of a remote device, as specified by its Bluetooth device address. |
static java.lang.String |
hciRemoteName(int dd,
BTAddress bdaddr,
int timeOut)
Gets the name of a remote device, as specified by its Bluetooth device address. |
static java.lang.String |
hciRemoteName(int dd,
java.lang.String bdaddr)
Gets the name of a remote device, as specified by its Bluetooth device address. |
static java.lang.String |
hciRemoteName(int dd,
java.lang.String bdaddr,
int timeOut)
Gets the name of a remote device, as specified by its Bluetooth device address. |
static boolean |
inquiryAndConAllowed()
Is Inquiry allowed during a connection? |
static boolean |
inquiryScanAndConAllowed()
Inquiry scanning allowed during connection? |
static boolean |
isMasterSwitchAllowed()
Is master/slave switch allowed? |
static void |
listService(java.lang.String bdaddr_jstr,
byte[][] uuid,
int[] attrIds,
int transID)
Lists all SDP services, which match a desired list of UUIDs. |
static byte[] |
newByteArray(int size)
Method called from the Windows native library to reserve storage space. |
static int |
newData(byte[] data,
int fid)
Method is called from native implementations when new Data has arrived for a connection listening for data. |
static L2CAPConnParam |
openL2CAP(JSR82URL url,
int timeout)
Opens an L2CAP connection with a remote BT device. |
static int |
openRFComm(JSR82URL url,
int timeout)
Opens an RFCOMM connection with a remote BT device. |
static boolean |
pageAndConnAllowed()
Is paging allowed during a connection? In other words, can a connection be established to one device if it is already connected to another device. |
static boolean |
pageScanAndConAllowed()
Page scanning allowed during connection? |
static int |
registerL2CAPService(int serviceHandle,
int channel,
boolean master,
boolean auth,
boolean encrypt,
int omtu,
int imtu)
Registers the service record identified by the variable "serviceHandle" and listens for an incoming L2CAP Connection |
static void |
registerNotifier(ConnectionNotifier a_notifier)
Registers a service and waits for incoming connections |
static int |
registerService(int serviceHandle,
int channel,
boolean master,
boolean auth,
boolean encrypt)
Registers the service record identified by the variable "serviceHandle" and listens for an incoming RFCOMM Connection |
static void |
removeNotifier(ConnectionNotifier a_notifier)
Remove the Notifier when creating a service has failed |
static void |
removeServiceByID(long id)
MacOS X only function to remove a service record by its ID. |
static int |
searchServices(java.lang.String bdaddr_jstr,
byte[][] uuid,
int[] attrIds,
DiscoveryListener flistener)
Starts a service search. |
static int[] |
sendHCI(int command,
int[] params)
Sends a native HCI command to the BT-Dongle. |
static void |
serviceSearchComplete(int transID,
int respCode)
Callback method which notifies the end of a service search. |
static int |
setAccessMode(int device,
int mode)
Sets the access mode of the local device |
static boolean |
setDeviceClass(int dev_id,
int cls)
sets the device class to "cls" of the local device number "dev_id" |
static boolean |
setDeviceName(java.lang.String name)
Change the local device name |
static void |
stackDown()
Method called from the Windows native DLL when the stack has gone down. |
static void |
startReaderThread(int fid,
int mtu)
For Windows and PocketPC, where reading should be started from the JavaVM. |
static void |
startTimeoutThread(int fid,
int timeout)
|
static int |
unPair(java.lang.String deviceAddr)
|
static int |
updateService(ServiceRecord service,
long recordHandle)
Updates an existing service record (the old |
static void |
writeBytesS(int fid,
byte[] b,
int off,
int len)
Writes byte to an existing connection |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static ConnectionFactory myFactory
public static int m_transactionId
public static final PooledExecutor executor
| Constructor Detail |
|---|
public BlueZ()
| Method Detail |
|---|
public static int getLinkQuality(java.lang.String bdaddr)
throws BlueZException
bdaddr - Bluetooth address String in the form
"00:12:34:56:78:9A".
BlueZException
public static int hciOpenDevice(int hciDevID,
BlueZ ref)
throws BlueZException
hciDevID - The local HCI device ID (see the hciconfig tool provided
by BlueZ for further information).
dd) for the HCI
device.
BlueZException - Unable to open the HCI device.protected static void hciCloseDevice(int dd)
dd - The HCI device descriptor (as returned from
hciOpenDevice)public static void cancelInquiry()
public static boolean hciInquiry(int hciDevID,
int len,
int max_num_rsp,
long flags,
DiscoveryAgent agent)
throws BlueZException
hciDevID - The local HCI device ID (see the hciconfig tool provided
by BlueZ for further information).len - Maximum amount of time before inquiry is halted. Time = len
x 1.28 secs.max_num_rsp - Maximum number of responses allowed before inquiry
is halted. For an unlimited number, set to 0.flags - Additional flags. See BlueZ documentation and source code
for details.
BlueZException - If the inquiry failed.#hciInquiry(int hciDevID)
public static boolean hciInquiry(int hciDevID,
DiscoveryAgent agent)
throws BlueZException
hciInquiry(int hciDevID, int len, int max_num_rsp, long
flags), except that the len, max_num_rsp
and flags fields are preset to 'default' values. These
values are 8, 10 and 0, respectively.
hciDevID - The local HCI device ID (see the hciconfig tool provided
by BlueZ for further information)
BlueZException - If the inquiry failed.
public static BTAddress hciDevBTAddress(int hciDevID)
throws BlueZException
hciDevID - The local HCI device ID (see the hciconfig tool provided
by BlueZ for further information)
BlueZException - If unable to get the Bluetooth device address.
public static int hciDeviceID(java.lang.String bdaddr)
throws BlueZException
bdaddr - Bluetooth address String in the form
"00:12:34:56:78:9A".
BlueZException - If unable to get the device ID.
public static int hciDeviceID(BTAddress bdaddr)
throws BlueZException
bdaddr - Bluetooth address as a BTAddress object.
BlueZException - If unable to get the device ID.
public static java.lang.String hciLocalName(int dd,
int timeOut)
throws BlueZException
hciOpenDevice before calling this method.
dd - HCI device descriptor.timeOut - Timeout, in milliseconds.
BlueZException - If unable to get the local device name.
public static java.lang.String hciLocalName(int dd)
throws BlueZException
hciOpenDevice before calling this method. This is the same
as hciLocalName(int dd, int timeOut) with the
timeOut argument set to 10000 (i.e. 10 seconds).
dd - HCI device descriptor.
BlueZException - If unable to get the local device name.
public static java.lang.String hciRemoteName(int dd,
java.lang.String bdaddr,
int timeOut)
throws BlueZException
hciOpenDevice
before calling this method.
dd - HCI device descriptor.bdaddr - Bluetooth address String in the form
"00:12:34:56:78:9A".timeOut - Timeout, in milliseconds.
BlueZException - If unable to get the remote device name.
public static java.lang.String hciRemoteName(int dd,
java.lang.String bdaddr)
throws BlueZException
hciOpenDevice
before calling this method. This is the same as
hciRemoteName(int dd, String bdaddr, int timeOut) with the
timeOut argument set to 10000 (i.e. 10 seconds).
dd - HCI device descriptor.bdaddr - Bluetooth address String in the form
"00:12:34:56:78:9A".
BlueZException - If unable to get the remote device name.
public static java.lang.String hciRemoteName(int dd,
BTAddress bdaddr,
int timeOut)
throws BlueZException
hciOpenDevice
before calling this method.
dd - HCI device descriptor.bdaddr - Bluetooth address as a BTAddress object.timeOut - Timeout, in milliseconds.
BlueZException - If unable to get the remote device name.
public static java.lang.String hciRemoteName(int dd,
BTAddress bdaddr)
throws BlueZException
hciOpenDevice
before calling this method. This is the same as
hciRemoteName(int dd, BTAddress bdaddr, int timeOut) with
the timeOut argument set to 10000 (i.e. 10 seconds).
dd - HCI device descriptor.bdaddr - Bluetooth address as a BTAddress object.
BlueZException - If unable to get the remote device name.
public static L2CAPConnParam openL2CAP(JSR82URL url,
int timeout)
throws BlueZException,
java.lang.Exception
url - The JSR82URL object describing the remote BT device (BT address and PSM),
the desired security options (master, authenticate, encrypt) and the desired connection options (imtu, omtu)
BlueZException - If an error occured in the C part of the Code
java.lang.Exception - If the URL is not a valid L2CAP URL.
public static int openRFComm(JSR82URL url,
int timeout)
throws BlueZException,
java.lang.Exception
url - The JSR82URL object describing the remote BT device (BT address and channel number),
the desired security options (master, authenticate, encrypt).
BlueZException - If an error occured in the C part of the Code
java.lang.Exception - If the URL is not a valid L2CAP URL.public static void closeConnectionS(int fid)
fid - The integer, which uniquely identifies the connection (the file descriptor under linux).
public static int[] sendHCI(int command,
int[] params)
throws BlueZException
command - params -
BlueZException
public static void writeBytesS(int fid,
byte[] b,
int off,
int len)
throws java.io.IOException
fid - The integer, which uniquely identifies the connection.b - The byte array storing the bytes to be writtenlen - The length of boff - The offset into b at which to start
java.io.IOException
public static void listService(java.lang.String bdaddr_jstr,
byte[][] uuid,
int[] attrIds,
int transID)
throws BlueZException
bdaddr_jstr - The address of the remote BT deviceuuid - The list of UUIDs the service record must contain.attrIds - The list of Attributes which will populate the Service record.
BlueZException
public static int createService(LocalServiceRecord service)
throws BlueZException
service - The service record
BlueZException
public static int updateService(ServiceRecord service,
long recordHandle)
throws BlueZException
newService - The byte representation of this new service recordlength - The length of this byte representationrecordHandle - The record handle of the old service record
BlueZException
public static int registerService(int serviceHandle,
int channel,
boolean master,
boolean auth,
boolean encrypt)
throws BlueZException
serviceHandle - The integer, which uniquely identifies the service recordchannel - The channel number (Incoming connections linked with a channel numbermaster - Is the local device master for this connection?auth - Must the remote device be authenticated during the establishment of the connectionencrypt - Must the ACL linkbe encrpyted during the establishment of the connection
BlueZException
public static int registerL2CAPService(int serviceHandle,
int channel,
boolean master,
boolean auth,
boolean encrypt,
int omtu,
int imtu)
throws BlueZException
serviceHandle - The integer, which uniquely identifies the service recordchannel - The channel number (Incoming connections linked with a channel numbermaster - Is the local device master for this connection?auth - Must the remote device be authenticated during the establishment of the connectionencrypt - Must the ACL linkbe encrpyted during the establishment of the connectionomtu - Set the size of the Output MTUimtu - Set the size of the Input MTU
BlueZException
public static void disposeLocalRecord(long recordHandle)
throws BlueZException
recordHandle -
BlueZException
public static int getAccessMode(int device)
throws BlueZException
device - The integer which identifies the local device
BlueZException
public static int setAccessMode(int device,
int mode)
throws BlueZException
device - The integer which identifies the local devicemode - The new access mode
BlueZException
public static int getDeviceClass(int dev_id)
throws BlueZException
dev_id - The number which identifies the local device
BlueZException
public static boolean setDeviceClass(int dev_id,
int cls)
throws BlueZException
dev_id - The number which identifies the local devicecls - The new device class of the device
BlueZException
public static boolean isMasterSwitchAllowed()
throws BlueZException
true If master/slave switch is allowedfalse Otherwise
BlueZException
public static int getMaxConnectedDevices()
throws BlueZException
BlueZException
public static boolean inquiryScanAndConAllowed()
throws BlueZException
true If the inquiry scanning is allowed during a connectionfalse Otherwise
BlueZException
public static boolean inquiryAndConAllowed()
throws BlueZException
true If the inquiry is allowed during a connectionfalse Otherwise
BlueZException
public static boolean pageScanAndConAllowed()
throws BlueZException
true If page scanning during a connection is allowed false Otherwise
BlueZException
public static boolean pageAndConnAllowed()
throws BlueZException
true If paging during a connection is allowed false Otherwise
BlueZExceptionpublic static boolean setDeviceName(java.lang.String name)
name -
public static int authenticate(int handle,
java.lang.String deviceAddr,
java.lang.String pin)
throws BlueZException
hci - number (0)deviceAddr - The BT address of the remote device (00-0d-93-05-17-0e)pin - in Windows, one can specify a given PIN number to use
BlueZException
public static int authenticate(java.lang.String deviceAddr,
java.lang.String pin)
throws BlueZException
deviceAddr - The BT address of the remote devicepin - in Windows, one can specify a given PIN number to use
BlueZException
public static int unPair(java.lang.String deviceAddr)
throws BlueZException
BlueZException
public static int encrypt(int handle,
java.lang.String deviceAddr,
boolean enable)
throws BlueZException
handle - The number, which uniquely identifies the connectiondeviceAddr - The BT address of the remote deviceenable - If true, turn on the encryption of the ACL link
BlueZException
public static boolean[] connectionOptions(int handle,
java.lang.String deviceAddr)
throws BlueZException
handle - The number, which uniquely identifies the connectiondeviceAddr - The BT address of the remote device
BlueZException
public static int searchServices(java.lang.String bdaddr_jstr,
byte[][] uuid,
int[] attrIds,
DiscoveryListener flistener)
bdaddr_jstr - The BT address of the remote deviceuuid - The list of UUIDs the services must matchattrIds - The list of attributes the services should containlistener - The discovery listener, which handles the callback methods.
BlueZException
public static void registerNotifier(ConnectionNotifier a_notifier)
throws java.lang.Exception
a_notifier - The connection notifier created by the user.
java.lang.Exceptionpublic static void removeNotifier(ConnectionNotifier a_notifier)
public static boolean connectionEstablished(int fid,
int channel,
int protocol,
java.lang.String jaddr)
fid - The number which uniquely identifies the connectionchannel - The channel or PSM numberprotocol - The protocol (see the class JSR82URL)jaddr - The BT address of the remote device
public static boolean connectionEstablished(int fid,
int channel,
int protocol,
java.lang.String jaddr,
int recMTU,
int transMTU)
public static boolean cancelServiceSearch(int transID)
public static void addService(int transID,
ServiceRecord[] rec)
transID - SDP transaction IDrec - The service record discovered
public static void addService(int transID,
ServiceRecord rec)
public static void serviceSearchComplete(int transID,
int respCode)
transID - SDP transaction coderespCode - The responde code of the C-implementationjBTAddr - The BT address of the remote devicepublic java.lang.Class createClass(java.lang.String name)
public static byte[] newByteArray(int size)
size -
public static void stackDown()
public static int getRssi(java.lang.String adr)
throws BlueZException
bdaddr - Bluetooth address String in the form
"00:12:34:56:78:9A".
BlueZException
public static int newData(byte[] data,
int fid)
data - fid -
public static void flush(int fd)
throws java.io.IOException
fd -
java.io.IOExceptionpublic static void connectionClosed(int fid)
fid -
public static void startReaderThread(int fid,
int mtu)
fid - mtu -
public static void startTimeoutThread(int fid,
int timeout)
public static void deviceDiscovered(RemoteDevice d)
public static void removeServiceByID(long id)
id - 0x00010004 for PDA-SyncService
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||