public void UpdateTagInfo(NFCTag tag) { string technologiesString = string.Empty; NFCTechnology[] technologies = tag.Technologies; int length = technologies.Length; for (int i = 0; i < length; i++) { if (i > 0) { technologiesString += ", "; } technologiesString += technologies[i].ToString(); } string maxWriteSizeString = string.Empty; if (tag.MaxWriteSize > 0) { maxWriteSizeString = tag.MaxWriteSize + " bytes"; } else { maxWriteSizeString = "Unknown"; } string tagInfo = string.Format(TAG_INFO_FORMAT, tag.ID, technologiesString, tag.Manufacturer, tag.Writable, maxWriteSizeString); tagInfoContentLabel.text = tagInfo; }
private static void MessageReceived(ITagInfo tagInfo) { string id = tagInfo.SerialNumber; //Messages reader string message = ""; if (!tagInfo.IsEmpty) { foreach (NFCNdefRecord record in tagInfo.Records) { message += record.Message != null?record.Message.ToString() : " "; } } var tag = new NFCTag() { TagId = id, MeetingCode = message }; foreach (var handler in OnMessageReceivedHandler) { handler(tag); } }
private void _nfcReader_TagFound(NFCTag tag) { // we get called twice for some reason. if (_busy) { return; } if (ShuttingDown) { return; } Log(" _nfcReader_TagFound"); if (_currentTag != null && _currentTag.UID == tag.UID) { return; } _currentTag = tag; CurrentDevice = new NFCHoloDevice(_currentTag); foreach (Delegate d in DeviceArrived.GetInvocationList()) { ISynchronizeInvoke syncer = d.Target as ISynchronizeInvoke; if (syncer != null) { syncer.BeginInvoke(d, new NFCHoloDevice[] { CurrentDevice }); } else { d.DynamicInvoke(CurrentDevice); } } }
private void theForm_TagFound(NFCTag Tag) { if (Tag != null) { tATR.Text = Tag.ATR; tUID.Text = Tag.UID; tType.Text = Tag.GetType().Name; } }
private void OnMessageReceived(NFCTag tag) { TagId_Label.Text = "ID: " + tag.TagId; //TODO currentTag = tag.TagId; Check_Button.IsEnabled = true; Check_Button.BackgroundColor = Color.FromHex("008B8B");; ImageWait.IsVisible = false; ImageOk.IsVisible = true; StartAgain(); }
private void OnMessagePublished(NFCTag tag) { ImageWait.IsVisible = false; ImageOk.IsVisible = true; //TagId_Label.Text = tag.TagId; //EventId_Label.Text = tag.MeetingCode; NFCController.StopAll(); SendRequest(tag.TagId); //Application.Current.MainPage.DisplayAlert("Success", "Succesfully assigned tag " + tag.TagId + " to " + currentPosition.RoomName + "/" + currentPosition.PositionNumber, "Ok"); currentPosition = null; GeneratePickerElements(); NFCController.StartListening(); }
private void bDisconnect_Click(object sender, EventArgs e) { if (!NFCHandler.IsInitialized) { return; } if (theTag != null) { tATR.Text = tUID.Text = tType.Text = tData.Text = ""; theTag.Dispose(); theTag = null; } }
private void bConnect_Click(object sender, EventArgs e) { if (!NFCHandler.IsInitialized) { return; } theTag = NFCHandler.Readers[dReaders.SelectedIndex].Connect(); if (theTag != null) { tATR.Text = theTag.ATR; tUID.Text = theTag.UID; tType.Text = theTag.GetType().Name; } }
private async void Button_Click(object sender, RoutedEventArgs e) { getid.IsEnabled = false; NFCHandler.Init(); dReaders.Items.Clear(); foreach (NFCReader rdr in NFCHandler.Readers) { dReaders.Items.Add(rdr.Name); } if (dReaders.Items.Count > 0) { dReaders.SelectedIndex = 0; } if (!NFCHandler.IsInitialized) { MessageBox.Show("card not installed"); getid.IsEnabled = true; } else if (dReaders.Items.Count == 0) { MessageBox.Show("Reader Not Found!!!"); getid.IsEnabled = true; } else { while (true) { theTag = NFCHandler.Readers[dReaders.SelectedIndex].Connect(); if (theTag != null) { var tagId = (BitConverter.ToUInt32(theTag.bUID, 0) % 10000000); //this is an example to play with your card number, if you are developing a system, you may need something like this //var tagId = theTag.bUID; //original tagid //var tagId = (BitConverter.ToUInt32(theTag.bUID, 0); //sometimes some rfid uses this format to show tag number idno.Text = tagId.ToString(); refno.Text = theTag.ATR.ToString(); await Task.Delay(2000); NFCHandler.Release(); getid.IsEnabled = true; break; } } } }
private void _nfcReader_TagLost() { Log("_nfcReader_TagLost"); if (DeviceDeparted != null) { foreach (Delegate d in DeviceDeparted.GetInvocationList()) { ISynchronizeInvoke syncer = d.Target as ISynchronizeInvoke; if (syncer != null) { syncer.BeginInvoke(d, new HoloDevice[] { CurrentDevice }); } else { d.DynamicInvoke(CurrentDevice); } } } _busy = false; _currentTag = null; CurrentDevice = null; }
private static void OnMessageReceived(NFCTag tag) { Redirect(); }
public void OnNFCTagDetected(NFCTag tag) { view.UpdateTagInfo(tag); }