Skip to main content

Module gatt

Module gatt 

Source
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§

CharacteristicDescriptor
GATT characteristic descriptor
CharacteristicProperties
Characteristic properties bitfield
Command
Command characteristic data
FragmentReassembler
Reassemble fragmented messages
NodeInfo
Node Info characteristic data
PeatCharacteristicUuids
Peat characteristic UUIDs derived from base service UUID
PeatCharacteristics
Characteristic definitions for Peat GATT service
PeatGattService
Peat GATT Service
StatusData
Status characteristic data
StatusFlags
Status flags
SyncDataHeader
Sync Data characteristic header
SyncMessage
A sync message ready to be sent
SyncProtocol
Sync protocol handler
SyncStateData
Sync State characteristic data

Enums§

CommandType
Command types
GattEvent
Events emitted by the GATT service
SyncDataOp
Sync Data operation types
SyncMessageType
Sync message types for the protocol state machine
SyncProtocolState
Sync protocol state machine state
SyncState
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§

GattEventCallback
GATT service event handler callback type