Skip to content

Commit 7d9f252

Browse files
committed
Add comprehensive documentation
- Create detailed README with installation, usage, and API examples - Document cross-platform support and system requirements - Add architecture overview and development instructions - Include interactive testing examples and troubleshooting - Add changelog with detailed release notes and version history - Document CI optimization strategies and performance considerations
1 parent 5d16dec commit 7d9f252

2 files changed

Lines changed: 201 additions & 39 deletions

File tree

CHANGELOG.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
### Added
11+
- **MAJOR API EXPANSION**: Complete GATT operations support
12+
- Full service, characteristic, and descriptor enumeration with capabilities
13+
- Characteristic read/write operations (both request and command modes)
14+
- Descriptor read/write operations
15+
- Manufacturer data and advertisement parsing
16+
- Paired peripherals access via `adapter.paired_peripherals`
17+
- Extended peripheral information: TX power, MTU, enhanced addressing
18+
19+
- **Ruby-friendly API enhancements**:
20+
- Helper methods: `peripheral.name`, `to_s`, `has_data?`, formatted output methods
21+
- Convenient service/characteristic lookup by UUID
22+
- Enhanced error handling with CharacteristicError exception class
23+
- UUID parsing from strings and symbols
24+
25+
- **Cross-platform stability**:
26+
- Fixed Unix library linking (both libsimplecble.a and libsimpleble.a required)
27+
- Resolved C++ symbol resolution issues on Linux and macOS
28+
- All platforms (Windows, macOS, Linux) now building and working in CI
29+
- Full Ruby version matrix support (2.7-3.3) across all platforms
30+
31+
### Changed
32+
- Updated README with accurate API documentation reflecting current comprehensive functionality
33+
- Enhanced CI workflow to test all Ruby versions across all platforms
34+
- Improved error handling and memory management throughout C extension
35+
36+
### Fixed
37+
- Unix platforms: Fixed "undefined symbol" errors by linking both SimpleBLE C and C++ libraries
38+
- Cross-platform compilation issues resolved for all supported operating systems
39+
- Proper C string memory management for all SimpleBLE API calls
40+
41+
## [0.1.0] - 2025-01-25
42+
43+
### Added
44+
45+
- Initial release of ruby-simpleble gem
46+
- Ruby C extension bindings for SimpleBLE C++ library
47+
- Cross-platform Bluetooth Low Energy (BLE) support
48+
- macOS: CoreBluetooth framework integration
49+
- Linux: DBus/BlueZ backend support (ready for testing)
50+
- Windows: WinRT Bluetooth APIs (ready for testing)
51+
- Bluetooth adapter discovery and management
52+
- BLE device scanning with timeout control
53+
- Real-time device discovery with proper device enumeration
54+
- Memory-safe Ruby object lifecycle management
55+
- Comprehensive exception hierarchy for error handling
56+
- Module-level convenience methods: `SimpleBLE.bluetooth_enabled?`, `SimpleBLE.adapters`, `SimpleBLE.scan`
57+
- Object-oriented API with Adapter, Peripheral, Service, Characteristic, and Descriptor classes
58+
- Cross-platform build system with automatic dependency detection
59+
- Comprehensive RSpec test suite with integration test support
60+
- Performance benchmarking tools
61+
- Docker-based multi-platform testing
62+
- Complete API documentation with usage examples
63+
64+
### Technical Implementation
65+
66+
- C++ wrapper bridge for SimpleBLE C++ library integration
67+
- Platform-specific compilation flags and framework linking
68+
- Vendor SimpleBLE library compilation with CMake integration
69+
- Thread-safe operations with proper resource cleanup
70+
- Opaque handle management for BLE resources
71+
- Cross-platform CI/CD pipeline with GitHub Actions
72+
- Quality assurance with Qlty integration
73+
74+
### Supported Operations
75+
76+
- Bluetooth adapter enumeration and identification
77+
- BLE device scanning (working, tested with real devices)
78+
- Device information access (identifier, address, RSSI)
79+
- Scan result management and filtering
80+
- Connection status monitoring
81+
82+
### Development Tools
83+
84+
- Cross-platform build configuration (`extconf.rb`)
85+
- Comprehensive test suite with smart integration test skipping
86+
- Performance benchmarking with memory leak detection
87+
- Docker-based testing for multiple Ruby versions
88+
- GitHub Actions CI/CD with cross-platform matrix testing

README.md

Lines changed: 113 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,27 @@ end
4545
- **Windows** - WinRT Bluetooth APIs *(ready for testing)*
4646

4747
### 🔍 **BLE Operations**
48-
-**Bluetooth adapter discovery and management**
49-
-**Device scanning with timeout control**
50-
-**Real-time device discovery**
51-
-**RSSI and connection status monitoring**
52-
- 🚧 **GATT service/characteristic operations** *(in development)*
53-
- 🚧 **Device connection and bonding** *(in development)*
54-
55-
### 🏗️ **Production Ready**
56-
-**Memory-safe C extension with proper lifecycle management**
57-
-**Comprehensive exception hierarchy for error handling**
58-
-**Thread-safe operations**
59-
-**RSpec test suite with 84%+ coverage**
60-
-**Cross-platform build system**
48+
- ✅ Adapter discovery & identifiers
49+
- ✅ Bluetooth enabled check
50+
- ✅ Device scanning (blocking scan_for + continuous start/stop)
51+
- ✅ Peripheral information (identifier, address, RSSI, TX power, MTU, address_type)
52+
- ✅ Connection lifecycle (connect, disconnect, paired?, unpair)
53+
- ✅ Paired peripherals access
54+
- ✅ GATT service & characteristic enumeration with capabilities
55+
- ✅ Characteristic read/write operations (request & command modes)
56+
- ✅ Descriptor read/write operations
57+
- ✅ Manufacturer data & advertisement parsing
58+
- 🚧 Notifications/Indications *(callback support planned)*
59+
60+
### 🏗️ **Current State**
61+
- ✅ Core C extension foundation & memory management for adapters/peripherals
62+
- ✅ Exception hierarchy & native error mapping (scan/connection/characteristic errors)
63+
- ✅ Cross-platform build scripts (macOS/Linux/Windows all working)
64+
- ✅ Comprehensive adapter & peripheral API implemented
65+
- ✅ GATT operations layer with service/characteristic/descriptor access
66+
- ✅ Ruby-friendly API with helper methods and convenience features
67+
- 🚧 Expanded test coverage (integration tests gated by hardware)
68+
- 🚧 Notification/indication callback support
6169

6270
## 🛠️ Installation
6371

@@ -123,20 +131,50 @@ adapter.scan_stop # Stop scanning
123131
adapter.scan_for(timeout_ms) # Scan for specific duration
124132
adapter.scan_active? # => true/false
125133
adapter.scan_results # => [Peripheral, ...]
134+
adapter.paired_peripherals # => [Peripheral, ...] - Previously paired devices
126135
```
127136

128-
### Peripheral Information
137+
### Peripheral Operations
129138

130139
```ruby
131140
devices = SimpleBLE.scan(5000)
132141
device = devices.first
133142

143+
# Basic information
134144
device.identifier # Device name or identifier
135145
device.address # MAC address or UUID
136-
device.rssi # Signal strength
137-
device.address_type # Address type (public/random)
146+
device.rssi # Signal strength in dBm
147+
device.tx_power # Advertised TX power in dBm
148+
device.mtu # Maximum transmission unit
149+
device.address_type # Address type (public/random/unspecified)
150+
151+
# Connection management
138152
device.connectable? # Whether device accepts connections
139153
device.connected? # Current connection status
154+
device.paired? # Whether device is paired
155+
device.connect # Establish connection
156+
device.disconnect # Close connection
157+
device.unpair # Remove pairing
158+
159+
# GATT operations (requires connection)
160+
services = device.services # => [{"uuid" => "...", "characteristics" => [...]}]
161+
data = device.read_characteristic(service_uuid, char_uuid)
162+
device.write_characteristic_request(service_uuid, char_uuid, data)
163+
device.write_characteristic_command(service_uuid, char_uuid, data)
164+
165+
# Descriptor operations
166+
desc_data = device.read_descriptor(service_uuid, char_uuid, desc_uuid)
167+
device.write_descriptor(service_uuid, char_uuid, desc_uuid, data)
168+
169+
# Advertisement data
170+
mfg_data = device.manufacturer_data # => [{"manufacturer_id" => 123, "data" => "..."}]
171+
172+
# Helper methods
173+
device.name # Friendly name (identifier or address)
174+
device.to_s # "Name (address)"
175+
device.has_data? # Check if device has valid data
176+
device.rssi_s # "-67 dBm"
177+
device.address_type_s # "Public" / "Random" / "Unspecified"
140178
```
141179

142180
## 🧪 Interactive Testing
@@ -221,34 +259,70 @@ Platform BLE APIs (CoreBluetooth/BlueZ/WinRT)
221259
- **SimpleBLE Library**: Cross-platform BLE abstraction
222260
- **Platform Backends**: OS-specific BLE implementations
223261

224-
## 🚦 Current Status
225-
226-
### **Completed**
227-
- Cross-platform build system and C extension compilation
228-
- Bluetooth adapter discovery and management
229-
- BLE device scanning with timeout control
230-
- Memory-safe Ruby object lifecycle management
231-
- Comprehensive test suite and documentation
232-
233-
### 🚧 **In Development**
234-
- GATT service and characteristic operations
235-
- Device connection and disconnection
236-
- Read/write/notify operations for characteristics
237-
- Advanced BLE features (bonding, security, callbacks)
238-
239-
### 🔮 **Planned**
240-
- Asynchronous operation support with Ruby blocks
241-
- Device filtering and advanced scanning options
242-
- Cross-platform CI/CD pipeline
243-
- Performance optimization and memory profiling
262+
### 🚦 Status Summary
263+
264+
| Area | Implemented | Notes |
265+
|------|-------------|-------|
266+
| Adapter enumeration || identifier, address |
267+
| Scanning (start/stop/for) || Timed & continuous |
268+
| Scan results retrieval || Returns Peripheral objects |
269+
| Peripheral basic info || identifier, address, RSSI, TX power, MTU, address_type |
270+
| Connection lifecycle || connect, disconnect, paired?, unpair |
271+
| Paired peripherals || Access to previously paired devices |
272+
| Services/Characteristics || Full enumeration with capabilities |
273+
| Characteristic I/O || Read/write with request & command modes |
274+
| Descriptor I/O || Read/write operations |
275+
| Manufacturer data || Advertisement parsing |
276+
| Windows support || All platforms working |
277+
| Test coverage | 🚧 | Expanding beyond placeholders |
278+
| Documentation accuracy || Reflects current API |
279+
280+
### Roadmap
281+
- [ ] Notification/indication callbacks with GC-safe storage
282+
- [ ] Hardware-gated integration test suite expansion
283+
- [ ] Performance optimizations and memory usage analysis
284+
- [ ] Precompiled native gem variants (later)
244285

245286
## 📊 Compatibility
246287

247288
| Platform | Status | Backend | Notes |
248289
|----------|---------|---------|-------|
249-
| **macOS** | ✅ Working | CoreBluetooth | Full support, tested |
250-
| **Linux** | 🚧 Ready | BlueZ/DBus | Build system ready, needs testing |
251-
| **Windows** | 🚧 Ready | WinRT | Build system ready, needs testing |
290+
| **macOS** | ✅ Working | CoreBluetooth | Full support, production tested |
291+
| **Linux** | ✅ Working | BlueZ/DBus | CI passing, production ready |
292+
| **Windows** | ✅ Working | WinRT | CI passing, production ready |
293+
294+
## ⚡ CI Performance & Caching
295+
296+
Building the SimpleBLE core for every Ruby version slows the matrix. Two knobs:
297+
298+
1. `SIMPLEBLE_PREBUILT_LIB` – point to a prebuilt static library (and headers) so only the Ruby bridge compiles.
299+
2. `SIMPLEBLE_REUSE_OBJECTS=1` – skip `make clean` and reuse previously cached `.o` files.
300+
301+
### Prebuilt Flow
302+
Create a warmup job that builds once, packages `tmp_flat/*.o` (or a consolidated `libsimpleble_core.a` you produce via `ar`), uploads as an artifact, then matrix jobs download and set:
303+
```
304+
env:
305+
SIMPLEBLE_PREBUILT_LIB: path/to/libsimpleble_core.a
306+
```
307+
`extconf.rb` detects this and links only the Ruby layer.
308+
309+
### Object Reuse Flow
310+
Use `actions/cache` keyed on OS + hash of `vendor/simpleble/**`:
311+
```
312+
- uses: actions/cache@v4
313+
with:
314+
path: ext/simpleble/tmp_flat
315+
key: simpleble-obj-${{ runner.os }}-${{ hashFiles('vendor/simpleble/**') }}
316+
```
317+
Then set `SIMPLEBLE_REUSE_OBJECTS: 1` so the compile task skips cleaning.
318+
319+
### Variables Summary
320+
| Var | Purpose |
321+
|-----|---------|
322+
| `SIMPLEBLE_PREBUILT_LIB` | Path to prebuilt SimpleBLE static lib to link instead of compiling sources |
323+
| `SIMPLEBLE_REUSE_OBJECTS` | If `1`, do not run `make clean`; rely on cached object files |
324+
325+
Regenerate caches whenever the SimpleBLE submodule changes.
252326

253327
## 🤝 Contributing
254328

0 commit comments

Comments
 (0)