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.c
|
|
|
|
* @author Ilja Kartašov <ik@lowenware.com>
|
|
|
|
* @brief Interface source file for AISL SDK modules
|
|
|
|
*
|
|
|
|
* @see https://lowenware.com/
|
|
|
|
*/
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2019-04-25 13:54:07 +02:00
|
|
|
#include <components/log.h>
|
2019-04-17 10:17:27 +02:00
|
|
|
#include "module.h"
|
2019-04-25 13:54:07 +02:00
|
|
|
#include "context.h"
|
2019-04-17 10:17:27 +02:00
|
|
|
|
|
|
|
|
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
|
|
|
AxContext ctx;
|
|
|
|
struct aisl_evt_open *so_evt;
|
2019-04-17 10:17:27 +02:00
|
|
|
|
|
|
|
switch(evt->code)
|
|
|
|
{
|
|
|
|
case AISL_EVENT_STREAM_OPEN:
|
2019-04-25 13:54:07 +02:00
|
|
|
so_evt = (struct aisl_evt_open *)evt;
|
|
|
|
|
2019-04-17 10:17:27 +02:00
|
|
|
if (strncmp(so_evt->path, mod->end_point, mod->ep_length))
|
|
|
|
return AISL_IDLE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AISL_EVENT_STREAM_HEADER:
|
|
|
|
case AISL_EVENT_STREAM_INPUT:
|
|
|
|
case AISL_EVENT_STREAM_REQUEST:
|
|
|
|
case AISL_EVENT_STREAM_OUTPUT:
|
|
|
|
case AISL_EVENT_STREAM_CLOSE:
|
2019-04-25 13:54:07 +02:00
|
|
|
if (!(ctx = aisl_get_context((AislStream)evt->source)))
|
2019-04-17 10:17:27 +02:00
|
|
|
return AISL_SUCCESS;
|
|
|
|
|
|
|
|
if (ctx->mod == mod)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* go through default */
|
|
|
|
|
|
|
|
default:
|
|
|
|
return AISL_IDLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mod->on_event(mod, evt);
|
|
|
|
}
|