![]() |
|||
| HSG |
|
Nach
sudo apt-get install python-dev sudo apt-get install libbluetooth-dev
gelingt die Installation mit
mk@x2:~/Downloads/PyBluez-0.18$ sudo python setup.py install
Python2.7
>>> import bluetooth
>>> nd = bluetooth.discover_devices()
>>> print(nd)
['00:16:53:11:25:41']
>>> nd = bluetooth.discover_devices(lookup_names=True)
>>> nd
[('00:16:53:11:25:41', 'NXT')]
>>> s = bluetooth.find_service(address='00:16:53:11:25:41')
>>> s
[]
>>> bd_addr = '00:16:53:11:25:41'
>>> bd_addr
'00:16:53:11:25:41'
>>> port=1
>>> s=bluetooth.BluetoothSocket(bluetooth.RFCOMM)
>>> s.connect((bd_addr,port))
>>> s.send('hallo')
5
>>> s.close()
>>>
Offensichtlich läuft auf einem Mindstorms-NXT ein RFCOMM-Server. Man kann auf dem Display des NXT sehen wie aus < <> wird und beim Schließen wieder < .