2019-04-17 10:17:27 +02:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright (c) 2017-2019 by Löwenware Ltd
|
|
|
|
* Please, refer LICENSE file for legal information
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file interface.h
|
|
|
|
* @author Ilja Kartašov <ik@lowenware.com>
|
|
|
|
* @brief Interface header file for AISL SDK modules
|
|
|
|
*
|
|
|
|
* @see https://lowenware.com/aisl/
|
|
|
|
*/
|
|
|
|
|
2019-04-25 13:54:07 +02:00
|
|
|
#ifndef MODULE_H_1AEFECA5_9341_431B_8194_EA0C2E76B5EA
|
|
|
|
#define MODULE_H_1AEFECA5_9341_431B_8194_EA0C2E76B5EA
|
2019-04-17 10:17:27 +02:00
|
|
|
|
|
|
|
#include <aisl/aisl.h>
|
|
|
|
|
2019-04-25 13:54:07 +02:00
|
|
|
#define AX_MODULE_INIT(MOD, END_POINT) \
|
2019-04-17 10:17:27 +02:00
|
|
|
do { \
|
2019-04-25 13:54:07 +02:00
|
|
|
((AxModule) mod)->end_point = END_POINT; \
|
|
|
|
((AxModule) mod)->ep_length = strlen(END_POINT); \
|
|
|
|
((AxModule) mod)->on_event = (AxObserver)MOD##_on_event; \
|
|
|
|
((AxModule) mod)->ctx_size = sizeof (struct context); \
|
2019-04-17 10:17:27 +02:00
|
|
|
} while(0) \
|
|
|
|
|
2019-04-25 13:54:07 +02:00
|
|
|
#define AX_MODULE(x) ((AxModule)x)
|
2019-04-17 10:17:27 +02:00
|
|
|
|
|
|
|
/** @brief AISL module structure pointer
|
|
|
|
*/
|
2019-04-25 13:54:07 +02:00
|
|
|
typedef struct ax_module * AxModule;
|
2019-04-17 10:17:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
/** @brief Pointer to AISL stream event observer
|
|
|
|
*/
|
2019-04-25 13:54:07 +02:00
|
|
|
typedef AislStatus
|
|
|
|
(* AxObserver)(AxModule mod, const struct aisl_evt *evt);
|
2019-04-17 10:17:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @brief Root level AISL mod's structure
|
|
|
|
*/
|
2019-04-25 13:54:07 +02:00
|
|
|
struct ax_module {
|
|
|
|
const char *end_point; /**< Root mod's URL or NULL */
|
|
|
|
AxObserver on_event; /**< Mod's stream event observer */
|
|
|
|
size_t ctx_size; /**< Mod's context size */
|
|
|
|
uint8_t ep_length; /**< End-Point length */
|
2019-04-17 10:17:27 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/** @brief Wrapper function that calles mod's observer
|
2019-04-25 13:54:07 +02:00
|
|
|
* @param mod an instance of AxModule#
|
2019-04-17 10:17:27 +02:00
|
|
|
* @param evt an AISL stream event
|
|
|
|
* @return AISL_SUCCESS if event handled, AISL_IDLE if event not handled or an
|
|
|
|
* error code
|
|
|
|
*/
|
2019-04-25 13:54:07 +02:00
|
|
|
AislStatus
|
|
|
|
ax_module_on_event(AxModule mod, const struct aisl_evt *evt);
|
2019-04-17 10:17:27 +02:00
|
|
|
|
2019-04-25 13:54:07 +02:00
|
|
|
#endif /* !MODULE;_H */
|