Bluenet
5.7.0
Bluenet, firmware for nRF52 smart home devices
|
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>
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... | |
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.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
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.
|
inline |
Utility function to get the data as uint8_t*.
void* event_t::data |
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.
size16_t event_t::size |
cmd_source_with_counter_t event_t::source |
Source of the command (optional).