public ObservableBluetoothLEAdvertisementSection(BluetoothLEAdvertisementDataSection section) { TypeAsString = section.DataType.ToString("X2"); TypeAsDisplayString = AdvertisementDataTypeHelper.ConvertSectionTypeToString(section.DataType); DataAsString = GattConvert.ToHexString(section.Data); if (section.DataType == BluetoothLEAdvertisementDataTypes.Flags) { var flagsInt = GattConvert.ToInt32(section.Data); DataAsDisplayString = ((BluetoothLEAdvertisementFlags)Enum.ToObject(typeof(BluetoothLEAdvertisementFlags), flagsInt)).ToString(); } else if (section.DataType == BluetoothLEAdvertisementDataTypes.CompleteLocalName || section.DataType == BluetoothLEAdvertisementDataTypes.ShortenedLocalName) { DataAsDisplayString = GattConvert.ToUTF8String(section.Data); } else if (section.DataType == BluetoothLEAdvertisementDataTypes.TxPowerLevel) { var txPowerLevel = GattConvert.ToInt16(section.Data); DataAsDisplayString = txPowerLevel.ToString(); } else { DataAsDisplayString = "<Unknown>"; } }
public ObservableBluetoothLEAdvertisementFilter(byte sectionType) { SectionType = sectionType; Name = AdvertisementDataTypeHelper.ConvertSectionTypeToString(sectionType); }