# Modules.Bluetooth.BluetoothDevice

Represents a remote bluetooth device.

Availability
1.0.0

# Overview

A BluetoothDevice object lets you create a connection with the remote device or query information about it, such as the name, address, UUID and type.

# Properties

# address READONLY

Availability
1.0.0
address :String

Address of the remote Bluetooth device.

This property returns the Bluetooth hardware address as string. For example, "00:11:22:AA:BB:CC".

# apiName READONLY

Availability
3.2.0
apiName :String

The name of the API that this proxy corresponds to.

The value of this property is the fully qualified name of the API. For example, Titanium.UI.Button returns Ti.UI.Button.


# bubbleParent

Availability
3.0.0
bubbleParent :Boolean

Indicates if the proxy will bubble an event to its parent.

Some proxies (most commonly views) have a relationship to other proxies, often established by the add() method. For example, for a button added to a window, a click event on the button would bubble up to the window. Other common parents are table sections to their rows, table views to their sections, and scrollable views to their views. Set this property to false to disable the bubbling to the proxy's parent.

Default: true


# lifecycleContainer

Availability
3.6.0

The Window or TabGroup whose Activity lifecycle should be triggered on the proxy.

If this property is set to a Window or TabGroup, then the corresponding Activity lifecycle event callbacks will also be called on the proxy. Proxies that require the activity lifecycle will need this property set to the appropriate containing Window or TabGroup.


# name READONLY

Availability
1.0.0
name :String

Name of the remote Bluetooth device.

This property returns the Bluetooth name or null if there was a problem.


# type READONLY

Availability
1.0.0
type :Number

Type of the remote Bluetooth device.

Possible values are DEVICE_TYPE_UNKNOWN, DEVICE_TYPE_CLASSIC, DEVICE_TYPE_DUAL and DEVICE_TYPE_LE.


# uUIDs READONLY

Availability
1.0.0
uUIDs :Array<String>

The supported UUIDs of the remote device.

This property does not start a service discovery procedure to retrieve the UUIDs from the remote device. Rather, the local cached copy of the service UUIDs are returned. Can be null on error.

# Methods

# addEventListener

Availability
1.0.0
addEventListener(name, callback) void

Adds the specified callback as an event listener for the named event.

Parameters

Name Type Description
name String

Name of the event.

callback Callback<Titanium.Event>

Callback function to invoke when the event is fired.

Returns

Type
void

# applyProperties

Availability
3.0.0
applyProperties(props) void

Applies the properties to the proxy.

Properties are supplied as a dictionary. Each key-value pair in the object is applied to the proxy such that myproxy[key] = value.

Parameters

Name Type Description
props Dictionary

A dictionary of properties to apply.

Returns

Type
void

# createSocket

Availability
1.0.0
createSocket(uuid[, secure]) Modules.Bluetooth.BluetoothSocket

Creates an RFCOMM Bluetooth socket.

This method, when called, creates an RFCOMM Bluetooth socket ready to start an outgoing connection to the remote device using SDP lookup of UUID.

Parameters

Name Type Description
uuid String

UUID of the service this socket will connect to.

secure Boolean

Determines whether the connection will be secure or insecure.

Returns

created socket for the device


# fetchUUIDs

Availability
1.0.0
fetchUUIDs() Boolean

Perform a service discovery on the remote device to get the UUIDs supported.

The outcome of the discovery is reported via the fetchedUUIDs event.

Returns

Returns true if service discovery started successfully.

Type
Boolean

# fireEvent

Availability
1.0.0
fireEvent(name[, event]) void

Fires a synthesized event to any registered listeners.

Parameters

Name Type Description
name String

Name of the event.

event Dictionary

A dictionary of keys and values to add to the Titanium.Event object sent to the listeners.

Returns

Type
void

# removeEventListener

Availability
1.0.0
removeEventListener(name, callback) void

Removes the specified callback as an event listener for the named event.

Multiple listeners can be registered for the same event, so the callback parameter is used to determine which listener to remove.

When adding a listener, you must save a reference to the callback function in order to remove the listener later:

var listener = function() { Ti.API.info("Event listener called."); }
window.addEventListener('click', listener);

To remove the listener, pass in a reference to the callback function:

window.removeEventListener('click', listener);

Parameters

Name Type Description
name String

Name of the event.

callback Callback<Titanium.Event>

Callback function to remove. Must be the same function passed to addEventListener.

Returns

Type
void

# Events

# fetchedUUIDs

Availability
1.0.0

Fired when the UUIDs of the remote device are received using SDP.

Properties

Name Type Description
device Modules.Bluetooth.BluetoothDevice

The Bluetooth device in question.

UUIDs Array<String>

The service UUIDs of the device.

source Object

Source object that fired the event.

type String

Name of the event fired.

bubbles Boolean

True if the event will try to bubble up if possible.

cancelBubble Boolean

Set to true to stop the event from bubbling.