Author Topic: Problem with sending Data  (Read 869 times)

laurenz

  • RFduino Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Problem with sending Data
« on: January 15, 2016, 10:39:04 AM »


Hi there,
I´m having problems to get a working communication from the iphone app to a RFduino.
I´m using: Xcode, Openframeworks, cpp and this library:
https://github.com/joshuajnoble/ofxBLEDevice

When I check if the touch command is executed:it is.
Code: [Select]
void ofApp::touchDown(ofTouchEventArgs & touch){
    unsigned char data[3];
    data[0] = '1';
    data[1] = '2';
    data[2] = '3';
    ofxBLESendData(BLEDeviceImpl, &data[0], tx, 3);
     cout << " didSendData " << endl;
}

And connecting to my particular device works as well:

Code: [Select]
void ofApp::didDiscoverBLEDevice(BLEDevice *device)
{
    cout << " didDiscoverBLEDevice " << endl;
    if(device.name != nil)
    {
        std::string deviceName([device.name UTF8String]);
            cout << deviceName << endl;
      //  cout << device.advertisementRSSI <<endl;

        if(deviceName == "LaurenzRFduino") {
            ofxBLEConnectDevice(device);

        }
    }
}

The connection is working and the touch is executed but no data are recieved on the Arduino end.

2016-01-15 15:09:21.911 HelloBT[813:222123] Creating OpenGL ES1 Renderer
2016-01-15 15:09:21.951 HelloBT[813:222123] init
2016-01-15 15:09:21.970 HelloBT[813:222123] central manager state = 5
2016-01-15 15:09:21.970 HelloBT[813:222123] CoreBluetooth BLE hardware is powered on and ready
2016-01-15 15:09:21.970 HelloBT[813:222123] startScan
2016-01-15 15:09:22.010 HelloBT[813:222123] BLEDevice init
didDiscoverBLEDevice
LaurenzRFduino
2016-01-15 15:09:22.010 HelloBT[813:222123] connect ble
2016-01-15 15:09:22.215 HelloBT[813:222123] didConnectPeripheral
2016-01-15 15:09:22.216 HelloBT[813:222123] BLEDevice connected
didConnectBLEDevice
2016-01-15 15:09:22.492 HelloBT[813:222123] didDiscoverServices
2016-01-15 15:09:22.616 HelloBT[813:222123] didDiscoverCharacteristicsForService
didSendData
didSendData
didSendData
didSendData



Thats the Arduino code:

Code: [Select]
#include <RFduinoBLE.h>


int testData = 1;
bool didConnect=false;

void setup() {
  Serial.begin(9600);
  RFduinoBLE.deviceName = "LaurenzRFduino";
  RFduinoBLE.advertisementData = "data";
  RFduinoBLE.begin();
 // RFduinoBLE.txPowerLevel = +4;


}

void loop() {
 //RFduinoBLE.sendInt(testData);
}

void RFduinoBLE_onAdvertisement(bool start) {
}

void RFduinoBLE_onConnect(){
Serial.println("Did connect");
 RFduinoBLE.sendInt(testData);
didConnect= true;
}

void RFduinoBLE_onRSSI(int rssi){
 Serial.println(rssi); // print rssi value via serial }
}

void RFduinoBLE_onDisconnect(){
Serial.println("Did disconnect");
didConnect= false;
}

void RFduinoBLE_onReceive(char *data, int len)
{
  // display the first recieved byte
  //Serial.println(data[0]);
  //Serial.println(len);
    Serial.println("hello");
    RFduinoBLE.sendInt(testData);
}

Same thing here: The connection works and I do get an RSSI value but no data is recieved nor can I send anything in the other direction.