0

I'm working on my first RFDuino project.

I can send data to it, but how do I get the RFDuino to remember what was sent so if the app is killed in the App Switcher it remembers the last items saved to it on the next launch?

EDIT:

I am sending data to my RFDuino and using NSUserDefaults so my app shows what is currently sent to the device.

Where I am stuck now is how to send my data in the way I want it.

So, for example:

I am sending it 3 values, let's say they are 2.0, 4, and 60.

The data that the RFDuino is getting is <02>, <04>, and <06>.

I'd like for it to get, 2,4,and60. The 2 may need to be 20, not sure on that part.

Here's how I am sending the data for the first number:

CGFloat firstTotal;

uint8_t tx = firstTotal;
NSData *burstRateData = [NSData dataWithBytes:(void*)&tx length:1];

[self.rfduino send:burstRateData];

Logging it, I would get <02> for 2.0.

How would I send 2 or 20 for 2.0?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Luke Irvin
  • 1,179
  • 1
  • 20
  • 39
  • Is this about getting the phone to save the data or the RFDuino to write the data? – Allison Oct 12 '14 at 05:22
  • Both. I want to make sure the RFDuino is doing what I tell it to do, as well as save the data that's sent until a user changes it. – Luke Irvin Oct 12 '14 at 18:32
  • For the saving use NSUserDefaults, http://stackoverflow.com/a/3074489/1166266, and I don't have any experience with RFDuinos, so you might want to post on the arduino forums? – Allison Oct 12 '14 at 20:22
  • What do you mean by "logging it"? The RFDuino is logging? Or some sort of iOS log? And what is it logging to? – bikemule Aug 09 '15 at 19:11

1 Answers1

0

Whatever you want to save, if your iOS device is connecting and sending correctly, you shouldn't really be concerned with iOS code. There isn't any iOS command to make an RFDuino save info, unless there's some library I don't know about.

You have to make the RFDuino store the data, either in RAM (as some sort of data structure) or flash memory (See official Arduino docs for API: https://www.arduino.cc/en/Reference/EEPROM).

How you do this is dependent on how you're sending the data. You basically have to create your own protocol for data because Bluetooth packets are 20-22 bytes max.

bikemule
  • 316
  • 1
  • 9