mirror of
https://github.com/markqvist/Sideband.git
synced 2025-11-30 04:06:39 -05:00
27 lines
557 B
Python
27 lines
557 B
Python
"""Service to run BLE scan for 60 seconds,
|
|
and log each `on_device` event.
|
|
"""
|
|
import time
|
|
|
|
from able import BluetoothDispatcher
|
|
from kivy.logger import Logger
|
|
|
|
|
|
class BLE(BluetoothDispatcher):
|
|
def on_device(self, device, rssi, advertisement):
|
|
title = device.getName() or device.getAddress()
|
|
Logger.info("BLE Device found: %s", title)
|
|
|
|
def on_error(self, msg):
|
|
Logger.error("BLE Error %s", msg)
|
|
|
|
|
|
def main():
|
|
ble = BLE()
|
|
ble.start_scan()
|
|
time.sleep(60)
|
|
ble.stop_scan()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|