This is probably a very basic question but I have been googleing for hours now and cannot find a solution.
I am trying to send three values from my RFduino to my iPhone which should all three then be displayed on my custom app (very simple). For this I changed the given Temperature app and RFduino code which I found on their GitHub.
But in all the example they only send 1 value over BLE, how can I send multiple without overwriting instantly?
In my code I am trying to do it like this and I also tried arrays, char arrays but nothing worked, at the moment the app only breaks..
my RFduino code looks like this (Minimal example)
#include <Wire.h>
#include <RFduinoBLE.h>
#include "Arduino.h"
int16_t x1,x2,x3;
void setup(){
Wire.begin();
Serial.begin(9600);
Serial.println("setting up Sensor...");
SetupSensor(); // Configure sensor
delay(1500); //wait for the sensor to be ready
RFduinoBLE.advertisementData = "sensor";
// start the BLE stack
RFduinoBLE.begin();
}
void loop(){
RFduino_ULPDelay( 25 );
getSensorValues(); // sensor update
RFduinoBLE.sendByte(x1);
RFduinoBLE.sendByte(x2);
RFduinoBLE.sendByte(x3);
}
(I am also very confused if I should send Byte or Int or Float and the whole thing with internal conversion..)
The "intresting" part in the app-code is this one:
- (void)didReceive:(NSData *)data
{
NSLog(@"RecievedRX");
float x1 = dataFloat(data);
float x2 = dataFloat(data);
float x3 = dataFloat(data);
NSString* string1 = [NSString stringWithFormat:@"%.2f", x1];
NSString* string2 = [NSString stringWithFormat:@"%.2f", x2];
NSString* string3 = [NSString stringWithFormat:@"%.2f", x3];
[label1 setText:string1];
[label2 setText:string2];
[label2 setText:string3];
}
I KNOW this is completely wrong but I have no idea on how to fix it? Can I just somehow pack my values into an array and sent all by one?