2

I have a project where I send data to an Android phone. I get data via the serial port to the rfduino and then send this data to the phone. First I had 20 byte data chunks. I use "Serial Event" to set a flag and then read and send the data within the main loop. The serial baud rate is 9600 as recommended by the rfduino staff.

Now I have 40 bytes of data. The Rfduino reads 40 bytes of serial data and sends it in two parts (see code). The first byte of each part is an identifier used to distunguish between the different packets. After some successful transmissions the data becomes corrupt. Usually, once the transmission starts being faulty, I have to reinitiate the connection to get correct data.

This is a basic idea of the code:

void loop() {
  if (mData)
     {
      mData = false;
      Serial.readBytes(data, 40);
      while(!RFduinoBLE.send(&data[0], 20));
      while(!RFduinoBLE.send(&data[20], 20));    
      }
}

void serialEvent(void) {
  mData = true;
}

I checked the serial data with a logic analyzer and there is nothing wrong with it. I also used wireshark to check the ble transmissions. Both 20 Byte chunks are send within the same connection interval. The data sent by the RFduino becomes corrupt after some time.

When I omit the second packet and just send 20 Bytes, the problem does not occur.

I assume, that the radio interferes with the reading of the serial port. I tried to use while(RFduinoBLE.radioActive); before the Serial.read, but I think the data is buffered before that. So this did not change anything.

Additionally I tried to lower the sending power to minimum, without any improvements.

I also tried different connection intervals. I have new data every 128ms. This limits the max. connection interval. All changes did not help at all.

I've read that the BLE radio priority takes about 5-6ms and that there is a 6 byte buffer for data. Using 9600 baud this buffer overflows.

I haven't looked for sources to those statements yet, but lowering the baud rate to 4800 seems to improve the issue with the faulty data. Still this is no satisfying data rate and the transmission faults still occur. Not that often anymore, but still.

I've run out of ideas how to fix this and would appreciate any thought! I mean it must be possible to send 40 bytes every 128ms... that's not that much.


I already posted this question in the RFduino Forum - without answer until now - and I wonder if anyone experienced similar issues with the RFduino.

RFduino Forum

tripleee
  • 175,061
  • 34
  • 275
  • 318
Chuchaki
  • 361
  • 1
  • 3
  • 14
  • 1
    Your Stack Overflow question should stand completely on its own, though linking to the effective duplicate for coordination would also be good. Either way, please [edit] this to focus on the technical problem as the primary topic. – tripleee Aug 06 '16 at 08:55
  • Hey, thanks for the input. I hope it is better now :-) – Chuchaki Aug 06 '16 at 09:05
  • Yes, much better, thanks! – tripleee Aug 06 '16 at 09:11

0 Answers0