Module phy

Module phy 

Source
Expand description

BLE PHY Configuration

Configures physical layer parameters for BLE connections, including support for LE Coded PHY for extended range operations.

§Overview

BLE 5.0 introduced multiple PHY options allowing applications to choose between range and throughput:

PHYData RateRangeUse Case
LE 1M1 Mbps~100mDefault, good balance
LE 2M2 Mbps~50mHigh throughput
LE Coded S=2500 kbps~200mExtended range
LE Coded S=8125 kbps~400mMaximum range

§Architecture

┌────────────────────────────────────────────────────────┐
│                    Application                          │
│            (range/throughput requirements)              │
└─────────────────────┬──────────────────────────────────┘
                      │
                      ▼
┌────────────────────────────────────────────────────────┐
│                 PhyController                           │
│  ┌──────────────┐  ┌────────────┐  ┌────────────────┐  │
│  │  PhyStrategy │──│   RSSI     │──│    PHY         │  │
│  │   (Adaptive) │  │  Monitor   │  │   Switch       │  │
│  └──────────────┘  └────────────┘  └────────────────┘  │
└─────────────────────┬──────────────────────────────────┘
                      │
                      ▼
┌────────────────────────────────────────────────────────┐
│              BLE Controller (HCI)                       │
│         LE Set PHY / PHY Update Procedure              │
└────────────────────────────────────────────────────────┘

§Usage

§Fixed PHY

use hive_btle::phy::{PhyController, PhyStrategy, PhyCapabilities, BlePhy};

let caps = PhyCapabilities::ble5_full();
let mut ctrl = PhyController::with_defaults(caps);

// Force maximum range mode
ctrl.set_strategy(PhyStrategy::MaxRange);

§Adaptive PHY

use hive_btle::phy::{PhyController, PhyStrategy, PhyCapabilities};

let caps = PhyCapabilities::ble5_full();
let mut ctrl = PhyController::with_defaults(caps);

// Adaptive selection based on RSSI
ctrl.set_strategy(PhyStrategy::adaptive(-50, -75, 5));

// Record RSSI samples
if let Some(event) = ctrl.record_rssi(rssi, current_time) {
    // Handle switch recommendation
}

§Range Estimation

Approximate relationship between RSSI and range for each PHY:

RSSILE 1MLE 2MCoded S=2Coded S=8
-40 dBm10m5m20m40m
-60 dBm30m15m60m120m
-80 dBm80m40m160m320m
-90 dBm200m400m

§Hardware Requirements

  • LE 2M: BLE 5.0 hardware
  • LE Coded: BLE 5.0 hardware with Long Range support
  • Not all BLE 5.0 devices support Coded PHY

Re-exports§

pub use controller::PhyController;
pub use controller::PhyControllerConfig;
pub use controller::PhyControllerEvent;
pub use controller::PhyControllerState;
pub use controller::PhyStats;
pub use controller::PhyUpdateResult;
pub use strategy::evaluate_phy_switch;
pub use strategy::PhyStrategy;
pub use strategy::PhySwitchDecision;
pub use types::BlePhy;
pub use types::PhyCapabilities;
pub use types::PhyPreference;

Modules§

controller
PHY Controller
strategy
PHY Selection Strategy
types
BLE PHY Types