Bluenet  5.4.0
Bluenet, the firmware for the Crownstone power outlet
Loading...
Searching...
No Matches
Characteristic< T, typename std::enable_if< std::is_arithmetic< T >::value >::type > Class Template Reference

A characteristic for built-in arithmetic types (int, float, etc) More...

#include <cs_Characteristic.h>

Inheritance diagram for Characteristic< T, typename std::enable_if< std::is_arithmetic< T >::value >::type >:
Collaboration diagram for Characteristic< T, typename std::enable_if< std::is_arithmetic< T >::value >::type >:

Public Member Functions

void operator= (const T &val)
 
uint8_t * getValuePtr ()
 Return the pointer to the memory where the value is stored In the case of aes encryption, this is the pointer to the unencrypted value. More...
 
uint16_t getValueLength ()
 Return the actual length of the value In the case of aes encryption, this is the length of the unencrypted data. More...
 
uint16_t getGattValueLength ()
 Return the actual length of the value used by the gatt server In the case of aes encryption, this is the length of the encrypted value otherwise it's the same as the value length. More...
 
uint16_t getGattValueMaxLength ()
 Return the maximum length of the value used by the gatt server In the case of aes encryption, this is the maximum length that the value can be when encrypted. More...
 
- Public Member Functions inherited from CharacteristicGeneric< T >
virtual ~CharacteristicGeneric ()
 Default empty destructor.
 
T & getValue ()
 Return the value In the case of aes encryption, this is the unencrypted value.
 
void onWrite (const callback_on_write_t &closure)
 Register an on write callback which will be triggered when a characteristic is written over ble.
 
 operator T& ()
 CharacteristicGeneric() returns value object In the case of aes encryption, this is the unencrypted value. More...
 
void operator= (const T &val)
 Assign a new value to the characteristic so that it can be read over ble. More...
 
void setDefaultValue (const T &t)
 Set the default value.
 
- Public Member Functions inherited from CharacteristicBase
 CharacteristicBase ()
 Unit. More...
 
virtual ~CharacteristicBase ()
 Empty destructor.
 
void init (Service *svc)
 Initialize the characteristic: add it to the softdevice. More...
 
void setName (const char *const name)
 Set the name of this characteristic.
 
void setWritable (bool writable)
 Set this characteristic to be writable.
 
void setNotifies (bool notifies)
 Set this characteristic to be notifiable.
 
bool isNotifyingEnabled ()
 
void setNotifyingEnabled (bool enabled)
 
void setIndicates (bool indicates)
 
void setUUID (const UUID &uuid)
 
uint16_t getValueHandle ()
 
uint16_t getCccdHandle ()
 
void setSharedEncryptionBuffer (bool val)
 
virtual uint16_t getGattValueMaxLength ()=0
 Return the maximum length of the value used by the gatt server In the case of aes encryption, this is the maximum length that the value can be when encrypted. More...
 
virtual void setGattValueLength (uint16_t)
 Set the length of the value used by the gatt server In the case of aes encryption, this is the length of the encrypted value otherwise it's the same as the value length which is a fixed value for normal types (arithmetic types and strings) but has to be set for buffer values because they have dynamic length. More...
 
virtual uint16_t getGattValueLength ()=0
 Return the actual length of the value used by the gatt server In the case of aes encryption, this is the length of the encrypted value otherwise it's the same as the value length. More...
 
uint8_t * getGattValuePtr ()
 Return the pointer to the memory where the value is accessed by the gatt server. More...
 
virtual uint8_t * getValuePtr ()=0
 Return the pointer to the memory where the value is stored In the case of aes encryption, this is the pointer to the unencrypted value. More...
 
virtual void setValueLength (uint16_t)
 Set the actual length of the data @length the length of the data to which the value points. More...
 
virtual uint16_t getValueLength ()=0
 Return the actual length of the value In the case of aes encryption, this is the length of the unencrypted data. More...
 
virtual void onWrite (uint16_t len)=0
 Helper function which is called when a characteristic is written over BLE. More...
 
uint32_t updateValue (ConnectionEncryptionType encryptionType=ConnectionEncryptionType::CTR)
 Update the value in the gatt server so that the value can be read over BLE If somebody is also listening to notifications for the characteristic notifications will be sent.
 
virtual uint32_t notify ()
 Notify any listening party. More...
 
void onNotifyTxError ()
 Callback function if a notify tx error occurs. More...
 
virtual void onTxComplete (const ble_common_evt_t *p_ble_evt)
 Callback function once tx operations complete @p_ble_evt the event object which triggered the onTxComplete callback. More...
 
void setAesEncrypted (bool encrypted)
 Enable / Disable aes encryption. More...
 
bool isAesEnabled ()
 Check if aes encryption is enabled.
 
void setMinAccessLevel (EncryptionAccessLevel level)
 
buffer_ptr_t & getEncryptionBuffer ()
 get the buffer used for encryption
 
ServicegetService ()
 

Additional Inherited Members

- Public Types inherited from CharacteristicGeneric< T >
typedef function< void(const EncryptionAccessLevel, const T &, uint16_t length)> callback_on_write_t
 Format of callback on write (from user)
 
- Protected Member Functions inherited from CharacteristicGeneric< T >
void onWrite (uint16_t len)
 Helper function if a characteristic is written over ble. More...
 
virtual bool configurePresentationFormat (ble_gatts_char_pf_t &presentation_format)
 Configure the characteristic value format (ble specific) More...
 
void initEncryptionBuffer ()
 Initialize / allocate a buffer for encryption. More...
 
void freeEncryptionBuffer ()
 Free / release the encryption buffer. More...
 
virtual void initEncryptionBuffer ()=0
 Initialize the encryption buffer to hold the encrypted value. More...
 
virtual void freeEncryptionBuffer ()=0
 Free / release the encryption buffer. More...
 
virtual bool configurePresentationFormat (ble_gatts_char_pf_t &)
 Configure the characteristic value format (ble specific) More...
 
- Protected Attributes inherited from CharacteristicGeneric< T >
_value
 The generic type is physically located in this field in this class (by value, not just by reference) In the case of aes encryption, this is the unencrypted value.
 
callback_on_write_t _callbackOnWrite
 The callback to call on a write coming from the softdevice (and originating from the user)
 
- Protected Attributes inherited from CharacteristicBase
const char * _name = nullptr
 Name of this characteristic.
 
UUID _uuid
 UUID of this characteristic.
 
ble_gatts_char_handles_t _handles
 Handles.
 
Service_service = nullptr
 Reference to corresponding service.
 
Status _status
 Status of CharacteristicBase (basically a bunch of 1-bit flags)
 
buffer_ptr_t _encryptionBuffer = nullptr
 
EncryptionAccessLevel _minAccessLevel = ADMIN
 used for encryption. More...
 

Detailed Description

template<typename T>
class Characteristic< T, typename std::enable_if< std::is_arithmetic< T >::value >::type >

A characteristic for built-in arithmetic types (int, float, etc)

Member Function Documentation

◆ getGattValueLength()

template<typename T >
uint16_t Characteristic< T, typename std::enable_if< std::is_arithmetic< T >::value >::type >::getGattValueLength ( )
inlinevirtual

Return the actual length of the value used by the gatt server In the case of aes encryption, this is the length of the encrypted value otherwise it's the same as the value length.

Implements CharacteristicBase.

◆ getGattValueMaxLength()

template<typename T >
uint16_t Characteristic< T, typename std::enable_if< std::is_arithmetic< T >::value >::type >::getGattValueMaxLength ( )
inlinevirtual

Return the maximum length of the value used by the gatt server In the case of aes encryption, this is the maximum length that the value can be when encrypted.

for normal types (arithmetic types and strings) this is a fixed value, for dynamic types, the max length has to be set at construction In the case of no encryption, for normal types, this is the same as the value length

Implements CharacteristicBase.

◆ getValueLength()

template<typename T >
uint16_t Characteristic< T, typename std::enable_if< std::is_arithmetic< T >::value >::type >::getValueLength ( )
inlinevirtual

Return the actual length of the value In the case of aes encryption, this is the length of the unencrypted data.

For normal types (arithmetic and strings) this is a fixed value. For buffer types it is dynamic

Implements CharacteristicBase.

◆ getValuePtr()

template<typename T >
uint8_t * Characteristic< T, typename std::enable_if< std::is_arithmetic< T >::value >::type >::getValuePtr ( )
inlinevirtual

Return the pointer to the memory where the value is stored In the case of aes encryption, this is the pointer to the unencrypted value.

Implements CharacteristicBase.


The documentation for this class was generated from the following file: