Skip to content

Instantly share code, notes, and snippets.

@Abathargh
Created August 21, 2021 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Abathargh/9b217bd1550af30a463219ae93068a43 to your computer and use it in GitHub Desktop.
Save Abathargh/9b217bd1550af30a463219ae93068a43 to your computer and use it in GitHub Desktop.
Esempio di utilizzo della classe di gestione di Stream in ingresso BtSlaveInputStream
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