啟用 Raspberry Pi 3 B+ 透過 IoS 裝置發送和接收資料的過程是什麼?
我開發了一個應用程序,使樹莓派藍牙能夠接收網路配置並配置自身(使用 Bluez、Pybluez 和 bluetoothctl)。對於 Android 設備來說,這非常有效。但對於蘋果設備(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()