예제 #1
0
        public AdvertisementMonitorPageViewModel()
        {
            Context = GattSampleContext.Context;
            Context.PropertyChanged += Context_PropertyChanged;

            foreach (var value in Enum.GetValues(typeof(AdvertisementSectionType)))
            {
                KnownDataSectionFilters.Add(new ObservableBluetoothLEAdvertisementFilter((byte)value));
            }
        }
예제 #2
0
        //private string name;
        //private ObservableBLEDevice foundDevice = null;

        public DiscoverDriver()
        {
            //context = GattSampleContext.context;          //***NOTE: Only use this to get <context> after it is initialised once
            context = new GattSampleContext();

            StartEnumeration();

            Console.WriteLine("Thread slept");
            Thread.Sleep(35000);
            Console.WriteLine("Thread awoke");

            ConnectToDeviceByName("ESP32 UART Test");
        }
예제 #3
0
        /// <summary>
        /// 设备枚举通知,判断可连接设备。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private async void Context_DeviceEnumEvent(GattSampleContext sender, BLTEEnumEventArgs args)
        {
            if (args.Device.Name.Contains(FilterName))
            {
                if (args.Notify == BLTEEnumEvent.Add)
                {
                    if (SelectedDevice == null)
                    {
                        SelectedDevice = args.Device;
                        Context.StopEnumeration();
                        await SelectedDevice.Connect();

                        GetCharacteristics();
                        OnCodeyConnected();
                    }
                }
                else
                {
                    SelectedDevice = null;
                }
            }
        }
예제 #4
0
 public void Show()
 {
     gattContext = GattSampleContext.Context;
     this.Scan();
     gattContext.BluetoothLEDevices.CollectionChanged += BluetoothLEDevices_CollectionChanged;
 }
 public AdvertisementBeaconPageViewModel()
 {
     Context = GattSampleContext.Context;
     Context.PropertyChanged += Context_PropertyChanged;
 }