Beispiel #1
0
        private void OnDeviceArrived(ProximityDevice sender)
        {
            var stopwatch = (Stopwatch)null;

            if (Debug)
            {
                stopwatch = new Stopwatch();
                stopwatch.Start();
            }

            if (subscriptionIdNdef == 0)
            {
                subscriptionIdNdef = sender.SubscribeForMessage("NDEF", OnMessageReceived);
            }

            var args = new DeviceStatusChangedEventArgs()
            {
                DeviceStatus = StatusEnum.DeviceArrived
            };

            if (Debug)
            {
                stopwatch.Stop();
                args.ExecutionTime = stopwatch.Elapsed;
                args.MethodName    = "TagReader.OnDeviceArrived";
            }

            OnDeviceStatusChanged(this, args);
        }
Beispiel #2
0
        private void OnDeviceStatusChanged(object sender, DeviceStatusChangedEventArgs e)
        {
            IDigitalInkDevice device = sender as IDigitalInkDevice;

            if (device == null)
            {
                return;
            }

            TextBlock textBlock = null;

            switch (device.TransportProtocol)
            {
            case TransportProtocol.BLE:
                textBlock = tbBle;
                break;

            case TransportProtocol.USB:
                textBlock = tbUsb;
                break;

            case TransportProtocol.BTC:
                textBlock = tbBtc;
                break;
            }

            var ignore = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                textBlock.Text = AppObjects.GetStringForDeviceStatus(e.Status);
            });
        }
        private void OnDeviceStatusChanged(object sender, DeviceStatusChangedEventArgs e)
        {
            var ignore = this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
            {
                switch (e.Status)
                {
                case DeviceStatus.Idle:
                    textBlockStatus.Text         = AppObjects.GetStringForDeviceStatus(e.Status);
                    buttonFileTransfer.IsEnabled = true;
                    buttonRealTime.IsEnabled     = true;
                    break;

                case DeviceStatus.ExpectingConnectionConfirmation:
                    textBlockStatus.Text         = AppObjects.GetStringForDeviceStatus(e.Status);
                    buttonFileTransfer.IsEnabled = false;
                    buttonRealTime.IsEnabled     = false;
                    break;

                case DeviceStatus.NotAuthorizedConnectionNotConfirmed:
                    await new MessageDialog(AppObjects.GetStringForDeviceStatus(e.Status)).ShowAsync();
                    Frame.Navigate(typeof(ScanAndConnectPage));
                    break;

                default:
                    textBlockStatus.Text = AppObjects.GetStringForDeviceStatus(e.Status);
                    break;
                }
            });
        }
 private void OnDeviceStatusChanged(object sender, DeviceStatusChangedEventArgs e)
 {
     var ignore = Task.Run(() =>
     {
         tbBle.Text = AppObjects.GetStringForDeviceStatus(e.Status); // FIX: make a switch on the transport protocol to switch the message for each text boxF
     });
 }
        private void OnDeviceStatusChanged(object sender, DeviceStatusChangedEventArgs e)
        {
            var ignore = Task.Run(() =>
            {
                switch (e.Status)
                {
                case DeviceStatus.Idle:
                    textBlockStatus.Text     = "";
                    buttonRealTime.IsEnabled = true;
                    break;

                case DeviceStatus.ExpectingButtonTapToConfirmConnection:
                    textBlockStatus.Text     = "Tap the Central Button to confirm the connection.";
                    buttonRealTime.IsEnabled = false;
                    break;

                case DeviceStatus.ExpectingButtonTapToReconnect:
                    textBlockStatus.Text = "Tap the Central Button to restore the connection.";
                    break;

                case DeviceStatus.HoldButtonToEnterUserConfirmationMode:
                    textBlockStatus.Text = "Press and hold the Central Button to enter user confirmation mode.";
                    break;

                    //case DeviceStatus.AcknowledgeConnectionConfirmationTimeout:
                    //	await new MessageDialog("The connection confirmation period expired.").ShowAsync();
                    //	Frame.Navigate(typeof(ScanAndConnectPage));
                    //	break;
                }
            });
        }
Beispiel #6
0
        private void OnMessageReceived(ProximityDevice sender, ProximityMessage message)
        {
            var stopwatch = (Stopwatch)null;

            if (Debug)
            {
                stopwatch = new Stopwatch();
                stopwatch.Start();
            }

            var rawMessage = message.Data.ToArray();

            NdefMessage ndefMessage;

            try
            {
                ndefMessage = NdefMessage.FromByteArray(rawMessage);
            }
            catch (NdefException e)
            {
                var exceptionArgs = new DeviceStatusChangedEventArgs()
                {
                    DeviceStatus = StatusEnum.DeviceArrived
                };
                if (Debug)
                {
                    stopwatch.Stop();
                    exceptionArgs.ExecutionTime = stopwatch.Elapsed;
                }
                OnDeviceStatusChanged(this, exceptionArgs);
                return;
            }

            var args = new MessageArrivedEventArgs()
            {
                DeviceStatus = StatusEnum.MessageReceived
            };

            foreach (NdefRecord record in ndefMessage)
            {
                if (NdefTextRecord.IsRecordType(record))
                {
                    NdefTextRecord textRecord = new NdefTextRecord(record);
                    args.Message = textRecord.Text;
                    break;
                }
            }

            if (Debug)
            {
                stopwatch.Stop();
                args.ExecutionTime = stopwatch.Elapsed;
                args.MethodName    = "TagReader.OnMessageReceived";
            }

            OnDeviceStatusChanged(this, args);
            OnMessageArrived(this, args);
        }
Beispiel #7
0
 public void OnDevicesStatusChanged(object sender, DeviceStatusChangedEventArgs e)
 {
     if (e.DeviceStatus == StatusEnum.DeviceArrived)
     {
         Pin.Write(GpioPinValue.High);
         Task.Delay(5).Wait();
         Pin.Write(GpioPinValue.Low);
     }
 }
Beispiel #8
0
        private void ScanDevMgr_DeviceStatusChanged(object sender, DeviceStatusChangedEventArgs e)
        {
            DeviceStatusSnapshot status = ScanDeviceController.Instance.GetDeviceStatusSnapshot(macAddress);

            if (status.ConnectionStatus == ConnectionStatus.Connected)
            {
                ScanStart(GetLineScript(10, 2, 1.2, 3.0, 2.0, 5.0));
            }
        }
        private void OnDeviceStatusChanged(object sender, DeviceStatusChangedEventArgs e)
        {
            var ignore = this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
            {
                switch (e.Status)
                {
                case DeviceStatus.NotAuthorizedConnectionNotConfirmed:
                    await new MessageDialog(AppObjects.GetStringForDeviceStatus(e.Status)).ShowAsync();
                    Frame.Navigate(typeof(ScanAndConnectPage));
                    break;

                default:
                    textBlockPrompt.Text = AppObjects.GetStringForDeviceStatus(e.Status);
                    break;
                }
            });
        }
Beispiel #10
0
        private void OnDevicesStatusChanged(object sender, DeviceStatusChangedEventArgs e)
        {
            var result = coreDispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                var stopwatch = (Stopwatch)null;
                if (Debug)
                {
                    stopwatch.Start();
                }

                DeviceStatus = Enum.GetName(typeof(StatusEnum), e.DeviceStatus);

                if (Debug)
                {
                    Log += $"{e.ToString()}\n";
                    stopwatch.Stop();
                    Log += $"{{\"Display.OnMessageArrived\":{{ \"ExecutionTime\":\"{stopwatch.Elapsed.ToString()}\" }} }}\n";
                }
            });
        }
        private void MDeviceMonitor_DeviceStatusChanged(object sender, DeviceStatusChangedEventArgs statusChangedEventArgs)
        {
            lock (mSyncLock)
            {
                if (mStateKeeper != null)
                {
                    mStateKeeper.Reset();
                }
            }

            try
            {
                UpdateDeviceData(GetDevices());
            }
            catch (AdbExeException adbExeEx)
            {
                Log.E(cLogTag, "An error occured while trying to update device data: {0}", adbExeEx.Message);
            }

            mEventProvider.OnDevicesStateChanged(new EventArgs());
        }
 private void OnStatusChanged(DeviceStatusChangedEventArgs eventArgs)
 {
     DeviceStatusChanged?.Invoke(this, eventArgs);
 }
 private void MyDevices_DeviceStatusChanged(object sender, DeviceStatusChangedEventArgs e)
 {
 }
Beispiel #14
0
 private void ScanDevMgr_DeviceStatusChanged(object sender, DeviceStatusChangedEventArgs e)
 {
     DeviceStatusChanged?.Invoke(sender, e);
 }