Beispiel #1
0
        /// <summary>
        /// 搜索蓝牙设备列表
        /// </summary>
        private void BleCore_DeviceScan(Windows.Devices.Bluetooth.BluetoothLEDevice bleDev)
        {
            bool exist = DeviceList.TryGetValue(bleDev.Name, out Windows.Devices.Bluetooth.BluetoothLEDevice outDev);

            if (exist)
            {
                return;
            }
            bool addRs = DeviceList.TryAdd(bleDev.Name, bleDev);
        }
Beispiel #2
0
        public SmartPack(BluetoothLEDevice device)
        {
            this.device   = device;
            addressString = device.BluetoothAddress.ToString("x012");
            try
            {
                linkLossService = device.GetGattService(GattServiceUuids.LinkLoss);
            }
            catch (Exception)
            {
                // e.HResult == 0x80070490 means that the device doesn't have the requested service.
                // We can still alert on the phone upon disconnection, but cannot ask the device to alert.
                // linkLossServer will remain equal to null.
            }

            if (localSettings.Values.ContainsKey(addressString))
            {
                string[] values = ((string)localSettings.Values[addressString]).Split(',');
                alertOnPhone  = bool.Parse(values[0]);
                alertOnDevice = bool.Parse(values[1]);
                alertLevel    = (AlertLevel)Enum.Parse(typeof(AlertLevel), values[2]);
            }
        }