17 #ifndef __GATT_CHARACTERISTIC_H__ 18 #define __GATT_CHARACTERISTIC_H__ 21 #include "ble/SecurityManager.h" 22 #include "GattAttribute.h" 23 #include "GattCallbackParamTypes.h" 1290 const uint8_t writable =
1295 return properties & writable;
1309 return properties & readable;
1400 uint8_t *valuePtr = NULL,
1402 uint16_t maxLen = 0,
1405 unsigned numDescriptors = 0,
1406 bool hasVariableLen =
true 1407 ) : _valueAttribute(uuid, valuePtr, len, maxLen, hasVariableLen),
1409 _descriptors(descriptors),
1410 _descriptorCount(numDescriptors),
1411 readAuthorizationCallback(),
1412 writeAuthorizationCallback(),
1413 _update_security(SecurityRequirement_t::NONE) {
1414 _valueAttribute.allowWrite(
isWritable(_properties));
1415 _valueAttribute.allowRead(
isReadable(_properties));
1417 #if BLE_FEATURE_SECURITY 1421 _valueAttribute.setWriteSecurityRequirement(
1425 #endif // BLE_FEATURE_SECURITY 1444 "Use setWriteSecurityRequirements, setReadSecurityRequirements and " 1445 "setUpdateSecurityRequirements" 1449 SecurityRequirement_t sec_requirements = SecurityModeToAttSecurity(securityMode);
1451 _valueAttribute.setReadSecurityRequirement(sec_requirements);
1452 _valueAttribute.setWriteSecurityRequirement(sec_requirements);
1453 _update_security = sec_requirements.
value();
1480 _valueAttribute.setReadSecurityRequirement(security);
1490 return _valueAttribute.getReadSecurityRequirement();
1505 #if BLE_FEATURE_SECURITY 1511 #endif // BLE_FEATURE_SECURITY 1512 _valueAttribute.setWriteSecurityRequirement(security);
1522 return _valueAttribute.getWriteSecurityRequirement();
1536 _update_security = security.
value();
1566 writeAuthorizationCallback.attach(
callback);
1581 template <
typename T>
1586 writeAuthorizationCallback.attach(
object, member);
1602 readAuthorizationCallback.attach(
callback);
1618 template <
typename T>
1623 readAuthorizationCallback.attach(
object, member);
1648 writeAuthorizationCallback.call(params);
1682 readAuthorizationCallback.call(params);
1694 return _valueAttribute;
1704 return _valueAttribute;
1745 "Use getWriteSecurityRequirements, getReadSecurityRequirements and " 1746 "getUpdateSecurityRequirements" 1758 bool needs_signing =
1761 switch(max_sec.
value()) {
1765 #if BLE_FEATURE_SECURITY 1767 return (needs_signing) ?
1772 return (needs_signing) ?
1775 #if BLE_FEATURE_SECURE_CONNECTIONS 1780 #endif // BLE_FEATURE_SECURE_CONNECTIONS 1781 #endif // BLE_FEATURE_SECURITY 1784 return SecurityManager::SECURITY_MODE_NO_ACCESS;
1795 return _descriptorCount;
1808 return readAuthorizationCallback;
1821 return writeAuthorizationCallback;
1834 if (index >= _descriptorCount) {
1838 return _descriptors[index];
1856 case SecurityManager::SECURITY_MODE_NO_ACCESS:
1860 #if BLE_FEATURE_SECURITY 1862 #if BLE_FEATURE_SIGNING 1868 #if BLE_FEATURE_SIGNING 1872 #endif // BLE_FEATURE_SECURITY 1888 uint8_t _properties;
1898 uint8_t _descriptorCount;
1904 readAuthorizationCallback;
1910 writeAuthorizationCallback;
1929 template <
typename T>
1955 unsigned numDescriptors = 0
1958 reinterpret_cast<uint8_t *>(valuePtr),
1972 template <
typename T>
1998 unsigned numDescriptors = 0
2001 reinterpret_cast<uint8_t *>(valuePtr),
2014 template <
typename T>
2040 unsigned numDescriptors = 0
2043 reinterpret_cast<uint8_t *>(valuePtr),
2057 template <
typename T,
unsigned NUM_ELEMENTS>
2080 T valuePtr[NUM_ELEMENTS],
2083 unsigned numDescriptors = 0
2086 reinterpret_cast<uint8_t *>(valuePtr),
2087 sizeof(T) * NUM_ELEMENTS,
2088 sizeof(T) * NUM_ELEMENTS,
2100 template <
typename T,
unsigned NUM_ELEMENTS>
2124 T valuePtr[NUM_ELEMENTS],
2127 unsigned numDescriptors = 0
2130 reinterpret_cast<uint8_t *>(valuePtr),
2131 sizeof(T) * NUM_ELEMENTS,
2132 sizeof(T) * NUM_ELEMENTS,
2145 template <
typename T,
unsigned NUM_ELEMENTS>
2169 T valuePtr[NUM_ELEMENTS],
2172 unsigned numDescriptors = 0
2175 reinterpret_cast<uint8_t *>(valuePtr),
2176 sizeof(T) * NUM_ELEMENTS,
2177 sizeof(T) * NUM_ELEMENTS,
Moment of force, newton meter.
Magnetic field strength, ampere per meter.
Characteristic of the Cycling Speed and Cadence (CSC) service that exposes measurements made by the s...
Helper class that represents a readable and writable GattCharacteristic.
Characteristic of the Environmental Sensing service that exposes the temperature measurement with a r...
Wave number reciprocal, meter.
Characteristic of the TX Power service that exposes the current transmission power in dBm...
Mass concentration (kilogram per cubic meter).
Permits reads of the characteristic value.
Surface tension, newton per meter.
Pulse Oxymeter, Glucose and Continuous Glucose Monitoring services use this control point to provide ...
GattAuthCallbackReply_t authorizationReply
Authorization result.
Characteristic of the Alert Notification Service that shows how many numbers of unread alerts exist i...
Characteristic of the Health Thermometer service that sends intermediate temperature values while the...
Characteristic of the Health Thermometer service that exposes the interval time between two measureme...
Logarithmic radio quantity, neper.
Characteristic of the Running Speed and Cadence (RSC) service that exposes measurements made by the s...
uint8_t getProperties(void) const
Get the characteristic's properties.
Not used in a service as a characteristic.
Not used in a service as a characteristic.
Not used as a characteristic UUID.
Heat flux density, watt per square meter.
void requireSecurity(SecurityManager::SecurityMode_t securityMode)
Set up the minimum security (mode and level) requirements for access to the characteristic's value at...
Density, kilogram per cubic meter.
Acceleration, meters per second squared.
Pressure, millimeter of mercury.
Part of the Human Interface Device service.
static bool isWritable(uint8_t properties)
Indicates if the properties has at least one of the writable flags.
GattAuthCallbackReply_t authorizeRead(GattReadAuthCallbackParams *params)
Invoke the read authorization callback.
Specific heat capacity, joule per kilogram kelvin.
Permits signed writes to the characteristic value.
Permeability, henry per meter.
GATT write authorization request event.
Specific volume (cubic meter per kilogram).
Catalytic activity, katal.
SecurityRequirement_t getReadSecurityRequirement() const
Get the security requirement of the read operation.
Not used as a characteristic UUID.
The operation require encryption with an authenticated peer that paired using secure connection pairi...
Characteristic of the Glucose service that exposes features supported by the server.
Characteristic of the Running Speed and Cadence (RSC) service that exposes features supported by the ...
Absorbed dose rate, gray per second.
void setUpdateSecurityRequirement(SecurityRequirement_t security)
Set the security requirement of update operations.
Electric current, ampere.
IEEE-754 64-bit floating point.
Security requirement that can be attached to an attribute operation.
Characteristic of the Environmental Sensing Service that exposes the pressure measured.
void setSecurityRequirements(SecurityRequirement_t read_security, SecurityRequirement_t write_security, SecurityRequirement_t update_security)
Set all security requirements of the characteristic.
Not used in a service as a characteristic.
The operation requires security and there's no requirement towards peer authentication.
Characteristic of the Device Information Service that contains a UTF8 string representing the model n...
Characteristic of the Device Information Service that contains a UTF8 string representing the firmwar...
Helper class that represents a readable and writable GattCharacteristic with an array value...
ble::att_security_requirement_t SecurityRequirement_t
Security level applied to GATT operations.
GATT read authorization request event.
GattAttribute & getValueAttribute()
Get the characteristic's value attribute.
Permits notifications of a characteristic value without acknowledgment.
Require signing or encryption, but no MITM protection.
GattAuthCallbackReply_t authorizationReply
Authorization result.
Molar energy, joule per mole.
Not used in a service as a characteristic.
uint8_t getDescriptorCount(void) const
Get the total number of descriptors within this characteristic.
Radiant intensity, watt per steradian.
Magnetic flux density, tesla.
LayoutType value() const
Explicit access to the inner value of the SafeEnum instance.
const GattAttribute & getValueAttribute() const
Get the characteristic's value attribute.
Characteristic of the Current Time service that exposes information related to the current time serve...
Exposure, coulomb per kilogram.
The operation does not have security requirements.
Characteristic of the Phone Alert Status service that returns the ringer setting when read...
Mass density, millimole per liter.
Require signing or encryption, and MITM protection.
type
struct scoped enum wrapped by the class
Characteristic of the Device Information Service, which exposes various regulatory or certification c...
Characteristic of the Alert Notification Service that defines the category of the alert and how many ...
Surface density (kilogram per square meter).
Helper class that represents a read-only GattCharacteristic with an array value.
Mass density, milligram per deciliter.
Representation of a Universally Unique Identifier (UUID).
Characteristic of the Scan Parameter service that sends a notification to a client when the server re...
Thermodynamic temperature, kelvin.
void setReadSecurityRequirement(SecurityRequirement_t security)
Set the security of the read operation.
Representation of a GattServer attribute.
Characteristic of the Phone Alert Status service that allows a client to configure operating mode...
Characteristic of the Heart Rate that sends heart rate measurements to registered clients...
Characteristic of the Scan Parameter service that stores the client's scan parameters (scan interval ...
Electric charge, ampere hours.
Not used in a service as a characteristic.
Permits writes of the characteristic value without response.
ble::attribute_handle_t Handle_t
Representation of an attribute handle.
Characteristic of the Next DST Change service that returns to clients the time with DST...
Characteristic of the Alert Notification service, which exposes categories of unread alert supported ...
Require encryption, but no MITM protection.
Pressure, pound-force per square inch.
Electrical potential difference, voltage.
Helper class that represents a write-only GattCharacteristic with an array value. ...
Characteristic of the Device Information Service that exposes a structure containing an Organizationa...
Catalytic activity concentration, katal per cubic meter.
IEEE-11073 16-bit SFLOAT.
Part of the Human Interface Device service.
Characteristic of the Device Information Service; it is a set of values used to create a device ID th...
GattCharacteristic(const UUID &uuid, uint8_t *valuePtr=NULL, uint16_t len=0, uint16_t maxLen=0, uint8_t props=BLE_GATT_CHAR_PROPERTIES_NONE, GattAttribute *descriptors[]=NULL, unsigned numDescriptors=0, bool hasVariableLen=true)
Constructs a new GattCharacteristic.
Not used in a service as a characteristic.
Electric field strength, volt per meter.
Electric charge density, coulomb per cubic meter.
Handle_t getHandle(void) const
Get the attribute's handle in the ATT table.
Electrical charge, coulomb.
Characteristic of the Blood Pressure service, which exposes intermediate cuff pressure measurements...
void setReadAuthorizationCallback(void(*callback)(GattReadAuthCallbackParams *))
Register the read requests event handler.
Dose equivalent, sievert.
Control point of the Alert Notification service that allows the client finely tune the notification c...
bool isReadAuthorizationEnabled() const
Check whether read authorization is enabled.
Describe the features supported by the blood pressure sensor exposed by the Blood Pressure service...
Energy, kilogram calorie.
Current density (ampere per square meter).
GattAuthCallbackReply_t authorizeWrite(GattWriteAuthCallbackParams *params)
Invoke the write authorization callback.
Not used in a service as a characteristic.
Part of the Human Interface Device service.
SecurityMode_t
level of security required from the link by the application
Dynamic viscosity, pascal second.
Electric resistance, ohm.
Control point of the Immediate Alert service that allows the client to command the server to alert to...
static const uint8_t size
Number of bits required to store the value.
Unsigned 128-bit integer.
Characteristic of the Current Time service that contains the current time.
Part of the Human Interface Device service.
Angular Velocity, revolution per minute.
Characteristic of the Heart Rate service used by the client to control the service behavior...
Characteristic of the Health Thermometer service that sends temperature measurement to clients...
static bool isReadable(uint8_t properties)
Indicates if the properties is readable.
Electric conductance, siemens.
Thermal conductivity, watt per meter kelvin.
SecurityRequirement_t getWriteSecurityRequirement() const
Get the security requirement of write operations.
The Characteristic Extended Properties descriptor defines additional characteristic properties...
Not used in a service as a characteristic.
Not used in actual BLE service.
Representation of a GattServer characteristic.
Part of the Human Interface Device service.
Not used in actual BLE service.
GattAttribute * getDescriptor(uint8_t index)
Get this characteristic's descriptor at a specific index.
Part of the Human Interface Device service.
Not used in actual BLE service.
Part of the Human Interface Device service.
Activity referred to a radionuclide, becquerel.
Permits indications of a characteristic value with acknowledgment.
Molar entropy, joule per mole kelvin.
Require encryption and MITM protection.
Helper class that represents a write only GattCharacteristic.
Celsius temperature, degree Celsius.
Radiance, watt per square meter steradian.
Require no protection, open link.
GattAttribute::Handle_t getValueHandle(void) const
Get the characteristic's value attribute handle in the ATT table.
Irradiance, watt per square meter.
Characteristic of the Heart Rate service that indicate the intended location of the heart rate monito...
Permits broadcasts of the characteristic value using the Server Characteristic Configuration descript...
Specific energy, joule per kilogram.
Characteristic of the Glucose service that exposes glucose measurements.
Characteristic of the current Time service that exposes information about the local time...
Characteristic of the Glucose service that sends additional information related to the glucose measur...
Characteristic of the Alert Notification Service that notifies the count of new alerts for a given ca...
bool isWriteAuthorizationEnabled() const
Check whether write authorization is enabled.
SecurityRequirement_t getUpdateSecurityRequirement() const
Get the security requirement of update operations.
void setReadAuthorizationCallback(T *object, void(T::*member)(GattReadAuthCallbackParams *))
Register the read requests event handler.
Period, beats per minute.
Thermodynamic temperature, degree Fahrenheit.
void setWriteAuthorizationCallback(void(*callback)(GattWriteAuthCallbackParams *))
Register a callback handling client's write requests or commands.
Characteristic of the Device Information Service that contains a UTF8 string representing the manufac...
Heat capacity, joule per kelvin.
void setWriteSecurityRequirement(SecurityRequirement_t security)
Set the security requirement of the write operations.
Logarithmic radio quantity, bel.
Characteristic of the Reference Time service that allows clients to control time update.
Characteristic of the Environmental Sensing service, which exposes humidity measurements.
The operation requires security and the peer must be authenticated.
IEEE-754 32-bit floating point.
Luminous intensity, candela.
Surface charge density, coulomb per square meter.
void setWriteAuthorizationCallback(T *object, void(T::*member)(GattWriteAuthCallbackParams *))
Register a callback handling client's write requests or commands.
Helper class that represents a read only GattCharacteristic.
Characteristic of the Device Information Service that contains an UTF8 string representing the softwa...
Velocity, kilometer per hour.
Amount of substance, mole.
Part of the Alert Notification service, which exposes the count of unread alert events existing in th...
Characteristic of the Device Information Service that contains a UTF8 string representing the hardwar...
Electric flux density, coulomb per square meter.
Velocity, meters per second.
Permits writes of the characteristic value with response.
Energy density, joule per cubic meter.
Characteristic of the Device Information Service that contains a UTF8 string representing the serial ...
Characteristic of the Cycling Speed and Cadence (CSC) service that exposes features supported by the ...
Characteristic of the Health Thermometer service that describes where the measurement takes place...
Amount concentration (mole per cubic meter).
Characteristic of the Reference Time service that informs clients of the status of the time update op...
Not used in actual BLE service.
Part of the Human Interface Device service.
Angular acceleration, radian per second squared.
Angular velocity, radian per second.
SecurityManager::SecurityMode_t getRequiredSecurity() const
Get the characteristic's required security.
GattAuthCallbackReply_t
Enumeration of allowed values returned by read or write authorization process.
Characteristic of the Battery service, which exposes the current battery level as a percentage...
Luminance (candela per square meter).
Concentration, count per cubic meter.
Permittivity, farad per meter.
Characteristic of the Blood Pressure service that exposes the measurement of the blood sensor...