extern_interface/include/exint/handler.h

52 lines
1.5 KiB
C
Raw Permalink Normal View History

#ifndef _INCLUDE_EXINT_HANDLER_
#define _INCLUDE_EXINT_HANDLER_
#include <stdint.h>
#include "comframe.h"
#define ET_HDL_FLAG_DEFAULT 0
#define ET_HDL_FLAG_DISABLED 1
#define ET_HDL_FLAG_ASYNC 2
#define ET_HDL_FLAG_NOVERIFY 4
#ifdef __cplusplus
extern "C" {
#endif
struct EtHandlerDef {
uint16_t hd_type;
uint16_t hd_flags;
ComFrame* (*hd_handler)(struct EtHandlerDef *handler, ComFrame* frame);
};
static inline struct EtHandlerDef* find_handler(uint16_t type, struct EtHandlerDef *handlers) {
while (handlers->hd_handler) {
if (handlers->hd_type == type) {
return handlers;
}
handlers++;
}
return nullptr;
}
// command.cpp
ComFrame* command_handler(EtHandlerDef *hdl, ComFrame* frame);
ComFrame* request_handler(EtHandlerDef *hdl, ComFrame* frame);
void send_command_event_callback(const char* event_name, size_t args_size, void* args, void* user_data);
// text_audio.cpp
ComFrame* text_handler(EtHandlerDef *hdl, ComFrame* frame);
ComFrame* audio_handler(EtHandlerDef *hdl, ComFrame* frame);
void send_audio_event_callback(const char* event_name, size_t args_size, void* args, void* user_data);
// telemetry.cpp
ComFrame* telemetry_request_handler(EtHandlerDef* hdl, ComFrame* frame);
ComFrame* upperhost_telemetry_request_handler(EtHandlerDef* hdl, ComFrame* frame);
// alarm.cpp
ComFrame* alarm_handler(EtHandlerDef *hdl, ComFrame* frame);
// time.cpp
ComFrame* grant_time_handler(EtHandlerDef *hdl, ComFrame* frame);
#ifdef __cplusplus
}
#endif
#endif