Bluetooth refers to the process of ensuring that it can communicate with other devices through wireless communication technology. Bluetooth is a widely used communication protocol for wireless data transfer between devices, inter-device connectivity and various other functions.
For example, a mobile application wants to receive weight data from a scale via a Bluetooth connection.
The app establishes a Bluetooth connection with the scale device. This may involve the user selecting and pairing a device within the app or in settings. The application communicates with the device using the platform's Bluetooth API or an appropriate Bluetooth SDK. This API provides the functionality to open the connection, read and write data. The application periodically reads weight data from the scale device over Bluetooth. The scale sends the weight measurements over Bluetooth and the application receives this data. The app processes the received data and displays it in the user interface. For example, it can display the weight as a number or graph. Allows the app to communicate with and receive data from external devices using Bluetooth features.
Therefore, in many application development projects, adding the Bluetooth feature can increase the functionality of the application and improve the user experience.
Let's perform the Bluetooth connection steps in the application.
Device Name: The name of the device visible to the user.
Device ID (Identifier): Unique identification information of the device. Not every device has it.
Device Address: The physical Bluetooth address of the device.
For example, the address of a Bluetooth device can be seen as: 00:1A:2B:3C:4D:5E.
It is not mandatory to enter Device Id and Device Address.If multiple data measurements are made between Bluetooth devices, characteristics are often used to distinguish and understand this data. Characteristics are used 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, a characteristic may contain Temperature Data or Humidity Data. In this way, the receiving device can distinguish between these data by recognizing which characteristic represents which type of data.
While Bluetooth technology can share data between multiple data measuring devices, certain methods need to be created to distinguish what kind of data it is.
Click Add New Method to create a method.
GATT stands for Generic Attribute Profile, a key component of Bluetooth Low Energy (BLE) technology. GATT is a standard protocol that governs how BLE devices exchange and communicate data. GATT defines how BLE devices will share data, what data they will share and how it will be controlled. On the screen that opens, there are Name, Characteristic ID, Service ID, Characteristic Type fields describing the main components of GATT.
Name: This is the field where the created method name is entered.
Characteristic ID:
A number that uniquely identifies the characteristics available under Bluetooth Low Energy (BLE) services. The characteristic ID is typically used to distinguish each characteristic.
Service ID: GATT defines services that devices can use to represent specific functions or data types. Each service includes one or more characteristics. A Service ID is a service number that identifies the services of Bluetooth BLE devices. Each service contains one or more characteristics. Service ID is a unique number that identifies a service.
Characteristic Type:
Characteristics, as units under services, 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.
Once the required fields have been filled in, click on the Save button to create the method.
In order for the created Method to be interpreted by the platform, actions must be created by clicking +Add Action in the Properties panel.
For example, click +Add Action→ Sub Arrayto convert the first two values read from a device into bytes (divide by 128) and convert them into temperature values. Click Symbol Picker in Sub Array.
This selection will be made because we want to read the Bluetooth value.
In the Count field, enter the value 2 since the first two values are requested.
Click +Add Action->Arithmetic→Dividefor byte conversion.
Click on the symbol picker in the value in Divide and select Action Results→Sub Arrayto call the value from the sub array.
Then type 128 in the value2 field.
Then click the CREATE button.