Created
August 21, 2021 18:32
-
-
Save Abathargh/9b217bd1550af30a463219ae93068a43 to your computer and use it in GitHub Desktop.
Esempio di utilizzo della classe di gestione di Stream in ingresso BtSlaveInputStream
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from shimmer_listener import BtSlaveInputStream | |
def on_connect(mac, info): | |
print(f"BT MAC {mac}: received presentation frame, {info}") | |
def on_disconnect(mac, lost): | |
if lost: | |
print(f"BT MAC {mac}: connection lost") | |
else: | |
print(f"BT MAC {mac}: disconnecting") | |
def on_message(mac, data): | |
print(f"BT MAC {mac}: got {data}") | |
try: | |
ins = BtSlaveInputStream("00:06:66:A0:3A:E9") | |
ins.on_connect = on_connect | |
ins.on_disconnect = on_disconnect | |
ins.on_message = on_message | |
ins.start() | |
except KeyboardInterrupt: | |
ins.close() | |
print("Bye") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment