2015-04-05 02:10:37 +02:00
|
|
|
|
2016-03-11 22:23:00 +01:00
|
|
|
#include "cw.h"
|
2018-03-17 17:29:09 +01:00
|
|
|
|
2015-04-05 02:10:37 +02:00
|
|
|
|
2015-04-11 19:00:51 +02:00
|
|
|
#include "dbg.h"
|
2015-04-10 17:52:01 +02:00
|
|
|
#include "log.h"
|
2018-03-12 18:01:40 +01:00
|
|
|
#include "msgset.h"
|
|
|
|
#include "ktv.h"
|
2015-04-07 07:42:36 +02:00
|
|
|
|
2015-04-05 02:10:37 +02:00
|
|
|
|
2018-03-12 18:01:40 +01:00
|
|
|
int cw_out_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
|
|
|
|
, uint8_t * dst)
|
2015-04-05 02:10:37 +02:00
|
|
|
{
|
2018-03-20 18:47:06 +01:00
|
|
|
char detail[128];
|
2018-03-15 20:07:17 +01:00
|
|
|
struct cw_KTV * elem, search;
|
2018-03-24 07:56:05 +01:00
|
|
|
int start, len, l;
|
2018-03-12 18:01:40 +01:00
|
|
|
/* Get the element to put */
|
2018-03-15 20:07:17 +01:00
|
|
|
|
2018-03-19 08:31:50 +01:00
|
|
|
search.key=(char*)handler->key;
|
2018-03-15 20:07:17 +01:00
|
|
|
elem = mavl_get(params->conn->local_cfg, &search);
|
2015-04-05 20:27:17 +02:00
|
|
|
|
|
|
|
|
2018-03-12 18:01:40 +01:00
|
|
|
if (elem == NULL) {
|
2015-04-19 16:44:20 +02:00
|
|
|
const char *vendor="";
|
2018-03-12 18:01:40 +01:00
|
|
|
if ( handler->vendor ) {
|
|
|
|
vendor=cw_strvendor(handler->vendor);
|
2015-04-19 16:44:20 +02:00
|
|
|
}
|
2018-03-15 20:07:17 +01:00
|
|
|
if ( params->elemdata->mand) {
|
|
|
|
cw_log(LOG_ERR,
|
2018-03-20 18:47:06 +01:00
|
|
|
"Can't put mandatory element %s %d-(%s) into %s. No value for '%s' found.",
|
|
|
|
vendor, handler->id, handler->name, params->msgdata->name
|
2018-03-15 20:07:17 +01:00
|
|
|
, handler->key
|
2015-04-11 19:00:51 +02:00
|
|
|
);
|
2018-03-15 20:07:17 +01:00
|
|
|
}
|
2015-04-11 19:00:51 +02:00
|
|
|
else{
|
2018-02-26 18:28:12 +01:00
|
|
|
/* cw_dbg(DBG_WARN,"No output for element %s%d -(%s) in %s. Item %s not found.",
|
2015-04-19 16:44:20 +02:00
|
|
|
vendor,
|
2015-04-11 19:00:51 +02:00
|
|
|
a->elem_id, cw_strelemp(conn->actions, a->elem_id)
|
|
|
|
, cw_strmsg(a->msg_id),a->item_id);
|
2018-02-26 18:28:12 +01:00
|
|
|
*/
|
2015-04-07 07:42:36 +02:00
|
|
|
}
|
|
|
|
return 0;
|
2018-03-12 18:01:40 +01:00
|
|
|
}
|
2018-03-27 07:07:14 +02:00
|
|
|
|
|
|
|
/* Size for msg elem header depends on
|
|
|
|
vendor specific payload */
|
|
|
|
start = handler->vendor ? 10 : 4;
|
2018-03-25 22:38:07 +02:00
|
|
|
len = ((const cw_Type_t*)(handler->type))->put(elem,dst+start);
|
2018-03-27 07:07:14 +02:00
|
|
|
|
|
|
|
/* ((const cw_Type_t*)(handler->type))->to_str(elem,detail,120);
|
2018-03-20 18:47:06 +01:00
|
|
|
sprintf(params->debug_details, " Value = %s", detail);
|
2018-03-27 07:07:14 +02:00
|
|
|
params->elem = elem;*/
|
2015-04-05 20:27:17 +02:00
|
|
|
|
2018-03-12 18:01:40 +01:00
|
|
|
if (handler->vendor)
|
|
|
|
return len + cw_put_elem_vendor_hdr(dst, handler->vendor, handler->id, len);
|
2015-04-05 20:27:17 +02:00
|
|
|
|
2018-03-24 07:56:05 +01:00
|
|
|
l = len + cw_put_elem_hdr(dst, handler->id, len);
|
|
|
|
cw_dbg_elem(DBG_ELEM_OUT,params->conn,params->msgdata->type,handler,dst,l);
|
|
|
|
return l;
|
2015-04-05 02:10:37 +02:00
|
|
|
}
|
2015-04-28 10:23:03 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|