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.
Dependents: BLE_PowerBank_HeyFaradey
Fork of BLE_API by
Revision 1056:ce2fb3d09929, committed 2016-01-11
- Comitter:
- vcoubard
- Date:
- Mon Jan 11 08:51:34 2016 +0000
- Parent:
- 1055:576c739b56a2
- Child:
- 1057:93a9679d655c
- Commit message:
- Synchronized with git rev d363d7ee
Author: Rohit Grover
Merge branch 'develop'
Changed in this revision
--- a/DOXYGEN_FRONTPAGE.md Mon Jan 11 08:51:33 2016 +0000 +++ b/DOXYGEN_FRONTPAGE.md Mon Jan 11 08:51:34 2016 +0000 @@ -4,8 +4,7 @@ Bluetooth Low Energy on multiple platforms. This documentation describes the internal structure of the mbed -[BLE API](https://github.com/armmbed/ble). It was automatically generated from -specially formatted comment blocks in BLE API's source code using Doxygen (see http://www.stack.nl/~dimitri/doxygen/ for more information on Doxygen). +[BLE API](https://github.com/armmbed/ble). For getting started with BLE on mbed, check our [introduction page](https://docs.mbed.com/docs/ble-intros/en/latest/).
--- a/ble.doxyfile Mon Jan 11 08:51:33 2016 +0000 +++ b/ble.doxyfile Mon Jan 11 08:51:34 2016 +0000 @@ -131,7 +131,7 @@ # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. -FULL_PATH_NAMES = NO +FULL_PATH_NAMES = YES # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is @@ -165,7 +165,7 @@ # comments will behave just like regular Qt-style comments # (thus requiring an explicit @brief command for a brief description.) -JAVADOC_AUTOBRIEF = YES +JAVADOC_AUTOBRIEF = NO # If the QT_AUTOBRIEF tag is set to YES then Doxygen will # interpret the first line (until the first dot) of a Qt-style @@ -245,15 +245,21 @@ # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given # extension. Doxygen has a built-in mapping, but you can override or extend it -# using this tag. The format is ext=language, where ext is a file extension, -# and language is one of the parsers supported by doxygen: IDL, Java, -# Javascript, CSharp, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, -# C++. For instance to make doxygen treat .inc files as Fortran files (default -# is PHP), and .f files as C (default is Fortran), use: inc=Fortran f=C. Note -# that for custom extensions you also need to set FILE_PATTERNS otherwise the -# files are not read by doxygen. - -EXTENSION_MAPPING = +# using this tag. The format is ext=language, where ext is a file extension, and +# language is one of the parsers supported by doxygen: IDL, Java, Javascript, +# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: +# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: +# Fortran. In the later case the parser tries to guess whether the code is fixed +# or free formatted code, this is the default for Fortran type files), VHDL. For +# instance to make doxygen treat .inc files as Fortran files (default is PHP), +# and .f files as C (default is Fortran), use: inc=Fortran f=C. +# +# Note: For files without extension you can use no_extension as a placeholder. +# +# Note that for custom extensions you also need to set FILE_PATTERNS otherwise +# the files are not read by doxygen. + +EXTENSION_MAPPING = h=C++ # If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all # comments according to the Markdown format, which allows for more readable @@ -361,12 +367,12 @@ # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES -EXTRACT_ALL = YES +EXTRACT_ALL = NO # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. -EXTRACT_PRIVATE = YES +EXTRACT_PRIVATE = NO # If the EXTRACT_PACKAGE tag is set to YES all members with package or internal # scope will be included in the documentation. @@ -376,7 +382,7 @@ # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. -EXTRACT_STATIC = YES +EXTRACT_STATIC = NO # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. @@ -389,7 +395,7 @@ # the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. -EXTRACT_LOCAL_METHODS = YES +EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called @@ -488,7 +494,7 @@ # This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO # and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. -SORT_MEMBERS_CTORS_1ST = NO +SORT_MEMBERS_CTORS_1ST = YES # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the # hierarchy of group names into alphabetical order. If set to NO (the default) @@ -638,7 +644,7 @@ # wrong or incomplete parameter documentation, but not about the absence of # documentation. -WARN_NO_PARAMDOC = NO +WARN_NO_PARAMDOC = YES # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text @@ -653,10 +659,10 @@ # and error messages should be written. If left blank the output is written # to stderr. -WARN_LOGFILE = +WARN_LOGFILE = doxygen_warn.log #--------------------------------------------------------------------------- -# configuration options related to the input files +# Configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain @@ -731,7 +737,7 @@ # and *.h) to filter out the source-files in the directories. If left # blank all files are included. -EXAMPLE_PATTERNS = * +EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude @@ -833,6 +839,16 @@ REFERENCES_LINK_SOURCE = YES +# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the +# source code will show a tooltip with additional information such as prototype, +# brief description and links to the definition and documentation. Since this +# will make the HTML file larger and loading of large files a bit slower, you +# can opt to disable this feature. +# The default value is: YES. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +SOURCE_TOOLTIPS = YES + # If the USE_HTAGS tag is set to YES then the references to source code # will point to the HTML generated by the htags(1) tool instead of doxygen # built-in source browser. The htags tool is part of GNU's global source @@ -855,7 +871,7 @@ # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. -ALPHABETICAL_INDEX = NO +ALPHABETICAL_INDEX = YES # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns @@ -871,7 +887,7 @@ IGNORE_PREFIX = #--------------------------------------------------------------------------- -# configuration options related to the HTML output +# Configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will @@ -1131,9 +1147,11 @@ GENERATE_ECLIPSEHELP = NO -# A unique identifier for the eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have -# this name. +# A unique identifier for the Eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have this +# name. Each documentation set should have its own identifier. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. ECLIPSE_DOC_ID = org.doxygen.Project @@ -1237,7 +1255,7 @@ # typically be disabled. For large projects the javascript based search engine # can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. -SEARCHENGINE = NO +SEARCHENGINE = YES # When the SERVER_BASED_SEARCH tag is enabled the search engine will be # implemented using a web server instead of a web client using Javascript. @@ -1273,10 +1291,11 @@ SEARCHDATA_FILE = searchdata.xml -# When SERVER_BASED_SEARCH AND EXTERNAL_SEARCH are both enabled the +# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the # EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is # useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple # projects and redirect the results back to the right project. +# This tag requires that the tag SEARCHENGINE is set to YES. EXTERNAL_SEARCH_ID = @@ -1290,7 +1309,7 @@ EXTRA_SEARCH_MAPPINGS = #--------------------------------------------------------------------------- -# configuration options related to the LaTeX output +# Configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will @@ -1396,7 +1415,7 @@ LATEX_BIB_STYLE = plain #--------------------------------------------------------------------------- -# configuration options related to the RTF output +# Configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output @@ -1685,7 +1704,7 @@ # this option also works with HAVE_DOT disabled, but it is recommended to # install and use dot, since it yields more powerful graphs. -CLASS_DIAGRAMS = NO +CLASS_DIAGRAMS = YES # You can define message sequence charts within doxygen comments using the \msc # command. Doxygen will then run the mscgen tool (see
--- a/ble/DiscoveredCharacteristic.h Mon Jan 11 08:51:33 2016 +0000
+++ b/ble/DiscoveredCharacteristic.h Mon Jan 11 08:51:34 2016 +0000
@@ -137,13 +137,13 @@
*/
ble_error_t write(uint16_t length, const uint8_t *value) const;
- /**
+ /**
* Same as above but register the callback wich will be called once the data has been written
*/
ble_error_t write(uint16_t length, const uint8_t *value, const GattClient::WriteCallback_t& onRead) const;
- void setupLongUUID(UUID::LongUUIDBytes_t longUUID) {
- uuid.setupLong(longUUID);
+ void setupLongUUID(UUID::LongUUIDBytes_t longUUID, UUID::ByteOrder_t order = UUID::MSB) {
+ uuid.setupLong(longUUID, order);
}
public:
--- a/ble/DiscoveredService.h Mon Jan 11 08:51:33 2016 +0000
+++ b/ble/DiscoveredService.h Mon Jan 11 08:51:34 2016 +0000
@@ -36,8 +36,8 @@
endHandle = endHandleIn;
}
- void setupLongUUID(UUID::LongUUIDBytes_t longUUID) {
- uuid.setupLong(longUUID);
+ void setupLongUUID(UUID::LongUUIDBytes_t longUUID, UUID::ByteOrder_t order = UUID::MSB) {
+ uuid.setupLong(longUUID, order);
}
public:
--- a/ble/Gap.h Mon Jan 11 08:51:33 2016 +0000
+++ b/ble/Gap.h Mon Jan 11 08:51:34 2016 +0000
@@ -183,14 +183,16 @@
}
/**
- * @return Minimum Advertising interval in milliseconds.
+ * @return Minimum Advertising interval in milliseconds for connectable
+ * undirected and connectable directed event types.
*/
virtual uint16_t getMinAdvertisingInterval(void) const {
return 0; /* Requesting action from porter(s): override this API if this capability is supported. */
}
/**
- * @return Minimum Advertising interval in milliseconds for non-connectible mode.
+ * @return Minimum Advertising interval in milliseconds for scannable
+ * undirected and non-connectable undirected event types.
*/
virtual uint16_t getMinNonConnectableAdvertisingInterval(void) const {
return 0; /* Requesting action from porter(s): override this API if this capability is supported. */
@@ -464,11 +466,6 @@
* peripheral faster, at the expense of more power being used by the radio
* due to the higher data transmit rate.
*
- * @note: This API is now *deprecated* and will be dropped in the future.
- * You should use the parallel API from Gap directly. A former call to
- * ble.setAdvertisingInterval(...) should now be achieved using
- * ble.gap().setAdvertisingInterval(...).
- *
* @Note: [WARNING] This API previously used 0.625ms as the unit for its
* 'interval' argument. That required an explicit conversion from
* milliseconds using Gap::MSEC_TO_GAP_DURATION_UNITS(). This conversion is
--- a/ble/UUID.h Mon Jan 11 08:51:33 2016 +0000
+++ b/ble/UUID.h Mon Jan 11 08:51:34 2016 +0000
@@ -19,9 +19,27 @@
#include <stdint.h>
#include <string.h>
+#include <algorithm>
#include "blecommon.h"
+/**
+ * A trivial converter for single hexadecimal character to unsigned-int.
+ * @param c hexadecimal character.
+ * @return the corresponding value as unsigned int.
+ */
+static uint8_t char2int(char c) {
+ if ((c >= '0') && (c <= '9')) {
+ return c - '0';
+ } else if ((c >= 'a') && (c <= 'f')) {
+ return c - 'a' + 10;
+ } else if ((c >= 'A') && (c <= 'F')) {
+ return c - 'A' + 10;
+ } else {
+ return 0;
+ }
+}
+
class UUID {
public:
enum UUID_Type_t {
@@ -29,12 +47,75 @@
UUID_TYPE_LONG = 1 // Full 128-bit UUID.
};
+ /**
+ * An enumeration to specify byte ordering of the long version of the UUID.
+ */
+ typedef enum {
+ MSB, /*!< Most-significant byte first (at the smallest address) */
+ LSB /*!< least-significant byte first (at the smallest address) */
+ } ByteOrder_t;
+
typedef uint16_t ShortUUIDBytes_t;
static const unsigned LENGTH_OF_LONG_UUID = 16;
typedef uint8_t LongUUIDBytes_t[LENGTH_OF_LONG_UUID];
+ static const unsigned MAX_UUID_STRING_LENGTH = LENGTH_OF_LONG_UUID * 2 + 4;
+
public:
+
+ /**
+ * Creates a new 128-bit UUID.
+ *
+ * @note The UUID is a unique 128-bit (16 byte) ID used to identify
+ * different service or characteristics on the BLE device.
+ *
+ * @param stringUUID
+ * The 128-bit (16-byte) UUID as a human readable const-string.
+ * Format: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
+ * Upper and lower case supported. Hyphens are optional, but only
+ * upto four of them. The UUID is stored internally as a 16 byte
+ * array, LSB (little endian), which is opposite from the string.
+ */
+ UUID(const char* stringUUID) : type(UUID_TYPE_LONG), baseUUID(), shortUUID(0) {
+ bool nibble = false;
+ uint8_t byte = 0;
+ size_t baseIndex = 0;
+ uint8_t tempUUID[LENGTH_OF_LONG_UUID];
+
+ // Iterate through string, abort if NULL is encountered prematurely.
+ // Ignore upto four hyphens.
+ for (size_t index = 0; (index < MAX_UUID_STRING_LENGTH) && (baseIndex < LENGTH_OF_LONG_UUID); index++) {
+ if (stringUUID[index] == '\0') {
+ // error abort
+ break;
+ } else if (stringUUID[index] == '-') {
+ // ignore hyphen
+ continue;
+ } else if (nibble) {
+ // got second nibble
+ byte |= char2int(stringUUID[index]);
+ nibble = false;
+
+ // store copy
+ tempUUID[baseIndex++] = byte;
+ } else {
+ // got first nibble
+ byte = char2int(stringUUID[index]) << 4;
+ nibble = true;
+ }
+ }
+
+ // populate internal variables if string was successfully parsed
+ if (baseIndex == LENGTH_OF_LONG_UUID) {
+ setupLong(tempUUID, UUID::MSB);
+ } else {
+ const uint8_t sig[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
+ 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB };
+ setupLong(sig, UUID::MSB);
+ }
+ }
+
/**
* Creates a new 128-bit UUID.
*
@@ -42,10 +123,12 @@
* different service or characteristics on the BLE device.
*
* @param longUUID
- * The 128-bit (16-byte) UUID value, MSB first (big-endian).
+ * The 128-bit (16-byte) UUID value.
+ * @param order
+ * The bit order of the UUID, MSB by default.
*/
- UUID(const LongUUIDBytes_t longUUID) : type(UUID_TYPE_LONG), baseUUID(), shortUUID(0) {
- setupLong(longUUID);
+ UUID(const LongUUIDBytes_t longUUID, ByteOrder_t order = UUID::MSB) : type(UUID_TYPE_LONG), baseUUID(), shortUUID(0) {
+ setupLong(longUUID, order);
}
/**
@@ -91,10 +174,15 @@
/**
* Fill in a 128-bit UUID; this is useful when the UUID isn't known at the time of the object construction.
*/
- void setupLong(const LongUUIDBytes_t longUUID) {
+ void setupLong(const LongUUIDBytes_t longUUID, ByteOrder_t order = UUID::MSB) {
type = UUID_TYPE_LONG;
- memcpy(baseUUID, longUUID, LENGTH_OF_LONG_UUID);
- shortUUID = (uint16_t)((longUUID[2] << 8) | (longUUID[3]));
+ if (order == UUID::MSB) {
+ // Switch endian. Input is big-endian, internal representation is little endian.
+ std::reverse_copy(longUUID, longUUID + LENGTH_OF_LONG_UUID, baseUUID);
+ } else {
+ std::copy(longUUID, longUUID + LENGTH_OF_LONG_UUID, baseUUID);
+ }
+ shortUUID = (uint16_t)((baseUUID[13] << 8) | (baseUUID[12]));
}
public:
@@ -132,12 +220,8 @@
private:
UUID_Type_t type; // UUID_TYPE_SHORT or UUID_TYPE_LONG
- LongUUIDBytes_t baseUUID; /* The base of the long UUID (if
- * used). Note: bytes 12 and 13 (counting from LSB)
- * are zeroed out to allow comparison with other long
- * UUIDs, which differ only in the 16-bit relative
- * part.*/
- ShortUUIDBytes_t shortUUID; // 16 bit UUID (byte 2-3 using with base).
+ LongUUIDBytes_t baseUUID; // The long UUID
+ ShortUUIDBytes_t shortUUID; // 16 bit UUID
};
#endif // ifndef __UUID_H__
\ No newline at end of file
--- a/ble/services/EnvironmentalService.h Mon Jan 11 08:51:33 2016 +0000
+++ b/ble/services/EnvironmentalService.h Mon Jan 11 08:51:34 2016 +0000
@@ -21,10 +21,10 @@
/**
* @class EnvironmentalService
-* @brief BLE Environmental Service. This service provides the location of the thermometer and the temperature. <br>
-* Service: https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.environmental_sensing.xml <br>
-* Temperature: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.temperature.xml <br>
-* Humidity: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.humidity.xml <br>
+* @brief BLE Environmental Service. This service provides temperature, humidity and pressure measurement.
+* Service: https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.environmental_sensing.xml
+* Temperature: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.temperature.xml
+* Humidity: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.humidity.xml
* Pressure: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.pressure.xml
*/
class EnvironmentalService {
--- a/ble/services/HealthThermometerService.h Mon Jan 11 08:51:33 2016 +0000
+++ b/ble/services/HealthThermometerService.h Mon Jan 11 08:51:34 2016 +0000
@@ -21,34 +21,34 @@
/**
* @class HealthThermometerService
-* @brief BLE Health Thermometer Service. This service provides the location of the thermometer and the temperature. <br>
-* Service: https://developer.bluetooth.org/gatt/profiles/Pages/ProfileViewer.aspx?u=org.bluetooth.profile.health_thermometer.xml <br>
-* Temperature Measurement: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.temperature_measurement.xml <br>
+* @brief BLE Health Thermometer Service. This service provides the location of the thermometer and the temperature.
+* Service: https://developer.bluetooth.org/gatt/profiles/Pages/ProfileViewer.aspx?u=org.bluetooth.profile.health_thermometer.xml
+* Temperature Measurement: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.temperature_measurement.xml
* Temperature Type: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.temperature_type.xml
*/
class HealthThermometerService {
public:
/**
- * @enum Sensor Location
- * @brief Location of sensor on the body
+ * @enum Sensor Location.
+ * @brief Location of sensor on the body.
*/
enum SensorLocation_t {
- LOCATION_ARMPIT = 1, /*!< armpit */
- LOCATION_BODY, /*!< body */
- LOCATION_EAR, /*!< ear */
- LOCATION_FINGER, /*!< finger */
+ LOCATION_ARMPIT = 1, /*!< Armpit. */
+ LOCATION_BODY, /*!< Body. */
+ LOCATION_EAR, /*!< Ear. */
+ LOCATION_FINGER, /*!< Finger. */
LOCATION_GI_TRACT, /*!< GI tract */
- LOCATION_MOUTH, /*!< mouth */
- LOCATION_RECTUM, /*!< rectum */
- LOCATION_TOE, /*!< toe */
- LOCATION_EAR_DRUM, /*!< ear drum */
+ LOCATION_MOUTH, /*!< Mouth. */
+ LOCATION_RECTUM, /*!< Rectum. */
+ LOCATION_TOE, /*!< Toe. */
+ LOCATION_EAR_DRUM, /*!< Eardrum. */
};
public:
/**
- * @brief Add the Health Thermometer Service to an existing ble object, initialize with temperature and location.
- * @param[ref] _ble reference to the BLE device
- * @param[in] initialTemp initial value in celsius
+ * @brief Add the Health Thermometer Service to an existing BLE object, initialize with temperature and location.
+ * @param[ref] _ble Reference to the BLE device.
+ * @param[in] initialTemp Initial value in celsius.
* @param[in] _location
*/
HealthThermometerService(BLE &_ble, float initialTemp, uint8_t _location) :
@@ -64,10 +64,10 @@
}
/**
- * @brief Update the temperature being broadcast
+ * @brief Update the temperature being broadcast.
*
* @param[in] temperature
- * Floating point value of the temperature
+ * Floating point value of the temperature.
*
*/
void updateTemperature(float temperature) {
@@ -80,14 +80,14 @@
/**
* @brief Update the location.
* @param loc
- * new location value.
+ * New location value.
*/
void updateLocation(SensorLocation_t loc) {
ble.gattServer().write(tempLocation.getValueHandle(), reinterpret_cast<uint8_t *>(&loc), sizeof(uint8_t));
}
private:
- /* Private internal representation for the bytes used to work with the vaulue of the heart-rate characteristic. */
+ /* Private internal representation for the bytes used to work with the vaulue of the temperature characteristic. */
struct TemperatureValueBytes {
static const unsigned OFFSET_OF_FLAGS = 0;
static const unsigned OFFSET_OF_VALUE = OFFSET_OF_FLAGS + sizeof(uint8_t);
@@ -101,7 +101,7 @@
static const uint8_t TEMPERATURE_UNITS_FAHRENHEIT = 1;
TemperatureValueBytes(float initialTemperature) : bytes() {
- /* assumption: temperature values are expressed in Celsius */
+ /* Assumption: temperature values are expressed in celsius */
bytes[OFFSET_OF_FLAGS] = (TEMPERATURE_UNITS_CELSIUS << TEMPERATURE_UNITS_FLAG_POS) |
(false << TIMESTAMP_FLAG_POS) |
(false << TEMPERATURE_TYPE_FLAG_POS);
@@ -128,15 +128,15 @@
* @return The temperature in 11073-20601 FLOAT-Type format.
*/
uint32_t quick_ieee11073_from_float(float temperature) {
- uint8_t exponent = 0xFE; //exponent is -2
+ uint8_t exponent = 0xFE; //Exponent is -2
uint32_t mantissa = (uint32_t)(temperature * 100);
return (((uint32_t)exponent) << 24) | mantissa;
}
private:
- /* First byte = 8-bit flags, Second field is a float holding the temperature value. */
- /* See --> https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.temperature_measurement.xml */
+ /* First byte: 8-bit flags. Second field is a float holding the temperature value. */
+ /* See https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.temperature_measurement.xml */
uint8_t bytes[SIZEOF_VALUE_BYTES];
};
--- a/ble/services/HeartRateService.h Mon Jan 11 08:51:33 2016 +0000
+++ b/ble/services/HeartRateService.h Mon Jan 11 08:51:34 2016 +0000
@@ -21,35 +21,35 @@
/**
* @class HeartRateService
-* @brief BLE Service for HeartRate. This BLE Service contains the location of the sensor, the heartrate in beats per minute. <br>
-* Service: https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.heart_rate.xml <br>
-* HRM Char: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.heart_rate_measurement.xml <br>
+* @brief BLE Service for HeartRate. This BLE Service contains the location of the sensor and the heart rate in beats per minute.
+* Service: https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.heart_rate.xml
+* HRM Char: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.heart_rate_measurement.xml
* Location: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.body_sensor_location.xml
*/
class HeartRateService {
public:
/**
* @enum SensorLocation
- * @brief Location of HeartRate sensor on body.
+ * @brief Location of the heart rate sensor on body.
*/
enum {
- LOCATION_OTHER = 0, /*!< Other Location */
- LOCATION_CHEST, /*!< Chest */
- LOCATION_WRIST, /*!< Wrist */
- LOCATION_FINGER, /*!< Finger */
- LOCATION_HAND, /*!< Hand */
- LOCATION_EAR_LOBE, /*!< Earlobe */
- LOCATION_FOOT, /*!< Foot */
+ LOCATION_OTHER = 0, /*!< Other location. */
+ LOCATION_CHEST, /*!< Chest. */
+ LOCATION_WRIST, /*!< Wrist. */
+ LOCATION_FINGER, /*!< Finger. */
+ LOCATION_HAND, /*!< Hand. */
+ LOCATION_EAR_LOBE, /*!< Earlobe. */
+ LOCATION_FOOT, /*!< Foot. */
};
public:
/**
- * @brief Constructor with 8bit HRM Counter value.
+ * @brief Constructor with 8-bit HRM Counter value.
*
* @param[ref] _ble
* Reference to the underlying BLE.
* @param[in] hrmCounter (8-bit)
- * initial value for the hrm counter.
+ * Initial value for the HRM counter.
* @param[in] location
* Sensor's location.
*/
@@ -70,7 +70,7 @@
* @param[in] _ble
* Reference to the underlying BLE.
* @param[in] hrmCounter (8-bit)
- * initial value for the hrm counter.
+ * Initial value for the HRM counter.
* @param[in] location
* Sensor's location.
*/
@@ -86,10 +86,10 @@
}
/**
- * @brief Set a new 8-bit value for heart rate.
+ * @brief Set a new 8-bit value for the heart rate.
*
* @param[in] hrmCounter
- * HeartRate in bpm.
+ * Heart rate in BPM.
*/
void updateHeartRate(uint8_t hrmCounter) {
valueBytes.updateHeartRate(hrmCounter);
@@ -97,10 +97,10 @@
}
/**
- * Set a new 16-bit value for heart rate.
+ * Set a new 16-bit value for the heart rate.
*
* @param[in] hrmCounter
- * HeartRate in bpm.
+ * Heart rate in BPM.
*/
void updateHeartRate(uint16_t hrmCounter) {
valueBytes.updateHeartRate(hrmCounter);
@@ -108,8 +108,8 @@
}
/**
- * This callback allows the HeartRateService to receive updates to the
- * controlPoint Characteristic.
+ * This callback allows the heart rate service to receive updates to the
+ * controlPoint characteristic.
*
* @param[in] params
* Information about the characterisitc being updated.
@@ -118,7 +118,7 @@
if (params->handle == controlPoint.getValueAttribute().getHandle()) {
/* Do something here if the new value is 1; else you can override this method by
* extending this class.
- * @NOTE: if you are extending this class, be sure to also call
+ * @NOTE: If you are extending this class, be sure to also call
* ble.onDataWritten(this, &ExtendedHRService::onDataWritten); in
* your constructor.
*/
@@ -135,9 +135,9 @@
}
protected:
- /* Private internal representation for the bytes used to work with the vaulue of the heart-rate characteristic. */
+ /* Private internal representation for the bytes used to work with the value of the heart rate characteristic. */
struct HeartRateValueBytes {
- static const unsigned MAX_VALUE_BYTES = 3; /* FLAGS + up to two bytes for heart-rate */
+ static const unsigned MAX_VALUE_BYTES = 3; /* Flags, and up to two bytes for heart rate. */
static const unsigned FLAGS_BYTE_INDEX = 0;
static const unsigned VALUE_FORMAT_BITNUM = 0;
@@ -175,8 +175,8 @@
}
private:
- /* First byte = 8-bit values, no extra info, Second byte = uint8_t HRM value */
- /* See --> https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.heart_rate_measurement.xml */
+ /* First byte: 8-bit values, no extra info. Second byte: uint8_t HRM value */
+ /* See https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.heart_rate_measurement.xml */
uint8_t valueBytes[MAX_VALUE_BYTES];
};
--- a/module.json Mon Jan 11 08:51:33 2016 +0000
+++ b/module.json Mon Jan 11 08:51:34 2016 +0000
@@ -1,6 +1,6 @@
{
"name": "ble",
- "version": "2.1.7",
+ "version": "2.1.11",
"description": "The BLE module offers a high level abstraction for using Bluetooth Low Energy on multiple platforms.",
"keywords": [
"Bluetooth",
