vtj_bluetooth_package 1.0.0 copy "vtj_bluetooth_package: ^1.0.0" to clipboard
vtj_bluetooth_package: ^1.0.0 copied to clipboard

A Flutter package for seamless Bluetooth Low Energy (BLE) communication with Ventriject medical devices. Provides easy-to-use APIs for device discovery, connection management, and data exchange.

Ventriject Bluetooth Package #

pub package License: MIT

A Flutter package that provides seamless Bluetooth Low Energy (BLE) communication with Ventriject medical devices. This package handles device discovery, connection management, and data exchange with Ventriject's proprietary BLE protocol.

Features #

  • 🔍 Easy device discovery and filtering for Ventriject devices
  • 🔄 Automatic connection management and state handling
  • 📶 Signal strength monitoring
  • 🔒 Secure communication with Ventriject devices
  • 📊 Data parsing and validation
  • 🔄 Automatic reconnection capabilities
  • 📱 Platform support: Android and iOS

Getting Started #

Prerequisites #

Add the package to your pubspec.yaml:

dependencies:
  vtj_bluetooth_package: ^1.0.0

Android Configuration #

Add these permissions to your AndroidManifest.xml:

<uses-permission android:name="android.permission.BLUETOOTH_SCAN"
    android:usesPermissionFlags="neverForLocation"
    tools:targetApi="s" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

iOS Configuration #

Add these entries to your Info.plist:

<key>NSBluetoothAlwaysUsageDescription</key>
<string>Need BLE permission to connect to Ventriject devices</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>Need BLE permission to connect to Ventriject devices</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Need location permission to scan for BLE devices</string>

Usage #

1. Initialize the Repository #

import 'package:vtj_bluetooth_package/vtj_bluetooth_package.dart';

final vtjRepository = VtjDevicesRepositoryImpl(BluePlusVtjDatasource());

2. Scan for Ventriject Devices #

// Start scanning for devices
await vtjRepository.startScan();

// Listen for scan results
final subscription = vtjRepository.getScanResults().listen((result) {
  result.fold(
    (failure) => print('Error: ${failure.message}'),
    (devices) {
      for (var device in devices) {
        print('Found device: ${device.name} (${device.id})');
      }
    },
  );
});

// Don't forget to cancel the subscription when done
// subscription.cancel();

3. Connect to a Device #

final result = await vtjRepository.connectToDevice(selectedDevice);
result.fold(
  (failure) => print('Connection failed: ${failure.message}'),
  (connectedDevice) {
    print('Connected to ${connectedDevice.name}');
    print('Firmware version: ${connectedDevice.firmwareVersion}');
  },
);

4. Execute Commands #

Get Device Version

final versionResult = await vtjRepository.getVersion(device);
versionResult.fold(
  (error) => print('Error: $error'),
  (version) => print('Device version: ${version.version}'),
);

Run Battery Self-Test

final result = await vtjRepository.performBattSelfTest(device);
result.fold(
  (failure) => print('Test failed: ${failure.message}'),
  (testResult) => print('Battery status: ${testResult.status}'),
);

Run Accelerometer Self-Test

final result = await vtjRepository.performAccelSelfTest(device);
result.fold(
  (failure) => print('Test failed: ${failure.message}'),
  (testResult) => print('Accelerometer status: ${testResult.status}'),
);

5. Disconnect from Device #

final result = await vtjRepository.disconnect(device);
result.fold(
  (failure) => print('Disconnection failed: ${failure.message}'),
  (_) => print('Successfully disconnected'),
);

Error Handling #

All operations return Either<VtjFailure, T> where:

  • VtjFailure contains error details if the operation failed
  • T is the success result type

Example error handling:

final result = await vtjRepository.connectToDevice(device);
result.fold(
  (failure) {
    if (failure is PermissionNotGranted) {
      // Handle permission errors
    } else if (failure is ConnectionError) {
      // Handle connection errors
    } else {
      // Handle other errors
    }
  },
  (device) {
    // Handle success
  },
);

Troubleshooting #

Common Issues #

  1. Bluetooth not enabled:

    if (await FlutterBluePlus.isAvailable) {
      // Bluetooth is available
    }
    
  2. Location Services: On Android, ensure location services are enabled for BLE scanning.

  3. Permissions: Always check and request necessary permissions before scanning or connecting.

License #

This project is licensed under the MIT License - see the LICENSE file for details.

Support #

For support, please open an issue in the GitHub repository or contact support@ventriject.com.

1
likes
0
points
39
downloads

Publisher

verified publisherventriject.com

Weekly Downloads

A Flutter package for seamless Bluetooth Low Energy (BLE) communication with Ventriject medical devices. Provides easy-to-use APIs for device discovery, connection management, and data exchange.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

device_info_plus, dio, flutter, flutter_blue_plus, fpdart, freezed_annotation, intl, json_annotation, permission_handler, retrofit, shared_preferences, uuid

More

Packages that depend on vtj_bluetooth_package