gpt4 book ai didi

python - 让我的 python 的蓝牙服务器对 iOS 可见

转载 作者:技术小花猫 更新时间:2023-10-29 10:53:02 26 4
gpt4 key购买 nike

我一直在努力将运行在 Linux 服务上的 Python 脚本中的蓝牙服务器(使用 Bluez 或类似软件)与运行 Cordova 混合应用程序的 iPhone 设备连接起来。

我为后者使用 cordova-plugin-ble-central,对于前者,我给你下面的代码:

try:
server_sock = BluetoothSocket(RFCOMM)

server_sock.bind(("", 0))
server_sock.listen(1)
port = server_sock.getsockname()[1]

uuid = "d507688e-5fa7-11e7-907b-a6006ad3dba0"
advertise_service(server_sock, "TestService", service_id=uuid, service_classes=[uuid])

print("Waiting for connection on RFCOMM channel %d" % port)

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()
except Exception as e:
print 'ERROR: ' + str(e)

问题是 iPhone 的“scan()”函数结果为我提供了附近的多个设备,但不是我的...在 Android 中它当然工作得很好!

我错过了什么?有没有办法让它被发现?

提前致谢

最佳答案

你不能。

iOS 过滤蓝牙配置文件,不支持 RFCOMM(又名蓝牙串行端口配置文件)。这是 iOS Supported Bluetooth profiles 的列表来自 Apple 本身。

是的,很遗憾,我们知道它在桌面和 Android 上运行完美,但你不能在 iOS 上做同样的事情:)

关于python - 让我的 python 的蓝牙服务器对 iOS 可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44881169/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com