BluetoothDevice Class
BluetoothDevice objects can be returned in deviceFound events, by the getRemoteDevice method, the getPairedDevices method, and the pairedDevices property of the Bluetooth module object.
Item Index
Methods
createSocket
-
params
Creates an RFCOMM Bluetooth socket ready to start an outgoing connection to this remote device using SDP lookup of UUID.
Note: This method requires that the app be built with Titanium version 3.1.1.GA or later due to TIMOB-13097. See also TIMOB-13620.
Parameters:
-
params
ObjectAn object with the following properties:
-
uuid
StringUUID of the service this socket will connect to.
-
[secure=false]
Boolean optionalDefines whether the connection will be secure or insecure.
-
Returns:
equals
()
Boolean
Compares one BluetoothDevice object to another.
Returns:
True iff the two objects are the same.
fetchUUIDs
()
Boolean
Perform a service discovery on the remote device to get the UUIDs supported.
The result of the discovery is reported via the fetchedUUIDs event. See also the getUUIDs method and UUIDs property.
This function requires API level 15 or higher.
Returns:
True if service discovery was started successfully.
getAddress
()
String
Returns the address of the remote Bluetooth device.
Returns:
getBondState
()
Number
Returns the bond state of the remote device. See the DEVICE_BONDED, DEVICE_BONDING, and DEVICE_NOT_BONDED constants on the Bluetooth module object.
Use the createBluetoothSocket method until then.
Returns:
getName
()
String
Returns the name of the remote Bluetooth device.
Returns:
getType
()
Number
Returns the type of the remote device.
Possible values are
DEVICE_TYPE_UNKNOWN,
DEVICE_TYPE_CLASSIC,
DEVICE_TYPE_DUAL, and
DEVICE_TYPE_LE.
This function requires API level 18 or higher.
Returns:
getUUIDs
()
Array of Strings
Returns the supported features (UUIDs) of the remote device.
This method does not start a service discovery procedure to retrieve the UUIDs from the remote device. Instead, the local cached copy of the service UUIDs are returned.
Use the fetchUUIDs method to start service discover.
This function requires API level 15 or higher.
Returns:
toString
()
String
Returns a string representation of this BluetoothDevice. Currently this is the Bluetooth hardware address, for example "00:11:22:AA:BB:CC". However, you should always use getAddress() if you explicitly require the Bluetooth hardware address in case the toString() representation changes in the future.
Returns:
A string representation of this BluetoothDevice.
Properties
address
String
read-only
The address of the remote Bluetooth device.
bondState
Number
read-only
The bond state of the remote device. See the DEVICE_BONDED, DEVICE_BONDING, and DEVICE_NOT_BONDED constants on the Bluetooth module object.
name
String
read-only
The name of the remote Bluetooth device.
type
Unknown
Returns the type of the remote device.
Possible values are
DEVICE_TYPE_UNKNOWN,
DEVICE_TYPE_CLASSIC,
DEVICE_TYPE_DUAL, and
DEVICE_TYPE_LE.
This function requires API level 18 or higher.
UUIDs
Unknown
The supported features (UUIDs) of the remote device.
Querying this property does not start a service discovery procedure to retrieve the UUIDs from the remote device. Instead, the local cached copy of the service UUIDs are returned.
Use the fetchUUIDs method to start service discover.
This function requires API level 15 or higher.