Download a stream of data to a peripheral over BLE.

Dependencies:   BLE_API mbed nRF51822

A simple demonstration of downloading a stream onto a peripheral over BLE. There's a corresponding Python script to driver the client.

Revision:
4:29ae814ca55e
Parent:
3:d58f3a5bd66c
Child:
5:90b73268e270
--- a/TransferService.cpp	Tue Sep 02 16:30:18 2014 +0000
+++ b/TransferService.cpp	Wed Nov 05 14:35:52 2014 +0000
@@ -71,13 +71,13 @@
 void refuseFile();
 void sendFileDownloadedSuccessfully();
 
-void handleDataWritten(uint16_t handle, const GattCharacteristicWriteCBParams *params)
+void handleDataWritten(const GattCharacteristicWriteCBParams *params)
 {
     if (!ble) {
         return;
     }
 
-    if (handle == transferFileInfo.getValueAttribute().getHandle()) {
+    if (params->charHandle == transferFileInfo.getValueAttribute().getHandle()) {
         if (params->len != sizeof(FileInfo_t)) {
             DEBUG("invalid write into fileInfo characteristic\r\n");
             return;
@@ -105,7 +105,7 @@
         } else {
             refuseFile();
         }
-    } else if (handle == transferFileBlock.getValueAttribute().getHandle()) {
+    } else if (params->charHandle == transferFileBlock.getValueAttribute().getHandle()) {
         if (params->len != sizeof(FileBlock_t)) {
             DEBUG("invalid write into fileInfo characteristic\r\n");
             return;
@@ -123,7 +123,7 @@
             DEBUG("Error: block %u is out of range\r\n", fileBlock.blockNumber);
         }
     } else {
-        DEBUG("Got data on unexpected characteristic handle %u!\r\n", handle);
+        DEBUG("Got data on unexpected characteristic handle %u!\r\n", params->charHandle);
     }
 }