diff --git a/src/pymc_core/hardware/signal_utils.py b/src/pymc_core/hardware/signal_utils.py index 65b57c0..d317001 100644 --- a/src/pymc_core/hardware/signal_utils.py +++ b/src/pymc_core/hardware/signal_utils.py @@ -2,8 +2,10 @@ from __future__ import annotations +from typing import Optional -def snr_register_to_db(raw_value: int | None, *, bits: int = 8) -> float: + +def snr_register_to_db(raw_value: Optional[int], *, bits: int = 8) -> float: """Convert signed SX126x/SX127x SNR register (value * 4) into dB. Args: diff --git a/src/pymc_core/hardware/sx1262_wrapper.py b/src/pymc_core/hardware/sx1262_wrapper.py index c8d54e5..46f89b4 100644 --- a/src/pymc_core/hardware/sx1262_wrapper.py +++ b/src/pymc_core/hardware/sx1262_wrapper.py @@ -8,7 +8,7 @@ import math import random import time -from typing import Optional +from typing import Optional, Union from .base import LoRaRadio from .gpio_manager import GPIOPinManager @@ -1275,11 +1275,11 @@ def _get_thresholds_for_current_settings(self) -> tuple[int, int]: async def perform_cad( self, - det_peak: int | None = None, - det_min: int | None = None, + det_peak: Optional[int] = None, + det_min: Optional[int] = None, timeout: float = 1.0, calibration: bool = False, - ) -> bool | dict: + ) -> Union[bool, dict]: """ Perform Channel Activity Detection (CAD). If calibration=True, uses provided thresholds and returns info. diff --git a/src/pymc_core/protocol/packet.py b/src/pymc_core/protocol/packet.py index f77fd9b..b405256 100644 --- a/src/pymc_core/protocol/packet.py +++ b/src/pymc_core/protocol/packet.py @@ -1,4 +1,4 @@ -from typing import ByteString +from typing import ByteString, Optional from .constants import ( MAX_PATH_SIZE, @@ -366,12 +366,12 @@ def calculate_packet_hash(self) -> bytes: self.get_payload_type(), self.path_len, self.payload ) - def get_packet_hash_hex(self, length: int | None = None) -> str: + def get_packet_hash_hex(self, length: Optional[int] = None) -> str: """ Return upper-case hex string representation of this packet's hash. Args: - length (int | None, optional): Maximum length of the returned hex string. + length (Optional[int], optional): Maximum length of the returned hex string. Defaults to None (full hash string). Returns: diff --git a/src/pymc_core/protocol/packet_utils.py b/src/pymc_core/protocol/packet_utils.py index f74b1a9..7164192 100644 --- a/src/pymc_core/protocol/packet_utils.py +++ b/src/pymc_core/protocol/packet_utils.py @@ -5,7 +5,7 @@ import hashlib import struct -from typing import Any, List, Union +from typing import Any, List, Optional, Union from .constants import ( MAX_HASH_SIZE, @@ -223,7 +223,7 @@ def calculate_packet_hash_string( payload_type: int, path_len: int, payload: bytes, - length: int | None = None, + length: Optional[int] = None, ) -> str: """ Return upper-case hex string representation of the packet hash.