Skip to main content

Module bluetooth

Module bluetooth 

Source
Expand description

Bluetooth Low Energy protocol and abstractions Bluetooth Low Energy (BLE) support for FEAGI embedded systems

This module provides a platform-agnostic BLE abstraction layer for embedded FEAGI agents. It includes:

  • Protocol layer for FEAGI commands and neuron data
  • Nordic UART Service (NUS) definitions
  • Platform-specific BLE stack implementations

§Architecture

┌─────────────────────────────────────────┐
│  Application (embodiment firmware)      │
└─────────────────┬───────────────────────┘
                  │ uses
┌─────────────────▼───────────────────────┐
│  Protocol Layer (protocol.rs)           │
│  - Command parsing                      │
│  - Neuron data formatting               │
│  - JSON message handling                │
└─────────────────┬───────────────────────┘
                  │ uses
┌─────────────────▼───────────────────────┐
│  BLE HAL Trait (../hal/bluetooth.rs)    │
└─────────────────┬───────────────────────┘
                  │ implements
┌─────────────────▼───────────────────────┐
│  Platform Implementation                │
│  - nRF52 (TrouBLE)                     │
│  - ESP32 (esp-idf)                     │
│  - STM32WB (ST BLE stack)              │
└─────────────────────────────────────────┘

§Usage

use feagi_hal::bluetooth::protocol::BluetoothService;
use feagi_hal::bluetooth::nus::FEAGI_DEVICE_NAME;

// Initialize BLE stack (platform-specific)
use feagi_hal::platforms::Esp32Bluetooth;
let mut ble = Esp32Bluetooth::new("FEAGI-robot").expect("BLE init failed");

// Protocol layer is platform-agnostic
let mut service = BluetoothService::new("FEAGI-robot");

loop {
    // Receive commands from FEAGI
    if let Ok(data) = ble.receive_data() {
        service.process_received_data(&data);
    }

    // Check for parsed commands
    if let Some(cmd) = service.receive_command() {
        // Handle command (GPIO, LED, etc.)
    }
}

§Feature Flags

  • bluetooth-nrf52 - nRF52-based devices (micro:bit, nRF52840-DK) using TrouBLE
  • bluetooth-esp32 - ESP32/ESP32-S3/ESP32-C3 using esp-idf BLE stack
  • bluetooth-stm32wb - STM32WB series with built-in BLE

§Current Status

PlatformStatusNotes
nRF52 (TrouBLE)⚠️ ExperimentalExecutor compatibility issues
ESP32 (esp-idf)🟢 PlannedShould work with embassy
STM32WB🔵 PlannedHardware BLE controller

Re-exports§

pub use crate::transports::protocol::Command;
pub use crate::transports::protocol::PacketCommand;
pub use crate::transports::protocol::Protocol as BluetoothProtocol;

Modules§

nus
Nordic UART Service (NUS) and FEAGI Service UUID Definitions