1

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?

Kathiieee
  • 211
  • 1
  • 3
  • 10
  • I dunno how you get the value of x1, x2, x3 from `getSensorValues()` but if you want to send an `int16_t` you shouldn't use `sendByte()` as it only sends in Byte (8bit, e.g. int8_t). If you want to send float, better use `sendFloat()` as in https://github.com/RFduino/RFduino/blob/master/libraries/RFduinoBLE/RFduinoBLE.cpp – Isa A Jan 29 '15 at 08:35
  • Also, from this example: https://github.com/RFduino/RFduino/blob/master/libraries/RFduinoBLE/examples/BulkDataTransfer/BulkDataTransfer.ino it seems like you can use array. I dunno anything about RFduino though.. – Isa A Jan 29 '15 at 08:36
  • @IsaA it does not matter how I get the sensorvalues, they are read from a digital sensor as a two's complement and the datatype needs to be int16_t I think (I tried Int but then the numbers are wrong, something with RFduino)... yes arrays are possible but only char-arrays.. I dont know how to do the conversion and if thats even possible... – Kathiieee Jan 29 '15 at 10:01

0 Answers0