19#define MAX_NOTIFICATION_LEN 20
176 ble_gatts_char_handles_t
_handles = ble_gatts_char_handles_t();
Base class for a BLE characteristic.
Definition: cs_CharacteristicBase.h:42
cs_ret_code_t notify(uint16_t length=0, uint16_t offset=0)
Notify or indicate the characteristic value.
ble_gatts_char_handles_t _handles
Handles, set by softdevice at init.
Definition: cs_CharacteristicBase.h:176
const char * _name
Name of this characteristic.
Definition: cs_CharacteristicBase.h:164
uint16_t getGattValueMaxLength()
Return the maximum length of the value used by the GATT server.
cs_ret_code_t notifyMultipart()
Notify the value in parts.
bool _subscribedForNotifications
Whether the central subscribed for notifications.
Definition: cs_CharacteristicBase.h:204
bool isEncrypted()
Returns true when the characteristic value is or should be encrypted.
uint16_t getGattValueLength()
Return the actual length of the value used by the GATT server.
cs_ret_code_t initEncryptedBuffer()
Initialize the encrypted buffer.
uint16_t _uuid
UUID of this characteristic.
Definition: cs_CharacteristicBase.h:167
void onWrite(uint16_t length)
Function to be called by the stack when this characteristic is written over BLE.
cs_ret_code_t setGattValue()
Update the gatt value in the softdevice.
cs_ret_code_t setEventHandler(const characteristic_callback_t &closure)
Register an event handler.
cs_data_t _encryptedBuffer
The buffer holding the encrypted characteristic value.
Definition: cs_CharacteristicBase.h:192
uint16_t getValueHandle()
Get the value handle.
cs_ret_code_t setInitialValueLength(cs_buffer_size_t size)
Set the initial value length.
cs_ret_code_t updateValue(uint16_t length)
Call this function when you changed the characteristic value.
bool _notificationPending
Flag to indicate if notification or indication is pending to be sent.
Definition: cs_CharacteristicBase.h:198
Service * _service
Reference to corresponding service, set at init.
Definition: cs_CharacteristicBase.h:179
friend Service
Definition: cs_CharacteristicBase.h:127
uint16_t _encryptedValueLength
Actual length of the (encrypted) data stored in the buffer.
Definition: cs_CharacteristicBase.h:195
cs_ret_code_t setValueBuffer(buffer_ptr_t buffer, cs_buffer_size_t size)
Set the buffer to be used for the (plain text) characteristic value.
uint16_t getCccdHandle()
Get the CCCD handle.
uint16_t _notificationOffset
When using the notification chunker, this is the current offset of the value to notify next.
Definition: cs_CharacteristicBase.h:201
virtual ~CharacteristicBase()
Definition: cs_CharacteristicBase.h:46
characteristic_callback_t _callback
The callback to call.
Definition: cs_CharacteristicBase.h:173
cs_ret_code_t init(Service *svc)
Initialize the characteristic: add it to the softdevice.
bool _subscribedForIndications
Whether the central subscribed for indication.
Definition: cs_CharacteristicBase.h:207
cs_data_t getValue()
Get the current (plain text) value.
void onDisconnect()
Function to be called by the stack on disconnect.
void onConnect()
Function to be called by the stack on connect.
cs_ret_code_t setName(const char *const name)
Set the name of this characteristic.
uint16_t _valueLength
Actual length of (plain text) data stored in the buffer.
Definition: cs_CharacteristicBase.h:187
characteristic_config_t _config
The configuration of the characteristic.
Definition: cs_CharacteristicBase.h:170
cs_ret_code_t setUuid(uint16_t uuid)
Set the UUID of this characteristic.
cs_ret_code_t setConfig(const characteristic_config_t &config)
Set configuration for this characteristic.
void onCccdWrite(const uint8_t *data, uint16_t size)
Function to be called by the stack when this characteristic configuration is written over BLE.
bool isSubscribedForNotifications()
Return true when the client subscribed for notifications or indications.
bool _initialized
Whether this characteristic has been initialized.
Definition: cs_CharacteristicBase.h:161
uint8_t * getGattValue()
Return the pointer to the memory where the value is accessed by the GATT server.
cs_data_t _buffer
The buffer holding the (plain text) characteristic value.
Definition: cs_CharacteristicBase.h:184
void onNotificationDone()
Function to be called by the stack when the notification or indication has been sent.
void deinitEncryptedBuffer()
Deallocates the encrypted buffer if it was allocated.
Base class for a BLE service.
Definition: cs_Service.h:26
function< void(CharacteristicEventType, CharacteristicBase *, EncryptionAccessLevel)> characteristic_callback_t
Callback function for events.
Definition: cs_CharacteristicBase.h:30
#define MAX_NOTIFICATION_LEN
Definition: cs_CharacteristicBase.h:19
CharacteristicEventType
Definition: cs_CharacteristicStructs.h:67
EncryptionAccessLevel
Packets (structs) that are used over the air, over uart, or stored in flash.
Definition: cs_Packets.h:36
uint16_t cs_buffer_size_t
Definition: cs_Typedefs.h:20
uint16_t cs_ret_code_t
Definition: cs_Typedefs.h:21
uint8_t * buffer_ptr_t
Author: Crownstone Team Copyright: Crownstone (https://crownstone.rocks) Date: 10 May....
Definition: cs_Typedefs.h:19
Definition: cs_CharacteristicBase.h:155
uint8_t partNr
Definition: cs_CharacteristicBase.h:156
Definition: cs_CharacteristicStructs.h:15
Packets (structs) that are used internally in the firmware, and can be changed freely.
Definition: cs_PacketsInternal.h:27