Understanding Bluetooth Low Energy (BLE)
Connectivity with flutter app
1. Introduction to BLE
1.1 What is BLE?
Bluetooth Low Energy (BLE) is a wireless technology designed for short-range communication with minimal power consumption. It’s part of the Bluetooth 4.0+ specification and is optimized for:
- Battery-operated devices
- Periodic data transmission
- Short-range communication
- Simple device discovery and pairing
1.2 BLE vs Classic Bluetooth
2. Core Concepts
2.1 Device Roles
- Central Device: A smartphone or tablet that scans for and connects to multiple peripherals.
- Peripheral Device: IoT sensors that advertise their presence and accept connections from a central device.
2.2 States and Transitions
- Advertising State: Device broadcasts its presence with basic information over specific channels.
- Scanning State: Central device searches and filters advertisers.
- Connected State: Enables two-way data exchange with power-saving features.
3. BLE Protocol Stack
3.1 Physical Layer: Operates on a 2.4 GHz band with 40 RF channels using GFSK modulation at 1 Mbps.
3.2 Link Layer: Manages advertising, scanning, connections, error detection, and flow control.
3.3 Host Layer
- L2CAP: Handles data multiplexing, segmentation, and QoS.
- ATT: Organizes data with basic read/write access methods.
- GATT: Defines data structures, service discovery, and characteristic operations.
- GAP: Manages device discovery, connections, and security features.
4. GATT Architecture
4.1 Hierarchy
Profile
└── Service
└── Characteristic
└── Descriptor
4.2 Components
- Services: Group related features, identified by UUID, as standard or custom services.
- Characteristics: Holds data with properties (read/write/notify), a value field, and descriptors.
- Descriptors: Provides extra information, configuration, and user descriptions.
5. Connection Process
5.1 Device Discovery: Peripheral advertises, central scans, processes packets, and filters devices.
5.2 Connection Establishment: Central sends connection request, negotiates parameters, and establishes link.
5.3 Service Discovery: Finds primary services, characteristics, descriptors, and collects handles.
6. Power Management
6.1 Connection Parameters: Defines connection interval, slave latency, and supervision timeout.
6.2 Power States
- Active: Full power mode for data transfer.
- Sleep: Low power mode with periodic wake-ups.
- Standby: Medium power mode with quick wake-up.
7. Security Features
7.1 Pairing Methods
- Just Works: No interaction; limited security.
- Passkey Entry: User confirms code for man-in-the-middle protection.
- Out of Band: Uses external channel for maximum security.
7.2 Security Levels
- No Security: Open connection without encryption.
- Encryption Only: Protects data without authentication.
- Authentication and Encryption: Verifies devices with secure connection.
8. Common Use Cases
8.1 Healthcare: Devices like heart rate monitors, glucose meters, fitness trackers, and temperature sensors.
8.2 Smart Home: Includes smart locks, light controls, environmental sensors, and presence detectors.
8.3 Industrial: Used for asset tracking, machine monitoring, environmental sensing, and predictive maintenance.
9. Limitations and Considerations
9.1 Technical Limitations: Includes range limits, data rate constraints, topology, and interference.
9.2 Design Considerations: Optimizes battery life, enhances security, improves user experience, and considers environmental factors.