Skip to content

sohailmahmud/connectflow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

22 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

ConnectFlow - BLE Device Manager

Flutter BLE app with clean architecture, BLoC pattern, real-time data streaming, and OTA firmware updates

Dart Flutter Platform Coverage Status Build Status

A professional-grade Flutter application for managing Bluetooth Low Energy (BLE) devices with real-time sensor monitoring, over-the-air firmware updates, and comprehensive device control capabilities.

โœจ Features

๐Ÿ” Device Management

  • Smart Scanning: Automatic BLE device discovery with RSSI indication
  • Secure Pairing: Robust device connection with timeout handling
  • Connection Management: Real-time connection status monitoring

๐Ÿ“Š Real-time Data Streaming

  • Live Sensor Data: Temperature, humidity, pressure, and battery monitoring
  • Data Visualization: Real-time charts and historical data tracking
  • Configurable Buffering: Adjustable data history with memory management

๐Ÿ”„ OTA Firmware Updates

  • Wireless Updates: Over-the-air firmware deployment
  • Progress Tracking: Real-time update progress with status indicators
  • Error Handling: Robust error recovery and retry mechanisms

๐Ÿ—๏ธ Architecture & Design

  • Clean Architecture: Separation of concerns with layered design
  • SOLID Principles: Maintainable and extensible codebase
  • BLoC Pattern: Reactive state management with event-driven architecture
  • Dependency Injection: Modular design with GetIt

๐Ÿ›๏ธ Architecture Overview

โ”œโ”€โ”€ ๐Ÿ“ฑ Presentation Layer
โ”‚   โ”œโ”€โ”€ BLoC (State Management)
โ”‚   โ”œโ”€โ”€ Pages (UI Screens)
โ”‚   โ””โ”€โ”€ Widgets (Reusable Components)
โ”‚
โ”œโ”€โ”€ ๐Ÿง  Domain Layer
โ”‚   โ”œโ”€โ”€ Entities (Business Models)
โ”‚   โ”œโ”€โ”€ Use Cases (Business Logic)
โ”‚   โ””โ”€โ”€ Repository Interfaces
โ”‚
โ””โ”€โ”€ ๐Ÿ’พ Data Layer
    โ”œโ”€โ”€ Data Sources (BLE Implementation)
    โ”œโ”€โ”€ Models (Data Transfer Objects)
    โ””โ”€โ”€ Repository Implementation

๐ŸŽฏ SOLID Principles Implementation

  • Single Responsibility: Each class has one clear purpose
  • Open/Closed: Easy to extend without modifying existing code
  • Liskov Substitution: Interfaces are properly abstracted
  • Interface Segregation: Small, focused interfaces
  • Dependency Inversion: High-level modules independent of low-level details

๐Ÿš€ Getting Started

Prerequisites

  • Flutter 3.0 or higher
  • Android SDK 21+ or iOS 12+
  • Physical device (BLE not supported on simulators)

Installation

  1. Clone the repository

    git clone https://github.com/sohailmahmud/ConnectFlow.git
    cd connectflow
  2. Install dependencies

    flutter pub get
  3. Generate code (if using build_runner)

    flutter packages pub run build_runner build
  4. Run the app

    flutter run

๐Ÿ“ฑ Platform Setup

Android Configuration

Add these permissions to android/app/src/main/AndroidManifest.xml:

<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.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />

iOS Configuration

Add to ios/Runner/Info.plist:

<key>NSBluetoothAlwaysUsageDescription</key>
<string>This app needs Bluetooth access to connect to BLE devices</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>This app needs Bluetooth access to connect to BLE devices</string>

๐Ÿ“ฆ Dependencies

Core Dependencies

dependencies:
  flutter_blue_plus: ^1.14.3      # Modern BLE library
  flutter_bloc: ^8.1.3            # State management
  equatable: ^2.0.5               # Value equality
  injectable: ^2.3.2              # Dependency injection annotations
  get_it: ^7.6.4                  # Service locator
  permission_handler: ^11.0.1     # Runtime permissions
  rxdart: ^0.27.7                 # Reactive extensions
  dartz: ^0.10.1                  # Functional programming

dev_dependencies:
  build_runner: ^2.4.7            # Code generation
  freezed: ^2.4.6                 # Immutable classes
  injectable_generator: ^2.4.1    # DI code generation
  json_serializable: ^6.7.1       # JSON serialization

๐ŸŽฎ Usage

Basic Workflow

  1. Scan for Devices

    context.read<BleBloc>().add(StartScanningEvent());
  2. Connect to Device

    context.read<BleBloc>().add(ConnectToDeviceEvent(deviceId));
  3. Start Data Streaming

    context.read<BleBloc>().add(StartDataStreamEvent(deviceId));
  4. Firmware Update

    context.read<BleBloc>().add(
      StartFirmwareUpdateEvent(deviceId, firmwareData)
    );

State Management Example

BlocBuilder<BleBloc, BleState>(
  builder: (context, state) {
    if (state is BleDataStreaming) {
      return DataVisualizationWidget(
        device: state.device,
        dataHistory: state.dataHistory,
      );
    }
    return CircularProgressIndicator();
  },
)

๐Ÿงช Testing

Running Tests

# Domain layer tests
flutter test test/domain/

# Data layer tests  
flutter test test/data/

# Presentation layer tests
flutter test test/presentation/

# All unit tests
flutter test

# Integration tests
flutter test integration_test/

# With coverage
flutter test --coverage

Test Structure

test/
โ”œโ”€โ”€ core/
โ”‚   โ””โ”€โ”€ errors/failures_test.dart
โ”œโ”€โ”€ domain/
โ”‚   โ”œโ”€โ”€ entities/
โ”‚   โ”œโ”€โ”€ usecases/
โ”œโ”€โ”€ data/
โ”‚   โ”œโ”€โ”€ models/
โ”‚   โ””โ”€โ”€ repositories/
โ”œโ”€โ”€ presentation/
โ”‚   โ”œโ”€โ”€ bloc/
โ”‚   โ””โ”€โ”€ widgets/
โ”œโ”€โ”€ mocks/
โ”œโ”€โ”€ test_helpers/
โ””โ”€โ”€ integration_test/

๐Ÿ”ง Configuration

BLE Service UUIDs

Update these constants in ble_datasource.dart:

static const String serviceUuid = "12345678-1234-1234-1234-123456789abc";
static const String dataCharacteristicUuid = "87654321-4321-4321-4321-cba987654321";
static const String otaCharacteristicUuid = "11111111-2222-3333-4444-555555555555";

Data Parsing

Customize sensor data parsing in _parseFloat() method based on your device's data format.

๐Ÿ“Š Performance

  • Memory Management: Automatic cleanup of streams and subscriptions
  • Battery Optimization: Efficient BLE scanning with timeouts
  • Data Buffering: Configurable history size to prevent memory leaks
  • Connection Pooling: Proper device connection lifecycle management

๐Ÿค Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Follow the existing code style and architecture patterns
  4. Write tests for new functionality
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

Code Style

  • Follow Effective Dart guidelines
  • Use meaningful variable and function names
  • Add documentation for public APIs
  • Maintain separation of concerns

๐Ÿ› Troubleshooting

Common Issues

BLE Not Working on Emulator

  • BLE requires physical device - emulators don't support Bluetooth hardware

Permission Denied Errors

  • Ensure all required permissions are added to platform-specific files
  • Check that location services are enabled (required for BLE scanning)

Connection Timeouts

  • Verify device is in pairing mode
  • Check signal strength (RSSI)
  • Ensure device is not connected to another app

OTA Update Failures

  • Verify firmware file format
  • Check MTU size limitations
  • Ensure stable connection during update

๏ฟฝ CI/CD & DevOps

This project includes comprehensive GitHub Actions workflows for automated testing, building, and deployment:

๐Ÿ”„ Continuous Integration (.github/workflows/ci.yml)

  • Automated Testing: Runs on every push and pull request
  • Multi-platform Support: Tests on Ubuntu, macOS, and Windows
  • Comprehensive Coverage: Unit, widget, and integration tests
  • Code Quality: Static analysis, formatting checks, and security scanning
  • Coverage Reporting: Automatic test coverage analysis

๐Ÿ› ๏ธ Maintenance Workflow (.github/workflows/maintenance.yml)

  • Weekly Dependency Updates: Automated dependency management
  • Security Audits: Regular vulnerability scanning
  • Automated PRs: Creates pull requests for updates

๐Ÿ“ฆ Release Workflow (.github/workflows/release.yml)

  • Production Builds: Automated APK and App Bundle generation
  • GitHub Releases: Automatic release creation with changelogs
  • Artifact Management: Binary distribution and versioning
  • Multi-format Support: Both stable and pre-release versions

Workflow Badges

Add these badges to track your CI/CD status:

[![CI](https://github.com/yourusername/connectflow/workflows/CI/badge.svg)](https://github.com/yourusername/connectflow/actions/workflows/ci.yml)
[![Maintenance](https://github.com/yourusername/connectflow/workflows/Maintenance/badge.svg)](https://github.com/yourusername/connectflow/actions/workflows/maintenance.yml)
[![Release](https://github.com/yourusername/connectflow/workflows/Release/badge.svg)](https://github.com/yourusername/connectflow/actions/workflows/release.yml)

๏ฟฝ๐Ÿ“„ License

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

๐Ÿ™ Acknowledgments

๐Ÿ“ž Support


Made with โค๏ธ using Flutter

About

Flutter BLE app for real-time data streaming and OTA firmware updates

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Languages