Esempio n. 1
0
        //
        // Write URI Tab
        //

        private void WriteURLButton_Click(object sender, RoutedEventArgs e)
        {
            string   url           = string.Copy(urlTextBox.Text);
            Command  cmd           = new WriteUri((byte)timeout.Value, (bool)lockCheckBox.IsChecked, new NdefUri(url));
            Callback repeatCommand = null;
            bool     repeat        = (bool)repeatUrlWrite.IsChecked;
            Action   sendCommand   = () => tappy.SendCommand(cmd, ResponseCallback + repeatCommand);

            ShowPendingStatus("Waiting for tap");

            repeatCommand = (ResponseFrame frame, Exception exc) =>
            {
                if (repeat)
                {
                    if (CheckForErrorsOrTimeout(frame, exc))
                    {
                        return;
                    }
                    Thread.Sleep(800);
                    ShowPendingStatus("Waiting for tap");
                    Dispatcher.BeginInvoke(sendCommand);
                }
            };

            tappy.SendCommand(cmd, ResponseCallback + repeatCommand);
        }
Esempio n. 2
0
        private void WriteUrlWithTagMirror_Click(object sender, RoutedEventArgs e)
        {
            string  temp         = string.Copy(urlTextBox.Text);
            bool    willLock     = (bool)lockCheckBox.IsChecked;
            bool    repeat       = (bool)repeatUrlWrite.IsChecked;
            byte    timeoutValue = (byte)timeout.Value;
            Command detectTag    = new DetectSingleTagUid(timeoutValue, DetectTagSetting.Type2Type4AandMifare);

            ShowPendingStatus("Waiting for tap");
            Callback detectTagCallback = null;

            Callback writeCallback = (ResponseFrame frame, Exception exc) =>
            {
                if (CheckForErrorsOrTimeout(frame, exc))
                {
                    return;
                }
                ShowSuccessStatus();

                if (repeat)
                {
                    Thread.Sleep(1000);
                    ShowPendingStatus("Waiting for tap");
                    Task.Run(() => tappy.SendCommand(detectTag, detectTagCallback));
                }
            };

            detectTagCallback = (ResponseFrame frame, Exception exc) =>
            {
                if (CheckForErrorsOrTimeout(frame, exc))
                {
                    return;
                }

                Tag     tag   = new Tag(frame.Data);
                Command write = new WriteUri(timeoutValue, willLock, temp.Replace("[uid]", tag.UidToString()));
                ShowPendingStatus("Tag detected, please hold steady while tag is written");
                Task.Run(() => tappy.SendCommand(write, writeCallback));
            };

            tappy.SendCommand(detectTag, detectTagCallback);
        }
Esempio n. 3
0
        private void configureTagForPlatform_Click(object sender, RoutedEventArgs e)
        {
            Command readCommand = new DetectSingleTagUid(0, DetectTagSetting.Type2Type4AandMifare);

            tappy.SendCommand(readCommand, delegate(ResponseFrame frame, Exception exc)
            {
                if (CheckForErrorsOrTimeout(frame, exc))
                {
                    return;
                }

                Tag tag       = new Tag(frame.Data);
                string uid    = BitConverter.ToString(tag.UID).Replace("-", "");
                string url    = $"https://members.taptrack.com/m?id={uid}";
                Command write = new WriteUri(0, false, new NdefUri(url));

                Task.Run(() =>
                {
                    tappy.SendCommand(write, ConfigSuccess);
                });
            });
        }