Skip to content

Commit

Permalink
docs: bleak specific updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ttu committed Sep 9, 2023
1 parent f8458d1 commit 335ccd4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ __NOTE:__ These methods shouldn't be used for a long duration with a short timeo

#### Get data from a sensor

__NOTE:__ For a single sensor it is recommended to use `RuuviTagSensor.get_data` or `RuuviTagSensor.get_data_async` methods instead of `RuuviTag`- or `RuuviTagAsync`-class.
__NOTE:__ For a single sensor it is recommended to use `RuuviTagSensor.get_data` or `RuuviTagSensor.get_data_async` methods instead of `RuuviTag`- or `RuuviTagAsync`-class. `RuuviTagAsync`-class doesn't work with macOS, due to the way how macOS returns MAC address.

```python
from ruuvitag_sensor.ruuvitag import RuuviTag
Expand Down Expand Up @@ -433,7 +433,7 @@ $ python -m pip install bleak
Add environment variable RUUVI_BLE_ADAPTER with value Bleak. E.g.

```sh
$ export RUUVI_BLE_ADAPTER="Bleak"
$ export RUUVI_BLE_ADAPTER="bleak"
```
Or use `os.environ`. NOTE: this must be set before importing `ruuvitag_sensor`.

Expand Down Expand Up @@ -477,10 +477,10 @@ Bleson is not installed automatically with `ruuvitag-sensor` package. Install it
$ pip install git+https://github.com/TheCellule/python-bleson
```

Add environment variable `RUUVI_BLE_ADAPTER` with value `Bleson`. E.g.
Add environment variable `RUUVI_BLE_ADAPTER` with value `bleson`. E.g.

```sh
$ export RUUVI_BLE_ADAPTER="Bleson"
$ export RUUVI_BLE_ADAPTER="bleson"
```

__NOTE:__ On macOS, only Data Format 5 works, as macOS doesn't advertise MAC address and only DF5 has MAC in sensor payload. `RuuviTag`-class doesn't work with macOS.
Expand Down
2 changes: 2 additions & 0 deletions developer_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Upgrade pip as recommended.
Install required dependencies
```sh
$ python -m pip install -e .[dev]
# on zsh, escape square brackets
$ python -m pip install -e .\[dev\]
```

Flake8
Expand Down
5 changes: 5 additions & 0 deletions ruuvitag_sensor/adapters/bleak_ble.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ async def detection_callback(device: BLEDevice, advertisement_data: Advertisemen

@staticmethod
async def get_first_data(mac: str, bt_device: str = "") -> RawData:
"""
NOTE: get_first_data does not work on macOS.
macOS doesn't return MAC address, as it uses system specific IDs
"""
data = None
data_iter = BleCommunicationBleak.get_data([], bt_device)
async for d in data_iter:
Expand Down
5 changes: 3 additions & 2 deletions ruuvitag_sensor/ruuvi.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ def get_first_raw_data(mac: str, bt_device: str = "") -> DataFormatAndRawSensorD
async def get_first_raw_data_async(mac: str, bt_device: str = "") -> DataFormatAndRawSensorData:
"""
Get raw data for selected RuuviTag. This method is intended to be used only by
RuuviTag-class.
It doesn't have asynchronous implementation.
RuuviTagAsync-class.
NOTE: This method is not working on macOS
Args:
mac (string): MAC address
Expand Down
4 changes: 4 additions & 0 deletions ruuvitag_sensor/ruuvitag.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ def update(self) -> Union[Dict, SensorData]:


class RuuviTagAsync(RuuviTagBase):
"""
NOTE: This class is not working on macOS
"""

async def update(self) -> Union[Dict, SensorData]:
"""
Get latest data from the sensor and update own state.
Expand Down

0 comments on commit 335ccd4

Please sign in to comment.