Warning Older Docs! - You are viewing documentation for a previous released version of RhoMobile Suite.

BluetoothManager API

Makes a connection between your Bluetooth-equipped device and another Bluetooth-equipped device. Click for a short example of using bluetooth, or here for Rhodes-System-Api-Samples – BluetoothChat.

Enabling Bluetooth

You need to enable Bluetooth on the device. Do this by adding that capability to the build.yml file:

capabilities:
  - bluetooth

is_bluetooth_available

Returns true if Bluetooth is available on the device, false otherwise.

Rho::BluetoothManager.is_bluetooth_available

off_bluetooth

Turn Bluetooth off for existing Bluetooth session instance. It DOES NOT turn off the BT adapter.

Rho::BluetoothManager.off_bluetooth

set_device_name

Change the local device name.

Rho::BluetoothManager.set_device_name(name)
name String. The new name for the device.

get_device_name

Get local device name for current device (the name displayed on another device).

Rho::BluetoothManager.get_device_name

get_last_error

Returns the last error: OK or ERROR or CANCEL.

Rho::BluetoothManager.get_last_error

create_session

Creates a Bluetooth session. Returns OK or ERROR.

Rho::BluetoothManager.create_session(role, callback_url)
role ROLE_SERVER or ROLE_CLIENT
callback_url url to a callback method called after the Bluetooth session is created or canceled. Parameters received in the callback: status of OK or ERROR or CANCEL; and connected_device_name, the name of the device connected via Bluetooth.

create_server_and_wait_for_connection

Connect without a user interface. Makes the current device discoverable for another device, and waits for the client connection from the other device.

Rho::BluetoothManager.create_server_and_wait_for_connection(callback_url)
callback_url url to a callback method called after the Bluetooth session is created or canceled. Parameters received in the callback: status of OK or ERROR or CANCEL; and connected_device_name, the name of the device connected via Bluetooth.

create_client_connection_to_device

Connect without user interface. Make the client connection to another device.

Rho::BluetoothManager.create_client_connection_to_device(server_name, callback_url)
server_name The name of the other device. If you connect with user interface, you receive this name as connected_device_name.
callback_url url to a callback method called after the Bluetooth session is created or canceled. Parameters received in the callback: status, OK or ERROR or CANCEL, and connected_device_name, the name of the Bluetooth connected device.

stop_current_connection_process

When connecting without user interface (create_server_and_wait_for_connection), cancel the current connection.

Rho::BluetoothManager.stop_current_connection_process
Back to Top