启用 Raspberry Pi 3 B+ 与 IoS 设备发送和接收数据的程序是什么?
我开发了一个应用程序,使树莓派蓝牙能够接收网络配置并自行配置(使用 Bluez、Pybluez 和 bluetoothctl)。对于 Android 设备,这非常有效。但对于 Apple 设备 (IoS),树莓派蓝牙甚至无法被检测到。有人可以帮我完成使 Raspberry Pi 3 B + 与 IoS 通信的步骤吗?
通过以下 shell 脚本启动蓝牙:
bt-adapter --set Powered 1
bt-adapter --set DiscoverableTimeout 0
bt-adapter --set Discoverable 1
bt-adapter --set PairableTimeout 0
bt-adapter --set Pairable 1
负责处理蓝牙连接和信息接收的ptyhon脚本如下所示:
if __name__ == "__main__":
server_sock = bluetooth.BluetoothSocket( bluetooth.RFCOMM )
server_sock.bind(('', bluetooth.PORT_ANY))
server_sock.listen(1)
port = server_sock.getsockname()[1]
bluetooth.advertise_service( server_sock, 'Rasp WiFi Configurator',
service_id = uuid, service_classes = [uuid, bluetooth.SERIAL_PORT_CLASS],
profiles = [bluetooth.SERIAL_PORT_PROFILE])
print('[INFO] Aguardando conexao bluetooth')
client_sock, client_info = server_sock.accept()
print('[INFO] Conexao aceita de {}'.format(client_info))
client_sock.send(json.dumps(net_info))
bl_man = threading.Thread(target = bluetooth_manager, args = (server_sock, client_sock,))
bl_man.start()