Skip to content

Commit

Permalink
v0.2.13
Browse files Browse the repository at this point in the history
  • Loading branch information
dudanov committed Jun 6, 2024
1 parent aac2023 commit ca1f70d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
3 changes: 3 additions & 0 deletions pyftms/client/backends/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ class SetupEventData(TypedDict, total=False):


class UpdateEventData(TypedDict, total=False):
rssi: int
"""RSSI."""

cadence_average: float
"""
Average Cadence.
Expand Down
19 changes: 11 additions & 8 deletions pyftms/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
StopPauseCode,
)
from . import const as c
from .backends import DataUpdater, FtmsCallback, MachineController
from .backends import DataUpdater, FtmsCallback, MachineController, UpdateEvent
from .manager import PropertiesManager
from .properties import (
DeviceInfo,
Expand Down Expand Up @@ -63,7 +63,6 @@ class FitnessMachine(ABC, PropertiesManager):
_data_updater: DataUpdater

_ble_device: BLEDevice
_advertisement_data: AdvertisementData | None
_need_connect: bool

# Static device info
Expand All @@ -84,10 +83,10 @@ def __init__(
super().__init__(on_ftms_event)

self._need_connect = False
self._advertisement_data = adv_data
self._ble_device = ble_device
self._timeout = timeout

self.set_ble_device_and_advertisement_data(ble_device, adv_data)

# Updaters
self._data_updater = DataUpdater(self._data_model, self._on_event)
self._controller = MachineController(self._on_event)
Expand All @@ -108,15 +107,19 @@ async def __aexit__(self, exc_type, exc, tb):
# BLE SPECIFIC PROPERTIES

def set_ble_device_and_advertisement_data(
self, ble_device: BLEDevice, adv_data: AdvertisementData
self, ble_device: BLEDevice, adv_data: AdvertisementData | None
):
self._advertisement_data = adv_data
self._ble_device = ble_device

if adv_data:
self._properties["rssi"] = adv_data.rssi

if self._cb:
self._cb(UpdateEvent("update", {"rssi": adv_data.rssi}))

@property
def rssi(self) -> int | None:
if self._advertisement_data:
return self._advertisement_data.rssi
return self.get_property("rssi")

@property
def name(self) -> str:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pyftms"
version = "0.2.12"
version = "0.2.13"
description = "PyFTMS - Python Fitness Machine Service client library."
authors = ["Sergey V. DUDANOV <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit ca1f70d

Please sign in to comment.