Bluenet  5.7.0
Bluenet, firmware for nRF52 smart home devices
Loading...
Searching...
No Matches
CrownstoneService Class Reference

Author: Crownstone Team Copyright: Crownstone (https://crownstone.rocks) Date: Oct 22, 2014 License: LGPLv3+, Apache License 2.0, and/or MIT (triple-licensed) More...

#include <cs_CrownstoneService.h>

Inheritance diagram for CrownstoneService:
Collaboration diagram for CrownstoneService:

Public Member Functions

 CrownstoneService ()
 Constructor for general crownstone service object. More...
 
virtual void handleEvent (event_t &event)
 Perform non urgent functionality every main loop. More...
 
- Public Member Functions inherited from Service
 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)
 

Protected Member Functions

void createCharacteristics ()
 Initialize a CrownstoneService object. More...
 
void addControlCharacteristic (buffer_ptr_t buffer, cs_buffer_size_t size, uint16_t charUuid, EncryptionAccessLevel minimumAccessLevel)
 Enable the control characteristic. More...
 
void addResultCharacteristic (buffer_ptr_t buffer, cs_buffer_size_t size, uint16_t charUuid, EncryptionAccessLevel minimumAccessLevel)
 Enable the result characteristic. More...
 
void addFactoryResetCharacteristic ()
 
void addSessionDataCharacteristic (buffer_ptr_t buffer, cs_buffer_size_t size, EncryptionAccessLevel minimumAccessLevel=BASIC)
 
void getReadBuffer (buffer_ptr_t &buffer, cs_buffer_size_t &maxLength)
 
void getWriteBuffer (buffer_ptr_t &buffer, cs_buffer_size_t &maxLength)
 
void removeBuffer ()
 
void writeResult (uint8_t protocol, CommandHandlerTypes type, cs_result_t &result)
 Write a result to the result characteristic. More...
 
void writeResult (uint8_t protocol, CommandHandlerTypes type, cs_ret_code_t retCode, cs_data_t data)
 Write a result to the result characteristic. More...
 

Protected Attributes

Characteristic< buffer_ptr_t > * _controlCharacteristic = nullptr
 
Characteristic< buffer_ptr_t > * _resultCharacteristic = nullptr
 
ControlPacketAccessor_controlPacketAccessor = nullptr
 
ResultPacketAccessor_resultPacketAccessor = nullptr
 

Private Attributes

uint8_t _keySessionDataBuffer [sizeof(session_data_t)]
 
Characteristic< buffer_ptr_t > * _sessionDataCharacteristic = nullptr
 
Characteristic< buffer_ptr_t > * _sessionDataUnencryptedCharacteristic = nullptr
 
Characteristic< uint32_t > * _factoryResetCharacteristic = nullptr
 

Additional Inherited Members

- Public Types inherited from Service
enum  condition_t { C_SERVICE_INITIALIZED }
 
- Private Member Functions inherited from EventListener
 EventListener ()
 
virtual ~EventListener ()
 unregisters the listener. More...
 
virtual void handleEvent (event_t &event)=0
 Handle events. More...
 
void listen ()
 Registers this with the EventDispatcher. More...
 

Detailed Description

Author: Crownstone Team Copyright: Crownstone (https://crownstone.rocks) Date: Oct 22, 2014 License: LGPLv3+, Apache License 2.0, and/or MIT (triple-licensed)

General Service for the Crownstone

There are several characteristics that fit into the general service description. There is a characteristic that measures the temperature, there are several characteristics that defines the crownstone, namely by name, by type, or by location (room), and there is a characteristic to update its firmware.

If meshing is enabled, it is also possible to send a message into the mesh network using a characteristic.

Constructor & Destructor Documentation

◆ CrownstoneService()

Constructor for general crownstone service object.

Creates persistent storage (FLASH) object which is used internally to store name and other information that is set over so-called configuration characteristics. It also initializes all characteristics.

Member Function Documentation

◆ addControlCharacteristic()

void CrownstoneService::addControlCharacteristic ( buffer_ptr_t  buffer,
cs_buffer_size_t  size,
uint16_t  charUuid,
EncryptionAccessLevel  minimumAccessLevel 
)
protected

Enable the control characteristic.

◆ addFactoryResetCharacteristic()

void CrownstoneService::addFactoryResetCharacteristic ( )
protected

◆ addResultCharacteristic()

void CrownstoneService::addResultCharacteristic ( buffer_ptr_t  buffer,
cs_buffer_size_t  size,
uint16_t  charUuid,
EncryptionAccessLevel  minimumAccessLevel 
)
protected

Enable the result characteristic.

◆ addSessionDataCharacteristic()

void CrownstoneService::addSessionDataCharacteristic ( buffer_ptr_t  buffer,
cs_buffer_size_t  size,
EncryptionAccessLevel  minimumAccessLevel = BASIC 
)
protected

◆ createCharacteristics()

void CrownstoneService::createCharacteristics ( )
protectedvirtual

Initialize a CrownstoneService object.

Add all characteristics and initialize them where necessary.

Implements Service.

Reimplemented in SetupService.

◆ getReadBuffer()

void CrownstoneService::getReadBuffer ( buffer_ptr_t buffer,
cs_buffer_size_t maxLength 
)
protected

◆ getWriteBuffer()

void CrownstoneService::getWriteBuffer ( buffer_ptr_t buffer,
cs_buffer_size_t maxLength 
)
protected

◆ handleEvent()

virtual void CrownstoneService::handleEvent ( event_t event)
virtual

Perform non urgent functionality every main loop.

Every component has a "tick" function which is for non-urgent things. Urgent matters have to be resolved immediately in interrupt service handlers. The temperature for example is updated every tick, because timing is not important for this at all.

Implements EventListener.

Reimplemented in SetupService.

◆ removeBuffer()

void CrownstoneService::removeBuffer ( )
protected

◆ writeResult() [1/2]

void CrownstoneService::writeResult ( uint8_t  protocol,
CommandHandlerTypes  type,
cs_result_t result 
)
protected

Write a result to the result characteristic.

Parameters
[in]protocolThe protocol version.
[in]typeThe command type that was handled.
[in]resultThe result of handling the command.

◆ writeResult() [2/2]

void CrownstoneService::writeResult ( uint8_t  protocol,
CommandHandlerTypes  type,
cs_ret_code_t  retCode,
cs_data_t  data 
)
protected

Write a result to the result characteristic.

Parameters
[in]protocolThe protocol version.
[in]typeThe command type that was handled.
[in]retCodeThe result code of handling the command.
[in]dataThe result data of handling the command.

Member Data Documentation

◆ _controlCharacteristic

Characteristic<buffer_ptr_t>* CrownstoneService::_controlCharacteristic = nullptr
protected

◆ _controlPacketAccessor

ControlPacketAccessor* CrownstoneService::_controlPacketAccessor = nullptr
protected

◆ _factoryResetCharacteristic

Characteristic<uint32_t>* CrownstoneService::_factoryResetCharacteristic = nullptr
private

◆ _keySessionDataBuffer

uint8_t CrownstoneService::_keySessionDataBuffer[sizeof(session_data_t)]
private

◆ _resultCharacteristic

Characteristic<buffer_ptr_t>* CrownstoneService::_resultCharacteristic = nullptr
protected

◆ _resultPacketAccessor

ResultPacketAccessor* CrownstoneService::_resultPacketAccessor = nullptr
protected

◆ _sessionDataCharacteristic

Characteristic<buffer_ptr_t>* CrownstoneService::_sessionDataCharacteristic = nullptr
private

◆ _sessionDataUnencryptedCharacteristic

Characteristic<buffer_ptr_t>* CrownstoneService::_sessionDataUnencryptedCharacteristic = nullptr
private

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