RFduino - Faulty Transmissions
<p>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.</p>

<p>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.</p>

<p>This is a basic idea of the code:</p>

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

void serialEvent(void) {
  mData = true;
}
</code></pre>

<p>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.</p>

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

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

<p>Additionally I tried to lower the sending power to minimum, without any improvements. </p>

<p>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. </p>

<p>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. </p>

<p>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.  </p>

<p>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.</p>

<hr>

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

<p><a href="http://forum.rfduino.com/index.php?topic=1450.0" rel="nofollow">RFduino Forum</a></p>