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

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

#include <cs_Event.h>

Collaboration diagram for event_t:

Public Member Functions

 event_t (CS_TYPE type, void *data, size16_t size, const cmd_source_with_counter_t &source, const cs_result_t &result)
 
 event_t (CS_TYPE type, void *data, size16_t size, const cmd_source_with_counter_t &source)
 
 event_t (CS_TYPE type, void *data, size16_t size, const cs_result_t &result)
 
 event_t (CS_TYPE type, void *data, size16_t size)
 
 event_t (CS_TYPE type)
 
uint8_t * getData ()
 Utility function to get the data as uint8_t*. More...
 
void dispatch ()
 Utility function so that not every file needs to include the eventdispatcher. More...
 

Public Attributes

CS_TYPE type
 
void * data
 
size16_t size
 
cmd_source_with_counter_t source
 Source of the command (optional). More...
 
cs_result_t result
 Result of the event (optional). More...
 

Detailed Description

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

An event which can be sent over the event bus. The event bus is synchronous.

There is no possibility to send a mere uint8_t or other primitive data type. Everything is passed by pointer. Hence, first create a local variable on the stack, then point to it.

uint8_t data = 1; event_t event(CS_TYPE::EVT_XXX, &data, sizeof(data));

There is no memory allocation or deallocation happening in this class. The caller is responsible for this. If you use the stack, make sure you dispatch the event when the data on the stack is still valid.

Constructor & Destructor Documentation

◆ event_t() [1/5]

event_t::event_t ( CS_TYPE  type,
void *  data,
size16_t  size,
const cmd_source_with_counter_t source,
const cs_result_t result 
)
inline

◆ event_t() [2/5]

event_t::event_t ( CS_TYPE  type,
void *  data,
size16_t  size,
const cmd_source_with_counter_t source 
)
inline

◆ event_t() [3/5]

event_t::event_t ( CS_TYPE  type,
void *  data,
size16_t  size,
const cs_result_t result 
)
inline

◆ event_t() [4/5]

event_t::event_t ( CS_TYPE  type,
void *  data,
size16_t  size 
)
inline

◆ event_t() [5/5]

event_t::event_t ( CS_TYPE  type)
inline

Member Function Documentation

◆ dispatch()

void event_t::dispatch ( )

Utility function so that not every file needs to include the eventdispatcher.

This runs the handleEvent(...) method of all registered listeners.

◆ getData()

uint8_t * event_t::getData ( )
inline

Utility function to get the data as uint8_t*.

Member Data Documentation

◆ data

void* event_t::data

◆ result

cs_result_t event_t::result

Result of the event (optional).

Sender of the event allocates the a buffer and assigns it to result.buf if it accepts response data. Handler of the event adjusts the result code, writes to result.buf.data and sets result.dataSize accordingly.

◆ size

size16_t event_t::size

◆ source

cmd_source_with_counter_t event_t::source

Source of the command (optional).

◆ type


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