Skip to content

Kotlin-based BLE Battery Service implementation. Phone-to-phone communication using standard Bluetooth Low Energy protocol. Built with BMAD AI methodology.

Notifications You must be signed in to change notification settings

abdullahxdev/ble-apps

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

BLE Battery Communication System

A comprehensive Android BLE (Bluetooth Low Energy) project demonstrating device-to-device communication using the standard Battery Service (UUID 0x180F). This project consists of two Kotlin-based Android applications that communicate wirelessly.

📱 Project Overview

This project simulates real-world IoT communication patterns between wearable devices and companion apps:

  • Phone A (BLE Peripheral): Acts as a wearable device, broadcasting battery level information
  • Phone B (BLE Central): Acts as a companion app, discovering and monitoring the peripheral's battery status

🏗️ Project Structure

BLE_Battery_Communication_Project/
├── ble_peripheral_app/          # Phone A - BLE Peripheral (Server)
│   ├── app/
│   │   └── src/main/kotlin/
│   └── build.gradle.kts
├── ble_central_app/             # Phone B - BLE Central (Client)
│   ├── app/
│   │   └── src/main/kotlin/
│   └── build.gradle.kts
└── README.md

✨ Features

BLE Peripheral App (Phone A)

  • ✅ Advertises as BLE peripheral device
  • ✅ Implements standard Battery Service (0x180F)
  • ✅ Broadcasts battery level percentage
  • ✅ Supports real-time battery notifications
  • ✅ Configurable advertising intervals

BLE Central App (Phone B)

  • ✅ Scans for nearby BLE peripheral devices
  • ✅ Discovers and connects to Battery Service devices
  • ✅ Reads battery level characteristic
  • ✅ Subscribes to live battery updates
  • ✅ Displays real-time battery percentage
  • ✅ Auto-reconnection support

🛠️ Technology Stack

  • Language: Kotlin
  • Platform: Android (API Level 21+)
  • Architecture: MVVM (Model-View-ViewModel)
  • BLE Protocol: Bluetooth Low Energy 4.0+
  • Standard Service: Battery Service (UUID: 0x180F)
  • IDE: Android Studio / VS Code

📋 Requirements

  • Android SDK 21 or higher (Lollipop 5.0+)
  • Bluetooth Low Energy support
  • Two Android devices (or one device + emulator with BLE support)
  • Location permissions (required for BLE scanning on Android)

🔧 Setup & Installation

1. Clone the Repository

git clone https://github.com/yourusername/ble-battery-communication.git
cd ble-battery-communication

2. Open Projects

Open both ble_peripheral_app and ble_central_app in Android Studio or VS Code

3. Sync Gradle Dependencies

./gradlew build

4. Configure Permissions

Both apps require the following permissions (already configured in AndroidManifest.xml):

  • BLUETOOTH
  • BLUETOOTH_ADMIN
  • BLUETOOTH_ADVERTISE (Android 12+)
  • BLUETOOTH_CONNECT (Android 12+)
  • BLUETOOTH_SCAN (Android 12+)
  • ACCESS_FINE_LOCATION

5. Run the Apps

  1. Install BLE Peripheral App on Device A
  2. Install BLE Central App on Device B
  3. Start Peripheral app first to begin advertising
  4. Launch Central app to scan and connect

🚀 Usage

Running BLE Peripheral (Phone A)

  1. Open the Peripheral app
  2. Tap "Start Advertising"
  3. App begins broadcasting battery service
  4. Battery level updates automatically

Running BLE Central (Phone B)

  1. Open the Central app
  2. Tap "Scan for Devices"
  3. Select the Peripheral device from the list
  4. View real-time battery level updates

📊 BLE Service Specifications

Battery Service (0x180F)

  • Service UUID: 0000180F-0000-1000-8000-00805F9B34FB
  • Characteristic UUID: 00002A19-0000-1000-8000-00805F9B34FB
  • Properties: Read, Notify
  • Data Format: Unsigned 8-bit integer (0-100%)

🧪 Development Methodology

This project was built using the BMAD (Building with AI) Framework, following a systematic development process:

  1. Requirements Document - Defined project scope and objectives
  2. Architecture Document - Designed system components and interactions
  3. Epics - Broke down into major functional areas
  4. User Stories - Created granular, actionable tasks
  5. AI-Assisted Development - Implemented features with full context

AI Agents Used

  • PM (Project Manager) - Requirements and planning
  • SM (Scrum Master) - Epic and story creation
  • DV (Developer) - Implementation
  • QA (Quality Assurance) - Testing and validation

🐛 Troubleshooting

Device Not Found

  • Ensure Bluetooth is enabled on both devices
  • Grant location permissions (required for BLE scanning)
  • Check that Peripheral app is advertising

Connection Issues

  • Verify both devices support BLE
  • Reduce distance between devices
  • Restart Bluetooth on both devices
  • Check Android version compatibility (API 21+)

Permission Errors

  • Go to App Settings → Permissions
  • Enable Location and Bluetooth permissions
  • For Android 12+, ensure nearby devices permission is granted

📝 Future Enhancements

  • Support for multiple peripheral connections
  • Battery history graph visualization
  • Low battery notifications
  • Custom service implementation
  • Background scanning support
  • Persistent connection management
  • Unit and integration tests

🤝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

👨‍💻 Author

⭐ If you find this project helpful, please consider giving it a star!

About

Kotlin-based BLE Battery Service implementation. Phone-to-phone communication using standard Bluetooth Low Energy protocol. Built with BMAD AI methodology.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published