/****************************************************************************** * * Copyright (c) 2017-2019 by Löwenware Ltd * Please, refer LICENSE file for legal information * ******************************************************************************/ /** * @file interface.h * @author Ilja Kartašov * @brief Interface header file for AISL SDK modules * * @see https://lowenware.com/aisl/ */ #ifndef AISLX_MODULE_H_1AEFECA5_9341_431B_8194_EA0C2E76B5EA #define AISLX_MODULE_H_1AEFECA5_9341_431B_8194_EA0C2E76B5EA #include #define AISLX_MODULE_INIT(MOD, END_POINT) \ do { \ ((aislx_module_t) mod)->end_point = END_POINT; \ ((aislx_module_t) mod)->ep_length = strlen(END_POINT); \ ((aislx_module_t) mod)->on_event = (aislx_observer_t)MOD##_on_event; \ ((aislx_module_t) mod)->ctx_size = sizeof(struct context); \ } while(0) \ #define AISLX_MODULE(x) ((aislx_module_t)x) /** @brief AISL module structure pointer */ typedef struct aislx_module * aislx_module_t; /** @brief Pointer to AISL stream event observer */ typedef aisl_status_t (* aislx_observer_t)(aislx_module_t mod, aisl_evt_t const evt); /** @brief Root level AISL mod's structure */ struct aislx_module { const char *end_point; /**< Root mod's URL or NULL */ aislx_observer_t on_event; /**< Mod's stream event observer */ size_t ctx_size; /**< Mod's context size */ uint8_t ep_length; /**< End-Point length */ }; /** @brief Wrapper function that calles mod's observer * @param mod an instance of #aislx_t * @param evt an AISL stream event * @return AISL_SUCCESS if event handled, AISL_IDLE if event not handled or an * error code */ aisl_status_t aislx_module_on_event(aislx_module_t mod, aisl_evt_t const evt); #endif /* !AISLX_MODULE;_H */