Lightly modified version of the BLE stack, that doesn't bring up a DFUService by default... as we have our own.

Fork of BLE_API by Bluetooth Low Energy

Revision:
187:057c547facd2
Parent:
186:ce34008cea95
Child:
188:9020a5ac80c8
--- a/services/URIBeacon2Service.h	Fri Nov 28 14:11:24 2014 +0000
+++ b/services/URIBeacon2Service.h	Fri Nov 28 14:11:24 2014 +0000
@@ -58,12 +58,12 @@
      * @return
      *     Pointer to the singleton uribeacon service if the initialization goes well; else NULL.
      */
-    static URIBeacon2Service *setup(BLEDevice &ble_, const char *urldata, uint8_t flagsIn = 0, int8_t effectiveTxPowerIn = 0, uint16_t beaconPeriodIn = 1000) {
-        if ((urldata == NULL) || (strlen(urldata) == 0)) {
+    static URIBeacon2Service *setup(BLEDevice &bleIn, const char *urlDataIn, uint8_t flagsIn = 0, int8_t effectiveTxPowerIn = 0, uint16_t beaconPeriodIn = 1000) {
+        if ((urlDataIn == NULL) || (strlen(urlDataIn) == 0)) {
             return NULL;
         }
 
-        static URIBeacon2Service service(ble_, urldata, flagsIn, effectiveTxPowerIn, beaconPeriodIn);
+        static URIBeacon2Service service(bleIn, urlDataIn, flagsIn, effectiveTxPowerIn, beaconPeriodIn);
         if (!service.failedToAccomodate) {
             return &service;
         }
@@ -127,21 +127,21 @@
     /**
      * Private constructor. We want a singleton.
      */
-    URIBeacon2Service(BLEDevice &ble_, const char *urldata, uint8_t flagsIn = 0, int8_t effectiveTxPowerIn = 0, uint16_t beaconPeriodIn = 1000) :
-        ble(ble_),
+    URIBeacon2Service(BLEDevice &bleIn, const char *urldataIn, uint8_t flagsIn = 0, int8_t effectiveTxPowerIn = 0, uint16_t beaconPeriodIn = 1000) :
+        ble(bleIn),
         payloadIndex(0),
         serviceDataPayload(),
         failedToAccomodate(false),
         lockedState(false),
-        uriDataLength(strlen(urldata)),
-        uriDataValue(),
+        uriDataLength(strlen(urldataIn)),
+        uriData(),
         flags(flagsIn),
         effectivePower(effectiveTxPowerIn),
         powerLevels(),
         beaconPeriod(Gap::MSEC_TO_ADVERTISEMENT_DURATION_UNITS(beaconPeriodIn)),
         lockedStateChar(lockedStateCharUUID, reinterpret_cast<uint8_t *>(&lockedState), 1, 1, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ),
         uriDataChar(uriDataCharUUID,
-                    uriDataValue,
+                    uriData,
                     MAX_SIZE_URI_DATA_CHAR_VALUE,
                     MAX_SIZE_URI_DATA_CHAR_VALUE,
                     GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE),
@@ -154,7 +154,7 @@
         beaconPeriodChar(beaconPeriodCharUUID, reinterpret_cast<uint8_t *>(&beaconPeriod), 2, 2,
                          GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE)
     {
-        strncpy(reinterpret_cast<char *>(uriDataValue), urldata, MAX_SIZE_URI_DATA_CHAR_VALUE);
+        strncpy(reinterpret_cast<char *>(uriData), urldataIn, MAX_SIZE_URI_DATA_CHAR_VALUE);
 
         configure();
 
@@ -177,7 +177,7 @@
         serviceDataPayload[payloadIndex++] = flags;
         serviceDataPayload[payloadIndex++] = effectivePower;
 
-        const char *urlData  = reinterpret_cast<char *>(uriDataValue);
+        const char *urlData  = reinterpret_cast<char *>(uriData);
         size_t sizeofURLData = uriDataLength;
         size_t encodedBytes  = encodeURISchemePrefix(urlData, sizeofURLData) + encodeURI(urlData, sizeofURLData);
 
@@ -276,7 +276,7 @@
         if (params->charHandle == uriDataChar.getValueAttribute().getHandle()) {
             if (lockedState) { /* When locked, the device isn't allowed to update the uriData characteristic. */
                 /* Restore GATT database with previous value. */
-                ble.updateCharacteristicValue(uriDataChar.getValueAttribute().getHandle(), uriDataValue, uriDataLength);
+                ble.updateCharacteristicValue(uriDataChar.getValueAttribute().getHandle(), uriData, uriDataLength);
                 return;
             }
 
@@ -286,7 +286,7 @@
             }
 
             uriDataLength = params->len;
-            memcpy(uriDataValue, params->data, uriDataLength);
+            memcpy(uriData, params->data, uriDataLength);
         } else if (params->charHandle == flagsChar.getValueAttribute().getHandle()) {
             if (lockedState) { /* When locked, the device isn't allowed to update the characteristic. */
                 /* Restore GATT database with previous value. */
@@ -341,7 +341,7 @@
 
     bool     lockedState;
     uint16_t uriDataLength;
-    uint8_t  uriDataValue[MAX_SIZE_URI_DATA_CHAR_VALUE];
+    uint8_t  uriData[MAX_SIZE_URI_DATA_CHAR_VALUE];
     uint8_t  flags;
     int8_t   effectivePower;
     int8_t   powerLevels[NUM_POWER_MODES];