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,
Logarithmic radio quantity, neper.
Part of the Human Interface Device service.
Luminous intensity, candela.
IEEE-754 32-bit floating point.
Not used in a service as a characteristic.
Angular Velocity, revolution per minute.
Helper class that represents a readable and writable GattCharacteristic.
Characteristic of the Device Information Service; it is a set of values used to create a device ID th...
Characteristic of the Glucose service that sends additional information related to the glucose measur...
Characteristic of the Glucose service that exposes glucose measurements.
Not used in actual BLE service.
IEEE-11073 16-bit SFLOAT.
Magnetic flux density, tesla.
Characteristic of the Health Thermometer service that exposes the interval time between two measureme...
Permits reads of the characteristic value.
Current density (ampere per square meter).
GattAuthCallbackReply_t authorizationReply
Authorization result.
Electrical potential difference, voltage.
Not used in actual BLE service.
Characteristic of the Current Time service that exposes information related to the current time serve...
Characteristic of the Next DST Change service that returns to clients the time with DST...
Electric field strength, volt per meter.
Specific heat capacity, joule per kilogram kelvin.
uint8_t getProperties(void) const
Get the characteristic's properties.
Characteristic of the Blood Pressure service that exposes the measurement of the blood sensor...
Celsius temperature, degree Celsius.
void requireSecurity(SecurityManager::SecurityMode_t securityMode)
Set up the minimum security (mode and level) requirements for access to the characteristic's value at...
Part of the Human Interface Device service.
Part of the Alert Notification service, which exposes the count of unread alert events existing in th...
static bool isWritable(uint8_t properties)
Indicates if the properties has at least one of the writable flags.
Characteristic of the Environmental Sensing service that exposes the temperature measurement with a r...
GattAuthCallbackReply_t authorizeRead(GattReadAuthCallbackParams *params)
Invoke the read authorization callback.
Not used in a service as a characteristic.
Permits signed writes to the characteristic value.
GATT write authorization request event.
Amount concentration (mole per cubic meter).
Characteristic of the Alert Notification service, which exposes categories of unread alert supported ...
Not used in actual BLE service.
Acceleration, meters per second squared.
Electric current, ampere.
Catalytic activity concentration, katal per cubic meter.
SecurityRequirement_t getReadSecurityRequirement() const
Get the security requirement of the read operation.
The operation require encryption with an authenticated peer that paired using secure connection pairi...
Density, kilogram per cubic meter.
Characteristic of the Blood Pressure service, which exposes intermediate cuff pressure measurements...
Characteristic of the Health Thermometer service that describes where the measurement takes place...
Characteristic of the Heart Rate service used by the client to control the service behavior...
void setUpdateSecurityRequirement(SecurityRequirement_t security)
Set the security requirement of update operations.
Electric charge, ampere hours.
Characteristic of the Running Speed and Cadence (RSC) service that exposes features supported by the ...
Specific volume (cubic meter per kilogram).
Security requirement that can be attached to an attribute operation.
Heat capacity, joule per kelvin.
void setSecurityRequirements(SecurityRequirement_t read_security, SecurityRequirement_t write_security, SecurityRequirement_t update_security)
Set all security requirements of the characteristic.
The operation requires security and there's no requirement towards peer authentication.
Electrical charge, coulomb.
Concentration, count per cubic meter.
Part of the Human Interface Device service.
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.
Velocity, kilometer per hour.
GattAttribute & getValueAttribute()
Get the characteristic's value attribute.
Heat flux density, watt per square meter.
Permits notifications of a characteristic value without acknowledgment.
Require signing or encryption, but no MITM protection.
Electric flux density, coulomb per square meter.
Not used in a service as a characteristic.
GattAuthCallbackReply_t authorizationReply
Authorization result.
uint8_t getDescriptorCount(void) const
Get the total number of descriptors within this characteristic.
Permeability, henry per meter.
Specific energy, joule per kilogram.
Not used as a characteristic UUID.
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 Reference Time service that allows clients to control time update.
Thermodynamic temperature, kelvin.
The operation does not have security requirements.
Not used in a service as a characteristic.
Characteristic of the Device Information Service that exposes a structure containing an Organizationa...
Characteristic of the Environmental Sensing service, which exposes humidity measurements.
Require signing or encryption, and MITM protection.
Molar energy, joule per mole.
type
struct scoped enum wrapped by the class
Thermodynamic temperature, degree Fahrenheit.
Describe the features supported by the blood pressure sensor exposed by the Blood Pressure service...
Electric resistance, ohm.
Characteristic of the Device Information Service that contains a UTF8 string representing the firmwar...
Helper class that represents a read-only GattCharacteristic with an array value.
Representation of a Universally Unique Identifier (UUID).
void setReadSecurityRequirement(SecurityRequirement_t security)
Set the security of the read operation.
Representation of a GattServer attribute.
Not used in a service as a characteristic.
Characteristic of the Device Information Service that contains an UTF8 string representing the softwa...
Characteristic of the Scan Parameter service that sends a notification to a client when the server re...
Characteristic of the Health Thermometer service that sends temperature measurement to clients...
Characteristic of the Device Information Service that contains a UTF8 string representing the manufac...
Characteristic of the Running Speed and Cadence (RSC) service that exposes measurements made by the s...
Permits writes of the characteristic value without response.
Characteristic of the Scan Parameter service that stores the client's scan parameters (scan interval ...
ble::attribute_handle_t Handle_t
Representation of an attribute handle.
Require encryption, but no MITM protection.
Characteristic of the Phone Alert Status service that allows a client to configure operating mode...
Characteristic of the Device Information Service that contains a UTF8 string representing the hardwar...
Velocity, meters per second.
Helper class that represents a write-only GattCharacteristic with an array value. ...
Angular acceleration, radian per second squared.
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.
Part of the Human Interface Device service.
Characteristic of the Cycling Speed and Cadence (CSC) service that exposes measurements made by the s...
Surface charge density, coulomb per square meter.
Handle_t getHandle(void) const
Get the attribute's handle in the ATT table.
Electric conductance, siemens.
void setReadAuthorizationCallback(void(*callback)(GattReadAuthCallbackParams *))
Register the read requests event handler.
bool isReadAuthorizationEnabled() const
Check whether read authorization is enabled.
Characteristic of the Heart Rate service that indicate the intended location of the heart rate monito...
Radiance, watt per square meter steradian.
Energy density, joule per cubic meter.
GattAuthCallbackReply_t authorizeWrite(GattWriteAuthCallbackParams *params)
Invoke the write authorization callback.
Characteristic of the Phone Alert Status service that returns the ringer setting when read...
Characteristic of the Cycling Speed and Cadence (CSC) service that exposes features supported by the ...
Catalytic activity, katal.
SecurityMode_t
level of security required from the link by the application
Surface density (kilogram per square meter).
static const uint8_t size
Number of bits required to store the value.
Not used in actual BLE service.
Characteristic of the Current Time service that contains the current time.
static bool isReadable(uint8_t properties)
Indicates if the properties is readable.
Not used in a service as a characteristic.
SecurityRequirement_t getWriteSecurityRequirement() const
Get the security requirement of write operations.
The Characteristic Extended Properties descriptor defines additional characteristic properties...
Molar entropy, joule per mole kelvin.
Characteristic of the Health Thermometer service that sends intermediate temperature values while the...
Representation of a GattServer characteristic.
Mass density, milligram per deciliter.
Not used in a service as a characteristic.
Characteristic of the current Time service that exposes information about the local time...
GattAttribute * getDescriptor(uint8_t index)
Get this characteristic's descriptor at a specific index.
Permits indications of a characteristic value with acknowledgment.
Require encryption and MITM protection.
Dynamic viscosity, pascal second.
Characteristic of the Battery service, which exposes the current battery level as a percentage...
Magnetic field strength, ampere per meter.
Pressure, pound-force per square inch.
Helper class that represents a write only GattCharacteristic.
Activity referred to a radionuclide, becquerel.
Exposure, coulomb per kilogram.
Control point of the Alert Notification service that allows the client finely tune the notification c...
Characteristic of the TX Power service that exposes the current transmission power in dBm...
Not used as a characteristic UUID.
Require no protection, open link.
GattAttribute::Handle_t getValueHandle(void) const
Get the characteristic's value attribute handle in the ATT table.
Characteristic of the Device Information Service that contains a UTF8 string representing the serial ...
Logarithmic radio quantity, bel.
Dose equivalent, sievert.
Part of the Human Interface Device service.
Permits broadcasts of the characteristic value using the Server Characteristic Configuration descript...
Characteristic of the Alert Notification Service that notifies the count of new alerts for a given ca...
Permittivity, farad per meter.
bool isWriteAuthorizationEnabled() const
Check whether write authorization is enabled.
Pressure, millimeter of mercury.
SecurityRequirement_t getUpdateSecurityRequirement() const
Get the security requirement of update operations.
Characteristic of the Alert Notification Service that shows how many numbers of unread alerts exist i...
void setReadAuthorizationCallback(T *object, void(T::*member)(GattReadAuthCallbackParams *))
Register the read requests event handler.
void setWriteAuthorizationCallback(void(*callback)(GattWriteAuthCallbackParams *))
Register a callback handling client's write requests or commands.
Part of the Human Interface Device service.
Energy, kilogram calorie.
Characteristic of the Alert Notification Service that defines the category of the alert and how many ...
Thermal conductivity, watt per meter kelvin.
void setWriteSecurityRequirement(SecurityRequirement_t security)
Set the security requirement of the write operations.
Mass density, millimole per liter.
Moment of force, newton meter.
The operation requires security and the peer must be authenticated.
Characteristic of the Heart Rate that sends heart rate measurements to registered clients...
Characteristic of the Glucose service that exposes features supported by the server.
Unsigned 128-bit integer.
Characteristic of the Reference Time service that informs clients of the status of the time update op...
void setWriteAuthorizationCallback(T *object, void(T::*member)(GattWriteAuthCallbackParams *))
Register a callback handling client's write requests or commands.
IEEE-754 64-bit floating point.
Helper class that represents a read only GattCharacteristic.
Wave number reciprocal, meter.
Characteristic of the Device Information Service that contains a UTF8 string representing the model n...
Mass concentration (kilogram per cubic meter).
Period, beats per minute.
Amount of substance, mole.
Part of the Human Interface Device service.
Not used in a service as a characteristic.
Part of the Human Interface Device service.
Absorbed dose rate, gray per second.
Permits writes of the characteristic value with response.
Irradiance, watt per square meter.
Control point of the Immediate Alert service that allows the client to command the server to alert to...
Characteristic of the Environmental Sensing Service that exposes the pressure measured.
Surface tension, newton per meter.
Characteristic of the Device Information Service, which exposes various regulatory or certification c...
Luminance (candela per square meter).
Angular velocity, radian per second.
Pulse Oxymeter, Glucose and Continuous Glucose Monitoring services use this control point to provide ...
Radiant intensity, watt per steradian.
SecurityManager::SecurityMode_t getRequiredSecurity() const
Get the characteristic's required security.
GattAuthCallbackReply_t
Enumeration of allowed values returned by read or write authorization process.
Electric charge density, coulomb per cubic meter.