docs.rs failed to build ble-windows-server-0.2.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build:
ble-windows-server-0.2.1
ble-windows-server
A simple, ergonomic BLE GATT server library for Windows using WinRT APIs.
Features
- Create BLE GATT services with read/notify characteristics
- Automatic Bluetooth adapter discovery and selection
- Multiple data type support (strings, numbers, JSON, raw bytes)
- Async/await support with Tokio
- Zero-copy where possible
- Windows 10/11 support via WinRT
Requirements
- Windows 10 (1803+) or Windows 11
- Bluetooth adapter with BLE peripheral role support
- Rust 1.70+
Installation
Add to your Cargo.toml:
[]
= "0.1"
= { = "1", = ["full"] }
For JSON serialization support:
[]
= { = "0.1", = ["json"] }
Quick Start
use ;
async
API Overview
Creating a Server
// Basic creation (characteristic UUID auto-generated)
let server = new;
// With explicit characteristic UUID
let server = with_characteristic;
Adapter Selection
use list_adapters;
// List available adapters
let adapters = list_adapters.await?;
for adapter in &adapters
// Use a specific adapter
server.use_adapter;
// Or use the default
server.use_default_adapter;
Sending Notifications
// Raw bytes
server.notify.await?;
// Strings
server.notify_str.await?;
// Formatted strings
server.notify_fmt.await?;
// Numbers (little-endian)
server.notify_u8.await?;
server.notify_i16.await?;
server.notify_u32.await?;
server.notify_f32.await?;
server.notify_f64.await?;
// Boolean
server.notify_bool.await?; // Sends 0x01
// JSON (requires "json" feature)
server.notify_json.await?;
// Sends: {"temperature":23.5,"humidity":65}
Server Lifecycle
// Start the server
server.start.await?;
// Check if running
if server.is_running
// Stop explicitly (also called on drop)
server.stop?;
Accessors
let name = server.device_name; // "MyDevice"
let svc_uuid = server.service_uuid; // Service UUID
let char_uuid = server.characteristic_uuid; // Characteristic UUID
let running = server.is_running; // true/false
Complete Example
use Duration;
use sleep;
use ;
async
Testing with nRF Connect
- Install nRF Connect on your phone
- Run your BLE server application
- Open nRF Connect and scan for devices
- Connect to your device
- Navigate to the service UUID
- Enable notifications on the characteristic
- Watch the data stream in!
Troubleshooting
"No Bluetooth adapters found"
- Ensure Bluetooth is enabled in Windows Settings
- Check that your adapter supports BLE peripheral role
- Try running as Administrator
Adapter doesn't support peripheral role
Not all Bluetooth adapters support acting as a BLE peripheral. Check adapter capabilities:
let adapters = list_adapters.await?;
for adapter in &adapters
Device not visible in scans
- Windows may use the computer's Bluetooth name instead of the provided device name
- Ensure
SetIsDiscoverable(true)is set (default in this library) - Try restarting Bluetooth in Windows Settings
License
MIT License - see LICENSE for details.
Contributing
Contributions welcome! Please open an issue or PR on GitHub.