-1

我正在尝试通过蓝牙查找其他 iphone,其中 iphone 应用程序是用 Objective-C 编写的。我受到这个插件的启发:github.com/don/cordova-plugin-ble-central

通过更改与扫描相关的部分:https ://github.com/don/cordova-plugin-ble-central/blob/master/src/ios/BLECentralPlugin.m#L235

根据文档:https ://developer.apple.com/library/prerelease/ios/documentation/CoreBluetooth/Reference/CBCentralManager_Class/index.html#//apple_ref/occ/instm/CBCentralManager/scanForPeripheralsWithServices:options :

您不能设置任何参数来检索附近所有打开蓝牙的设备,但这不起作用。

有谁知道如何解决?

4

1 回答 1

0

蓝牙 LE 扫描不会找到另一部手机,除非该手机正在宣传蓝牙 LE 服务。

您可以在一部手机上使用LightBlue来创建提供服务的外围设备。使用右上角的“+”按钮并创建一个虚拟外围设备。

使用另一部手机,使用Cordova BLE 插件运行应用程序并扫描设备。

ble.scan([], 5, onDiscoverDevice, failure);

每次发现外围设备时都会调用 onDiscoverDevice。

var onDiscoverDevice = function(peripheral) {
    console.log(JSON.stringify(peripheral, null, 2));
}
于 2016-02-17T05:42:31.797 回答