-
-
Save garsaud/0da0cf3f1602e2b0377f9a30b26bdfef to your computer and use it in GitHub Desktop.
Send and receive text data through bluetooth. Alternative to obsolete rfcomm.
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
import socket | |
sock = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM) | |
sock.bind(('XX:XX:XX:XX:XX:XX', 1)) # find local address using `sudo bluetoothctl list` | |
sock.connect(('YY:YY:YY:YY:YY:YY', 1)) # target device after having paired it | |
sock.send(b'coucou\n') | |
sock.recv(100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment