High level Bluetooth Low Energy API and radio abstraction layer

Dependents:   BLE_ANCS_SDAPI BLE_temperature BLE_HeartRate BLE_ANCS_SDAPI_IRC ... more

Overview

The BLE_API is a high level abstraction for using Bluetooth Low Energy on multiple platforms. For details and examples using the BLE_API please see the BLE_API Summary Page. Or click on the API Documentation tab above.

Supported Services

Supported services can be found in the BLE_API/services folder.

Files at this revision

API Documentation at this revision

Comitter:
rgrover1
Date:
Thu Dec 10 09:15:01 2015 +0000
Parent:
1018:8a29b01b47db
Child:
1020:c8664d12bf10
Commit message:
Synchronized with git rev 13bf70b6
Author: Rohit Grover
Release 2.1.5
=============

A minor release to separate the concept of minlen and len in
GattCharacteristic. Also contains some improvements to documentation.

Changed in this revision

README.md Show annotated file Show diff for this revision Revisions of this file
ble.doxyfile Show annotated file Show diff for this revision Revisions of this file
ble/GattAttribute.h Show annotated file Show diff for this revision Revisions of this file
ble/GattCharacteristic.h Show annotated file Show diff for this revision Revisions of this file
ble/services/EddystoneConfigService.h Show annotated file Show diff for this revision Revisions of this file
ble/services/LinkLossService.h Show annotated file Show diff for this revision Revisions of this file
ble/services/UARTService.h Show annotated file Show diff for this revision Revisions of this file
ble/services/URIBeaconConfigService.h Show annotated file Show diff for this revision Revisions of this file
ble/services/iBeacon.h Show annotated file Show diff for this revision Revisions of this file
module.json Show annotated file Show diff for this revision Revisions of this file
--- a/README.md	Thu Dec 10 09:15:01 2015 +0000
+++ b/README.md	Thu Dec 10 09:15:01 2015 +0000
@@ -16,10 +16,13 @@
 * UriBeacon
 * iBeacon
 
+The [documentation](https://docs.mbed.com/docs/ble-intros/en/latest/AdvSamples/Overview/)
+contains an overview on how to create new, application-specific services.
+
 # Getting Started
 The mbed BLE API is meant to be used in projects on developer.mbed.org. Please see examples and sample project files there.
 A good starting point are these pages:
 * [mbed BLE Homepage](https://developer.mbed.org/teams/Bluetooth-Low-Energy/) for all things BLE
 * [mbed BLE Getting Started Guide](https://developer.mbed.org/forum/team-63-Bluetooth-Low-Energy-community/topic/5262/) a wonderful primer on using BLE with mbed
 * [mbed BLE doc](https://docs.mbed.com/docs/ble-intros/en/latest/) for an introduction to mbed BLE
-* [mbed BLE API page](https://developer.mbed.org/teams/Bluetooth-Low-Energy/code/BLE_API/docs/tip/) for the API in generated by doxygen
\ No newline at end of file
+* [mbed BLE API page](https://docs.mbed.com/docs/ble-api/en/latest/api/index.html) for the Doxygen API documentation
\ No newline at end of file
--- a/ble.doxyfile	Thu Dec 10 09:15:01 2015 +0000
+++ b/ble.doxyfile	Thu Dec 10 09:15:01 2015 +0000
@@ -696,7 +696,7 @@
 # Note that relative paths are relative to the directory from which doxygen is
 # run.
 
-EXCLUDE                = configs
+EXCLUDE                = configs CONTRIBUTING.md README.md
 
 # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
 # directories that are symbolic links (a Unix file system feature) are excluded
@@ -1611,18 +1611,7 @@
 # undefined via #undef or recursively expanded use the := operator
 # instead of the = operator.
 
-PREDEFINED             = WIN32 \
-                         NTLM \
-                         USE_LZO \
-                         ENABLE_FRAGMENT \
-                         P2MP \
-                         P2MP_SERVER \
-                         USE_CRYPTO \
-                         USE_SSL \
-                         ENABLE_PLUGIN \
-                         ENABLE_MANAGEMENT \
-                         ENABLE_OCC \
-                         HAVE_GETTIMEOFDAY
+PREDEFINED             = TARGET_NRF51822
 
 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
 # this tag can be used to specify a list of macro names that should be expanded.
--- a/ble/GattAttribute.h	Thu Dec 10 09:15:01 2015 +0000
+++ b/ble/GattAttribute.h	Thu Dec 10 09:15:01 2015 +0000
@@ -33,8 +33,8 @@
      *              The UUID to use for this attribute.
      *  @param[in]  valuePtr
      *              The memory holding the initial value.
-     *  @param[in]  initialLen
-     *              The min length in bytes of this attribute's value.
+     *  @param[in]  len
+     *              The length in bytes of this attribute's value.
      *  @param[in]  maxLen
      *              The max length in bytes of this attribute's value.
      *
@@ -47,8 +47,8 @@
      *
      *  @endcode
      */
-    GattAttribute(const UUID &uuid, uint8_t *valuePtr = NULL, uint16_t initialLen = 0, uint16_t maxLen = 0) :
-        _uuid(uuid), _valuePtr(valuePtr), _initialLen(initialLen), _lenMax(maxLen), _len(initialLen), _handle() {
+    GattAttribute(const UUID &uuid, uint8_t *valuePtr = NULL, uint16_t len = 0, uint16_t maxLen = 0) :
+        _uuid(uuid), _valuePtr(valuePtr), _lenMax(maxLen), _len(len), _handle() {
         /* Empty */
     }
 
@@ -56,7 +56,6 @@
     Handle_t    getHandle(void)        const {return _handle;    }
     const UUID &getUUID(void)          const {return _uuid;      }
     uint16_t    getLength(void)        const {return _len;       }
-    uint16_t    getInitialLength(void) const {return _initialLen;}
     uint16_t    getMaxLength(void)     const {return _lenMax;    }
     uint16_t   *getLengthPtr(void)           {return &_len;      }
     void        setHandle(Handle_t id)       {_handle = id;      }
@@ -65,7 +64,6 @@
 private:
     UUID      _uuid;        /* Characteristic UUID. */
     uint8_t  *_valuePtr;
-    uint16_t  _initialLen;  /* Initial length of the value. */
     uint16_t  _lenMax;      /* Maximum length of the value. */
     uint16_t  _len;         /* Current length of the value. */
     Handle_t  _handle;
--- a/ble/GattCharacteristic.h	Thu Dec 10 09:15:01 2015 +0000
+++ b/ble/GattCharacteristic.h	Thu Dec 10 09:15:01 2015 +0000
@@ -307,8 +307,8 @@
      *              The memory holding the initial value. The value is copied
      *              into the stack when the enclosing service is added, and
      *              is thereafter maintained internally by the stack.
-     *  @param[in]  initialLen
-     *              The min length in bytes of this characteristic's value.
+     *  @param[in]  len
+     *              The length in bytes of this characteristic's value.
      *  @param[in]  maxLen
      *              The max length in bytes of this characteristic's value.
      *  @param[in]  props
@@ -321,19 +321,19 @@
      *  @param[in]  numDescriptors
      *              The number of descriptors in the previous array.
      *
-     * @NOTE: If valuePtr == NULL, initialLength == 0, and properties == READ
+     * @NOTE: If valuePtr == NULL, length == 0, and properties == READ
      *        for the value attribute of a characteristic, then that particular
      *        characteristic may be considered optional and dropped while
      *        instantiating the service with the underlying BLE stack.
      */
     GattCharacteristic(const UUID    &uuid,
                        uint8_t       *valuePtr       = NULL,
-                       uint16_t       initialLen     = 0,
+                       uint16_t       len            = 0,
                        uint16_t       maxLen         = 0,
                        uint8_t        props          = BLE_GATT_CHAR_PROPERTIES_NONE,
                        GattAttribute *descriptors[]  = NULL,
                        unsigned       numDescriptors = 0) :
-        _valueAttribute(uuid, valuePtr, initialLen, maxLen),
+        _valueAttribute(uuid, valuePtr, len, maxLen),
         _properties(props),
         _requiredSecurity(SecurityManager::SECURITY_MODE_ENCRYPTION_OPEN_LINK),
         _descriptors(descriptors),
--- a/ble/services/EddystoneConfigService.h	Thu Dec 10 09:15:01 2015 +0000
+++ b/ble/services/EddystoneConfigService.h	Thu Dec 10 09:15:01 2015 +0000
@@ -42,7 +42,7 @@
 
 /**
 * @class EddystoneConfigService
-* @brief Eddystone Configuration Service. Can be used to set URL, adjust power levels, and set flags.
+* @brief Eddystone Configuration Service. Used to set URL, adjust power levels, and set flags.
 * See https://github.com/google/eddystone
 *
 */
@@ -61,54 +61,54 @@
     };
 
     static const unsigned ADVERTISING_INTERVAL_MSEC = 1000; // Advertising interval for config service.
-    static const unsigned SERVICE_DATA_MAX          = 31;   // Maximum size of service data in ADV packets
+    static const unsigned SERVICE_DATA_MAX          = 31;   // Maximum size of service data in ADV packets.
 
-    typedef uint8_t Lock_t[16];                             /* 128 bits */
+    typedef uint8_t Lock_t[16];                             /* 128 bits. */
     typedef int8_t PowerLevels_t[NUM_POWER_MODES];
 
-    // There are currently 3 subframes defined, URI, UID, and TLM
+    // There are currently three subframes defined: URI, UID, and TLM.
 #define EDDYSTONE_MAX_FRAMETYPE 3
     static const unsigned URI_DATA_MAX = 18;
     typedef uint8_t UriData_t[URI_DATA_MAX];
 
-    // UID Frame Type subfields
+    // UID Frame Type subfields.
     static const size_t UID_NAMESPACEID_SIZE = 10;
     typedef uint8_t UIDNamespaceID_t[UID_NAMESPACEID_SIZE];
     static const size_t UID_INSTANCEID_SIZE = 6;
     typedef uint8_t UIDInstanceID_t[UID_INSTANCEID_SIZE];
 
-    // Eddystone Frame Type ID
+    // Eddystone Frame Type ID.
     static const uint8_t FRAME_TYPE_UID = 0x00;
     static const uint8_t FRAME_TYPE_URL = 0x10;
     static const uint8_t FRAME_TYPE_TLM = 0x20;
 
-    static const uint8_t FRAME_SIZE_TLM = 14; // TLM frame is a constant 14Bytes
-    static const uint8_t FRAME_SIZE_UID = 20; // includes RFU bytes
+    static const uint8_t FRAME_SIZE_TLM = 14; // TLM frame is a constant 14B.
+    static const uint8_t FRAME_SIZE_UID = 20; // includes RFU bytes.
 
     struct Params_t {
         // Config Data
-        bool             isConfigured; // Flag for configuration being complete,
-                                       //   True = configured, false = not configured. Reset at instantiation, used for external callbacks.
+        bool             isConfigured; // Flag for configuration being complete:
+                                       //   True = configured, False = not configured. Reset at instantiation, used for external callbacks.
         uint8_t          lockedState;
         Lock_t           lock;
         uint8_t          flags;
-        PowerLevels_t    advPowerLevels;  // Current value of AdvertisedPowerLevels
-        uint8_t          txPowerMode;     // Firmware power levels used with setTxPower()
+        PowerLevels_t    advPowerLevels;  // Current value of AdvertisedPowerLevels.
+        uint8_t          txPowerMode;     // Firmware power levels used with setTxPower().
         uint16_t         beaconPeriod;
         // TLM Frame Data
-        uint8_t          tlmVersion;      // version of TLM packet
+        uint8_t          tlmVersion;      // Version of TLM packet.
         bool             tlmEnabled;
-        float            tlmBeaconPeriod; // how often to broadcat TLM frame, in seconds.
+        float            tlmBeaconPeriod; // How often to broadcat TLM frame, in seconds.
         // URI Frame Data
         uint8_t          uriDataLength;
         UriData_t        uriData;
         bool             uriEnabled;
-        float            uriBeaconPeriod; // how often to broadcast URIFrame, in seconds.
+        float            uriBeaconPeriod; // How often to broadcast URIFrame, in seconds.
         // UID Frame Data
-        UIDNamespaceID_t uidNamespaceID;  // UUID type, Namespace ID, 10B
-        UIDInstanceID_t  uidInstanceID;   // UUID type, Instance ID,  6B
+        UIDNamespaceID_t uidNamespaceID;  // UUID type, Namespace ID, 10B.
+        UIDInstanceID_t  uidInstanceID;   // UUID type, Instance ID, 6B.
         bool             uidEnabled;
-        float            uidBeaconPeriod; // how often to broadcast UID Frame, in seconds.
+        float            uidBeaconPeriod; // How often to broadcast UID Frame, in seconds.
     };
 
     /**
@@ -118,19 +118,19 @@
      *                    Reference to application-visible beacon state, loaded
      *                    from persistent storage at startup.
      * @param[in]     defaultAdvPowerLevelsIn
-     *                    Default power-levels array; applies only if the resetToDefaultsFlag is true.
+     *                    Default power-levels array; applies only if resetToDefaultsFlag is true.
      */
     EddystoneConfigService(BLEDevice     &bleIn,
                            Params_t      &paramsIn,
                            PowerLevels_t &defaultAdvPowerLevelsIn,
                            PowerLevels_t &radioPowerLevelsIn) :
         ble(bleIn),
-        params(paramsIn),       // Initialize URL Data
+        params(paramsIn),       // Initialize URL data.
         defaultAdvPowerLevels(defaultAdvPowerLevelsIn),
         radioPowerLevels(radioPowerLevelsIn),
         initSucceeded(false),
         resetFlag(),
-        defaultUidNamespaceID(), // Initialize UID Data
+        defaultUidNamespaceID(), // Initialize UID data.
         defaultUidInstanceID(),
         defaultUidPower(defaultAdvPowerLevelsIn[params.txPowerMode]),
         uidIsSet(false),
@@ -149,7 +149,7 @@
         txPowerModeChar(UUID_TX_POWER_MODE_CHAR, &params.txPowerMode),
         beaconPeriodChar(UUID_BEACON_PERIOD_CHAR, &params.beaconPeriod),
         resetChar(UUID_RESET_CHAR, &resetFlag) {
-        // set eddystone as not configured yet. Used to exit config before timeout if GATT services are written to.
+        // Set Eddystone as not configured yet. Used to exit config before timeout if GATT services are written to.
         params.isConfigured = false;
 
         lockChar.setWriteAuthorizationCallback(this, &EddystoneConfigService::lockAuthorizationCallback);
@@ -195,12 +195,12 @@
             updateCharacteristicValues();
         }
 
-        setupEddystoneConfigAdvertisements(); /* Setup advertising for the configService. */
+        setupEddystoneConfigAdvertisements(); /* Set up advertising for the config service. */
         initSucceeded = true;
     }
 
     /*
-    * Check if eddystone initialized successfully
+    * Check if Eddystone initialized successfully.
     */
     bool initSuccessfully(void) const {
         return initSucceeded;
@@ -209,8 +209,8 @@
     /*
     * @brief Function to update the default values for the TLM frame. Only applied if Reset Defaults is applied.
     *
-    * @param[in] tlmVersionIn     Version of the TLM frame being used
-    * @param[in] advPeriodInMin how long between TLM frames being advertised, this is measured in minutes.
+    * @param[in] tlmVersionIn     Version of the TLM frame being used.
+    * @param[in] advPeriodInMin How long between TLM frames being advertised, measured in minutes.
     *
     */
     void setDefaultTLMFrameData(uint8_t tlmVersionIn = 0, float advPeriodInSec = 60){
@@ -221,35 +221,35 @@
         TlmPduCount         = 0;
         TlmTimeSinceBoot    = 0;
         defaultTlmAdvPeriod = advPeriodInSec;
-        tlmIsSet            = true; // flag to add this to eddystone service when config is done
+        tlmIsSet            = true; // Flag to add this to Eddystone service when config is done.
     }
 
     /*
     * @brief Function to update the default values for the URI frame. Only applied if Reset Defaults is applied.
     *
-    * @param[in] uriIn      url to advertise
-    * @param[in] advPeriod  how long to advertise the url for, measured in number of ADV frames.
+    * @param[in] uriIn      URL to advertise.
+    * @param[in] advPeriod  How long to advertise the URL, measured in number of ADV frames.
     *
     */
     void setDefaultURIFrameData(const char *uriIn, float advPeriod = 1){
         DBG("Setting Default URI Data");
         // Set URL Frame
-        EddystoneService::encodeURL(uriIn, defaultUriData, defaultUriDataLength);   // encode URL to URL Formatting
+        EddystoneService::encodeURL(uriIn, defaultUriData, defaultUriDataLength);   // Encode URL to URL Formatting.
         if (defaultUriDataLength > URI_DATA_MAX) {
             return;
         }
         INFO("\t  URI input = %s : %d", uriIn, defaultUriDataLength);
         INFO("\t default URI = %s : %d ", defaultUriData, defaultUriDataLength );
         defaultUriAdvPeriod = advPeriod;
-        urlIsSet            = true; // flag to add this to eddystone service when config is done
+        urlIsSet            = true; // Flag to add this to Eddystone service when config is done.
     }
 
     /*
     * @brief Function to update the default values for the UID frame. Only applied if Reset Defaults is applied.
     *
-    * @param[in] namespaceID 10Byte Namespace ID
-    * @param[in] instanceID  6Byte Instance ID
-    * @param[in] advPeriod   how long to advertise the URL for, measured in the number of adv frames.
+    * @param[in] namespaceID 10Byte Namespace ID.
+    * @param[in] instanceID  6Byte Instance ID.
+    * @param[in] advPeriod   How long to advertise the URL, measured in the number of ADV frames.
     *
     */
     void setDefaultUIDFrameData(UIDNamespaceID_t *namespaceID, UIDInstanceID_t *instanceID, float advPeriod = 10){
@@ -258,12 +258,12 @@
         memcpy(defaultUidNamespaceID, namespaceID, UID_NAMESPACEID_SIZE);
         memcpy(defaultUidInstanceID,  instanceID,  UID_INSTANCEID_SIZE);
         defaultUidAdvPeriod = advPeriod;
-        uidIsSet            = true; // flag to add this to eddystone service when config is done
+        uidIsSet            = true; // Flag to add this to Eddystone service when config is done.
     }
 
-    /* Start out by advertising the configService for a limited time after
-     * startup; and switch to the normal non-connectible beacon functionality
-     * afterwards. */
+    /* Start out by advertising the config service for a limited time after
+     * startup, then switch to the normal non-connectible beacon functionality.
+     */
     void setupEddystoneConfigAdvertisements() {
         const char DEVICE_NAME[] = "eddystone Config";
 
@@ -271,7 +271,7 @@
 
         ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
 
-        // UUID is in different order in the ADV frame (!)
+        // UUID is in a different order in the ADV frame (!)
         uint8_t reversedServiceUUID[sizeof(UUID_URI_BEACON_SERVICE)];
         for (unsigned int i = 0; i < sizeof(UUID_URI_BEACON_SERVICE); i++) {
             reversedServiceUUID[i] = UUID_URI_BEACON_SERVICE[sizeof(UUID_URI_BEACON_SERVICE) - i - 1];
@@ -292,18 +292,18 @@
 
     /*
     *   This function actually impliments the Eddystone Beacon service. It can be called with the help of the wrapper function
-    *   to load saved config params, or it can be called explicitly to reset the eddystone beacon to hardcoded values on each reset.
+    *   to load saved config params, or it can be called explicitly to reset the Eddystone beacon to hardcoded values on each reset.
     *
     */
     void setupEddystoneAdvertisements() {
         DBG("Switching Config -> adv");
-        // Save params to storage
+        // Save params to storage.
         extern void saveURIBeaconConfigParams(const Params_t *paramsP); /* forward declaration; necessary to avoid a circular dependency. */
         saveURIBeaconConfigParams(&params);
         INFO("Saved Params to Memory.")
-        // Setup Eddystone Service
+        // Set up Eddystone Service.
         static EddystoneService eddyServ(ble, params.beaconPeriod, radioPowerLevels[params.txPowerMode]);
-        // Set configured frames (TLM,UID,URI...etc)
+        // Set configured frames (TLM, UID, URI and so on).
         if (params.tlmEnabled) {
             eddyServ.setTLMFrameData(params.tlmVersion, params.tlmBeaconPeriod);
         }
@@ -316,7 +316,7 @@
                                      (uint8_t *)params.uidInstanceID,
                                      params.uidBeaconPeriod);
         }
-        // Start Advertising the eddystone service.
+        // Start advertising the Eddystone service.
         eddyServ.start();
     }
 
@@ -330,19 +330,19 @@
         uint16_t handle = writeParams->handle;
 
         if (handle == lockChar.getValueHandle()) {
-            // Validated earlier
+            // Validated earlier.
             memcpy(params.lock, writeParams->data, sizeof(Lock_t));
-            // Set the state to be locked by the lock code (note: zeros are a valid lock)
+            // Set the state to be locked by the lock code (note: zeros are a valid lock).
             params.lockedState = true;
             INFO("Device Locked");
         } else if (handle == unlockChar.getValueHandle()) {
-            // Validated earlier
+            // Validated earlier.
             params.lockedState = false;
             INFO("Device Unlocked");
         } else if (handle == uriDataChar.getValueHandle()) {
             params.uriDataLength = writeParams->len;
-            memset(params.uriData, 0x00, URI_DATA_MAX);                      // clear URI string
-            memcpy(params.uriData, writeParams->data, writeParams->len); // set URI string
+            memset(params.uriData, 0x00, URI_DATA_MAX);                      // Clear URI string.
+            memcpy(params.uriData, writeParams->data, writeParams->len); // Set URI string.
             params.uriEnabled = true;
             INFO("URI = %s, URILen = %d", writeParams->data, writeParams->len);
         } else if (handle == flagsChar.getValueHandle()) {
@@ -377,7 +377,7 @@
             resetToDefaults();
         }
         updateCharacteristicValues();
-        params.isConfigured = true; // some configuration data has been passed, on disconnect switch to advertising mode.
+        params.isConfigured = true; // Some configuration data has been passed; on disconnect switch to advertising mode.
     }
 
     /*
@@ -385,7 +385,7 @@
      */
     void resetToDefaults(void) {
         INFO("Resetting to defaults");
-        // General
+        // General.
         params.lockedState = false;
         memset(params.lock, 0, sizeof(Lock_t));
         params.flags = 0x10;
@@ -393,18 +393,18 @@
         params.txPowerMode  = TX_POWER_MODE_LOW;
         params.beaconPeriod = (uint16_t) defaultUriAdvPeriod * 1000;
 
-        // TLM Frame
+        // TLM Frame.
         params.tlmVersion      = defaultTlmVersion;
         params.tlmBeaconPeriod = defaultTlmAdvPeriod;
         params.tlmEnabled      = tlmIsSet;
 
-        // URL Frame
+        // URL Frame.
         memcpy(params.uriData, defaultUriData, URI_DATA_MAX);
         params.uriDataLength   = defaultUriDataLength;
         params.uriBeaconPeriod = defaultUriAdvPeriod;
         params.uriEnabled      = urlIsSet;
 
-        // UID Frame
+        // UID Frame.
         memcpy(params.uidNamespaceID, defaultUidNamespaceID, UID_NAMESPACEID_SIZE);
         memcpy(params.uidInstanceID,  defaultUidInstanceID,  UID_INSTANCEID_SIZE);
         params.uidBeaconPeriod = defaultUidAdvPeriod;
@@ -496,15 +496,15 @@
     Params_t                                   &params;
     Ticker                                     timeSinceBootTick;
     Timeout                                    switchFrame;
-    // Default value that is restored on reset
-    PowerLevels_t                              &defaultAdvPowerLevels; // this goes into the advertising frames (radio power measured at 1m from device)
-    PowerLevels_t                              &radioPowerLevels;      // this configures the power levels of the radio
+    // Default value that is restored on reset.
+    PowerLevels_t                              &defaultAdvPowerLevels; // This goes into the advertising frames (radio power measured at 1m from device).
+    PowerLevels_t                              &radioPowerLevels;      // This configures the power levels of the radio.
     uint8_t                                    lockedState;
     bool                                       initSucceeded;
     uint8_t                                    resetFlag;
     bool                                       switchFlag;
 
-    //UID Default value that is restored on reset
+    //UID default value that is restored on reset.
     UIDNamespaceID_t                           defaultUidNamespaceID;
     UIDInstanceID_t                            defaultUidInstanceID;
     float                                      defaultUidAdvPeriod;
@@ -512,14 +512,14 @@
     uint16_t                                   uidRFU;
     bool                                       uidIsSet;
 
-    //URI  Default value that is restored on reset
+    //URI default value that is restored on reset.
     uint8_t                                    defaultUriDataLength;
     UriData_t                                  defaultUriData;
     int8_t                                     defaultUrlPower;
     float                                      defaultUriAdvPeriod;
     bool                                       urlIsSet;
 
-    //TLM  Default value that is restored on reset
+    //TLM default value that is restored on reset.
     uint8_t                                    defaultTlmVersion;
     float                                      defaultTlmAdvPeriod;
     volatile uint16_t                          TlmBatteryVoltage;
--- a/ble/services/LinkLossService.h	Thu Dec 10 09:15:01 2015 +0000
+++ b/ble/services/LinkLossService.h	Thu Dec 10 09:15:01 2015 +0000
@@ -21,9 +21,9 @@
 
 /**
 * @class LinkLossService
-* @brief This service defines behavior when a link is lost between two devices. <br>
-* Service:  https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.link_loss.xml <br>
-* Alertness Level Char: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.alert_level.xml <br>
+* @brief This service defines behavior when a link is lost between two devices.
+* Service:  https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.link_loss.xml
+* Alertness Level Char: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.alert_level.xml
 */
 class LinkLossService {
 public:
@@ -67,7 +67,7 @@
     }
 
     /**
-     * Update Alertness Level.
+     * Update alertness level.
      */
     void setAlertLevel(AlertLevel_t newLevel) {
         alertLevel = newLevel;
@@ -75,7 +75,7 @@
 
 protected:
     /**
-     * This callback allows receiving updates to the AlertLevel Characteristic.
+     * This callback allows receiving updates to the AlertLevel characteristic.
      *
      * @param[in] params
      *     Information about the characterisitc being updated.
--- a/ble/services/UARTService.h	Thu Dec 10 09:15:01 2015 +0000
+++ b/ble/services/UARTService.h	Thu Dec 10 09:15:01 2015 +0000
@@ -40,12 +40,12 @@
 extern const uint8_t  UARTServiceRXCharacteristicUUID[UUID::LENGTH_OF_LONG_UUID];
 
 /**
-* @class UARTService
-* @brief BLE Service to enable UART over BLE
+* @class UARTService.
+* @brief BLE Service to enable UART over BLE.
 */
 class UARTService {
 public:
-    /**< Maximum length of data (in bytes) that can be transmitted by the UART service module to the peer. */
+    /**< Maximum length of data (in bytes) that the UART service module can transmit to the peer. */
     static const unsigned BLE_UART_SERVICE_MAX_DATA_LEN = (BLE_GATT_MTU_SIZE_DEFAULT - 3);
 
 public:
@@ -87,20 +87,20 @@
 
     /**
      * We attempt to collect bytes before pushing them to the UART RX
-     * characteristic--writing to the RX characteristic will then generate
+     * characteristic; writing to the RX characteristic then generates
      * notifications for the client. Updates made in quick succession to a
-     * notification-generating characteristic will result in data being buffered
-     * in the bluetooth stack as notifications are sent out. The stack will have
-     * its limits for this buffering; typically a small number under 10.
+     * notification-generating characteristic result in data being buffered
+     * in the Bluetooth stack as notifications are sent out. The stack has
+     * its limits for this buffering - typically a small number under 10.
      * Collecting data into the sendBuffer buffer helps mitigate the rate of
      * updates. But we shouldn't buffer a large amount of data before updating
-     * the characteristic otherwise the client will need to turn around and make
+     * the characteristic, otherwise the client needs to turn around and make
      * a long read request; this is because notifications include only the first
      * 20 bytes of the updated data.
      *
-     * @param  buffer The received update
-     * @param  length Amount of characters to be appended.
-     * @return        Amount of characters appended to the rxCharacteristic.
+     * @param  buffer The received update.
+     * @param  length Number of characters to be appended.
+     * @return        Number of characters appended to the rxCharacteristic.
      */
     size_t write(const void *_buffer, size_t length) {
         size_t         origLength = length;
@@ -112,13 +112,13 @@
                 unsigned bytesRemainingInSendBuffer = BLE_UART_SERVICE_MAX_DATA_LEN - sendBufferIndex;
                 unsigned bytesToCopy                = (length < bytesRemainingInSendBuffer) ? length : bytesRemainingInSendBuffer;
 
-                /* copy bytes into sendBuffer */
+                /* Copy bytes into sendBuffer. */
                 memcpy(&sendBuffer[sendBufferIndex], &buffer[bufferIndex], bytesToCopy);
                 length          -= bytesToCopy;
                 sendBufferIndex += bytesToCopy;
                 bufferIndex     += bytesToCopy;
 
-                /* have we collected enough? */
+                /* Have we collected enough? */
                 if ((sendBufferIndex == BLE_UART_SERVICE_MAX_DATA_LEN) ||
                     // (sendBuffer[sendBufferIndex - 1] == '\r')          ||
                     (sendBuffer[sendBufferIndex - 1] == '\n')) {
@@ -134,14 +134,14 @@
     /**
      * Helper function to write out strings.
      * @param  str The received string.
-     * @return     Amount of characters appended to the rxCharacteristic.
+     * @return     Number of characters appended to the rxCharacteristic.
      */
     size_t writeString(const char *str) {
         return write(str, strlen(str));
     }
 
     /**
-     * Override for Stream::_putc()
+     * Override for Stream::_putc().
      * @param  c
      *         This function writes the character c, cast to an unsigned char, to stream.
      * @return
@@ -152,7 +152,7 @@
     }
 
     /**
-     * Override for Stream::_getc()
+     * Override for Stream::_getc().
      * @return
      *     The character read.
      */
@@ -168,7 +168,7 @@
     /**
      * This callback allows the UART service to receive updates to the
      * txCharacteristic. The application should forward the call to this
-     * function from the global onDataWritten() callback handler; or if that's
+     * function from the global onDataWritten() callback handler; if that's
      * not used, this method can be used as a callback directly.
      */
     void onDataWritten(const GattWriteCallbackParams *params) {
--- a/ble/services/URIBeaconConfigService.h	Thu Dec 10 09:15:01 2015 +0000
+++ b/ble/services/URIBeaconConfigService.h	Thu Dec 10 09:15:01 2015 +0000
@@ -47,18 +47,18 @@
 class URIBeaconConfigService {
   public:
     /**
-     * @brief Transmission Power Modes for UriBeacon
+     * @brief Transmission power modes for UriBeacon.
      */
-    static const uint8_t TX_POWER_MODE_LOWEST = 0; /*!< Lowest TX power mode */
-    static const uint8_t TX_POWER_MODE_LOW    = 1; /*!< Low TX power mode */
-    static const uint8_t TX_POWER_MODE_MEDIUM = 2; /*!< Medium TX power mode */
-    static const uint8_t TX_POWER_MODE_HIGH   = 3; /*!< High TX power mode */
-    static const unsigned NUM_POWER_MODES     = 4; /*!< Number of Power Modes defined */
+    static const uint8_t TX_POWER_MODE_LOWEST = 0; /*!< Lowest TX power mode. */
+    static const uint8_t TX_POWER_MODE_LOW    = 1; /*!< Low TX power mode. */
+    static const uint8_t TX_POWER_MODE_MEDIUM = 2; /*!< Medium TX power mode. */
+    static const uint8_t TX_POWER_MODE_HIGH   = 3; /*!< High TX power mode. */
+    static const unsigned NUM_POWER_MODES     = 4; /*!< Number of power modes defined. */
 
     static const int ADVERTISING_INTERVAL_MSEC = 1000;  // Advertising interval for config service.
-    static const int SERVICE_DATA_MAX = 31;             // Maximum size of service data in ADV packets
+    static const int SERVICE_DATA_MAX = 31;             // Maximum size of service data in ADV packets.
 
-    typedef uint8_t Lock_t[16];               /* 128 bits */
+    typedef uint8_t Lock_t[16];               /* 128 bits. */
     typedef int8_t PowerLevels_t[NUM_POWER_MODES];
 
     static const int URI_DATA_MAX = 18;
@@ -69,8 +69,8 @@
         uint8_t       uriDataLength;
         UriData_t     uriData;
         uint8_t       flags;
-        PowerLevels_t advPowerLevels; // Current value of AdvertisedPowerLevels
-        uint8_t       txPowerMode;    // Firmware power levels used with setTxPower()
+        PowerLevels_t advPowerLevels; // Current value of AdvertisedPowerLevels.
+        uint8_t       txPowerMode;    // Firmware power levels used with setTxPower().
         uint16_t      beaconPeriod;
     };
 
@@ -86,9 +86,9 @@
      *                    un-initialized, and default values should be used
      *                    instead. Otherwise, paramsIn overrides the defaults.
      * @param[in]     defaultUriDataIn
-     *                    Default un-encoded URI; applies only if the resetToDefaultsFlag is true.
+     *                    Default un-encoded URI. Applies only if the resetToDefaultsFlag is true.
      * @param[in]     defaultAdvPowerLevelsIn
-     *                    Default power-levels array; applies only if the resetToDefaultsFlag is true.
+     *                    Default power-levels array. Applies only if the resetToDefaultsFlag is true.
      */
     URIBeaconConfigService(BLE          &bleIn,
                            Params_t      &paramsIn,
@@ -148,7 +148,7 @@
         ble.addService(configService);
         ble.onDataWritten(this, &URIBeaconConfigService::onDataWrittenCallback);
 
-        setupURIBeaconConfigAdvertisements(); /* Setup advertising for the configService. */
+        setupURIBeaconConfigAdvertisements(); /* Set up advertising for the config service. */
 
         initSucceeded = true;
     }
@@ -157,9 +157,9 @@
         return initSucceeded;
     }
 
-    /* Start out by advertising the configService for a limited time after
-     * startup; and switch to the normal non-connectible beacon functionality
-     * afterwards. */
+    /* Start out by advertising the config service for a limited time after
+     * startup. Then switch to the normal non-connectible beacon functionality.
+     */
     void setupURIBeaconConfigAdvertisements()
     {
         const char DEVICE_NAME[] = "mUriBeacon Config";
@@ -186,14 +186,14 @@
         ble.gap().setAdvertisingInterval(GapAdvertisingParams::MSEC_TO_ADVERTISEMENT_DURATION_UNITS(ADVERTISING_INTERVAL_MSEC));
     }
 
-    /* Helper function to switch to the non-connectible normal mode for URIBeacon. This gets called after a timeout. */
+    /* Helper function to switch to the non-connectible normal mode for UriBeacon. This gets called after a timeout. */
     void setupURIBeaconAdvertisements()
     {
         /* Reinitialize the BLE stack. This will clear away the existing services and advertising state. */
         ble.shutdown();
         ble.init();
 
-        // Fields from the Service
+        // Fields from the service.
         unsigned beaconPeriod                                 = params.beaconPeriod;
         unsigned txPowerMode                                  = params.txPowerMode;
         unsigned uriDataLength                                = params.uriDataLength;
@@ -201,7 +201,7 @@
         URIBeaconConfigService::PowerLevels_t &advPowerLevels = params.advPowerLevels;
         uint8_t flags                                         = params.flags;
 
-        extern void saveURIBeaconConfigParams(const Params_t *paramsP); /* forward declaration; necessary to avoid a circular dependency. */
+        extern void saveURIBeaconConfigParams(const Params_t *paramsP); /* Forward declaration; necessary to avoid a circular dependency. */
         saveURIBeaconConfigParams(&params);
 
         ble.gap().clearAdvertisingPayload();
@@ -224,7 +224,7 @@
     }
 
   private:
-    // True if the lock bits are non-zero
+    // True if the lock bits are non-zero.
     bool isLocked() {
         Lock_t testLock;
         memset(testLock, 0, sizeof(Lock_t));
@@ -233,19 +233,19 @@
 
     /*
      * This callback is invoked when a GATT client attempts to modify any of the
-     * characteristics of this service. Attempts to do so are also applied to
+     * characteristics of this service. These attempts are also applied to
      * the internal state of this service object.
      */
     void onDataWrittenCallback(const GattWriteCallbackParams *writeParams) {
         uint16_t handle = writeParams->handle;
 
         if (handle == lockChar.getValueHandle()) {
-            // Validated earlier
+            // Validated earlier,
             memcpy(params.lock, writeParams->data, sizeof(Lock_t));
-            // use isLocked() in case bits are being set to all 0's
+            // Use isLocked() in case bits are being set to all zeros.
             lockedState = isLocked();
         } else if (handle == unlockChar.getValueHandle()) {
-            // Validated earlier
+            // Validated earlier.
             memset(params.lock, 0, sizeof(Lock_t));
             lockedState = false;
         } else if (handle == uriDataChar.getValueHandle()) {
@@ -260,7 +260,7 @@
         } else if (handle == beaconPeriodChar.getValueHandle()) {
             params.beaconPeriod = *((uint16_t *)(writeParams->data));
 
-            /* Re-map beaconPeriod to within permissible bounds if necessary. */
+            /* Remap beaconPeriod to within permissible bounds if necessary. */
             if (params.beaconPeriod != 0) {
                 bool paramsUpdated = false;
                 if (params.beaconPeriod < ble.gap().getMinAdvertisingInterval()) {
@@ -378,9 +378,9 @@
     BLE           &ble;
     Params_t      &params;
 
-    size_t        defaultUriDataLength;   // Default value that is restored on reset
-    UriData_t     defaultUriData;         // Default value that is restored on reset
-    PowerLevels_t &defaultAdvPowerLevels; // Default value that is restored on reset
+    size_t        defaultUriDataLength;   // Default value that is restored on reset.
+    UriData_t     defaultUriData;         // Default value that is restored on reset.
+    PowerLevels_t &defaultAdvPowerLevels; // Default value that is restored on reset.
 
     uint8_t       lockedState;
     bool          initSucceeded;
@@ -398,7 +398,7 @@
 
 public:
     /*
-     *  Encode a human-readable URI into the binary format defined by URIBeacon spec (https://github.com/google/uribeacon/tree/master/specification).
+     *  Encode a human-readable URI into the binary format defined by the UriBeacon spec (https://github.com/google/uribeacon/tree/master/specification).
      */
     static void encodeURI(const char *uriDataIn, UriData_t uriDataOut, size_t &sizeofURIDataOut) {
         const char *prefixes[] = {
@@ -447,7 +447,7 @@
         }
 
         /*
-         * handle suffixes
+         * Handle suffixes.
          */
         while (*uriDataIn && (sizeofURIDataOut < URI_DATA_MAX)) {
             /* check for suffix match */
@@ -457,10 +457,10 @@
                 if (strncmp(uriDataIn, suffixes[i], suffixLen) == 0) {
                     uriDataOut[sizeofURIDataOut++]  = i;
                     uriDataIn                      += suffixLen;
-                    break; /* from the for loop for checking against suffixes */
+                    break; /* From the for loop for checking against suffixes. */
                 }
             }
-            /* This is the default case where we've got an ordinary character which doesn't match a suffix. */
+            /* This is the default case where we've got an ordinary character that doesn't match a suffix. */
             if (i == NUM_SUFFIXES) {
                 uriDataOut[sizeofURIDataOut++] = *uriDataIn;
                 ++uriDataIn;
--- a/ble/services/iBeacon.h	Thu Dec 10 09:15:01 2015 +0000
+++ b/ble/services/iBeacon.h	Thu Dec 10 09:15:01 2015 +0000
@@ -21,7 +21,7 @@
 
 /**
 * @class iBeacon
-* @brief iBeacon Service. This sets up a device to broadcast advertising packets to mimic an iBeacon<br>
+* @brief iBeacon Service. This sets up a device to broadcast advertising packets to mimic an iBeacon.
 */
 class iBeacon
 {
@@ -56,12 +56,12 @@
             uint16_t        compID = 0x004C) :
         ble(_ble), data(uuid, majNum, minNum, txP, compID)
     {
-        // Generate the 0x020106 part of the iBeacon Prefix
+        // Generate the 0x020106 part of the iBeacon Prefix.
         ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE );
-        // Generate the 0x1AFF part of the iBeacon Prefix
+        // Generate the 0x1AFF part of the iBeacon Prefix.
         ble.accumulateAdvertisingPayload(GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA, data.raw, sizeof(data.raw));
 
-        // Set advertising type
+        // Set advertising type.
         ble.setAdvertisingType(GapAdvertisingParams::ADV_NON_CONNECTABLE_UNDIRECTED);
     }
 
--- a/module.json	Thu Dec 10 09:15:01 2015 +0000
+++ b/module.json	Thu Dec 10 09:15:01 2015 +0000
@@ -1,6 +1,6 @@
 {
   "name": "ble",
-  "version": "2.1.4",
+  "version": "2.1.5",
   "description": "The BLE module offers a high level abstraction for using Bluetooth Low Energy on multiple platforms.",
   "keywords": [
     "Bluetooth",
@@ -26,7 +26,7 @@
       "x-nucleo-idb0xa1": "ARMmbed/ble-x-nucleo-idb0xa1"
     },
     "nrf51822": {
-      "ble-nrf51822": "^2.0.0"
+      "ble-nrf51822": "^2.1.1"
     },
     "cordio": {
       "ble-wicentric": "~0.0.4"