2022-07-08 23:55:31 +00:00
|
|
|
"""Constants for the Bluetooth integration."""
|
2022-08-17 00:52:53 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
from datetime import timedelta
|
2022-08-19 01:41:07 +00:00
|
|
|
from typing import Final, TypedDict
|
2022-07-08 23:55:31 +00:00
|
|
|
|
|
|
|
DOMAIN = "bluetooth"
|
2022-07-25 14:52:35 +00:00
|
|
|
|
|
|
|
CONF_ADAPTER = "adapter"
|
2022-08-19 01:41:07 +00:00
|
|
|
CONF_DETAILS = "details"
|
2022-07-25 14:52:35 +00:00
|
|
|
|
2022-08-19 01:41:07 +00:00
|
|
|
WINDOWS_DEFAULT_BLUETOOTH_ADAPTER = "bluetooth"
|
|
|
|
MACOS_DEFAULT_BLUETOOTH_ADAPTER = "Core Bluetooth"
|
2022-07-25 14:52:35 +00:00
|
|
|
UNIX_DEFAULT_BLUETOOTH_ADAPTER = "hci0"
|
|
|
|
|
|
|
|
DEFAULT_ADAPTERS = {MACOS_DEFAULT_BLUETOOTH_ADAPTER, UNIX_DEFAULT_BLUETOOTH_ADAPTER}
|
2022-08-17 00:52:53 +00:00
|
|
|
|
2022-08-19 01:41:07 +00:00
|
|
|
DEFAULT_ADAPTER_BY_PLATFORM = {
|
|
|
|
"Windows": WINDOWS_DEFAULT_BLUETOOTH_ADAPTER,
|
|
|
|
"Darwin": MACOS_DEFAULT_BLUETOOTH_ADAPTER,
|
|
|
|
}
|
|
|
|
|
|
|
|
# Some operating systems hide the adapter address for privacy reasons (ex MacOS)
|
|
|
|
DEFAULT_ADDRESS: Final = "00:00:00:00:00:00"
|
|
|
|
|
2022-08-17 00:52:53 +00:00
|
|
|
SOURCE_LOCAL: Final = "local"
|
|
|
|
|
2022-08-17 20:51:56 +00:00
|
|
|
DATA_MANAGER: Final = "bluetooth_manager"
|
2022-08-17 00:52:53 +00:00
|
|
|
|
|
|
|
UNAVAILABLE_TRACK_SECONDS: Final = 60 * 5
|
|
|
|
START_TIMEOUT = 12
|
|
|
|
SCANNER_WATCHDOG_TIMEOUT: Final = 60 * 5
|
|
|
|
SCANNER_WATCHDOG_INTERVAL: Final = timedelta(seconds=SCANNER_WATCHDOG_TIMEOUT)
|
2022-08-19 01:41:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
class AdapterDetails(TypedDict, total=False):
|
|
|
|
"""Adapter details."""
|
|
|
|
|
|
|
|
address: str
|
|
|
|
sw_version: str
|
|
|
|
hw_version: str
|
|
|
|
|
|
|
|
|
|
|
|
ADAPTER_ADDRESS: Final = "address"
|
|
|
|
ADAPTER_SW_VERSION: Final = "sw_version"
|
|
|
|
ADAPTER_HW_VERSION: Final = "hw_version"
|