title: Bluetooth BLE Android write to peripheral with max throughput
body: <p>Our company develops a hardware unit that has Bluetooth BLE and we have a service app in a Nexus 7 (2013) that we want to send firmware files to the unit with. The files can be as large as 500kb.</p>
  
  <p>The BT chip is a Texas Instruments CC2540.</p>
  
  <p>I have gone through tons of we pages, and scanned Stack overflow for information how to speed up the transfer of data from the Android device to the CC2540, but haven´t found any really good example.</p>
  
  <p>On Nordic semiconductors homepage I found an example of how they calculate the maximum throughput for a Android unit:
  (<a href="https://devzone.nordicsemi.com/index.php/how-do-i-calculate-throughput-for-a-ble-link">https://devzone.nordicsemi.com/index.php/how-do-i-calculate-throughput-for-a-ble-link</a>)</p>
  
  <pre><code>Nexus 4 with nRF51822: 4 * 20 B * 1/0.0075 s = 10.6 kB/s = 84 kbps
  </code></pre>
  
  <p>It says that an Android unit can send 4 packets of 20 bytes per connection interval, and that Android can handle connection intervals of 7.5ms.</p>
  
  <p>In our app we are currently sending data with <strong>writeCharateristics</strong> and wait for <strong>onWriteCharateristics</strong> callback before we send the next chunk of data. However, that sending rate is painfully slow as the callback takes about 2 seconds to be called(!!). That makes a data transfer rate of 10 bytes/s which is far away from the 10.6kb/s in the example calculation above.</p>
  
  <p>We have tried transferring 50kb of data between two iOS devices (with a modified version of the KeyFob demo for iOS) and got a transfer rate of 3.4kb/s. But that was using the <strong>CBPeripheralManager UpdateValue</strong> which I understand is a way of sending a notification from peripheral to central.</p>
  
  <p>What I have read there is no way right now to have an Android device working as peripheral. Does this mean it's impossible for a CC2540 to send notifications to the Nexus 7? And is the only way to maximize the throughput to send the data through notifications?</p>
  
  <p>Is it the stack in the TI device that makes it all slow, or is there any way to change any parameters to make the data transfer faster between the Nexus and the CC-unit?</p>
  
  <p>We had an idea of implementing a GATT server in the Nexus 7 device and make the CC2540 subscribe for notifications from it. Is that possible? That means the Nexus first have to scan for the CC2540 and connect to it when it finds the service. When the connection is established, the CC2540 starts to subscribe for notifications from the Nexus 7. After that sending notifications from the Nexus to the CC2540 with a higher transfer rate.</p>
  
  <p>Hopefully someone else has been trying to do the same thing as we are trying to do! </p>