在iOS应用中自动连接到BLE设备 [英] Auto connect to BLE device in iOS app
问题描述
我正在编写一个iOS应用程序,该应用程序将使用低功耗蓝牙(BLE)与设备通信.
I am writing an iOS application which will communicate to a device using Bluetooth Low Energy (BLE).
当我连接的设备超出范围时,我的应用程序将收到断开连接事件.
When my connected device is out of range, my application is getting disconnect event.
但是当设备返回范围时,我没有收到任何连接事件.
But I am not getting any connect event when the device comes back to the range.
请建议使用任何方法来检测设备何时返回范围.
Please suggest any approach to detect when the device comes back to the range.
推荐答案
当您的设备断开连接或进入蓝牙范围之外时,您无需扫描外围设备,因为它已经扫描了BLE设备.
When your device get disconnected or goto out of range of Bluetooth then you don't need to scan for Peripheral devices because it already scanned for the BLE devices.
当BLE设备断开连接时,将函数[centralObj connectPeripheral:peripheral options:nil];
调用到didDisconnectPeripheral
委托方法中.
Call function [centralObj connectPeripheral:peripheral options:nil];
into didDisconnectPeripheral
delegate method when BLE device disconnected.
这篇关于在iOS应用中自动连接到BLE设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!