Skip to content

Commit

Permalink
docs: update examples (#256)
Browse files Browse the repository at this point in the history
Changes:
* Remove adapter setting for asynchronous examples
* Set BlueZ adapter for synchronous examples
  • Loading branch information
terop authored Nov 8, 2024
1 parent db55ff1 commit cc8e811
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 12 deletions.
4 changes: 4 additions & 0 deletions examples/find_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Find RuuviTags
"""

import os

os.environ["RUUVI_BLE_ADAPTER"] = "bluez"

import ruuvitag_sensor.log
from ruuvitag_sensor.ruuvi import RuuviTagSensor

Expand Down
3 changes: 0 additions & 3 deletions examples/find_tags_async_bleak.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
"""

import asyncio
import os

os.environ["RUUVI_BLE_ADAPTER"] = "bleak"

import ruuvitag_sensor.log
from ruuvitag_sensor.ruuvi import RuuviTagSensor
Expand Down
3 changes: 0 additions & 3 deletions examples/get_async_bleak.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import asyncio
import os

os.environ["RUUVI_BLE_ADAPTER"] = "bleak"

import ruuvitag_sensor.log
from ruuvitag_sensor.ruuvi import RuuviTagSensor
Expand Down
4 changes: 4 additions & 0 deletions examples/get_ble_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Get all BLE device broadcasts
"""

import os

os.environ["RUUVI_BLE_ADAPTER"] = "bluez"

import ruuvitag_sensor.log
from ruuvitag_sensor.adapters.nix_hci import BleCommunicationNix

Expand Down
3 changes: 0 additions & 3 deletions examples/get_first_async_bleak.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import asyncio
import os

os.environ["RUUVI_BLE_ADAPTER"] = "bleak"

import ruuvitag_sensor.log
from ruuvitag_sensor.decoder import Df5Decoder
Expand Down
4 changes: 4 additions & 0 deletions examples/post_to_influxdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@
Add new graph to dashboard
"""

import os

from influxdb import InfluxDBClient

os.environ["RUUVI_BLE_ADAPTER"] = "bluez"

from ruuvitag_sensor.ruuvi import RuuviTagSensor

client = InfluxDBClient(host="localhost", port=8086, database="ruuvi")
Expand Down
Empty file modified examples/post_to_mqtt.py
100755 → 100644
Empty file.
3 changes: 3 additions & 0 deletions examples/post_to_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
Requests - pip install requests
"""

import os
from urllib.parse import quote

import requests

os.environ["RUUVI_BLE_ADAPTER"] = "bluez"

from ruuvitag_sensor.ruuvi import RuuviTagSensor

macs = ["F4:A5:74:89:16:57", "CC:2C:6A:1E:59:3D", "BB:2C:6A:1E:59:3D"]
Expand Down
2 changes: 2 additions & 0 deletions examples/print_to_screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import os
from datetime import datetime

os.environ["RUUVI_BLE_ADAPTER"] = "bluez"

from ruuvitag_sensor.ruuvi import RuuviTagSensor

# Change here your own device's mac-address
Expand Down
2 changes: 2 additions & 0 deletions examples/print_to_screen_ruuvitag_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import time
from datetime import datetime

os.environ["RUUVI_BLE_ADAPTER"] = "bluez"

from ruuvitag_sensor.ruuvitag import RuuviTag

# Change here your own device's mac-address
Expand Down
3 changes: 0 additions & 3 deletions examples/rx_async.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import asyncio
import os

os.environ["RUUVI_BLE_ADAPTER"] = "bleak"

from ruuvitag_sensor.ruuvi_rx import RuuviTagReactive

Expand Down
3 changes: 3 additions & 0 deletions examples/send_updated_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@
"""

import copy
import os
from datetime import datetime, timedelta
from urllib.parse import quote

import requests

os.environ["RUUVI_BLE_ADAPTER"] = "bluez"

from ruuvitag_sensor.ruuvi import RuuviTagSensor

all_data = {}
Expand Down

0 comments on commit cc8e811

Please sign in to comment.