de.avetana.bluetooth.sdp
Class RemoteServiceRecord

java.lang.Object
  extended byde.avetana.bluetooth.sdp.SDPServiceRecord
      extended byde.avetana.bluetooth.sdp.RemoteServiceRecord
All Implemented Interfaces:
ServiceRecord

public class RemoteServiceRecord
extends SDPServiceRecord

The class used to manage remote service records.

COPYRIGHT:
(c) Copyright 2004 Avetana GmbH ALL RIGHTS RESERVED.

This file is part of the Avetana bluetooth API for Linux.

The Avetana bluetooth API for Linux is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

The Avetana bluetooth API is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

The development of the Avetana bluetooth API is based on the work of Christian Lorenz (see the Javabluetooth Stack at http://www.javabluetooth.org) for some classes, on the work of the jbluez team (see http://jbluez.sourceforge.net/) and on the work of the bluez team (see the BlueZ linux Stack at http://www.bluez.org) for the C code. Classes, part of classes, C functions or part of C functions programmed by these teams and/or persons are explicitly mentioned.



Description:

This class is used to manage the remote service records. As requested by the JSR82 Specification, the class is an instance of javax.bluetooth.ServiceRecord.
A remote service search will always return RemoteServiceRecord objects. Indeed, the common use of a JSR82 implementation is to first make a service search, then to select the desired service, to retrieve te connection URL and finally to connect with the remote device. That's why the method getConnectionURL(..) of this class is one of the most used.


Field Summary
 
Fields inherited from class de.avetana.bluetooth.sdp.SDPServiceRecord
m_attributes, m_recordHandle
 
Fields inherited from interface javax.bluetooth.ServiceRecord
AUTHENTICATE_ENCRYPT, AUTHENTICATE_NOENCRYPT, NOAUTHENTICATE_NOENCRYPT
 
Constructor Summary
RemoteServiceRecord()
          Default constructor: creates a RemoteServiceRecord object, which extends SDPServiceRecord
RemoteServiceRecord(java.lang.String badr)
          Creates a RemoteServiceRecord object and sets the remote device this service belongs to.
 
Method Summary
static ServiceRecord createServiceRecord(java.lang.String adr, byte[][] uuids, int[] attrs, byte[] data)
           
 java.lang.String getConnectionURL(int requiredSecurity, boolean mustBeMaster)
          JSR82 Specification:
Returns a String including optional parameters that can be used by a client to connect to the service described by this ServiceRecord.
 RemoteDevice getHostDevice()
          Returns the remote device this service belongs to
static void main(java.lang.String[] args)
           
 boolean populateRecord(int[] attr)
          JSR82 Specification:
Retrieves the values by contacting the remote Bluetooth device for a set of service attribute IDs of a service that is available on a Bluetooth device.
 void setDeviceServiceClasses(int parm1)
          This method is not yet supported by the implementation.
 
Methods inherited from class de.avetana.bluetooth.sdp.SDPServiceRecord
getAttributeIDs, getAttributeValue, getRecordHandle, setAttributeValue, setRecordHandle, toByteArray, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RemoteServiceRecord

public RemoteServiceRecord()
Default constructor: creates a RemoteServiceRecord object, which extends SDPServiceRecord

See Also:
SDPServiceRecord

RemoteServiceRecord

public RemoteServiceRecord(java.lang.String badr)
Creates a RemoteServiceRecord object and sets the remote device this service belongs to.

Parameters:
badr - The BT address of the remote device
Method Detail

getHostDevice

public RemoteDevice getHostDevice()
Returns the remote device this service belongs to

Specified by:
getHostDevice in interface ServiceRecord
Specified by:
getHostDevice in class SDPServiceRecord
Returns:
The remote device this service belongs to

populateRecord

public boolean populateRecord(int[] attr)
                       throws java.io.IOException
JSR82 Specification:
Retrieves the values by contacting the remote Bluetooth device for a set of service attribute IDs of a service that is available on a Bluetooth device. (This involves going over the air and contacting the remote device for the attribute values.) The system might impose a limit on the number of service attribute ID values one can request at a time. Applications can obtain the value of this limit as a String by calling LocalDevice.getProperty("bluetooth.sd.attr.retrievable.max"). The method is blocking and will return when the results of the request are available. Attribute IDs whose values could be obtained are added to this service record. If there exist attribute IDs for which values are retrieved this will cause the old values to be overwritten. If the remote device cannot be reached, an IOException will be thrown.

Parameters:
attr - the list of service attributes IDs whose value are to be retrieved; the number of attributes cannot exceed the property bluetooth.sd.attr.retrievable.max; the attributes in the request must be legal, i.e. their values are in the range of [0, 216-1]. The input attribute IDs can include attribute IDs from the default attribute set too.
Returns:
true if the request was successful in retrieving values for some or all of the attribute IDs; false if it was unsuccessful in retrieving any values
Throws:
java.io.IOException - if the local device is unable to connect to the remote Bluetooth device that was the source of this ServiceRecord; if this ServiceRecord was deleted from the SDDB of the remote device
java.lang.IllegalArgumentException - if the size of attrIDs exceeds the system specified limit as defined by bluetooth.sd.attr.retrievable.max; if the attrIDs array length is zero; if any of their values are not in the range of [0, 216-1]; if attrIDs has duplicate values
java.lang.NullPointerException - if attrIDs is null
java.lang.RuntimeException - if this ServiceRecord describes a service on the local device rather than a service on a remote device

getConnectionURL

public java.lang.String getConnectionURL(int requiredSecurity,
                                         boolean mustBeMaster)
                                  throws java.lang.IllegalArgumentException
JSR82 Specification:
Returns a String including optional parameters that can be used by a client to connect to the service described by this ServiceRecord. The return value can be used as the first argument to Connector.open(). In the case of a Serial Port service record, this string might look like "btspp://0050CD00321B:3;authenticate=true;encrypt=false;master=true", where "0050CD00321B" is the Bluetooth address of the device that provided this ServiceRecord, "3" is the RFCOMM server channel mentioned in this ServiceRecord, and there are three optional parameters related to security and master/slave roles.

If this method is called on a ServiceRecord returned from LocalDevice.getRecord(), it will return the connection string that a remote device will use to connect to this service.
AvetanaBluetooth:
The implementation of getConnectionURL() only supports RFCOMM and L2CAP.

Parameters:
requiredSecurity - determines whether authentication or encryption are required for a connection
mustBeMaster - true indicates that this device must play the role of master in connections to this service; false indicates that the local device is willing to be either the master or the slave
Returns:
a string that can be used to connect to the service or null if the ProtocolDescriptorList in this ServiceRecord is not formatted according to the Bluetooth specification
Throws:
java.lang.IllegalArgumentException - if requiredSecurity is not one of the constants NOAUTHENTICATE_NOENCRYPT, AUTHENTICATE_NOENCRYPT, or AUTHENTICATE_ENCRYPT
See Also:
ServiceRecord.NOAUTHENTICATE_NOENCRYPT, ServiceRecord.AUTHENTICATE_NOENCRYPT, ServiceRecord.AUTHENTICATE_ENCRYPT

setDeviceServiceClasses

public void setDeviceServiceClasses(int parm1)
This method is not yet supported by the implementation.

Parameters:
parm1 -

createServiceRecord

public static ServiceRecord createServiceRecord(java.lang.String adr,
                                                byte[][] uuids,
                                                int[] attrs,
                                                byte[] data)
                                         throws java.io.IOException
Throws:
java.io.IOException

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception