Bluenet  5.7.0
Bluenet, firmware for nRF52 smart home devices
Loading...
Searching...
No Matches
Service Class Referenceabstract

Base class for a BLE service. More...

#include <cs_Service.h>

Inheritance diagram for Service:
Collaboration diagram for Service:

Public Types

enum  condition_t { C_SERVICE_INITIALIZED }
 

Public Member Functions

 Service ()
 
virtual ~Service ()
 Default empty destructor. More...
 
void init (Stack *stack)
 Initialize the service: register it at the softdevice. More...
 
void setUUID (const UUID &uuid)
 Set the UUID. More...
 
StackgetStack ()
 
const UUIDgetUUID () const
 
uint16_t getHandle ()
 
tuple< CharacteristicBase * > getCharacteristics ()
 
virtual void createCharacteristics ()=0
 
void onBleEvent (const ble_evt_t *event)
 
void onConnect (uint16_t connectionHandle, const ble_gap_evt_connected_t &event)
 
void onDisconnect (uint16_t connectionHandle, const ble_gap_evt_disconnected_t &event)
 
bool onWrite (const ble_gatts_evt_write_t &event, uint16_t gattHandle)
 
void onTxComplete (const ble_common_evt_t *event)
 
void addCharacteristic (CharacteristicBase *characteristic)
 Add a single characteristic to the list @characteristic Characteristic to add. More...
 
void updatedCharacteristics ()
 
- Public Member Functions inherited from BaseClass< 1 >
 BaseClass ()
 
bool isInitialized (uint8_t i=0)
 
void setInitialized (uint8_t i=0)
 
void setUninitialized (uint8_t i=0)
 

Private Attributes

Stack_stack = nullptr
 Back reference to the stack. More...
 
UUID _uuid
 
uint16_t _handle = BLE_CONN_HANDLE_INVALID
 Service handle will be obtained from SoftDevice. More...
 
tuple< CharacteristicBase * > _characteristics
 List of characteristics. More...
 

Detailed Description

Base class for a BLE service.

Member Enumeration Documentation

◆ condition_t

Enumerator
C_SERVICE_INITIALIZED 

Constructor & Destructor Documentation

◆ Service()

◆ ~Service()

virtual Service::~Service ( )
inlinevirtual

Default empty destructor.

We don't currently delete our characteristics as we don't really support dynamic service destruction. If we wanted to allow services to be removed at runtime, we would need to, amongst many other things, keep track of whether we allocated the characteristic or whether it was passed into us.

Member Function Documentation

◆ addCharacteristic()

void Service::addCharacteristic ( CharacteristicBase characteristic)

Add a single characteristic to the list @characteristic Characteristic to add.

◆ createCharacteristics()

virtual void Service::createCharacteristics ( )
pure virtual

◆ getCharacteristics()

tuple< CharacteristicBase * > Service::getCharacteristics ( )
inline

◆ getHandle()

uint16_t Service::getHandle ( )
inline

◆ getStack()

Stack * Service::getStack ( )
inline

◆ getUUID()

const UUID & Service::getUUID ( ) const
inline

◆ init()

void Service::init ( Stack stack)

Initialize the service: register it at the softdevice.

◆ onBleEvent()

void Service::onBleEvent ( const ble_evt_t *  event)

◆ onConnect()

void Service::onConnect ( uint16_t  connectionHandle,
const ble_gap_evt_connected_t &  event 
)

◆ onDisconnect()

void Service::onDisconnect ( uint16_t  connectionHandle,
const ble_gap_evt_disconnected_t &  event 
)

◆ onTxComplete()

void Service::onTxComplete ( const ble_common_evt_t *  event)

◆ onWrite()

bool Service::onWrite ( const ble_gatts_evt_write_t &  event,
uint16_t  gattHandle 
)

◆ setUUID()

void Service::setUUID ( const UUID uuid)

Set the UUID.

The UUID cannot be set anymore after the service has been initialized.

◆ updatedCharacteristics()

void Service::updatedCharacteristics ( )
inline

Member Data Documentation

◆ _characteristics

tuple<CharacteristicBase*> Service::_characteristics
private

List of characteristics.

◆ _handle

uint16_t Service::_handle = BLE_CONN_HANDLE_INVALID
private

Service handle will be obtained from SoftDevice.

◆ _stack

Stack* Service::_stack = nullptr
private

Back reference to the stack.

◆ _uuid

UUID Service::_uuid
private

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