从设备获取CBUUID

问题描述:

如何从我的应用当前正在运行的设备获取CBUUID?我使用Xamarin,但在Objective-C或Swift中回答也会很好。从设备获取CBUUID

使用Plugin.BLE(https://www.nuget.org/packages/Plugin.BLE/

foreach(AdvertisementRecord record in e.Device.AdvertisementRecords) 
{ 
    if (record.Type == AdvertisementRecordType.UuidsComplete128Bit || record.Type == AdvertisementRecordType.UuidsComplete16Bit) 
    { 
     b.ServiceUUID = record.Data; 
     break; 
    } 
} 

然后

foreach(Beacon beacon in beaconList) 
{ 
    cbuuidList.Add(CBUUID.FromBytes(beacon.ServiceUUID)); 
}            

CBUUID[] uuid = cbuuidList.ToArray(); 
BLEManager.ScanForPeripherals(uuid); 

这里详细:https://forums.xamarin.com/discussion/92838/proper-way-to-retrieve-uuid-of-device