Last active
November 6, 2022 23:39
-
-
Save kevindoran/5428612 to your computer and use it in GitHub Desktop.
A simple Python script to receive messages from a client over Bluetooth using PyBluez (with Python 2).
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
""" | |
A simple Python script to receive messages from a client over | |
Bluetooth using PyBluez (with Python 2). | |
""" | |
import bluetooth | |
hostMACAddress = '00:1f:e1:dd:08:3d' # The MAC address of a Bluetooth adapter on the server. The server might have multiple Bluetooth adapters. | |
port = 3 | |
backlog = 1 | |
size = 1024 | |
s = bluetooth.BluetoothSocket(bluetooth.RFCOMM) | |
s.bind((hostMACAddress, port)) | |
s.listen(backlog) | |
try: | |
client, clientInfo = s.accept() | |
while 1: | |
data = client.recv(size) | |
if data: | |
print(data) | |
client.send(data) # Echo back to client | |
except: | |
print("Closing socket") | |
client.close() | |
s.close() |
You need to make an array of bytes and send it by 1kb then merge it on the receiver
@detend3nKer you should post in on StackOverflow
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have the problem when I send a file with the size 12kb only 1kb is being received even when i set the buffer limit much above