简体   繁体   English

使用MAC ios连接到BLE设备

[英]Connect to a BLE device using MAC ios

I'm working on an application for iOS (Objective-C). 我正在为iOS(Objective-C)开发应用程序。

I'm looking for a way to connect to a BLE device so that you can specify the MAC or UUID of this device. 我正在寻找一种连接到BLE设备的方法,以便您可以指定此设备的MAC或UUID。

Currently I have two BLE devices with the same name so the app is not able to differentiate between the two , which gives many problems (these devices do not have the same functions). 目前,我有两个名称相同的BLE设备,因此该应用程序无法区分这两个设备,这会带来很多问题(这些设备不具有相同的功能)。

Is there any way to specify the MAC or UUID when connected to BLE device? 连接到BLE设备时,有什么方法可以指定MAC或UUID?

RSSI signal strength discover the differentiate two or more device. RSSI信号强度发现区分两个或多个设备。 If once time UUID get from peripheral then also differentiate peripheral. 如果一次UUID从外围设备获取,则还要区分外围设备。

Note: iOS doesn't give permission to read MAC address of peripheral. 注意:iOS不允许读取外围设备的MAC地址。

The MAC of the device is not available, nor is any other particularly useful identifier. 设备的MAC不可用,任何其他特别有用的标识符也不可用。 However, since "these devices do not have the same functions," they should have different services that they advertise. 但是,由于“这些设备不具有相同的功能”,因此它们应具有其宣传的不同服务。 When calling scanForPeripherals(withServices:options:) you should be passing the specific service or services you're interested in. This is much better for performance, and also will automatically filter out devices you are not interested in. Passing nil for serviceUUIDs should only be done for a generic BLE scanner. 调用scanForPeripherals(withServices:options :)时,您应该传递您感兴趣的特定服务。这对于性能而言要好得多,并且还将自动过滤出您不感兴趣的设备。为serviceUUID传递nil仅应针对通用BLE扫描器完成

If you control the device firmware, you can add services to identify the type of device, or add information in the manufacturer's advertising data to distinguish the devices during scanning. 如果控制设备固件,则可以添加服务以标识设备的类型,或者在制造商的广告数据中添加信息以在扫描过程中区分设备。

If these devices advertise the same services and are otherwise identical, then you will need to connect to both and query them to determine which device you wanted. 如果这些设备宣告相同的服务,但在其他方面相同,则您需要连接到两者并查询它们以确定所需的设备。 You still will not receive a MAC, however, unless the device provides it via some characteristic. 但是,除非设备通过某种特性提供它,否则您仍然不会收到MAC。

Typically, a given device will continue to have the same CBPeripheral UUID, and this can be used to reconnect to previously known devices. 通常,给定设备将继续具有相同的CBP外围设备UUID,并且可用于重新连接到先前已知的设备。 However, if the device never pairs securely, this UUID is not always stable, either. 但是,如果设备从不安全配对,则该UUID也不总是稳定的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM