BluetoothConnection

Properties5

Example extension api

This is example of API. Implementation contain in extension.

Methods

createClientConnection
(STRING serverName, CallBackHandler callback)

Parameters

  • serverName : STRING

  • callback : CallBackHandler Mandatory

Async Callback Returning Parameters: HASH

    • status : STRING

      STATUS_* code. See error code by lastError property

    • connectionID : STRING Optional

Synchronous Return:

  • Void : this method also supports async callbacks - check the Callback tab for callback return parameters.

Method Access:

  • Class Method: This method can only be accessed via the API class object.
    • JavaScript: Rho.BluetoothConnection.createClientConnection(STRING serverName, CallBackHandler callback)
    • Ruby: Rho::BluetoothConnection.createClientConnection(STRING serverName, CallBackHandler callback)
createConnection
(STRING role, CallBackHandler callback)

Parameters

  • role : STRING

  • callback : CallBackHandler Mandatory

Async Callback Returning Parameters: HASH

    • status : STRING

      STATUS_* code. See error code by lastError property

    • connectionID : STRING Optional

Synchronous Return:

  • Void : this method also supports async callbacks - check the Callback tab for callback return parameters.

Method Access:

  • Class Method: This method can only be accessed via the API class object.
    • JavaScript: Rho.BluetoothConnection.createConnection(STRING role, CallBackHandler callback)
    • Ruby: Rho::BluetoothConnection.createConnection(STRING role, CallBackHandler callback)
createServerConnection
(CallBackHandler callback)

Parameters

  • callback : CallBackHandler Mandatory

Async Callback Returning Parameters: HASH

    • status : STRING

      STATUS_* code. See error code by lastError property

    • connectionID : STRING Optional

Synchronous Return:

  • Void : this method also supports async callbacks - check the Callback tab for callback return parameters.

Method Access:

  • Class Method: This method can only be accessed via the API class object.
    • JavaScript: Rho.BluetoothConnection.createServerConnection(CallBackHandler callback)
    • Ruby: Rho::BluetoothConnection.createServerConnection(CallBackHandler callback)
disableBluetooth
()

disable BT HW

Synchronous Return:

  • Void

Method Access:

  • Class Method: This method can only be accessed via the API class object.
    • JavaScript: Rho.BluetoothConnection.disableBluetooth()
    • Ruby: Rho::BluetoothConnection.disableBluetooth()
disconnect
()

Synchronous Return:

  • Void

Method Access:

  • Instance Method: This method can be accessed via an instance object of this class:
    • myObject.disconnect()
enableBluetooth
()

enable BT HW

Synchronous Return:

  • Void

Method Access:

  • Class Method: This method can only be accessed via the API class object.
    • JavaScript: Rho.BluetoothConnection.enableBluetooth()
    • Ruby: Rho::BluetoothConnection.enableBluetooth()
getConnectionByID
(STRING connectionID)

Parameters

  • connectionID : STRING

Synchronous Return:

  • SELF_INSTANCE

Method Access:

  • Class Method: This method can only be accessed via the API class object.
    • JavaScript: Rho.BluetoothConnection.getConnectionByID(STRING connectionID)
    • Ruby: Rho::BluetoothConnection.getConnectionByID(STRING connectionID)
readData
()

Synchronous Return:

  • ARRAY
    • byte : INTEGER

Method Access:

  • Instance Method: This method can be accessed via an instance object of this class:
    • myObject.readData()
readString
()

Synchronous Return:

  • STRING

Method Access:

  • Instance Method: This method can be accessed via an instance object of this class:
    • myObject.readString()
setCallback
(CallBackHandler callback)

Parameters

  • callback : CallBackHandler Mandatory

Async Callback Returning Parameters: HASH

    • status : STRING

      see CONNECTION_STATUS_

    • connectionID : STRING Optional

Synchronous Return:

  • Void : this method also supports async callbacks - check the Callback tab for callback return parameters.

Method Access:

  • Instance Method: This method can be accessed via an instance object of this class:
    • myObject.setCallback(CallBackHandler callback)
stopCurrentConnectionProcess
()

Synchronous Return:

  • Void

Method Access:

  • Class Method: This method can only be accessed via the API class object.
    • JavaScript: Rho.BluetoothConnection.stopCurrentConnectionProcess()
    • Ruby: Rho::BluetoothConnection.stopCurrentConnectionProcess()
writeData
(ARRAY data)

Parameters

  • data : ARRAY

    • byte : INTEGER

Synchronous Return:

  • Void

Method Access:

  • Instance Method: This method can be accessed via an instance object of this class:
    • myObject.writeData(ARRAY data)
writeString
(STRING string)

Parameters

  • string : STRING

Synchronous Return:

  • Void

Method Access:

  • Instance Method: This method can be accessed via an instance object of this class:
    • myObject.writeString(STRING string)

Properties

connectionID
: STRING Read Only
{}

Property Access:

  • Instance: This property can be accessed via an instance object of this class:
    • myObject.connectionID
deviceName
: STRING

name of this device – show on connected device

Property Access:

  • Instance: This property can be accessed via an instance object of this class:
    • myObject.deviceName
isAvailable
: BOOLEAN Read Only

return TRUE if Bluetooth available for connection now

Property Access:

  • Instance: This property can be accessed via an instance object of this class:
    • myObject.isAvailable
lastError
: STRING Read Only
{}

Property Access:

  • Instance: This property can be accessed via an instance object of this class:
    • myObject.lastError
status
: INTEGER Read Only

-1 if error, 0 if empty or more than zero if data waiting for read

Property Access:

  • Instance: This property can be accessed via an instance object of this class:
    • myObject.status

Constants

STATUS_OK

all is OK

STATUS_ERROR

some error is occured during method call. Check error via lastError property

STATUS_CANCEL

user cancelled operation

ROLE_SERVER

server role

ROLE_CLIENT

client role

ERROR_NO_ERRORS
ERROR_NOT_FOUND
ERROR_UNKNOWN
CONNECTION_STATUS_INPUT_DATA_RECEIVED
CONNECTION_STATUS_DISCONNECTED
CONNECTION_STATUS_ERROR