public static BeaconData FromBuffer(IBuffer buffer) { var bytes = new byte[buffer.Length]; using (var reader = DataReader.FromBuffer(buffer)) { reader.ReadBytes(bytes); } return(BeaconData.FromBytes(bytes)); }
public static void Watcher_Received(BluetoothLEAdvertisementWatcher sender, BluetoothLEAdvertisementReceivedEventArgs args) { const ushort AppleCompanyId = 0x004C; foreach (var adv in args.Advertisement.ManufacturerData.Where(x => x.CompanyId == AppleCompanyId)) { var beaconData = BeaconData.FromBuffer(adv.Data); MessageBox.Show(String.Format( "[{0}] {1}:{2}:{3} TxPower={4}, Rssi={5}", args.Timestamp, beaconData.Uuid, beaconData.Major, beaconData.Minor, beaconData.TxPower, args.RawSignalStrengthInDBm)); } }