eon_cordova_bluetoothle object

This object allows you to interact with Bluetooth Low Energy devices on Android and iOS mobile devices.

Functions

of_base64tojson

Description

Converts a base64 encoded string to a JSON array.

Syntax

of_base64tojson ( string as_data )

Parameter

as_data - The base64 encoded string.

Return value

String. The decoded data.

of_characteristics

Description

Discovers the service's characteristics. When successful, the oe_success event will be triggered; when failed, the oe_error event will be triggered.

Syntax

of_characteristics ( string as_address, string as_service )

Parameter

as_address - The address/identifier provided by the scan's return object.

as_service - Service UUID.

Return value

None.

of_close

Description

Closes the connection with a bluetooth LE device. When successful, the oe_success event will be triggered; when failed, the oe_error event will be triggered.

Syntax

of_close ( string as_address )

Parameter

as_address - The address/identifier provided by the scan's return object.

Return value

None

of_close_no_event

Description

Closes the connection with a bluetooth LE device. No oe_success or oe_error event will be triggered.

Syntax

of_close_no_event ( string as_address )

Parameter

as_address - The address/identifier provided by the scan's return object.

Return value

None

of_connect

Description

Connects to a bluetooth LE device. When successful, the oe_success event will be triggered; when failed, the oe_error event will be triggered.

Syntax

of_connect ( string as_address )

Parameter

as_address - The address/identifier provided by the scan's return object.

Return value

None

of_decode

Description

Decodes the data after it is read.

Syntax

of_decode ( string as_data )

Parameter

as_data - The encoded data.

Return value

String. The decoded data.

of_disconnect

Description

Disconnects from a bluetooth LE device. When successful, the oe_success event will be triggered; when failed, the oe_error event will be triggered.

Syntax

of_disconnect ( string as_address )

Parameter

as_address - The address/identifier provided by the scan's return object.

Return value

None

of_discover

Description

Discovers all the device's services, characteristics, and descriptors after connecting with a device successfully.

When successful, the oe_success event will be triggered; when failed, the oe_error event will be triggered.

Supported on Android only. Use of_services and of_characteristics instead on iOS.

Syntax

of_discover ( string as_address )

Parameter

as_address - The address/identifier provided by the scan's return object.

Return value

None

of_encode

Description

Encodes the data before it is written to the device.

Syntax

of_encode ( string as_data )

Parameter

as_data - The decoded data.

Return value

String. The encoded data.

of_init

Description

Connects with the Cordova bluetooth LE plugin, detects if the plugin is available to call, and binds the current PowerBuilder object with the JavaScript object defined by the plugin. After that, the PowerBuilder object has all of the methods and properties that the JavaScript object has.

Syntax

of_init ( )

Return value

Integer.

1 - Success.

-1 - It is called in PowerBuilder or Appeon Web, or there is an error.

of_initialize

Description

Initializes bluetooth on the device. This function must be called after of_init and before any others and it should only be called once. When successful, the oe_success event will be triggered; when failed, the oe_error event will be triggered.

Syntax

of_initialize ( boolean ab_request )

Parameter

ab_request - Whether to prompt the user to enable bluetooth.

Return value

None

of_isconnected

Description

Determines whether the device is connected.

Syntax

of_isconnected ( )

Return value

Boolean.

True - Connected.

False - Not connected.

of_isenabled

Description

Detects if bluetooth is turned on or not on the device. The oe_enable event will be triggered.

Supported on the Android device only.

Syntax

of_isenabled ( )

Return value

None.

of_read

Description

Reads a particular service's characteristics. When successful, the oe_success event will be triggered; when failed, the oe_error event will be triggered.

Syntax

of_read ( string as_address, string as_service, string as_characteristic )

Parameter

as_address - The address/identifier provided by the scan's return object.

as_service - The service's UUID.

as_characteristic - The characteristic's UUID.

Return value

None

of_services

Description

Discovers the device's services. The UUID of the service can be used by of_characteristics.

When successful, the oe_success event will be triggered; when failed, the oe_error event will be triggered; and value returned by the JavaScript function will be passed to parameter of the event.

Supported on iOS only.

Syntax

of_services ( string as_address )

Parameter

as_address - The address/identifier provided by the scan's return object.

Return value

None

of_services_no_event

Description

Discovers the device's services. The UUID of the service can be used by of_characteristics.

Supported on iOS only.

Syntax

of_services_no_event ( string as_address )

Parameter

as_address - The address/identifier provided by the scan's return object.

Return value

String. The service UUID.

of_startscan

Description

Scans for bluetooth LE devices. When successful, the oe_success event will be triggered; when failed, the oe_error event will be triggered.

Syntax

of_startscan ( )

Return value

None

of_stopscan

Description

Stops scanning for bluetooth LE devices. When successful, the oe_success event will be triggered; when failed, the oe_error event will be triggered.

Syntax

of_stopscan ( )

Return value

None

of_write

Description

Writes a particular service's characteristic. When successful, the oe_success event will be triggered; when failed, the oe_error event will be triggered.

Syntax

of_write ( string as_address, string as_service, string as_characteristic, string as_data )

Parameter

as_address - The address/identifier provided by the scan's return object.

as_service - The service's UUID.

as_characteristic - The characteristic's UUID.

as_data - Base64 encoded string.

Return value

None

Events

oe_enable

Description

Occurs when the of_isenabled function is executed; asks to turn on bluetooth if it is not turned on. If the JavaScript function in the Cordova plugin returns any value, that value will be passed to the as_message parameter.

Supported on the Android device only.

Syntax

oe_enable ( string as_message )

Parameter

as_message - A JSON-format string which contains values returned by the function.

Return value

None

oe_error

Description

Occurs when an error occurs during the function call. If the JavaScript function in the Cordova plugin returns any error, that error will be passed to the as_error parameter.

Syntax

oe_error ( string as_error )

Parameter

as_error - A JSON-format string which contains error information returned by the function.

Return value

None

oe_success

Description

Occurs when the function is successfully executed. If the JavaScript function in the Cordova plugin returns any value, that value will be passed to the as_message parameter.

Syntax

oe_success ( string as_message )

Parameter

as_message - A JSON-format string which contains values returned by the function.

Return value

None

Properties

boolean ib_enable

Indicates whether bluetooth is enabled on the device.

boolean ib_exist

Indicates whether the newly scanned device exists in the scan result list.

eon_str_cordova_bluetooth ieon_str_bluetooth[]

The structure for storing the address and name of the found bluetooth device.

long il_type

Functionality extension for developers: 1 - scan, 2 - connect, 3 - read

oleobject ieon_ole

PowerBuilder OLEObject object to be connected with the Cordova plugin.

powerobject ipo_bindevent

PowerBuilder object to be bound with the JavaScript object.

string is_connectinfo

Stores the success or error information when establishing a connection.

string is_errorevent

Stores the error event name of the PowerBuilder object.

string is_errorText

Stores the error information returned by the JavaScript function when execution failed.

string is_jserrorText

Stores the JavaScript error information when JavaScript call fails.

string is_successevent

Stores the success event name of the PowerBuilder object.

string is_successText

Stores the value returned by the JavaScript function when execution is successful.

Structures

eon_str_cordova_bluetooth

Description

Struct.

Stores the information of the bluetooth device including address, name, status etc.

Property

Type

Variable Name

Description

string

address

Address of the bluetooth device.

string

name

Name of the bluetooth device.

string

rssi

RSSI of the bluetooth broadcasting.

string

advertisement

Advertisement of the bluetooth broadcasting.

string

status

Status of the bluetooth broadcasting.