LocalDevice
class defines the basic functions of the
Bluetooth manager. The
Bluetooth manager provides the lowest level of interface possible
into the Bluetooth stack. It provides access to and control of the
local Bluetooth device.
This class produces a singleton object.
Retrieves the
DeviceClass
object that represents the
service classes, major device class, and minor device class of the
local device.
getDiscoverable
()
Retrieves the local device's discoverable mode.
DiscoveryAgent
getDiscoveryAgent
()
Returns the discovery agent for this device.
java.lang.String
getFriendlyName
()
Retrieves the name of the local device.
static
LocalDevice
getLocalDevice
()
Retrieves the
LocalDevice
object for the local Bluetooth
device.
static java.lang.String
getProperty
(java.lang.String property)
Retrieves Bluetooth system properties.
ServiceRecord
getRecord
(javax.microedition.io.Connection notifier)
Gets the service record corresponding to a
btspp
,
btl2cap
, or
btgoep
notifier.
boolean
setDiscoverable
(int mode)
Sets the discoverable mode of the device.
updateRecord
(
ServiceRecord
srvRecord)
Updates the service record in the local SDDB that corresponds
to the
ServiceRecord
parameter.
LocalDevice
object for the local Bluetooth
device. Multiple calls to this method will return the same
object. This method will never return
null
.
null
.
null
if the
name could not be retrieved
DeviceClass
object that represents the
service classes, major device class, and minor device class of the
local device. This method will return
null
if the
service classes, major device class, or minor device class could not
be determined.
null
if the service
classes, major device class or minor device class could not be
determined
mode
may be
any number in the range 0x9E8B00 to 0x9E8B3F as defined by the Bluetooth
Assigned Numbers Document. When this specification was defined, only GIAC
(
DiscoveryAgent.GIAC
) and
LIAC (
DiscoveryAgent.LIAC
) were defined, but Bluetooth profiles
may add additional access codes in the future. To determine what values
may be used, check the Bluetooth Assigned Numbers document at
http://www.bluetooth.org/assigned-numbers/baseband.htm. If
DiscoveryAgent.GIAC
or
DiscoveryAgent.LIAC
are
provided, then this method will attempt to put the device into general or
limited discoverable mode, respectively. To take a device out of
discoverable mode, provide the
DiscoveryAgent.NOT_DISCOVERABLE
flag. The BCC decides if the
request will be granted. In addition to the BCC, the Bluetooth system
could effect the discoverability of a device.
According to the Bluetooth Specification, a device should only be
limited discoverable (
DiscoveryAgent.LIAC
) for 1 minute.
This is handled by the implementation of the API. After the minute is
up, the device will revert back to the previous discoverable mode.
mode
- the mode the device should be in; valid modes are
DiscoveryAgent.GIAC
,
DiscoveryAgent.LIAC
,
DiscoveryAgent.NOT_DISCOVERABLE
and any value in the
range 0x9E8B00 to 0x9E8B3F
true
if the request succeeded, otherwise
false
if the request failed because the BCC denied
the request;
false
if the Bluetooth system does not
support the access mode specified in
mode
mode
is
not
DiscoveryAgent.GIAC
,
DiscoveryAgent.LIAC
,
DiscoveryAgent.NOT_DISCOVERABLE
, or in the range
0x9E8B00 to 0x9E8B3F
DiscoveryAgent.GIAC
,
DiscoveryAgent.LIAC
,
DiscoveryAgent.NOT_DISCOVERABLE
property
- the property to retrieve as defined in this class.
null
if
the
property
is not defined
DiscoveryAgent.GIAC
,
DiscoveryAgent.LIAC
,
DiscoveryAgent.NOT_DISCOVERABLE
, or a value in the
range 0x9E8B00 to 0x9E8B3F.
DiscoveryAgent.GIAC
,
DiscoveryAgent.LIAC
,
DiscoveryAgent.NOT_DISCOVERABLE
null
. The Bluetooth address
will be 12 characters long. Valid characters are 0-9 and A-F.
btspp
,
btl2cap
, or
btgoep
notifier. In the
case of a run-before-connect service, the service record
returned by
getRecord()
was created by the same
call to
Connector.open()
that created the
notifier
.
If a connect-anytime server application does not already
have a service record in the SDDB, either because a service
record for this service was never added to the SDDB or because
the service record was added and then removed, then the
ServiceRecord
returned by
getRecord()
was created by the same call to
Connector.open()
that created the notifier.
In the case of a connect-anytime service, there may be a
service record in the SDDB corresponding to this service prior
to application startup. In this case, the
getRecord()
method must return a
ServiceRecord
whose contents match those of the
corresponding service record in the SDDB. If a connect-anytime
server application made changes previously to its service record
in the SDDB (for example, during a previous execution of the
server), and that service record is still in the SDDB, then
those changes must be reflected in the
ServiceRecord
returned by
getRecord()
.
Two invocations of this method with the same
notifier
argument return objects that describe the
same service attributes, but the return values may be different
object references.
notifier
- a connection that waits for clients to connect
to a Bluetooth service
ServiceRecord
associated with
notifier
notifier
is
closed, or if
notifier
does not implement one of
the following interfaces:
javax.microedition.io.StreamConnectionNotifier
,
javax.bluetooth.L2CapConnectionNotifier
, or
javax.obex.SessionNotifier
. This exception is
also thrown if
notifier
is not a Bluetooth
notifier, e.g., a
StreamConnectionNotifier
created
with a scheme other than
btspp
.
notifier
is
throws
ServiceRegistrationException
ServiceRecord
parameter. Updating is
possible only if
srvRecord
was obtained using the
getRecord()
method. The service record in the SDDB
is modified to have the same service attributes with the same
contents as
srvRecord
.
If
srvRecord
was obtained from the SDDB of a
remote device using the service search methods, updating is not
possible and this method will throw an
IllegalArgumentException
.
If the
srvRecord
parameter is a
btspp
service record, then before the SDDB is changed the following
checks are performed. If any of these checks fail, then an
IllegalArgumentException
is thrown.
btspp
service record, must
be present in
srvRecord
.
srvRecord
must not have changed the RFCOMM server
channel number from the channel number that is currently in the
SDDB version of this service record.
If the
srvRecord
parameter is a
btl2cap
service record, then before the SDDB is changed the following
checks are performed. If any of these checks fail, then an
IllegalArgumentException
is thrown.
btl2cap
service record,
must be present in
srvRecord
.
srvRecord
must not have changed the PSM value
from the PSM value that is currently in the SDDB version of this
service record.
If the
srvRecord
parameter is a
btgoep
service record, then before the SDDB is changed the following
checks are performed. If any of these checks fail, then an
IllegalArgumentException
is thrown.
btgoep
service record, must
be present in
srvRecord
.
srvRecord
must not have changed the RFCOMM server
channel number from the channel number that is currently in the
SDDB version of this service record.
updateRecord()
is not required to ensure that
srvRecord
is a completely valid service record. It
is the responsibility of the application to ensure that
srvRecord
follows all of the applicable syntactic
and semantic rules for service record correctness.
If there is currently no SDDB version of the
srvRecord
service record, then this method will do
nothing.
srvRecord
- the new contents to use for the service record in
the SDDB
srvRecord
is
null
srvRecord
is missing any mandatory service
attributes, or if an attempt has been made to change any of the
values described as fixed.