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>";
            }
        }
示例#2
0
        public void Int16Test2()
        {
            byte[] input    = { 0, 42, 0, 42, 0, 42, 0 };
            byte[] expected = { 0, 42 };

            Assert.AreEqual(BitConverter.ToInt16(expected, 0), GattConvert.ToInt16(GattConvert.ToIBuffer(input)));
        }
示例#3
0
        public void Int16Test()
        {
            Int16 data  = 42;
            Int64 wrong = Int64.MaxValue;

            Assert.AreEqual(data, GattConvert.ToInt32(GattConvert.ToIBuffer(data)));
            Assert.AreNotEqual(data - 1, GattConvert.ToInt16(GattConvert.ToIBuffer(data)));

            Assert.AreNotEqual(wrong, GattConvert.ToInt16(GattConvert.ToIBuffer(wrong)));
        }