Add a New Method for Bluetooth Connection to Your Application

When multiple data measurements are made between Bluetooth devices, characteristics are used to distinguish and accurately make sense of that data. Characteristics are defined as a component of a particular service or data type. For example, if a temperature sensor makes multiple measurements, each measurement is transmitted under a different characteristic. Each characteristic represents a specific type of data; for example, one characteristic may contain temperature data, while another may contain humidity data. Thanks to this structure, the receiving device can easily recognize which characteristic represents which type of data and accurately distinguish between them. When sharing data between devices measuring multiple data measurements using Bluetooth technology, it is important to define characteristics to identify and distinguish which type of data these data are. In this chapter, you will learn how to define and use Bluetooth characteristics.

  1. After adding a Bluetooth connection to your application, click the “ADD NEW METHOD” button in the right corner.

GATT stands for Generic Attribute Profile, a core component of Bluetooth Low Energy (BLE) technology. GATT is a standard protocol that governs how BLE devices exchange and communicate data. It determines how BLE devices share and control data and what data is shared. On the pop-up screen, there are Name, Characteristic ID, Service ID, and Characteristic Type fields describing the main components of GATT.

2. From the pop-up, configure the settings in your application's method.

  • Name (1): This is the field where the created method name is entered.
  • Characteristic ID (2): This is the number that uniquely identifies the characteristics available under Bluetooth Low Energy (BLE) services. The characteristic ID is usually used to distinguish each characteristic.
  • Service ID (3): GATT defines services that devices can use to represent specific functions or data types. Each service contains one or more characteristics. The Service ID is the service number that identifies the services of BLE devices. The service ID uniquely identifies a service.
  • Characteristic Type (4): As units under services, characteristics represent a specific function or data. Each characteristic is identified by a UUID (Universally Unique Identifier) and can allow operations such as read (Read), write (Write) or mark (Notify or Indicate).

For example, a temperature measurement characteristic represents temperature data and can allow the central device to read this data. A characteristic is a value that indicates the type or nature of the data it carries. This means that the data is temperature, humidity, pressure or some other type of measurement. The characteristic type usually corresponds to the types defined in a specific Bluetooth profile or manual. For example, Temperature Measurement.

3. Once the required fields are filled in, click on the “SAVE” button to create the method.

4. Select the method so that the created method can be interpreted by the Kuika platform.

5. Click on “+ADD ACTION” from the Properties panel on the right side. For example, click “+ADD ACTION >Sub Array” to convert the first two values read from a device to Byte (divide by 128) and convert them to temperature value. Click on the Symbol Picker in the Sub Array.

6. In the “Count” field, enter the value “2” since the first two values are requested.

7. Click on “+ADD ACTION>Arithmetic>Divide” for byte conversion.

8. Click the Symbol Picker in Value in Divide and select “Action Results>Sub Array” to call the value from Sub Array. Then type “128” in the value2 field.

9. Then click the “UPDATE” button in the right corner.

Add Method Input

Method Input allows you to define all the inputs required for a method interacting with Bluetooth to work successfully. You can use the “ADD METHOD INPUT” drop-down menu in the Properties panel to define the inputs for the method used when receiving data from a Bluetooth device or when the device is sending data.

To add a new Method Input:

  1. Click “+ADD METHOD INPUT” (1) in the Properties panel.
  2. Configure the following fields from the drop-down menu:some text
    • Input Name (2): This is the field where you specify the name of the input that the method expects. For example, if you are getting data from a temperature sensor, you can name the input “temperature”.
    • Type (3): This is the field where you specify the data type of the input. For example, you can use “String” for text data and “Image” for visual data.
  3. Then click on the “CREATE” (4) button.