This is a rather intricate question. I am having trouble writing some code that will capture incoming bluetooth packets from a certain device. I am on mac and using lightblue, if anyone could help me out or point me in the right direction I would be very happy.
Here is the code I am using:
import bluetooth
hostMACAddress = '00:1f:e1:dd:08:3d' #example address, not the real one
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()
With the code above I am trying to capture the incoming packets that are sent from the external device. I get an error, and I believe I am not doing it right. I get this error when running:
import bluetooth
File "/Library/Python/2.6/site-packages/bluetooth/__init__.py", line 36, in <module>
from osx import *
File "/Library/Python/2.6/site-packages/bluetooth/osx.py", line 3, in <module>
raise NotImplementedError
NotImplementedError
I have never done anything with communications and I am very confused.
Thank you for reading