Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Bluetooth socket accept()方法不支持';不接受连接_Python_Sockets_Bluetooth_Raspberry Pi3 - Fatal编程技术网

Python Bluetooth socket accept()方法不支持';不接受连接

Python Bluetooth socket accept()方法不支持';不接受连接,python,sockets,bluetooth,raspberry-pi3,Python,Sockets,Bluetooth,Raspberry Pi3,我目前正在尝试将我的手机与我的Raspberry Pi 3连接,以便将数据从RPI3发送到手机 在《覆盆子》中,我写了以下脚本: 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") o

我目前正在尝试将我的手机与我的Raspberry Pi 3连接,以便将数据从RPI3发送到手机

在《覆盆子》中,我写了以下脚本:

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()
当我尝试从手机连接到Raspberry时,我什么也没有得到,程序在.accept()处被阻止,等待传入连接,即使我已连接

这是我的控制台打印

Socket handler ...
Bind ...
Listen ...
Waiting for a connection...
我试图在
/etc/bluetooth/main.conf
中添加
DisablePlugins=pnat
,但什么也没发生

有什么想法吗