2

我有一部 iPhone,我有一个低功耗蓝牙(又名蓝牙 4.o)设备。两人过去曾有过联系。但现在他们分开了。发生了一些事情,说了无法收回的话,现在他们已经断开了联系。

现在他们又在同一个房间里。BTLE 设备想要再次连接。它不想等待 iPhone 调用它。它正在采取主动。它想与 iPhone 通话,并让他们曾经共享的应用程序再次启动。

如何设置 iPhone 代码以支持此功能?

4

2 回答 2

4

(Wow, corny.)

You have to leave the app connecting to the device, so when the device becomes available the app will connect to it (so long as the app is alive). Just call [centralManager connectPeripheral] on the CMPeripheral, so the phone will keep listening for the device and connect immediately when it sees it. That doesn't time out, so you can just leave it running forever.

If no app is to connect to the peripheral, there's nothing the peripheral can do to change that.

于 2012-07-30T23:35:07.457 回答
1

这有点晚了,但这是我要做的事情:

  • 当您的设备想要连接时,让它宣传一项特殊服务。
  • 假设手机已经在扫描设备,它将看到该服务,您可以自动连接到它。
  • 现在,您可以通过更新特征等来在中心上随意触发外围触发器。

当然,这依赖于您需要触发动作时的手机扫描,但这就是野兽的本性。

于 2013-04-17T00:35:45.160 回答