Skip to content

Commit 16f8e8d

Browse files
committed
Updating documentation
1 parent d154c6b commit 16f8e8d

11 files changed

Lines changed: 388 additions & 4150 deletions

README.md

Lines changed: 284 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,298 @@
1-
# libble++
1+
# libble++ - Modern C++ Bluetooth Low Energy Library
22

3-
Implementation of Bluetooth Low Energy functions in modern C++, without
4-
the BlueZ DBUS API.
3+
A modern C++ implementation of Bluetooth Low Energy (BLE) functionality with support for both client (central) and server (peripheral) modes, without requiring the BlueZ D-Bus API.
54

6-
### Includes
7-
* Scanning for bluetooth packets
8-
* Implementation of the GATT profile and ATT protocol
9-
* Lots of comments, complete with references to the specific part of
10-
the Bluetooth 4.0 standard.
11-
* Example programs
5+
## Features
126

13-
### Design
14-
Clean, modern C++ with callbacks. Feed it with lambdas (or whatever you like)
15-
to perform an event happens. Access provided to the raw socket FD, so
16-
you can use select(), poll() or blocking IO.
7+
### Core Functionality
8+
- **BLE Central/Client Mode**
9+
- Scan for BLE devices
10+
- Connect to peripherals
11+
- Service discovery (GATT)
12+
- Read/write characteristics
13+
- Subscribe to notifications/indications
14+
- Full ATT protocol implementation
1715

18-
### The example programs
19-
* lescan_simple: Simplest possible program for scanning for devices. Only 2 non boilerplate lines.
20-
* lescan: A "proper" scanning program that cleans up properly. It's got the same 2 lines of BLE related code and a bit of pretty standard unix for dealing with non blocking I/O and signals.
21-
* temperature: A program for logging temperature values from a device providing a standard temperature characteristic. Very short to indicate the usave, but not much error checking.
16+
- **BLE Peripheral/Server Mode** *(optional)*
17+
- Create custom GATT services
18+
- Advertise services
19+
- Accept incoming connections
20+
- Handle read/write requests
21+
- Send notifications/indications
22+
- Attribute database management
2223

24+
### Transport Layer Abstraction
25+
libblepp supports multiple transport layers for maximum hardware compatibility:
2326

24-
### Building the library
25-
There are currently autoconf (./configure) and CMake options. It's not
26-
a complex library to build, so either option should work fine.
27-
Autoconf:
27+
- **BlueZ Transport** (Linux standard)
28+
- Uses HCI sockets for scanning
29+
- Uses L2CAP sockets for connections
30+
- Works with any BlueZ-compatible adapter
31+
32+
- **ATBM/NimBLE Transport** (hardware-specific)
33+
- Direct ioctl interface (`/dev/atbm_ioctl`)
34+
- Optimized for Altobeam WiFi+BLE combo chips
35+
- Signal-based asynchronous event handling
36+
- Full HCI packet wrapping/unwrapping
37+
38+
### Design Philosophy
39+
- Clean, modern C++11/14 with callbacks
40+
- Extensively commented with references to Bluetooth 4.0+ specifications
41+
- Direct socket access for `select()`, `poll()`, or blocking I/O
42+
- No dependency on BlueZ D-Bus API
43+
- Thread-safe transport implementations
44+
45+
## Quick Start
46+
47+
### Installation
48+
49+
#### Using CMake (Recommended)
50+
```bash
51+
mkdir build && cd build
52+
cmake ..
53+
make
54+
sudo make install
2855
```
29-
./configure
56+
57+
#### Using Autoconf
58+
```bash
59+
./configure
3060
make
31-
```
32-
CMake:
61+
sudo make install
3362
```
34-
mkdir build && cd build
63+
64+
### Basic Scanning Example
65+
```cpp
66+
#include <blepp/lescan.h>
67+
68+
int main() {
69+
BLEPP::HCIScanner scanner;
70+
71+
scanner.on_device_found = [](const BLEPP::AdvertisementData& ad) {
72+
std::cout << "Device: " << ad.address
73+
<< " RSSI: " << (int)ad.rssi << std::endl;
74+
};
75+
76+
scanner.start();
77+
// Process events...
78+
scanner.stop();
79+
}
80+
```
81+
82+
### Basic Server Example
83+
```cpp
84+
#include <blepp/blegattserver.h>
85+
86+
int main() {
87+
BLEPP::BLEGATTServer server;
88+
89+
// Add a service with a characteristic
90+
auto service = server.add_service(0x180F); // Battery Service
91+
auto characteristic = service->add_characteristic(
92+
0x2A19, // Battery Level
93+
BLEPP::ReadOnly
94+
);
95+
96+
characteristic->set_read_callback([](auto conn) {
97+
return std::vector<uint8_t>{85}; // 85% battery
98+
});
99+
100+
server.start_advertising("MyDevice");
101+
server.run(); // Event loop
102+
}
103+
```
104+
105+
## Build Options
106+
107+
### CMake Build Options
108+
109+
| Option | Default | Description |
110+
|--------|---------|-------------|
111+
| `WITH_SERVER_SUPPORT` | `OFF` | Enable BLE peripheral/server mode |
112+
| `WITH_BLUEZ_SUPPORT` | `ON` | Enable BlueZ HCI/L2CAP transport |
113+
| `WITH_ATBM_SUPPORT` | `OFF` | Enable ATBM ioctl transport |
114+
| `WITH_EXAMPLES` | `OFF` | Build example programs |
115+
116+
### Build Configuration Examples
117+
118+
**Client-only (BlueZ):**
119+
```bash
35120
cmake ..
36-
make install
121+
make
122+
```
123+
124+
**Client + Server (BlueZ):**
125+
```bash
126+
cmake -DWITH_SERVER_SUPPORT=ON ..
127+
make
128+
```
129+
130+
**Client + Server + ATBM:**
131+
```bash
132+
cmake -DWITH_SERVER_SUPPORT=ON -DWITH_ATBM_SUPPORT=ON ..
133+
make
134+
```
135+
136+
**Everything with examples:**
137+
```bash
138+
cmake -DWITH_SERVER_SUPPORT=ON -DWITH_ATBM_SUPPORT=ON -DWITH_EXAMPLES=ON ..
139+
make
37140
```
38-
CMake with examples:
39-
Examples will be in ```build/examples```
141+
142+
### Makefile Build Options
143+
144+
```bash
145+
# Client-only
146+
make
147+
148+
# Client + Server
149+
make BLEPP_SERVER_SUPPORT=1
150+
151+
# Client + Server + ATBM
152+
make BLEPP_SERVER_SUPPORT=1 BLEPP_ATBM_SUPPORT=1 BLEPP_BLUEZ_SUPPORT=1
40153
```
154+
155+
See [BUILD_OPTIONS.md](docs/BUILD_OPTIONS.md) for complete build configuration reference.
156+
157+
## Example Programs
158+
159+
Located in the `examples/` directory:
160+
161+
- **lescan_simple** - Minimal BLE scanning example (2 lines of BLE code)
162+
- **lescan** - Production-ready scanner with signal handling and cleanup
163+
- **temperature** - Read temperature from standard temperature characteristic
164+
- **gatt_server** - Simple GATT server implementation *(requires server support)*
165+
166+
Build examples with CMake:
167+
```bash
41168
mkdir build && cd build
42169
cmake -DWITH_EXAMPLES=ON ..
43-
make install
44-
```
170+
make
171+
```
172+
173+
Examples will be in `build/examples/`.
174+
175+
## Documentation
176+
177+
- [BUILD_OPTIONS.md](docs/BUILD_OPTIONS.md) - Complete build configuration reference
178+
- [CMAKE_BUILD_GUIDE.md](docs/CMAKE_BUILD_GUIDE.md) - CMake build system guide
179+
- [CLIENT_TRANSPORT_ABSTRACTION.md](docs/CLIENT_TRANSPORT_ABSTRACTION.md) - Transport layer architecture
180+
- [ATBM_IOCTL_API.md](docs/ATBM_IOCTL_API.md) - ATBM transport API reference
181+
- [ATBM_IMPLEMENTATION_COMPLETE.md](docs/ATBM_IMPLEMENTATION_COMPLETE.md) - ATBM implementation details
182+
183+
## Requirements
184+
185+
### Common Requirements
186+
- C++11 or later compiler
187+
- Linux kernel 3.4+ (for BLE support)
188+
189+
### BlueZ Transport (default)
190+
- BlueZ 5.0 or later
191+
- libbluetooth-dev (development headers)
192+
- Root privileges or `CAP_NET_ADMIN` + `CAP_NET_RAW` capabilities
193+
194+
Install on Debian/Ubuntu:
195+
```bash
196+
sudo apt-get install libbluetooth-dev
197+
```
198+
199+
### ATBM Transport (optional)
200+
- Altobeam WiFi+BLE driver loaded
201+
- `/dev/atbm_ioctl` device accessible
202+
- Appropriate device permissions
203+
- Apache NimBLE 4.2+ (bundled with driver)
204+
205+
## Architecture
206+
207+
### Transport Abstraction
208+
```
209+
┌─────────────────────────────────────┐
210+
│ Application Code │
211+
└──────────────┬──────────────────────┘
212+
213+
┌──────────┴──────────┐
214+
│ │
215+
┌───▼─────┐ ┌────────▼────────┐
216+
│ Scanner │ │ GATT Client │
217+
└───┬─────┘ └────────┬────────┘
218+
│ │
219+
└──────────┬──────────┘
220+
221+
┌──────────▼─────────────┐
222+
│ BLEClientTransport │ ◄─ Abstract Interface
223+
│ (Pure Virtual) │
224+
└──────────┬─────────────┘
225+
226+
┌────────┴────────┐
227+
│ │
228+
┌─────▼──────┐ ┌─────▼──────┐
229+
│ BlueZ │ │ ATBM │
230+
│ Transport │ │ Transport │
231+
└─────┬──────┘ └─────┬──────┘
232+
│ │
233+
┌─────▼──────┐ ┌─────▼──────┐
234+
│ HCI/L2CAP │ │ /dev/atbm │
235+
│ Sockets │ │ ioctl │
236+
└────────────┘ └────────────┘
237+
```
238+
239+
## Using libblepp in Your Project
240+
241+
### CMake
242+
```cmake
243+
find_library(BLEPP_LIB ble++ REQUIRED)
244+
find_path(BLEPP_INCLUDE blepp REQUIRED)
245+
246+
add_executable(my_app main.cpp)
247+
target_include_directories(my_app PRIVATE ${BLEPP_INCLUDE})
248+
target_link_libraries(my_app ${BLEPP_LIB} bluetooth pthread)
249+
```
250+
251+
### pkg-config
252+
```bash
253+
g++ main.cpp $(pkg-config --cflags --libs libblepp) -o my_app
254+
```
255+
256+
### Direct Linking
257+
```bash
258+
g++ main.cpp -lble++ -lbluetooth -lpthread -o my_app
259+
```
260+
261+
## License
262+
263+
[License information - please verify in source]
264+
265+
## Contributing
266+
267+
Contributions are welcome! Please ensure:
268+
- Code follows existing style conventions
269+
- Changes include relevant documentation updates
270+
- Build succeeds with all configuration options
271+
- Examples compile and run correctly
272+
273+
## References
274+
275+
- Bluetooth Core Specification 4.0+
276+
- BlueZ 5.x documentation
277+
- Apache NimBLE documentation
278+
- Linux kernel Bluetooth subsystem
279+
280+
## Version History
281+
282+
See git history for detailed changelog. Recent major updates include:
283+
- ATBM/NimBLE transport support with ioctl interface
284+
- Transport abstraction layer for multiple hardware backends
285+
- Complete GATT server implementation
286+
- CMake build system alongside autoconf
287+
- Comprehensive documentation suite
288+
289+
## Support & Issues
290+
291+
For bugs, feature requests, or questions:
292+
1. Check existing documentation in `docs/`
293+
2. Search closed issues
294+
3. Open a new issue with details about your environment
295+
296+
## Credits
297+
298+
Originally designed for BlueZ-based systems, now extended to support multiple transport layers for broader hardware compatibility.

0 commit comments

Comments
 (0)