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: microbit-dal microbit-dal microbit-ble-open microbit-dal ... more
Fork of BLE_API by
Revision 950:b576e5675a8c, committed 2015-11-26
- Comitter:
- rgrover1
- Date:
- Thu Nov 26 12:52:09 2015 +0000
- Parent:
- 949:1902cbd0dd83
- Child:
- 951:2dc552be2b94
- Commit message:
- Synchronized with git rev 183a572f
Author: Liyou Zhou
Styling changes.
Changed in this revision
--- a/CONTRIBUTING.md Thu Nov 26 12:52:08 2015 +0000 +++ b/CONTRIBUTING.md Thu Nov 26 12:52:09 2015 +0000 @@ -1,7 +1,7 @@ # Hello! -We are an open source project of [ARM mbed](https://www.mbed.com). Contributions via [pull request](https://github.com/ARMmbed/ble/pulls), and [bug reports](https://github.com/ARMmbed/ble/issues) are welcome! +We are an open source project of [ARM mbed](www.mbed.com). Contributions via [pull request](https://github.com/armmbed/yotta/pulls), and [bug reports](https://github.com/armmbed/yotta/issues) are welcome! Please submit your pull request to the 'develop' branch of this module. Commits to develop will merge into master at the time of the next release. # Contributor agreement -For your pull request to be accepted, we will need you to agree to our [contributor agreement](https://developer.mbed.org/contributor_agreement/) to give us the necessary rights to use and distribute your contributions. (To click through the agreement create an account on mbed.com and log in.) \ No newline at end of file +For your pull request to be accepted, we will need you to agree to our [contributor agreement](http://developer.mbed.org/contributor_agreement/) to give us the necessary rights to use and distribute your contributions. (To click through the agreement create an account on mbed.com and log in.) \ No newline at end of file
--- a/DOXYGEN_FRONTPAGE.md Thu Nov 26 12:52:08 2015 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ -#BLE API - -The BLE module within mbed OS offers a high level abstraction for using -Bluetooth Low Energy on multiple platforms. - -This documentation describes the internal structure of 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). - -For getting started with BLE on mbed, check our (introduction -page)[https://docs.mbed.com/docs/ble-intros/en/latest/]. - -For mbed OS examples using BLE, check (this -repository)[https://github.com/armmbed/ble-examples]. For mbed-classic -examples, refer to (code under mbed.org)[https://developer.mbed.org/teams/Bluetooth-Low-Energy/code/]. \ No newline at end of file
--- a/README.md Thu Nov 26 12:52:08 2015 +0000 +++ b/README.md Thu Nov 26 12:52:09 2015 +0000 @@ -1,25 +1,21 @@ # mbed Bluetooth Low Energy Stack -This is the Github repo for the `BLE_API` used by developer.mbed.org. Please see the [mbed BLE Homepage](https://developer.mbed.org/teams/Bluetooth-Low-Energy/) for all documentation, code examples and general help. +This is the github repo for the BLE_API used by developer.mbed.org. Please see [mbed BLE Homepage](http://developer.mbed.org/teams/Bluetooth-Low-Energy/) for all documentation, code examples and general help. # Supported Services -Supported GATT services and constantly being added and can be found in the (`ble/ble/services/`)[https://github.com/ARMmbed/ble/tree/master/ble/services] folder. - -Currently supported services include: -* Battery +Supported GATT services and constantly being added and can be found in the /services folder. +Currently supported services include: +* Battery * Device Firmware Update (DFU) -* Device Information -* Eddystone Configuration Service +* Device Information * Health Thermometer * Heart Rate -* Link Loss * UART * UriBeacon * iBeacon -# 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. +# 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 Homepage](http://developer.mbed.org/teams/Bluetooth-Low-Energy/) for all things BLE +* [mbed BLE Getting Started Guide](http://developer.mbed.org/forum/team-63-Bluetooth-Low-Energy-community/topic/5262/) a wonderful primer on using BLE with mbed +* [mbed BLE API page](http://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
--- a/ble/services/BatteryService.h Thu Nov 26 12:52:08 2015 +0000
+++ b/ble/services/BatteryService.h Thu Nov 26 12:52:09 2015 +0000
@@ -21,8 +21,8 @@
/**
* @class BatteryService
-* @brief BLE Battery Service. This service displays the battery level from 0% to 100%, represented as an 8bit number.
-* Service: https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.battery_service.xml
+* @brief BLE Battery Service. This service displays the battery level from 0%->100% represented as a 8bit number.<br>
+* Service: https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.battery_service.xml <br>
* Battery Level Char: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.battery_level.xml
*/
class BatteryService {
@@ -45,11 +45,11 @@
}
/**
- * @brief Update the battery level with a new value. [Valid values lie between 0 and 100];
- * anything outside this range will be ignored.
+ * @brief Update the battery level with a new value. Valid values range from
+ * 0..100. Anything outside this range will be ignored.
*
* @param newLevel
- * Update to battery level.
+ * update to battery level.
*/
void updateBatteryLevel(uint8_t newLevel) {
batteryLevel = newLevel;
--- a/ble/services/DFUService.h Thu Nov 26 12:52:08 2015 +0000
+++ b/ble/services/DFUService.h Thu Nov 26 12:52:09 2015 +0000
@@ -20,7 +20,9 @@
#include "ble/BLE.h"
#include "ble/UUID.h"
-extern "C" void bootloader_start(void);
+extern "C" {
+#include "dfu_app_handler.h"
+}
extern const uint8_t DFUServiceBaseUUID[];
extern const uint16_t DFUServiceShortUUID;
@@ -37,20 +39,20 @@
class DFUService {
public:
/**
- * @brief Signature for the handover callback. The application may provide this
- * callback when setting up the DFU service. The callback is then
+ * @brief Signature for the handover callback. The application may provide such a
+ * callback when setting up the DFU service, in which case it will be
* invoked before handing control over to the bootloader.
*/
typedef void (*ResetPrepare_t)(void);
public:
/**
- * @brief Adds Device Firmware Update Service to an existing BLE object.
+ * @brief Adds Device Firmware Update service to an existing ble object.
*
* @param[ref] _ble
* BLE object for the underlying controller.
* @param[in] _handoverCallback
- * Application-specific handover callback.
+ * Application specific handover callback.
*/
DFUService(BLE &_ble, ResetPrepare_t _handoverCallback = NULL) :
ble(_ble),
@@ -59,12 +61,12 @@
GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE),
controlBytes(),
packetBytes() {
- static bool serviceAdded = false; /* We only add the DFU service once. */
+ static bool serviceAdded = false; /* We should only ever need to add the DFU service once. */
if (serviceAdded) {
return;
}
- /* Set an initial value for control bytes, so that the application's DFU service can
+ /* 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;
@@ -80,7 +82,7 @@
}
/**
- * @brief Get the handle for the value attribute of the control characteristic.
+ * @brief get the handle for the value attribute of the control characteristic.
*/
uint16_t getControlHandle(void) const {
return controlPoint.getValueHandle();
@@ -88,7 +90,7 @@
/**
* @brief This callback allows the DFU service to receive the initial trigger to
- * hand control over to the bootloader. First, the application is given a
+ * handover control to the bootloader; but first the application is given a
* chance to clean up.
*
* @param[in] params
@@ -96,12 +98,20 @@
*/
virtual void onDataWritten(const GattWriteCallbackParams *params) {
if (params->handle == controlPoint.getValueHandle()) {
- /* At present, writing anything will do the trick - this needs to be improved. */
+ /* At present, writing anything will do the trick--this needs to be improved. */
if (handoverCallback) {
handoverCallback();
}
- bootloader_start();
+ // Call bootloader_start implicitly trough a event handler call
+ // it is a work around for bootloader_start not being public in sdk 8.1
+ ble_dfu_t p_dfu;
+ ble_dfu_evt_t p_evt;
+
+ p_dfu.conn_handle = params->connHandle;
+ p_evt.ble_dfu_evt_type = BLE_DFU_START;
+
+ dfu_app_on_dfu_evt(&p_dfu, &p_evt);
}
}
@@ -112,22 +122,22 @@
protected:
BLE &ble;
- /**< Writing to the control characteristic triggers the handover to DFU
- * bootloader. At present, writing anything will do the trick - this needs
+ /**< Writing to the control characteristic triggers the handover to dfu-
+ * bootloader. At present, writing anything will do the trick--this needs
* to be improved. */
WriteOnlyArrayGattCharacteristic<uint8_t, SIZEOF_CONTROL_BYTES> controlPoint;
- /**< The packet characteristic in this service doesn't do anything meaningful;
- * it is only a placeholder to mimic the corresponding characteristic in the
+ /**< The packet characteristic in this service doesn't do anything meaningful, but
+ * is only a placeholder to mimic the corresponding characteristic in the
* actual DFU service implemented by the bootloader. Without this, some
- * FOTA clients might get confused, because service definitions change after
+ * FOTA clients might get confused as service definitions change after
* handing control over to the bootloader. */
GattCharacteristic packet;
uint8_t controlBytes[SIZEOF_CONTROL_BYTES];
uint8_t packetBytes[SIZEOF_PACKET_BYTES];
- static ResetPrepare_t handoverCallback; /**< Application-specific handover callback. */
+ static ResetPrepare_t handoverCallback; /**< application specific handover callback. */
};
#endif /* #ifndef __BLE_DFU_SERVICE_H__*/
\ No newline at end of file
--- a/ble/services/DeviceInformationService.h Thu Nov 26 12:52:08 2015 +0000
+++ b/ble/services/DeviceInformationService.h Thu Nov 26 12:52:09 2015 +0000
@@ -21,30 +21,41 @@
/**
* @class DeviceInformationService
-* @brief BLE Device Information Service
-* Service: https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.device_information.xml
+* @brief BLE Device Information Service <br>
+* Service: https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.device_information.xml <br>
* Manufacturer Name String Char: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.manufacturer_name_string.xml
*/
class DeviceInformationService {
public:
/**
- * @brief Device Information Service Constructor: copies device-specific information
- * into the BLE stack.
+ * @brief Device Information Service Constructor.
*
* @param[ref] _ble
* BLE object for the underlying controller.
* @param[in] manufacturersName
- * The name of the manufacturer of the device.
+ * This characteristic represents the name of the
+ * manufacturer of the device. The name is copied into the
+ * BLE stack during this constructor.
* @param[in] modelNumber
- * The model number that is assigned by the device vendor.
+ * This characteristic represents the model number that is
+ * assigned by the device vendor. The value is copied into
+ * the BLE stack during this constructor.
* @param[in] serialNumber
- * The serial number for a particular instance of the device.
+ * This characteristic represents the serial number for a
+ * particular instance of the device. The value is copied
+ * into the BLE stack during this constructor.
* @param[in] hardwareRevision
- * The hardware revision for the hardware within the device.
+ * This characteristic represents the hardware revision for
+ * the hardware within the device. The value is copied
+ * into the BLE stack during this constructor.
* @param[in] firmwareRevision
- * The device's firmware version.
+ * This characteristic represents the firmware revision for
+ * the firmware within the device. The value is copied
+ * into the BLE stack during this constructor.
* @param[in] softwareRevision
- * The device's software version.
+ * This characteristic represents the software revision for
+ * the software within the device. The value is copied
+ * into the BLE stack during this constructor.
*/
DeviceInformationService(BLE &_ble,
const char *manufacturersName = NULL,
@@ -56,36 +67,36 @@
ble(_ble),
manufacturersNameStringCharacteristic(GattCharacteristic::UUID_MANUFACTURER_NAME_STRING_CHAR,
(uint8_t *)manufacturersName,
- (manufacturersName != NULL) ? strlen(manufacturersName) : 0, /* Min length */
- (manufacturersName != NULL) ? strlen(manufacturersName) : 0, /* Max length */
+ (manufacturersName != NULL) ? strlen(manufacturersName) : 0, /* minLength */
+ (manufacturersName != NULL) ? strlen(manufacturersName) : 0, /* maxLength */
GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ),
modelNumberStringCharacteristic(GattCharacteristic::UUID_MODEL_NUMBER_STRING_CHAR,
(uint8_t *)modelNumber,
- (modelNumber != NULL) ? strlen(modelNumber) : 0, /* Min length */
- (modelNumber != NULL) ? strlen(modelNumber) : 0, /* Max length */
+ (modelNumber != NULL) ? strlen(modelNumber) : 0, /* minLength */
+ (modelNumber != NULL) ? strlen(modelNumber) : 0, /* maxLength */
GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ),
serialNumberStringCharacteristic(GattCharacteristic::UUID_SERIAL_NUMBER_STRING_CHAR,
(uint8_t *)serialNumber,
- (serialNumber != NULL) ? strlen(serialNumber) : 0, /* Min length */
- (serialNumber != NULL) ? strlen(serialNumber) : 0, /* Max length */
+ (serialNumber != NULL) ? strlen(serialNumber) : 0, /* minLength */
+ (serialNumber != NULL) ? strlen(serialNumber) : 0, /* maxLength */
GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ),
hardwareRevisionStringCharacteristic(GattCharacteristic::UUID_HARDWARE_REVISION_STRING_CHAR,
(uint8_t *)hardwareRevision,
- (hardwareRevision != NULL) ? strlen(hardwareRevision) : 0, /* Min length */
- (hardwareRevision != NULL) ? strlen(hardwareRevision) : 0, /* Max length */
+ (hardwareRevision != NULL) ? strlen(hardwareRevision) : 0, /* minLength */
+ (hardwareRevision != NULL) ? strlen(hardwareRevision) : 0, /* maxLength */
GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ),
firmwareRevisionStringCharacteristic(GattCharacteristic::UUID_FIRMWARE_REVISION_STRING_CHAR,
(uint8_t *)firmwareRevision,
- (firmwareRevision != NULL) ? strlen(firmwareRevision) : 0, /* Min length */
- (firmwareRevision != NULL) ? strlen(firmwareRevision) : 0, /* Max length */
+ (firmwareRevision != NULL) ? strlen(firmwareRevision) : 0, /* minLength */
+ (firmwareRevision != NULL) ? strlen(firmwareRevision) : 0, /* maxLength */
GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ),
softwareRevisionStringCharacteristic(GattCharacteristic::UUID_SOFTWARE_REVISION_STRING_CHAR,
(uint8_t *)softwareRevision,
- (softwareRevision != NULL) ? strlen(softwareRevision) : 0, /* Min length */
- (softwareRevision != NULL) ? strlen(softwareRevision) : 0, /* Max length */
+ (softwareRevision != NULL) ? strlen(softwareRevision) : 0, /* minLength */
+ (softwareRevision != NULL) ? strlen(softwareRevision) : 0, /* maxLength */
GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ)
{
- static bool serviceAdded = false; /* We only add the information service once. */
+ static bool serviceAdded = false; /* We should only ever need to add the information service once. */
if (serviceAdded) {
return;
}
--- a/module.json Thu Nov 26 12:52:08 2015 +0000
+++ b/module.json Thu Nov 26 12:52:09 2015 +0000
@@ -13,7 +13,7 @@
"url": "https://github.com/ARMmbed/ble.git",
"type": "git"
},
- "homepage": "https://developer.mbed.org/teams/Bluetooth-Low-Energy/",
+ "homepage": "http://mbed.org/ble",
"licenses": [
{
"url": "https://spdx.org/licenses/Apache-2.0",
