Last active
August 13, 2020 12:54
-
-
Save HiCraigChen/780bd9a8edfe02f2c26d876ad0fbeb6c to your computer and use it in GitHub Desktop.
Enable bluetooth socket (server socket) to communicate with other device (client socket) using python
This file contains hidden or 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 bluetooth | |
server_socket=bluetooth.BluetoothSocket( bluetooth.RFCOMM ) | |
port = 1 | |
server_socket.bind(("",port)) | |
server_socket.listen(1) | |
client_socket,address = server_socket.accept() | |
print("Accepted connection from ",address) | |
while True: | |
res = self.client_socket.recv(1024) | |
client_socket.send(res) | |
if res == 'q': | |
print ("Quit") | |
break | |
else: | |
print("Received:",res) | |
client_socket.close() | |
server_socket.close() |
Hello,
Have you tried to install python packages in this following link?
https://stackoverflow.com/questions/23985163/python3-error-no-module-named-bluetooth-on-linux-mint
Best,
Craig
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
i'm using RPI 3B+ and Python3.5.3 version. Unfortunetly i have error when i want make .py:
"Traceback (most recent call last):
File "testy.py", line 1, in
from bluetooth import *
ImportError: No module named 'bluetooth'"
I checked what say uncle Google but not found answer.
Any idea what i do wrong?