Week8
Week 8 Progress: BLE Android App Development and Testing
Objective:
To implement and test the BLE (Bluetooth Low Energy) communication feature on the Android mobile application, enabling real-time reception of status, alarm, and ADC data from the ankle-worn hardware device.
BLE Communication Principle (Android BLE Overview):
BLE is a wireless protocol designed for short-range, low-power communication. It works via a client-server model, where:
-
Peripheral (Server): The ankle-worn device (XIAO nRF52840), advertises services and characteristics.
-
Central (Client): The Android phone scans for nearby BLE devices, connects to a chosen peripheral, and subscribes to its characteristics.
On Android, the workflow is as follows:
-
Scan for nearby devices using
BluetoothLeScanner. -
Connect to a selected device using
connectGatt(). -
Discover Services to identify the available UUIDs.
-
Enable Notifications for a given characteristic via descriptor
0x2902. -
Receive Updates when the peripheral updates that characteristic value (e.g., every second).
Implementation:
The app was developed using Jetpack Compose and Kotlin in Android Studio. It consists of:
-
A device scanning screen
-
A data display screen showing status, alarm, and live ADC values
-
BLE service handlers for connection, notification, and data parsing
🔧 Key Code Analysis
1. Device Scanning and Connection
Starts BLE scan and connects to selected device using a
BluetoothGattCallback.
2. Service Discovery and Notification Enablement
This block enables BLE notifications from the device's custom characteristic. UUIDs were manually matched with the board's firmware.
3. Data Handling from Peripheral (BLE Notification)
Receives composite data string like
"MOVING,ALARM,6423"-
Splits it into
status,alarm, andADC value, and updates UI in real time
Results:
-
BLE device scanning and connection on Android were successful
-
Characteristic data was correctly received once per second and parsed without error
-
Real-time system status, alarm state, and ADC values were displayed in the app
-
The app provided stable and low-latency updates, verifying correct BLE integration with the board






Comments
Post a Comment