#include #include #include #include "encoding.h" #include "platform.h" #include "eos.h" #include "log.h" #include "msgq.h" #include "event.h" EOSMsgQ _eos_event_q; static EOSMsgItem event_q_array[EOS_EVT_SIZE_Q]; static eos_evt_handler_t evt_handler[EOS_EVT_MAX]; static eos_evt_handler_global_t evt_handler_global; static eos_evt_loopf_t evt_loop_f; static void evtq_handler(unsigned char type, unsigned char *buffer, uint16_t len, uint8_t _idx) { unsigned char idx = (type & EOS_EVT_MASK) >> 4; if (idx && (idx <= EOS_EVT_MAX)) { evt_handler[idx - 1](type, buffer, len); } else { eos_evtq_bad_handler(type, buffer, len); } } int eos_evtq_init(void) { int i; evt_handler_global = evtq_handler; for (i=0; i> 4; if (handler == NULL) handler = eos_evtq_bad_handler; if (idx && (idx <= EOS_EVT_MAX)) evt_handler[idx - 1] = handler; } eos_evt_handler_t eos_evtq_get_handler(unsigned char type) { unsigned char idx = (type & EOS_EVT_MASK) >> 4; if (idx && (idx <= EOS_EVT_MAX)) return evt_handler[idx - 1]; return NULL; } void eos_evtq_set_handler_global(eos_evt_handler_global_t handler) { evt_handler_global = handler; } eos_evt_handler_global_t eos_evtq_get_handler_global(void) { return evt_handler_global; }