mirror of
https://github.com/esphome/esphome.git
synced 2026-10-07 11:26:39 +00:00
[rp2_ble_tracker] BLE tracker for Raspberry Pi Pico W (#18002)
This commit is contained in:
@@ -10,6 +10,7 @@ from esphome.components.bk72xx_ble_tracker import (
|
||||
)
|
||||
from esphome.components.ble_device_base import to_ble_units
|
||||
from esphome.components.esp32_ble_tracker import SCAN_PARAMETERS_SCHEMA as ESP32_SCHEMA
|
||||
from esphome.components.rp2_ble_tracker import SCAN_PARAMETERS_SCHEMA as RP2_SCHEMA
|
||||
|
||||
|
||||
def _validate(**kwargs: str) -> dict:
|
||||
@@ -59,6 +60,15 @@ def test_esp32_defaults_are_valid() -> None:
|
||||
assert config["active"] is True
|
||||
|
||||
|
||||
def test_rp2_defaults_are_valid() -> None:
|
||||
"""rp2 pins 100 ms interval / 30 ms window — a 30 % duty cycle leaving the
|
||||
shared CYW43 radio mostly free for WiFi."""
|
||||
config = RP2_SCHEMA({})
|
||||
assert to_ble_units(config["interval"]) == 160
|
||||
assert to_ble_units(config["window"]) == 48
|
||||
assert "active" not in config
|
||||
|
||||
|
||||
def test_esp32_active_can_disable() -> None:
|
||||
config = ESP32_SCHEMA({"active": False})
|
||||
assert config["active"] is False
|
||||
@@ -102,6 +112,11 @@ def test_window_equal_to_interval_accepted() -> None:
|
||||
assert to_ble_units(config["interval"]) == to_ble_units(config["window"])
|
||||
|
||||
|
||||
def test_duration_equal_to_three_intervals_accepted() -> None:
|
||||
"""The three-interval floor is inclusive, mirroring the ceilings above."""
|
||||
_validate(duration="3s", interval="1s", window="500ms")
|
||||
|
||||
|
||||
# --- rejected configurations ---
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
rp2_ble_tracker:
|
||||
id: ble_tracker
|
||||
scan_parameters:
|
||||
# Boundary coverage: the documented 2.5 ms floor on window (expressible only
|
||||
# via the microsecond-accurate validation), a non-round interval exercising the
|
||||
# 0.625 ms unit conversion without collapsing onto the window's unit count,
|
||||
# and the non-continuous config path.
|
||||
interval: 5000us
|
||||
window: 2500us
|
||||
duration: 5min
|
||||
continuous: false
|
||||
@@ -0,0 +1,16 @@
|
||||
rp2_ble_tracker:
|
||||
id: ble_tracker
|
||||
scan_parameters:
|
||||
interval: 100ms
|
||||
window: 30ms
|
||||
duration: 5min
|
||||
continuous: true
|
||||
|
||||
# Pulls in USE_OTA_STATE_LISTENER so the OTA scan-pause path compiles in CI
|
||||
# (same coverage arrangement as the esp32_ble_tracker tests).
|
||||
wifi:
|
||||
ssid: MySSID
|
||||
password: password1
|
||||
|
||||
ota:
|
||||
- platform: esphome
|
||||
@@ -0,0 +1,2 @@
|
||||
packages:
|
||||
rp2_ble_tracker: !include common.yaml
|
||||
@@ -0,0 +1,2 @@
|
||||
packages:
|
||||
rp2_ble_tracker: !include common-boundary.yaml
|
||||
Reference in New Issue
Block a user