You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
632 B
23 lines
632 B
#include "app_event_distribute.h"
|
|
|
|
#include "app_event.h"
|
|
#include "app_scheduler.h"
|
|
|
|
static AppEventListener m_listener[10];
|
|
static int m_listener_num = 0;
|
|
|
|
static void app_event_process_cb(void* p_event_data, uint16_t event_size) {
|
|
for (int i = 0; i < m_listener_num; i++) {
|
|
if (m_listener[i].cbfunc) {
|
|
m_listener[i].cbfunc(p_event_data, event_size);
|
|
}
|
|
}
|
|
}
|
|
|
|
void AppEvent_regListener(app_event_listener_t listener) { //
|
|
m_listener[m_listener_num++].cbfunc = listener;
|
|
}
|
|
|
|
void AppEvent_pushEvent(app_event_t* event) { //
|
|
app_sched_event_put(event, sizeof(app_event_t), app_event_process_cb);
|
|
}
|