如何通过蓝牙将iPhone连接到本地Python客户端?

时间:2021-09-23 03:01:25

I'm running a basic Python client over Bluetooth:

我正在通过蓝牙运行基本的Python客户端:

import bluetooth

bd_addr = "78:A3:E4:07:14:27"

port = 1

sock=bluetooth.BluetoothSocket( bluetooth.RFCOMM )
sock.connect((bd_addr, port))

sock.send("hello!!")
sock.close()

I'd like to connect to the client using CoreBluetooth and my iPhone as the server pushing data, but I'm unsure how. The end goal is to transfer text from the iphone to the Python server, and have it print the data.

我想使用CoreBluetooth和我的iPhone作为服务器推送数据连接到客户端,但我不确定如何。最终目标是将文本从iphone传输到Python服务器,并让它打印数据。

EDIT**** the documentation doesn't offer much help on using non-objective c devices. for example, I'm not sure if I need to advertise, because that seems like an iOS thing, whereas python only deals with the sockets. how would i interface between the two?

编辑****文档对使用非客观c设备没有太大帮助。例如,我不确定我是否需要做广告,因为这似乎是iOS的事情,而python只处理套接字。我将如何在两者之间进行接口?

1 个解决方案

#1


0  

You won't be able to initiate a Bluetooth connection with an iOS app using that code. That code is using a Bluetooth 2.1 profile which is only supported with MFi devices on iOS. Core Bluetooth can be used on iOS to communicate with Bluetooth low energy devices using the GATT profile.

您将无法使用该代码启动与iOS应用程序的蓝牙连接。该代码使用的是蓝牙2.1配置文件,仅支持iOS上的MFi设备。核心蓝牙可以在iOS上用于使用GATT配置文件与蓝牙低功耗设备进行通信。

#1


0  

You won't be able to initiate a Bluetooth connection with an iOS app using that code. That code is using a Bluetooth 2.1 profile which is only supported with MFi devices on iOS. Core Bluetooth can be used on iOS to communicate with Bluetooth low energy devices using the GATT profile.

您将无法使用该代码启动与iOS应用程序的蓝牙连接。该代码使用的是蓝牙2.1配置文件,仅支持iOS上的MFi设备。核心蓝牙可以在iOS上用于使用GATT配置文件与蓝牙低功耗设备进行通信。