ihealth_hr 0.0.1 copy "ihealth_hr: ^0.0.1" to clipboard
ihealth_hr: ^0.0.1 copied to clipboard

A Flutter plugin to integrate the iHealth KN-550BT blood pressure monitor.

ihealth_hr #

A Flutter plugin to integrate the iHealth KN-550BT Blood Pressure Monitor with your Flutter app.

Features #

  • Scan for iHealth KN-550BT devices via Bluetooth
  • Connect and receive real-time blood pressure and heart rate data
  • Receive offline historical measurement data from the device
  • Monitor device battery level and connection status
  • Stream device data seamlessly to Flutter using Dart streams

Currently supports Android only (iOS coming soon)

Getting Started #

1. Add the plugin to your pubspec.yaml: #

dependencies:
  ihealth_hr: ^0.0.1
  permission_handler: ^11.0.1

Then run:

flutter pub get

2. Android Setup #

Update your Android configuration:

  • Open android/app/build.gradle and modify the following:

    android {
        namespace "com.example.ihealth_hr" // <-- CHANGE THIS
    }
    
    defaultConfig {
        applicationId "com.example.ihealth_hr" // <-- CHANGE THIS
    }
    
  • Open android/app/src/main/kotlin/com/example/ihealth_hr/MainActivity.kt and change the package declaration at the top:

    package com.example.ihealth_hr
    
  • Open android/app/src/main/AndroidManifest.xml and at the top of the file make sure it's declared like this:

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        package="com.example.ihealth_hr">
    
  • Add the required permissions inside the manifest:

    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
    
  • Inside the <application> tag, add this line:

    <application
        android:name="com.example.ihealth_hr.BaseApplication"
        android:label="ihealth_hr_example" 
        android:icon="@mipmap/ic_launcher"
        tools:replace="android:label">
        <!-- ... -->
    </application>
    

3. Dart Usage #

Import the plugin:

import 'package:ihealth_hr/ihealth_hr.dart';

Request permissions using the permission_handler plugin:

await [
  Permission.bluetooth,
  Permission.bluetoothScan,
  Permission.bluetoothConnect,
  Permission.locationWhenInUse,
].request();

Start scanning:

IhealthHrPlugin.startScan();

Listen to events from the device:

StreamSubscription? _subscription;

_subscription = IhealthHrPlugin.deviceStatusStream.listen((event) {
  if (event is Map) {
    final eventType = event['event'];
    switch (eventType) {
      case 'connectionStateChanged':
        final status = event['status']; // "connected" or "disconnected"
        break;
      case 'offlineHistoryCount':
        final count = event['count'];   // Number of offline records
        final message = event['message'];
        break;
      case 'historyData':
        final sys = event['sys'];
        final dia = event['dia'];
        final heartRate = event['heartRate'];
        final time = event['time'];
        break;
      case 'batteryLevel':
        final battery = event['level'];
        break;
      case 'displayStatus':
        final backlightOn = event['backlightOn'];
        final clockOn = event['clockOn'];
        break;
      case 'deviceTime':
        final time = event['time'];
        break;
    }
  }
});

Don’t forget to dispose the stream when your widget is disposed:

@override
void dispose() {
  _subscription?.cancel();
  super.dispose();
}

License #

MIT

2
likes
0
points
19
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin to integrate the iHealth KN-550BT blood pressure monitor.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, permission_handler, plugin_platform_interface

More

Packages that depend on ihealth_hr

Packages that implement ihealth_hr