Connecting scales to Healthcare app

Mobile
IntelliCeedBlog list

Connecting scales to Healthcare app

Connecting scales to Healthcare app

author: Olha Maksymets

publication date: Jul 12, 2024

Our developer Oleksandr successfully connected scales to the Healthcare app using Bluetooth Low Energy (BLE) technology. In this article, we'll look at the features of BLE, the challenges Oleksandr faced, and the solutions used.

Varieties of Bluetooth

There are two main types of Bluetooth challenges:

  1. 1. Classical Bluetooth: Connects devices that require constant contact, such as headphones. These devices support continuous communication with the device.
  2. 2. Bluetooth Low Energy (BLE): An energy-saving technology that does not require a constant connection. This makes BLE ideal for devices such as scales that need to operate for long periods of time without frequent recharging.

BLE Standardization

BLE has standards that simplify the process for devices. Device manufacturers adhering to these standards ensure that any smartphone can connect to it. If a device does not meet the standards, app developers must write additional code to connect it.

Connecting non-standard scales

The scale that Oleksandr connected did not comply with the BLE standards. The manufacturer of the scales provided documentation describing the process of correctly reading the data and interpreting the current readings. Oleksandr's main task was to use this documentation to retrieve and correctly display the weight values.

Using React Native BLE PLX

To implement the connection to BLE devices in a React Native application, Oleksandr used the react-native-ble-plx library. This library provides all the necessary functions to scan, connect and interact with BLE devices.

import { BleManager } from 'react-native-ble-plx';

export const manager = new BleManager();

Creating a single instance of BleManager allows you to manage all BLE operations.

Requesting Location Permissions

In order for BLE to work correctly, the application must request location permissions from the user. This allows the application to determine if the device is within range to connect.


async function requestLocationPermission() {
  try {
    const granted = await PermissionsAndroid.request(
      PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
      {
        title: "Location Access Required",
        message: "This app needs to access your location to detect Bluetooth devices",
      }
    );
    if (granted === PermissionsAndroid.RESULTS.GRANTED) {
      console.log("Location permission granted");
    } else {
      console.log("Location permission denied");
    }
  } catch (err) {
    console.warn(err);
  }
}

Conclusion

Through the efforts of our developer and utilizing the documentation provided, the scale has been successfully integrated with the Healthcare app. This allows users to conveniently and accurately read weight readings through the app, providing better control over their health. The use of React Native BLE PLX and proper management of location permissions made this process efficient and reliable.