Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/pymc_core/hardware/signal_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions src/pymc_core/hardware/sx1262_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions src/pymc_core/protocol/packet.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import ByteString
from typing import ByteString, Optional

from .constants import (
MAX_PATH_SIZE,
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions src/pymc_core/protocol/packet_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down