45 #define MAX_TRANSMISSIONS 8
50 #define PRINTF(...) printf(__VA_ARGS__)
58 read_data(
struct rucb_conn *c)
62 if(c->u->read_chunk) {
63 len = c->u->read_chunk(c, c->chunk * RUCB_DATASIZE,
71 acked(
struct runicast_conn *ruc,
const rimeaddr_t *to, uint8_t retransmissions)
73 struct rucb_conn *c = (
struct rucb_conn *)ruc;
74 PRINTF(
"%d.%d: rucb acked\n",
77 if(read_data(c) > 0) {
78 runicast_send(&c->c, &c->receiver, MAX_TRANSMISSIONS);
87 timedout(
struct runicast_conn *ruc,
const rimeaddr_t *to, uint8_t retransmissions)
89 struct rucb_conn *c = (
struct rucb_conn *)ruc;
90 PRINTF(
"%d.%d: rucb timedout\n",
98 recv(
struct runicast_conn *ruc,
const rimeaddr_t *from, uint8_t seqno)
100 struct rucb_conn *c = (
struct rucb_conn *)ruc;
102 PRINTF(
"%d.%d: rucb: recv from %d.%d len %d\n",
106 if(seqno == c->last_seqno) {
109 c->last_seqno = seqno;
121 if(datalen < RUCB_DATASIZE) {
122 PRINTF(
"%d.%d: get %d bytes, file complete\n",
125 c->u->write_chunk(c, c->chunk * RUCB_DATASIZE,
128 c->u->write_chunk(c, c->chunk * RUCB_DATASIZE,
139 static const struct runicast_callbacks ruc = {recv, acked, timedout};
142 rucb_open(
struct rucb_conn *c, uint16_t channel,
143 const struct rucb_callbacks *u)
146 runicast_open(&c->c, channel, &ruc);
152 rucb_close(
struct rucb_conn *c)
154 runicast_close(&c->c);
158 rucb_send(
struct rucb_conn *c,
const rimeaddr_t *receiver)
164 runicast_send(&c->c, receiver, MAX_TRANSMISSIONS);