Fixed radio_out_generic

FossilOrigin-Name: 4598d7fd166507406cc644a9a91af6cec90f0cd3d33c60c09063cd317cdf7d1c
This commit is contained in:
7u83@mail.ru
2016-04-11 06:37:52 +00:00
parent 0a3ffcf280
commit a746d01823
2 changed files with 29 additions and 6 deletions

View File

@ -10,11 +10,31 @@ int cw_out_radio_generic(struct conn *conn, struct cw_action_out *a, uint8_t * d
int l=0;
MAVLITER_DEFINE(it,conn->radios_upd);
mavliter_foreach(&it){
struct mbag_item *i = mavliter_get(&it);
if ( i->type != MBAG_MBAG ) {
struct mbag_item *radio = mavliter_get(&it);
if ( radio->type != MBAG_MBAG ) {
continue;
}
cw_out_generic(conn,a,dst);
/* Size for msg elem header depends on
vendor specific payload */
int start = a->vendor_id ? 10 : 4;
struct mbag_item * item = mbag_get(radio->data,a->item_id);
if (!item){
continue;
}
int len=0;
len += cw_put_byte(dst+start,radio->iid);
len += cw_put_mbag_item(dst + start+1, item);
if (a->vendor_id)
l+= len + cw_put_elem_vendor_hdr(dst, a->vendor_id, a->elem_id, len);
else
l += len + cw_put_elem_hdr(dst, a->elem_id, len);
}
return l;