<p>你试过使用<a href="https://github.com/pybluez/pybluez" rel="nofollow noreferrer">this Python library</a>吗?它列出了Raspberry Pi支持</p>
<p>此外,以下是有关侦听传入蓝牙连接的一些信息:</p>
<blockquote>
<p>Bluetooth programming in Python follows the socket programming model.
This is a concept that should be familiar to almost all network
programmers, and makes the transition from Internet programming to
Bluetooth programming much simpler. Example 3-2 and Example 3-3 show
how to establish a connection using an RFCOMM socket, transfer some
data, and disconnect.</p>
</blockquote>
<pre><code>import bluetooth
server_sock=bluetooth.BluetoothSocket( bluetooth.RFCOMM )
port = 1
server_sock.bind(("",port))
server_sock.listen(1)
client_sock,address = server_sock.accept()
print "Accepted connection from ",address
data = client_sock.recv(1024)
print "received [%s]" % data
client_sock.close()
server_sock.close()
</code></pre>
<blockquote>
<p>An RFCOMM BluetoothSocket used to accept incoming connections must be
attached to operating system resources with the bind method. bind
takes in a tuple specifying the address of the local Bluetooth adapter
to use and a port number to listen on. Usually, there is only one
local Bluetooth adapter or it doesn't matter which one to use, so the
empty string indicates that any local Bluetooth adapter is acceptable.
Once a socket is bound, a call to listen puts the socket into
listening mode and it is then ready to accept incoming connections.</p>
<p>...</p>
</blockquote>
<p><a href="https://people.csail.mit.edu/albert/bluez-intro/x232.html" rel="nofollow noreferrer">Source</a></p>