Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9026377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:30:16+00:00 2026-06-16T06:30:16+00:00

I am trying to write some code that integrates an RFID reader, and I

  • 0

I am trying to write some code that integrates an RFID reader, and I have gotten kind of far with it, but I am still struggling on how I can set a wait time of some sort.

Basically, I have an RFID reader that is hooked up to a jailbroken iPhone, and I have created an “NSMutableString” that stores the RFID Badge number, but the problem is the serial port is opened when the user clicks the “AddRFID” button within the app, and I can’t figure out how I would setup a loop or something of that nature to wait for the user to scan their RFID badge, so they can associate a badge with a user account, and put the RFID badge # in the “NSMutableString”.

If you have any ideas on how I could accomplish this, I wouldn’t mind see some code examples.

So far this is what I have,

 /* Begin addRFID - Serial Communication */

- (IBAction)addRFID:(id)sender {

   // btnAddRFID pressed

   NSLog(@"rfid badge # is %@",rfidbadgenumber);

  // launch an alert with text input
   UIAlertView *alertrfid = [[UIAlertView alloc] initWithTitle:@"Scan RFID badge"
                                                    message:@"Associate RFID badge with user account"
                                                   delegate:self
                                          cancelButtonTitle:@"Dismiss"
                                          otherButtonTitles:@"Save", nil];



// set alert with a text input field
[alertrfid setAlertViewStyle:UIAlertViewStylePlainTextInput];
// set text field input to max character length of 10
//[[alertrfid textFieldAtIndex:0].text substringWithRange:NSMakeRange(0,10)];



    [alertrfid show];


    // set the delegate for the UIAlertView textfield
    [alertrfid textFieldAtIndex:0].delegate = self;



     //open serial port
     [serial open:B2400];

     NSLog(@"rfid badge # is: %@",rfidbadgenumber);


    // assign alert input text to RFID badge #
    [alertrfid textFieldAtIndex:0].text = rfidbadgenumber;


  }

  # pragma mark - JailbrokenSerialDelegate
  - (void) JailbrokenSerialReceived:(char) ch {

    NSString *rfidbadgenumbernew = [[NSString alloc]init];

    NSLog(@"rfidbadgenumbernew is: %@",rfidbadgenumbernew);

    // put serial received data in a char buffer
    [rfidbadgenumber stringByReplacingOccurrencesOfString:rfidbadgenumber withString:rfidbadgenumbernew];

     NSLog(@"serialrecvd -  rfidbadgenumber is: %@",rfidbadgenumber);

    //[rfidbadgenumber appendFormat:@"%c", ch];

    //[rfidbadgenumber stringByReplacingOccurrencesOfString:rfidbadgenumber withString:rfidbadgenumbernew];
  }

  - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {

NSLog(@"Range: %@", NSStringFromRange(range));
return (textField.text.length - range.length + string.length <= 10);
}

 // add method for cancel button
  - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {

  if (buttonIndex == 0) {
    NSLog(@"The cancel button was clicked");

    rfidbadgenumber = NULL;

    //rfidbadgenumbernew = NULL;

    [serial close];
 } 

 // do stuff for additonal buttons
}

   // close serial port


  /* End addRFID - Serial Communication */
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T06:30:17+00:00Added an answer on June 16, 2026 at 6:30 am

    With the help of a friend yesterday I came up with this code. The following code puts the captured RFID tagID into a textfield located in a UIAlertView.

    /* Begin addRFID - Serial Communication */
    
    - (IBAction)addRFID:(id)sender {
    
    // btnAddRFID pressed
    
    NSLog(@"rfid badge # is %@",newrfidtagid);
    
    
    // set alert with a text input field
    [alertrfid setAlertViewStyle:UIAlertViewStylePlainTextInput];
    // set text field input to max character length of 10
    //[[alertrfid textFieldAtIndex:0].text substringWithRange:NSMakeRange(0,10)];
    
    [alertrfid show];
    
    // set the delegate for the UIAlertView textfield
    [alertrfid textFieldAtIndex:0].delegate = self;
    
    
    //open serial port
    
    [serial open:B2400];
    if(serial.isOpened)
    {
        NSLog(@"Open");
    }
    else NSLog(@"closed dingo");
    }
    
    
     # pragma mark - JailbrokenSerialDelegate
     - (void) JailbrokenSerialReceived:(char) ch {
    
    NSLog(@"got it");
    
    NSString *s = [NSString stringWithFormat:@"%c",ch];
    NSLog(@"s = %@",s);
    
    [newrfidtagid appendString:s];
    
    NSLog(@"rfid char  = %@",newrfidtagid);
    
    if (newrfidtagid.length == 10)
    {
        NSLog(@"new tagid = %@",newrfidtagid);
        [alertrfid textFieldAtIndex:0].text = newrfidtagid;
        //[serial open:B2400];
      }
      }
    
    - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
    
    NSLog(@"Range: %@", NSStringFromRange(range));
    return (textField.text.length - range.length + string.length <= 10);
    }
    
    // add method for cancel button
    - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    
    if (buttonIndex == 0) {
        NSLog(@"The cancel button was clicked");
    
        [serial close];
    
        [alertrfid dismissWithClickedButtonIndex:0 animated:YES];
        [newrfidtagid setString:@""];
        [alertrfid textFieldAtIndex:0].text = @"";
    
        //alertrfid.hidden = TRUE;
    
    }
    
    // do stuff for additonal buttons
    }
    
    // close serial port
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write some code that calculates powers of 2 but stores them
I have been trying to write some code that asks the user for several
I am currently trying to write some code that will accept some FTP details,
I am trying to write some code that will generate accurate .proto files from
I am trying to write some code that that will draw the line which
I'm trying to write some c++ code that tests if a string is in
I’m trying to write some encryption code that is passed through a Url .
I'm trying to write some Python code that will establish an invisible relay between
I am trying to write some XML schema code to specify that a particular
Problem: I am trying to write an app that executes some code when the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.