Crates.io | bluedroid |
lib.rs | bluedroid |
version | 0.3.7 |
source | src |
created_at | 2022-10-22 14:58:27.898729 |
updated_at | 2023-03-06 14:21:11.257528 |
description | A wrapper for the ESP32 Bluedroid Bluetooth stack. |
homepage | |
repository | https://github.com/pulse-loop/bluedroid |
max_upload_size | |
id | 694508 |
size | 167,488 |
This is a Rust wrapper for the Bluedroid Bluetooth stack for ESP32. It allows you to build a GATT server with a declarative API and supports multithreading.
Declare a characteristic:
let manufacturer_name_characteristic = Characteristic::new(BleUuid::Uuid16(0x2A29))
.name("Manufacturer Name String")
.permissions(AttributePermissions::new().read().write())
.properties(CharacteristicProperties::new().read().write().notify())
.max_value_length(20)
.on_write(|data, param| {
info!("Received write request: {:?} {:?}", data, param);
})
.show_name()
.set_value("Hello, world!".as_bytes().to_vec())
.build();
Declare a service:
let device_information_service = Service::new(BleUuid::Uuid16(0x180A))
.name("Device Information")
.primary()
.characteristic(&manufacturer_name_characteristic)
.build();
Declare a profile and start the server:
let profile = Profile::new(0x0001)
.name("Device Information")
.service(&device_information_service)
.build();
GLOBAL_GATT_SERVER
.lock()
.unwrap()
.profile(profile)
.device_name("ESP32-GATT-Server")
.appearance(Appearance::WristWornPulseOximeter)
.advertise_service(&device_information_service)
.start();
There are currently no plans to implement the GATT client API. Contributions are welcome.
There are currently no plans to implement the Bluetooth Classic API. Contributions are welcome.