From 1f11ee26eb7b4c652323955e09e1e7fa1057bd0e Mon Sep 17 00:00:00 2001 From: jeanGaston Date: Tue, 6 Feb 2024 09:44:38 +0100 Subject: [PATCH] Change to bleak instead of bluepy --- DataScraper/DOCKERFILE | 5 ++--- DataScraper/main.py | 21 +++++++-------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/DataScraper/DOCKERFILE b/DataScraper/DOCKERFILE index 354ca19..446f4a1 100644 --- a/DataScraper/DOCKERFILE +++ b/DataScraper/DOCKERFILE @@ -1,5 +1,5 @@ # Use the official Python image as a base image -FROM python:3.11-bullseye +FROM python:3.11-pt bullseye # Set the working directory in the container WORKDIR /app @@ -9,12 +9,11 @@ COPY ./main.py /app/ # Install any dependencies RUN apt-get update && apt-get install -y \ - bluez \ dbus \ bluetooth -RUN pip3 install --no-cache-dir pybluez +RUN pip3 install --no-cache-dir bleak # Set the entry point COPY entrypoint.sh . diff --git a/DataScraper/main.py b/DataScraper/main.py index 262dc8c..0d0137b 100644 --- a/DataScraper/main.py +++ b/DataScraper/main.py @@ -1,16 +1,9 @@ -from bluepy.btle import Scanner +import asyncio +from bleak import BleakScanner +async def main(): + devices = await BleakScanner.discover() + for d in devices: + print(d) -scanner = Scanner() -print("Begin device scan") -while True: - devices = scanner.scan(timeout=3.0) - - for device in devices: - print( - f"Device found {device.addr} ({device.addrType}), " - f"RSSI={device.rssi} dB" - ) - for adtype, description, value in device.getScanData(): - print(f" ({adtype}) {description} = {value}") - +asyncio.run(main()) \ No newline at end of file