简体   繁体   中英

Connect to a BLE device using MAC ios

I'm working on an application for 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.

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).

Is there any way to specify the MAC or UUID when connected to BLE device?

RSSI signal strength discover the differentiate two or more device. If once time UUID get from peripheral then also differentiate peripheral.

Note: iOS doesn't give permission to read MAC address of peripheral.

The MAC of the device is not available, nor is any other particularly useful identifier. 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.

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.

Typically, a given device will continue to have the same CBPeripheral UUID, and this can be used to reconnect to previously known devices. However, if the device never pairs securely, this UUID is not always stable, either.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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