2017-08-02 83 views
0

如何從我的應用當前正在運行的設備獲取CBUUID?我使用Xamarin,但在Objective-C或Swift中回答也會很好。從設備獲取CBUUID

回答

1

使用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