Skip to content

Commit

Permalink
Use firmware default BLE scan parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
thecode committed Oct 5, 2024
1 parent e85be0b commit 66faac0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 24 deletions.
16 changes: 2 additions & 14 deletions aioshelly/ble/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@
BLE_CODE,
BLE_SCRIPT_NAME,
VAR_ACTIVE,
VAR_DURATION_MS,
VAR_EVENT_TYPE,
VAR_INTERVAL_MS,
VAR_VERSION,
VAR_WINDOW_MS,
)

LOGGER = logging.getLogger(__name__)
Expand All @@ -36,14 +33,8 @@ async def async_stop_scanner(device: RpcDevice) -> None:
await device.script_stop(script_id)


async def async_start_scanner( # noqa: PLR0913
device: RpcDevice,
active: bool,
event_type: str,
data_version: int,
interval_ms: int,
window_ms: int,
duration_ms: int,
async def async_start_scanner(

Check warning on line 36 in aioshelly/ble/__init__.py

View check run for this annotation

Codecov / codecov/patch

aioshelly/ble/__init__.py#L36

Added line #L36 was not covered by tests
device: RpcDevice, active: bool, event_type: str, data_version: int
) -> None:
"""Start scanner."""
script_name_to_id = await _async_get_scripts_by_name(device)
Expand All @@ -59,9 +50,6 @@ async def async_start_scanner( # noqa: PLR0913
BLE_CODE.replace(VAR_ACTIVE, "true" if active else "false")
.replace(VAR_EVENT_TYPE, event_type)
.replace(VAR_VERSION, str(data_version))
.replace(VAR_INTERVAL_MS, str(interval_ms))
.replace(VAR_WINDOW_MS, str(window_ms))
.replace(VAR_DURATION_MS, str(duration_ms))
)

needs_putcode = False
Expand Down
11 changes: 1 addition & 10 deletions aioshelly/ble/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@
VAR_EVENT_TYPE = "%event_type%"
VAR_ACTIVE = "%active%"
VAR_VERSION = "%version%"
VAR_INTERVAL_MS = "%interval_ms%"
VAR_WINDOW_MS = "%window_ms%"
VAR_DURATION_MS = "%duration_ms%"

DEFAULT_INTERVAL_MS = 320
DEFAULT_WINDOW_MS = 30
DEFAULT_DURATION_MS = -1

BLE_CODE = """
// aioshelly BLE script 2.0
Expand Down Expand Up @@ -76,10 +69,8 @@
// Skip starting if scanner is active
if (!BLE.Scanner.isRunning()) {
BLE.Scanner.Start({
duration_ms: %duration_ms%,
duration_ms: -1,
active: %active%,
interval_ms: %interval_ms%,
window_ms: %window_ms%,
});
}
Expand Down

0 comments on commit 66faac0

Please sign in to comment.