Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions include/events.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// This file is going to need to expose the get functions for the web thread
// We can also probably store some structs in here

#ifndef __EVENTS_H__
#define __EVENTS_H__

#include <point.h>
#include <stdbool.h>

// Forward declaration for event filter callback
typedef bool (*event_filter_callback_t)(const point *p);

// Event configuration structure - defined here, table populated by applications
typedef struct {
const char *type;
const char *key;
bool store_in_nvs;
float warning_threshold; // For numeric types (0 = not used)
float critical_threshold; // For numeric types (0 = not used)
bool always_generate; // Bypass filtering (for points that only get generated when an event has occurred)
} event_config_t;

// Application-specific event configuration table
// Should be placed at the top of main.c in application
extern const event_config_t event_configs[];
extern const size_t event_configs_count;

int get_all_events(uint8_t *recv_buffer, size_t buffer_size);

void events_start_thread(void);

// Set application-specific event filtering callback
void events_set_filter_callback(event_filter_callback_t callback);

#endif // __EVENTS_H__
1 change: 1 addition & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ if(CONFIG_LIB_SIOT)
zbus.c
nvs.c
siot-string.c
events.c
)
endif()
20 changes: 19 additions & 1 deletion lib/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,22 @@ config SIOT_LOG_LEVEL
4: Debug
5: Verbose

endif #LIB_SIOT
config NVS_EVENT_QUEUE_SIZE
int "NVS Event Queue Size"
default 10
help
Defines the size of persisted events in the event history thread

config RAM_EVENT_QUEUE_SIZE
int "RAM Event Queue Size"
default 20
help
Defines the size of volatile events in the event history thread

config EVENTS_ENABLED
bool "Enable events thread"
default y
help
Enable the events history thread in the mylib module.

endif # LIB_SIOT
Loading