Getting list of available bluetooth devices in ios

对着背影说爱祢 提交于 2019-12-24 04:12:13

问题


Is there a way to get list of mac addresses of available bluetooth devices in ios? I'm working on a programm which finds people nearby using bluetooth mac addresses.


回答1:


I'm sure you have:

[centralManager scanForPeripheralsWithServices:nil
                                       options:nil];

That means your app is searching for BLE peripherals.

Every time your app discovers a peripheral invokes:

- (void)centralManager:(CBCentralManager *)central
didDiscoverPeripheral:(CBPeripheral *)peripheral
 advertisementData:(NSDictionary *)advertisementData
              RSSI:(NSNumber *)RSSI 

You can add each discovered peripheral to an NSArray of CBPeripheral




回答2:


It is generally not possible, as iOS does not expose the Bluetooth address to the app.

If you are using non-iOS Bluetooth peripherals, you can manually include the BD_ADDR into the Manufacturer Info field of the advertising data. iOS exposes this manufacturer info, and you can get the BD_ADDR from there.

For many use cases, the UUID that iOS generates for each device is sufficient. If you could provide more details (possibly in a follow-up question), there may be a good chance that a solution can be found that does not need this workaround.



来源:https://stackoverflow.com/questions/22668689/getting-list-of-available-bluetooth-devices-in-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!