pulling in doxygen improvements submitted by Austin.
This commit is contained in:
parent
ad56c72314
commit
149605fe95
7 changed files with 188 additions and 62 deletions
|
@ -19,11 +19,20 @@
|
|||
|
||||
#include "BLEDevice.h"
|
||||
|
||||
/* Battery Service */
|
||||
/* Service: https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.battery_service.xml */
|
||||
/* Battery Level Char: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.battery_level.xml */
|
||||
/**
|
||||
* @class BatteryService
|
||||
* @breif 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 {
|
||||
public:
|
||||
/**
|
||||
* @param[ref] _ble
|
||||
* BLEDevice object for the underlying controller.
|
||||
* @param[in] level
|
||||
* 8bit batterly level. Usually used to represent percentage of batterly charge remaining.
|
||||
*/
|
||||
BatteryService(BLEDevice &_ble, uint8_t level = 100) :
|
||||
ble(_ble),
|
||||
batteryLevel(level),
|
||||
|
@ -43,9 +52,11 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Update the battery level with a new value. Valid values range from
|
||||
* @breif Update the battery level with a new value. Valid values range from
|
||||
* 0..100. Anything outside this range will be ignored.
|
||||
* @param newLevel New level.
|
||||
*
|
||||
* @param newLevel
|
||||
* update to battery level.
|
||||
*/
|
||||
void updateBatteryLevel(uint8_t newLevel) {
|
||||
batteryLevel = newLevel;
|
||||
|
|
|
@ -30,16 +30,28 @@ extern const uint8_t DFUServiceUUID[];
|
|||
extern const uint8_t DFUServiceControlCharacteristicUUID[];
|
||||
extern const uint8_t DFUServicePacketCharacteristicUUID[];
|
||||
|
||||
/**
|
||||
* @class DFUService
|
||||
* @breif Device Firmware Update Service.
|
||||
*/
|
||||
class DFUService {
|
||||
public:
|
||||
/**
|
||||
* Signature for the handover callback. The application may provide such a
|
||||
* @breif 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:
|
||||
/**
|
||||
* @breif Adds Device Firmware Update service to an existing ble object.
|
||||
*
|
||||
* @param[ref] _ble
|
||||
* BLEDevice object for the underlying controller.
|
||||
* @param[in] _handoverCallback
|
||||
* Application specific handover callback.
|
||||
*/
|
||||
DFUService(BLEDevice &_ble, ResetPrepare_t _handoverCallback = NULL) :
|
||||
ble(_ble),
|
||||
controlBytes(),
|
||||
|
@ -68,14 +80,21 @@ public:
|
|||
ble.onDataWritten(this, &DFUService::onDataWritten);
|
||||
}
|
||||
|
||||
/**
|
||||
* @breif
|
||||
* @return
|
||||
*/
|
||||
uint16_t getControlHandle(void) {
|
||||
return controlPoint.getValueAttribute().getHandle();
|
||||
}
|
||||
|
||||
/**
|
||||
* This callback allows the DFU service to receive the initial trigger to
|
||||
* @breif This callback allows the DFU service to receive the initial trigger to
|
||||
* handover control to the bootloader; but first the application is given a
|
||||
* chance to clean up.
|
||||
*
|
||||
* @param[in]
|
||||
*
|
||||
*/
|
||||
virtual void onDataWritten(const GattCharacteristicWriteCBParams *params) {
|
||||
if (params->charHandle == controlPoint.getValueAttribute().getHandle()) {
|
||||
|
|
|
@ -19,16 +19,19 @@
|
|||
|
||||
#include "BLEDevice.h"
|
||||
|
||||
/* Device Information Service */
|
||||
/* Service: https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.device_information.xml */
|
||||
/* Manufacturer Name String Char: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.manufacturer_name_string.xml */
|
||||
/**
|
||||
* @class DeviceInformationService
|
||||
* @breif 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:
|
||||
/**
|
||||
* Constructor.
|
||||
* @breif Device Information Service Constructor.
|
||||
*
|
||||
* @param[in] _ble
|
||||
* Reference to the BLEDevice.
|
||||
* @param[ref] _ble
|
||||
* BLEDevice object for the underlying controller.
|
||||
* @param[in] manufacturersName
|
||||
* This characteristic represents the name of the
|
||||
* manufacturer of the device. The name is copied into the
|
||||
|
|
|
@ -19,28 +19,37 @@
|
|||
|
||||
#include "BLEDevice.h"
|
||||
|
||||
/* Health Thermometer Service */
|
||||
/* 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
|
||||
* @breif 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>
|
||||
* Temperature Type: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.temperature_type.xml
|
||||
*/
|
||||
class HealthThermometerService {
|
||||
public:
|
||||
|
||||
/**
|
||||
* @enum Sensor Location
|
||||
* @breif Location of sensor on the body
|
||||
*/
|
||||
enum {
|
||||
LOCATION_ARMPIT = 1,
|
||||
LOCATION_BODY,
|
||||
LOCATION_EAR,
|
||||
LOCATION_FINGER,
|
||||
LOCATION_GI_TRACT,
|
||||
LOCATION_MOUTH,
|
||||
LOCATION_RECTUM,
|
||||
LOCATION_TOE,
|
||||
LOCATION_EAR_DRUM,
|
||||
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 */
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* @param[in] _ble reference to the BLE device
|
||||
* @breif 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
|
||||
*/
|
||||
|
@ -59,6 +68,13 @@ public:
|
|||
ble.addService(hrmService);
|
||||
}
|
||||
|
||||
/**
|
||||
* @breif Update the temperature being broadcast
|
||||
*
|
||||
* @param[in] temperature
|
||||
* Floating point value of the temperature
|
||||
*
|
||||
*/
|
||||
void updateTemperature(float temperature) {
|
||||
if (ble.getGapState().connected) {
|
||||
valueBytes.updateTemperature(temperature);
|
||||
|
|
|
@ -19,31 +19,39 @@
|
|||
|
||||
#include "BLEDevice.h"
|
||||
|
||||
/* Heart Rate Service */
|
||||
/* 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
|
||||
* @breif 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>
|
||||
* Location: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.body_sensor_location.xml
|
||||
*/
|
||||
class HeartRateService {
|
||||
public:
|
||||
|
||||
/**
|
||||
* @enum SensorLocation
|
||||
* @breif Location of HeartRate sensor on body.
|
||||
*/
|
||||
enum {
|
||||
LOCATION_OTHER = 0,
|
||||
LOCATION_CHEST,
|
||||
LOCATION_WRIST,
|
||||
LOCATION_FINGER,
|
||||
LOCATION_HAND,
|
||||
LOCATION_EAR_LOBE,
|
||||
LOCATION_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:
|
||||
/**
|
||||
* Constructor.
|
||||
* @breif Constructor with 8bit HRM Counter value.
|
||||
*
|
||||
* param[in] _ble
|
||||
* @param[ref] _ble
|
||||
* Reference to the underlying BLEDevice.
|
||||
* param[in] hrmCounter (8-bit)
|
||||
* @param[in] hrmCounter (8-bit)
|
||||
* initial value for the hrm counter.
|
||||
* param[in] location
|
||||
* @param[in] location
|
||||
* Sensor's location.
|
||||
*/
|
||||
HeartRateService(BLEDevice &_ble, uint8_t hrmCounter, uint8_t location) :
|
||||
|
@ -60,7 +68,14 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Same constructor as above, but with a 16-bit HRM Counter value.
|
||||
* @breif Constructor with a 16-bit HRM Counter value.
|
||||
*
|
||||
* @param[in] _ble
|
||||
* Reference to the underlying BLEDevice.
|
||||
* @param[in] hrmCounter (8-bit)
|
||||
* initial value for the hrm counter.
|
||||
* @param[in] location
|
||||
* Sensor's location.
|
||||
*/
|
||||
HeartRateService(BLEDevice &_ble, uint16_t hrmCounter, uint8_t location) :
|
||||
ble(_ble),
|
||||
|
@ -76,7 +91,10 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Set a new 8-bit value for heart rate.
|
||||
* @breif Set a new 8-bit value for heart rate.
|
||||
*
|
||||
* @param[in] hrmCounter
|
||||
* HeartRate in bpm.
|
||||
*/
|
||||
void updateHeartRate(uint8_t hrmCounter) {
|
||||
valueBytes.updateHeartRate(hrmCounter);
|
||||
|
@ -85,6 +103,9 @@ public:
|
|||
|
||||
/**
|
||||
* Set a new 16-bit value for heart rate.
|
||||
*
|
||||
* @param[in] hrmCounter
|
||||
* HeartRate in bpm.
|
||||
*/
|
||||
void updateHeartRate(uint16_t hrmCounter) {
|
||||
valueBytes.updateHeartRate(hrmCounter);
|
||||
|
@ -94,6 +115,7 @@ public:
|
|||
/**
|
||||
* This callback allows the HeartRateService to receive updates to the
|
||||
* controlPoint Characteristic.
|
||||
*
|
||||
*/
|
||||
virtual void onDataWritten(const GattCharacteristicWriteCBParams *params) {
|
||||
if (params->charHandle == controlPoint.getValueAttribute().getHandle()) {
|
||||
|
|
|
@ -34,6 +34,10 @@ extern const uint8_t UARTServiceUUID_reversed[LENGTH_OF_LONG_UUID];
|
|||
extern const uint8_t UARTServiceTXCharacteristicUUID[LENGTH_OF_LONG_UUID];
|
||||
extern const uint8_t UARTServiceRXCharacteristicUUID[LENGTH_OF_LONG_UUID];
|
||||
|
||||
/**
|
||||
* @class UARTService
|
||||
* @breif 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. */
|
||||
|
@ -41,6 +45,11 @@ public:
|
|||
static const unsigned BLE_UART_SERVICE_MAX_DATA_LEN = (GATT_MTU_SIZE_DEFAULT - 3);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* @param[ref] ble
|
||||
* BLEDevice object for the underlying controller.
|
||||
*/
|
||||
UARTService(BLEDevice &_ble) :
|
||||
ble(_ble),
|
||||
receiveBuffer(),
|
||||
|
@ -131,6 +140,11 @@ public:
|
|||
return (write(&c, 1) == 1) ? 1 : EOF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override for Stream::_getc()
|
||||
* @return
|
||||
* The character read.
|
||||
*/
|
||||
int _getc() {
|
||||
if (receiveBufferIndex == numBytesReceived) {
|
||||
return EOF;
|
||||
|
@ -179,4 +193,3 @@ private:
|
|||
};
|
||||
|
||||
#endif /* #ifndef __BLE_UART_SERVICE_H__*/
|
||||
|
||||
|
|
|
@ -32,14 +32,24 @@ static const uint8_t txPowerModeCharUUID[] = URI_BEACON_CONFIG_UUID_INI
|
|||
static const uint8_t beaconPeriodCharUUID[] = URI_BEACON_CONFIG_UUID_INITIALIZER_LIST(0x20, 0x88);
|
||||
static const uint8_t resetCharUUID[] = URI_BEACON_CONFIG_UUID_INITIALIZER_LIST(0x20, 0x89);
|
||||
|
||||
/**
|
||||
* @class URIBeaconConfigService
|
||||
* @breif UriBeacon Configuration Service. Can be used to set URL, adjust power levels, and set flags.
|
||||
*/
|
||||
class URIBeaconConfigService {
|
||||
public:
|
||||
|
||||
/**
|
||||
* @enum TXPowerModes_t
|
||||
* @breif Transmission Power Modes for UriBeacon
|
||||
*/
|
||||
enum TXPowerModes_t {
|
||||
TX_POWER_MODE_LOWEST = 0,
|
||||
TX_POWER_MODE_LOW = 1,
|
||||
TX_POWER_MODE_MEDIUM = 2,
|
||||
TX_POWER_MODE_HIGH = 3,
|
||||
NUM_POWER_MODES
|
||||
|
||||
TX_POWER_MODE_LOWEST = 0, /*!< Lowest TX power mode */
|
||||
TX_POWER_MODE_LOW = 1, /*!< Low TX power mode */
|
||||
TX_POWER_MODE_MEDIUM = 2, /*!< Medium TX power mode */
|
||||
TX_POWER_MODE_HIGH = 3, /*!< High TX power mode */
|
||||
NUM_POWER_MODES /*!< Number of Power Modes defined */
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -115,17 +125,18 @@ public:
|
|||
* transactions.
|
||||
*/
|
||||
public:
|
||||
|
||||
/**
|
||||
* Update flags of the URIBeacon dynamically.
|
||||
*
|
||||
* @param[in] flagsIn
|
||||
*
|
||||
* @verbatim
|
||||
* ### UriBeacon Flags
|
||||
* Bit | Description
|
||||
* :---- | :----------
|
||||
* 0 | Invisible Hint
|
||||
* 1..7 | Reserved for future use. Must be zero.
|
||||
*
|
||||
* @endverbatim
|
||||
* The `Invisible Hint` flag is a command for the user-agent that tells
|
||||
* it not to access or display the UriBeacon. This is a guideline only,
|
||||
* and is not a blocking method. User agents may, with user approval,
|
||||
|
@ -138,7 +149,10 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Update the txPowerLevels table.
|
||||
* @breif Update the txPowerLevels table.
|
||||
*
|
||||
* @param[in] powerLevelsIn
|
||||
* Array of power levels
|
||||
*/
|
||||
void setTxPowerLevels(const int8_t powerLevelsIn[NUM_POWER_MODES]) {
|
||||
memcpy(powerLevels, powerLevelsIn, sizeof(powerLevels));
|
||||
|
@ -147,7 +161,10 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Set the effective power mode from one of the values in the powerLevels tables.
|
||||
* @breif Set the effective power mode from one of the values in the powerLevels tables.
|
||||
*
|
||||
* @param[in] mode
|
||||
* Set the TX Power Mode.
|
||||
*/
|
||||
void setTxPowerMode(TXPowerModes_t mode) {
|
||||
txPowerMode = mode;
|
||||
|
@ -158,16 +175,19 @@ public:
|
|||
/**
|
||||
* The period in milliseconds that a UriBeacon packet is transmitted.
|
||||
*
|
||||
* @Note: A value of zero disables UriBeacon transmissions.
|
||||
* @note A value of zero disables UriBeacon transmissions.
|
||||
*
|
||||
* @param beaconPeriodIn
|
||||
* Beacon advertising period in milliseconds
|
||||
*/
|
||||
void setBeaconPeriod(uint16_t beaconPeriodIn) {
|
||||
void setBeaconPeriod(uint16_t beaconPeriodIn) {
|
||||
beaconPeriod = beaconPeriodIn;
|
||||
configureGAP();
|
||||
updateBeaconPeriodCharacteristic();
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
/*
|
||||
* Setup the advertisement payload and GAP settings.
|
||||
*/
|
||||
void configureGAP(void) {
|
||||
|
@ -191,11 +211,15 @@ private:
|
|||
ble.setTxPower(powerLevels[txPowerMode]);
|
||||
}
|
||||
|
||||
/*
|
||||
* Encode the URI Prefix to a single byte if possible.
|
||||
*/
|
||||
size_t encodeURISchemePrefix(const char *&urldata, size_t &sizeofURLData) {
|
||||
if (!sizeofURLData) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* These are the URI Prefixes that can be abbreviated.*/
|
||||
const char *prefixes[] = {
|
||||
"http://www.",
|
||||
"https://www.",
|
||||
|
@ -220,8 +244,13 @@ private:
|
|||
|
||||
return encodedBytes;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Encode the URI Suffix to a single byte if possible.
|
||||
*/
|
||||
size_t encodeURI(const char *urldata, size_t sizeofURLData) {
|
||||
|
||||
/* These are the URI suffixes that can be abbreviated. */
|
||||
const char *suffixes[] = {
|
||||
".com/",
|
||||
".org/",
|
||||
|
@ -273,6 +302,9 @@ private:
|
|||
return encodedBytes;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
void onDataWritten(const GattCharacteristicWriteCBParams *params) {
|
||||
uint16_t handle = params->charHandle;
|
||||
if (handle == uriDataChar.getValueHandle()) {
|
||||
|
@ -328,6 +360,9 @@ private:
|
|||
ble.setAdvertisingPayload();
|
||||
}
|
||||
|
||||
/*
|
||||
* Reset the default values.
|
||||
*/
|
||||
void resetDefaults(void) {
|
||||
lockedState = false;
|
||||
uriDataLength = 0;
|
||||
|
@ -340,6 +375,9 @@ private:
|
|||
updateGATT();
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
void updateGATT(void) {
|
||||
updateLockedStateCharacteristic();
|
||||
updateURIDataCharacteristic();
|
||||
|
@ -373,9 +411,13 @@ private:
|
|||
ble.updateCharacteristicValue(txPowerLevelsChar.getValueHandle(), reinterpret_cast<uint8_t *>(powerLevels), NUM_POWER_MODES * sizeof(int8_t));
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* For debugging only.
|
||||
* The following is a private debug function.
|
||||
*/
|
||||
private:
|
||||
|
||||
/**
|
||||
* For debugging only. Print Hex representation of ServiceDataPayload to terminal.
|
||||
*/
|
||||
void dumpEncodedSeviceData() const {
|
||||
printf("encoded: '");
|
||||
|
@ -415,4 +457,4 @@ private:
|
|||
GattCharacteristic resetChar;
|
||||
};
|
||||
|
||||
#endif /* #ifndef __BLE_URI_BEACON_CONFIG_SERVICE_H__*/
|
||||
#endif /* #ifndef __BLE_URI_BEACON_CONFIG_SERVICE_H__*/
|
Loading…
Reference in a new issue