Expand description
Peat GATT Service Module
Provides the GATT service implementation for Peat Protocol BLE communication.
§Service Structure
Peat GATT Service (UUID: f47ac10b-58cc-4372-a567-0e02b2c3d479)
├── Node Info (read) - Basic node information
├── Sync State (read/notify) - Current sync status
├── Sync Data (write/indicate) - Sync data transfer
├── Command (write) - Control commands
└── Status (read/notify) - Node status updates§Usage
ⓘ
use peat_btle::gatt::{PeatGattService, PeatCharacteristics};
use peat_btle::{NodeId, HierarchyLevel};
// Create the GATT service
let service = PeatGattService::new(
NodeId::new(0x12345678),
HierarchyLevel::Platform,
0, // capabilities
);
// Get characteristic descriptors for registration
let chars = service.characteristics();
// Handle reads
let node_info = service.read_node_info().await;
// Handle writes
service.write_command(&command_data).await?;§Sync Protocol
The sync protocol uses fragmentation for large messages:
ⓘ
use peat_btle::gatt::SyncProtocol;
let mut protocol = SyncProtocol::new();
protocol.set_mtu(251); // Use negotiated MTU
// Start sync with local sync vector
protocol.start_sync(sync_vector);
// Send outgoing messages
while let Some(msg) = protocol.next_outgoing() {
// Write msg.encode() to Sync Data characteristic
}
// Process incoming messages
if let Some((msg_type, payload)) = protocol.process_incoming(&data) {
// Handle received message
}Structs§
- Characteristic
Descriptor - GATT characteristic descriptor
- Characteristic
Properties - Characteristic properties bitfield
- Command
- Command characteristic data
- Fragment
Reassembler - Reassemble fragmented messages
- Node
Info - Node Info characteristic data
- Peat
Characteristic Uuids - Peat characteristic UUIDs derived from base service UUID
- Peat
Characteristics - Characteristic definitions for Peat GATT service
- Peat
Gatt Service - Peat GATT Service
- Status
Data - Status characteristic data
- Status
Flags - Status flags
- Sync
Data Header - Sync Data characteristic header
- Sync
Message - A sync message ready to be sent
- Sync
Protocol - Sync protocol handler
- Sync
State Data - Sync State characteristic data
Enums§
- Command
Type - Command types
- Gatt
Event - Events emitted by the GATT service
- Sync
Data Op - Sync Data operation types
- Sync
Message Type - Sync message types for the protocol state machine
- Sync
Protocol State - Sync protocol state machine state
- Sync
State - Sync state values
Constants§
- DEFAULT_
MAX_ PAYLOAD - Default maximum payload assuming 23-byte MTU
Functions§
- fragment_
payload - Fragment a large payload into multiple sync messages
- max_
payload_ size - Maximum payload size for a single GATT write (MTU - 3 - header)
Type Aliases§
- Gatt
Event Callback - GATT service event handler callback type