Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds possibility to change print for a callback function on messages in class Scanner #41

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sanyi
Copy link

@sanyi sanyi commented Sep 28, 2023

Added output_callback init argument to class Scanner. So one can divert the data received to an external function rather than print

Ussage:

from queue import Queue
from victron_ble.scanner import Scanner

loop = asyncio.get_event_loop()
messages = Queue()

device_keys = (("DE:38:XX:XX:XX:XX", "somesecret"),)

async def scan(keys):
    scanner = Scanner(keys, output_callback=messages.put)
    await scanner.start()

asyncio.ensure_future(scan({k: v for k, v in device_keys}))
loop.run_forever()

Added output_callback init argument to Scanner.  So one can divert the data received to an external function rather than print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant