X-Git-Url: http://git.droids-corp.org/?p=protos%2Fxbee-avr.git;a=blobdiff_plain;f=rc_proto.c;h=56e8ad60333b398e8f0c3637082ab0e510450d2d;hp=b04e18cc1e63814119c19c19b888472d7f69e1d8;hb=4d9670d6245cc381313a3ff41dd80f6596a266c8;hpb=9d53e5fccc7924c9ac24b8963376fb30c79b968e diff --git a/rc_proto.c b/rc_proto.c index b04e18c..56e8ad6 100644 --- a/rc_proto.c +++ b/rc_proto.c @@ -34,8 +34,6 @@ #include -#include -#include #include #include #include @@ -43,6 +41,7 @@ #include "callout.h" #include "rc_proto.h" +#include "xbee_user.h" #include "main.h" /* */ @@ -79,22 +78,21 @@ void rc_proto_rx_power_probe(int power_level) } /* send a hello message */ -// XXX iovec for xbee ? int8_t rc_proto_send_hello(uint64_t addr, void *data, uint8_t data_len) { - struct { - struct rc_proto_echo_req hdr; - char buf[XBEE_MAX_FRAME_LEN - sizeof(struct rc_proto_echo_req)]; - } frame; + struct rc_proto_echo_req hdr; + struct xbee_msg msg; - if (data_len > sizeof(frame.buf)) - return -1; + hdr.type = RC_PROTO_HELLO; + hdr.datalen = data_len; + + msg.iovlen = 2; + msg.iov[0].buf = &hdr; + msg.iov[0].len = sizeof(hdr); + msg.iov[1].buf = data; + msg.iov[1].len = data_len; - frame.hdr.type = RC_PROTO_HELLO; - frame.hdr.datalen = data_len; - memcpy(frame.buf, data, data_len); - return xbeeapp_send_msg(addr, &frame, - data_len + sizeof(struct rc_proto_echo_req), 1); + return xbeeapp_send_msg(addr, &msg, 1); }