我测试中的无聊代码:
import gobject
import dbus.mainloop.glib
import os
import sys
import time
import bluetooth as bt
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
os.system("hciconfig hci0 up")
os.system("hciconfig hci0 piscan")
os.system("hciconfig hci0 iscan")
print "Socket handler ..."
sock_control = bt.BluetoothSocket(bt.L2CAP)
sock_interrupt = bt.BluetoothSocket(bt.L2CAP)
print "Bind ..."
sock_control.bind(("",17))
sock_interrupt.bind(("",19))
print "Listen ..."
sock_control.listen(1) # Limit of 1 connection
sock_interrupt.listen(1)
print "Waiting for a connection..."
conn_control, conn_info = self.sock_control.accept()
print "Got a connection on the control channel from ", self.conn_info[0]
conn_interrupt, conn_info = self.sock_interrupt.accept()
print "Got a connection on the interrupt channel from " + self.conn_info[0]
while True:
data = 0x00001e0000000000
conn_interrupt.send(str(data))
time.sleep(1)
data = 0x0000000000000000
conn_interrupt.send(str(data))
mainloop = gobject.MainLoop()
mainloop.run()
给我这个错误:
捕获" NSInternalInconsistencyException","没有通过测试配置指定目标应用程序路径: