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

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. #include "app_event_distribute.h"
  2. #include "app_event.h"
  3. #include "app_scheduler.h"
  4. static AppEventListener m_listener[10];
  5. static int m_listener_num = 0;
  6. static void app_event_process_cb(void* p_event_data, uint16_t event_size) {
  7. for (int i = 0; i < m_listener_num; i++) {
  8. if (m_listener[i].cbfunc) {
  9. m_listener[i].cbfunc(p_event_data, event_size);
  10. }
  11. }
  12. }
  13. void AppEvent_regListener(app_event_listener_t listener) { //
  14. m_listener[m_listener_num++].cbfunc = listener;
  15. }
  16. void AppEvent_pushEvent(app_event_t* event) { //
  17. app_sched_event_put(event, sizeof(app_event_t), app_event_process_cb);
  18. }