BT data (NSData *) question
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