2018-04-13 07:28:11 +02:00
|
|
|
|
|
|
|
#include "cw.h"
|
|
|
|
#include "dbg.h"
|
|
|
|
|
|
|
|
int cw_out_idx_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
|
|
|
|
, uint8_t * dst)
|
|
|
|
{
|
|
|
|
char key[CW_KTV_MAX_KEY_LEN];
|
|
|
|
struct cw_KTV * elem, search;
|
2018-04-13 17:42:12 +02:00
|
|
|
int i;
|
2018-04-13 12:54:58 +02:00
|
|
|
int idx, sr;
|
2018-04-13 17:42:12 +02:00
|
|
|
int len;
|
|
|
|
uint8_t * mdst, *start;
|
|
|
|
|
2018-04-13 07:28:11 +02:00
|
|
|
|
|
|
|
i=0;
|
|
|
|
|
2018-04-13 17:42:12 +02:00
|
|
|
len = 0;
|
2018-04-13 12:54:58 +02:00
|
|
|
mdst = dst;
|
2018-04-13 07:28:11 +02:00
|
|
|
|
|
|
|
do {
|
2018-04-13 12:54:58 +02:00
|
|
|
|
|
|
|
|
2018-04-13 07:28:11 +02:00
|
|
|
sprintf(key,handler->key,i);
|
|
|
|
search.key=key;
|
|
|
|
/*elem = mavl_get(params->conn->local_cfg, &search);*/
|
|
|
|
elem = mavl_get_first(params->conn->local_cfg,&search);
|
|
|
|
if(elem != NULL){
|
2018-04-13 17:42:12 +02:00
|
|
|
printf("Elem key: %s\n",elem->key);
|
2018-04-13 07:28:11 +02:00
|
|
|
}
|
2018-04-13 12:54:58 +02:00
|
|
|
sr = sscanf(elem->key,handler->key,&idx);
|
2018-04-13 07:28:11 +02:00
|
|
|
|
|
|
|
if (sr!=1)
|
|
|
|
break;
|
2018-04-13 17:42:12 +02:00
|
|
|
if (idx<i)
|
2018-04-13 07:28:11 +02:00
|
|
|
break;
|
|
|
|
|
2018-04-13 12:54:58 +02:00
|
|
|
sprintf(key,handler->key,idx);
|
|
|
|
|
|
|
|
printf("Here we are '%s'! --> %d\n",key,idx);
|
|
|
|
|
2018-04-13 17:42:12 +02:00
|
|
|
len =0;
|
|
|
|
start = mdst + params->conn->header_len(handler);
|
2018-04-13 12:54:58 +02:00
|
|
|
|
2018-04-13 17:42:12 +02:00
|
|
|
len += cw_put_byte(start+len,idx);
|
|
|
|
len += cw_ktv_write_struct(params->conn->local_cfg,handler->type,key,start+len);
|
2018-04-13 12:54:58 +02:00
|
|
|
|
2018-04-13 17:42:12 +02:00
|
|
|
mdst += params->conn->write_header(handler,mdst,len);
|
2018-04-13 12:54:58 +02:00
|
|
|
|
|
|
|
|
|
|
|
i=idx+1;
|
|
|
|
|
2018-04-13 07:28:11 +02:00
|
|
|
}while(1);
|
|
|
|
|
2018-04-13 17:42:12 +02:00
|
|
|
|
2018-04-13 07:28:11 +02:00
|
|
|
|
2018-04-13 17:42:12 +02:00
|
|
|
/* radios = cw_ktv_get_byte(params->conn->local_cfg,"wtp-descriptor/max-radios",0);
|
2018-04-13 07:28:11 +02:00
|
|
|
|
|
|
|
for(i=1;i<radios+1;i++){
|
|
|
|
l = cw_write_radio_element(handler,params,i,dst+len);
|
|
|
|
cw_dbg_elem(DBG_ELEM_OUT,params->conn,params->msgdata->type,handler,dst,l);
|
|
|
|
len+=l;
|
|
|
|
}
|
2018-04-13 17:42:12 +02:00
|
|
|
*/
|
|
|
|
return mdst-dst;
|
2018-04-13 07:28:11 +02:00
|
|
|
}
|
|
|
|
|