Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of BLE_API by
Diff: services/DFUService.h
- Revision:
- 120:467527c1b943
- Parent:
- 119:18684018b83e
- Child:
- 238:a77aefd88e78
--- a/services/DFUService.h	Fri Sep 26 14:28:59 2014 +0100
+++ b/services/DFUService.h	Fri Sep 26 16:42:50 2014 +0100
@@ -43,6 +43,7 @@
     DFUService(BLEDevice &_ble, ResetPrepare_t _handoverCallback = NULL) :
         ble(_ble),
         controlBytes(),
+        packetBytes(),
         controlPoint(DFUServiceControlCharacteristicUUID, controlBytes, SIZEOF_CONTROL_BYTES, SIZEOF_CONTROL_BYTES,
                      GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY),
         packet(DFUServicePacketCharacteristicUUID, packetBytes, SIZEOF_PACKET_BYTES, SIZEOF_PACKET_BYTES,
@@ -52,6 +53,11 @@
             return;
         }
 
+        /* Set an initial value for control bytes so that the application's DFUService can
+         * be distinguished from the real DFU service provided by the bootloader. */
+        controlBytes[0] = 0xFF;
+        controlBytes[1] = 0xFF;
+
         GattCharacteristic *dfuChars[] = {&controlPoint, &packet};
         GattService         dfuService(DFUServiceUUID, dfuChars, sizeof(dfuChars) / sizeof(GattCharacteristic *));
 
@@ -86,7 +92,7 @@
     static const unsigned SIZEOF_CONTROL_BYTES = 2;
     static const unsigned SIZEOF_PACKET_BYTES  = 20;
 
-    static ResetPrepare_t  handoverCallback;  /**< application specific handover callback. */
+    static ResetPrepare_t handoverCallback;  /**< application specific handover callback. */
 
 private:
     BLEDevice          &ble;
    