How jjjsmit/bluetoothbleclient works
Project type and purpose
• This is a small, Linux-based Bluetooth Low Energy (BLE) central‐client tool written in C.
• It leverages the BlueZ 5.49 Bluetooth stack via D‐Bus and a GLib main loop to connect to a known BLE peripheral and interact with specific GATT characteristics.
File structure
• Top-level files:
• README.md – describes purpose, setup, dependencies
• Makefile – builds your client plus unmodified BlueZ sources
• ble.c – your main entry point (initializes, parses args)
• bleClient.c / bleClient.h – implementation of BLE/D‐Bus interactions
• External sources (not shown in tree) are pulled in from the BlueZ 5.49 directory: examples and headers for D‐Bus, GLib, and GATT support.
README for additional insights
• Dependencies: BlueZ ≥ 5.49, libdbus-1, libglib2.0
• Execution environment: Linux (e.g., Raspbian Stretch), interacts with system bluetoothd via D‐Bus
• Core functionality: minimal, low-priority thread, known device/service/characteristics
Main components
a. Application (ble executable)
– ble.c: startup, argument parsing
– bleClient.{c,h}: BLE connection management, GATT read/notify
b. BlueZ daemon (bluetoothd)
– exposes D-Bus API for BLE operations
– manages HCI interface to the Bluetooth adapter
c. Linux Bluetooth HCI layer
– Kernel driver + hardware interface (USB or built-in)
d. BLE peripheral device
– GATT server with known service UUIDs and characteristics you target
e. External libraries
– D-Bus library (libdbus-1)
– GLib (main event loop)
Relationships and interactions
• Your ble client binds to the GLib main loop → schedules GATT operations
• bleClient calls D-Bus methods (AcquireNotify, ReadValue) on bluetoothd
• bluetoothd drives HCI commands down to the kernel driver
• BLE radio on the adapter communicates wirelessly with the peripheral’s GATT server
• Notifications from peripheral propagate back up through HCI → bluetoothd → your client’s callback
Architectural patterns / design principles
• Layered architecture:
1. Application layer (ble client)
2. IPC layer (D-Bus)
3. Bluetooth stack (BlueZ daemon + kernel HCI)
4. Hardware / radio
5. Remote GATT server
• Event-driven: GLib main loop dispatches asynchronous notifications
• Minimalism: only uses necessary BlueZ files, no heavyweight abstractions
Detail to capture
• D-Bus AcquireNotify and ReadValue methods
• GLib main loop for event dispatch
• Exact flow of BLE notifications