Bluetooth Configuration

The widget allowing device configuration through Bluetooth. You can scan for nearby Bluetooth devices, select one of the discovered ones, and then change the characteristics you have defined in the template, for instance, the access to the home WIFI (SSID and password).

Scan for Devices

Select Device  

Configure Device

Custom Update Logic

To convert specific configuration needs you can define JavaScript functions that are called during the widget usage.

Writer Function

This JavaScript function is called each time a characteristic must be written. In this way, you can implement your custom write login, for instance by transforming the value to write, or by splitting it among multiple calls.

var bleCustomWrite = function(device, characteristic, value, widget) {
  return new Promise((resolve, reject) => {
     console.log(device);
     console.log(characteristic);
     console.log(value);
     resolve();
  });
};

See the Writer Function property on each characteristic.

Update Callback

This JavaScript function is called after the Update button is pressed, so you can implement you custom post-update logic, for instance by calling an external service API, or by setting another characteristic to reboot the device or similar.

var bleCustomUpdate = function(device, context, widget) {
  return new Promise((resolve, reject) => {
     console.log("UPDATED");
     console.log(device);
     resolve();
  });
};

See the Update Callback property on the widget.

Template Syntax

Below you can find some examples of how to use the component within a template.


<bluetooth-configuration-widget [title]="'WIFI Configuration'" 
                                [config]="{statusService: '61fe', statusCharacteristic: '03ed06ef', pin: '12345'}">               
                         
        <property label="WIFI SSID" [config]="{service: '61fe', uuid: '16e009ba', mode: 'WRITE', editable: true}"></property>
        <property label="WIFI Password" [config]="{service: '61fe', uuid: '16e009bb', mode: 'WRITE', editable: true}"></property>  
        
        <property label="Serial Number" [config]="{service: '61fe', uuid: '16e009aa' mode : 'READ', editable: false"></property> 
        
</bluetooth-configuration-widget>

Component Reference

Here is a comprehensive list of all the elements and properties that can be used to configure the component.

Bluetooth Configuration <bluetooth-configuration-widget>

PROPERTIES

CSS Class

The name(s) of the CSS class used to customize the widget layout.
Type: STRING | Optional
class="my-custom-class"

Debug Mode

The flag to enable BLE debugging that displays additional icons to access the BLE device and characteristic details of read or write errors.
Type: BOOLEAN | Optional | Values:

true

false


[config]="{debug: true}"

PIN

The optional PIN used to access the device.
Type: STRING | Optional
[config]="{pin: '12345'}"

Status Characteristic UUID

The UUID of the characteristic that provides the state of the device.
Type: STRING | Optional
[config]="{statusCharacteristic: '2c257ad2-4b74-11ec-71d3-1242ac130003'}"

Status Service UUID

The UUID of the service that provides the device state characteristic.
Type: STRING | Optional
[config]="{statusService: '2fdd12fb-366a-11ec-8e3d-0242ac131003'}"

Title

The title displayed on the top part of the widget box.
Type: STRING | Optional
[title]="'Details'"

Update Callback

The name of the JavaScript function to be invoked when the device update is complete.
Type: STRING | Optional
[config]="{onUpdate: 'MyUpdateCallback'}"

Visibility Condition

The expression that allows you to reduce the visibility of the element.
Type: STRING | Optional
*ngIf="getUser().organizationId != null"

SUB-ELEMENTS

Characteristic

The BLE characteristic to read or write.
Multiple | Optional

<property config.service="2fdd12fb-366a-11ec-8e3d-0242ac131003" config.uuid="2c257ad2-4b74-11ec-71d3-1242ac130003" config.mode="WRITE" config.property="serialNumber"></property>

Characteristic <property>

PROPERTIES

Characteristic UUID

The UUID of the characteristic to read or write.
Type: STRING | Required
[config]="{uuid: '2c257ad2-4b74-11ec-71d3-1242ac130003'}"

Editable

The flag indicating whether the value can be changed manually within the widget, in case the characteristic is writable.
Type: BOOLEAN | Optional | Values:

true

false


[config]="{editable: true}"

Hidden

The flag that hides the characteristic when it is not editable.
Type: BOOLEAN | Optional | Values:

true

false


[config]="{hidden: true}"

Id

The symbolic name of the characteristic.
Type: STRING | Optional
id="wifiPassword"

Input placeholder

The value input placeholder.
Type: STRING | Optional
[config]="{placeholder: 'Password'}"

Input Type

The type of the input to be used for the editing.
Type: ENUM | Optional | Values:

TEXT

PASSWORD


[config]="{inputType: 'PASSWORD'}"

Label

The label displayed for this characteristic.
Type: STRING | Optional
label="Temperature"

Mode

The way the characteristic is accessed.
Type: ENUM | Required | Values:

READ

WRITE

READ_WRITE


[config]="{mode: 'WRITE'}"

Property

The property to be used to write the characteristic.
Type: PROPERTY | Required
[config]="{property: 'serialNumber'}"

Reader Function

The name of the JavaScript function that implements the custom read logic for the characteristic. It is generally used when it is necessary to transform the value after the read.
Type: STRING | Optional
[config]="{reader: 'myBleReadFn'}"

Service UUID

The UUID of the service of this characteristic.
Type: STRING | Required
[config]="{service: '2fdd12fb-366a-11ec-8e3d-0242ac131003'}"

Value

The static value to use as default characteristic value.
Type: STRING | Optional
[config]="{value: 'Foo Bar'}"

Writer Function

The name of the JavaScript function that implements custom writing logic for the characteristic. It is generally used when it is necessary to transform the value before writing or to divide it among multiple calls.
Type: STRING | Optional
[config]="{writer: 'myBleUpdateFn'}"