• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
BT data (NSData *) question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

BT data (NSData *) question


  • Subject: BT data (NSData *) question
  • From: "Eric E. Dolecki" <email@hidden>
  • Date: Tue, 07 Jan 2014 13:22:20 -0500

I am receiving data from an RFduino board to my iOS application. In Arduino
land it's being sent like so:

RFduinoBLE.send(1); //button pressed
RFduinoBLE.send(0); //button released

In my didReceive:(NSData *)data I have this:

const uint8_t *value = [data bytes];

I would like to evaluate that value in an if else statement. Right now
someone wrote in that method:

if( value[0]){
    NSLog(@"pressed");
} else {
    NSLog(@"released");
}

So I think this is simply looking for a 1 (true) or anything else (0). If I
wanted to add support for another button, I'd send a different byte...

RFduino.send(2);

How can I adjust that if else statement properly to evaluate the data sent
to the iOS application over BLE?

I'm in unchartered territory here. Is it something like the below? I'm
thinking no...

if( value[0] == 1 ){
    NSLog(@"button a pressed");
} else if( value[0] == 2){
    NSLog(@"button b pressed");
} else {
    NSLog("button released");
}

Thanks for your time and attention,
Eric
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: BT data (NSData *) question
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: Set up an editable view based NSTableView programmatically - how to?
  • Next by Date: Re: BT data (NSData *) question
  • Previous by thread: Letting an instance know its own index within a container
  • Next by thread: Re: BT data (NSData *) question
  • Index(es):
    • Date
    • Thread