53 #define PRINTF(...) printf(__VA_ARGS__)
60 recv_from_uc(
struct unicast_conn *uc,
const rimeaddr_t *from)
62 register struct stunicast_conn *c = (
struct stunicast_conn *)uc;
63 PRINTF(
"%d.%d: stunicast: recv_from_uc from %d.%d\n",
65 from->u8[0], from->u8[1]);
66 if(c->u->recv !=
NULL) {
72 sent_by_uc(
struct unicast_conn *uc,
int status,
int num_tx)
74 register struct stunicast_conn *c = (
struct stunicast_conn *)uc;
75 PRINTF(
"%d.%d: stunicast: recv_from_uc from %d.%d\n",
77 packetbuf_addr(PACKETBUF_ADDR_SENDER)->u8[0],
78 packetbuf_addr(PACKETBUF_ADDR_SENDER)->u8[1]);
79 if(c->u->sent !=
NULL) {
80 c->u->sent(c, status, num_tx);
84 static const struct unicast_callbacks stunicast = {recv_from_uc,
88 stunicast_open(
struct stunicast_conn *c, uint16_t channel,
89 const struct stunicast_callbacks *u)
91 unicast_open(&c->c, channel, &stunicast);
96 stunicast_close(
struct stunicast_conn *c)
103 stunicast_receiver(
struct stunicast_conn *c)
111 struct stunicast_conn *c = ptr;
113 PRINTF(
"%d.%d: stunicast: resend to %d.%d\n",
115 c->receiver.u8[0], c->receiver.u8[1]);
117 queuebuf_to_packetbuf(c->buf);
118 unicast_send(&c->c, &c->receiver);
127 stunicast_set_timer(
struct stunicast_conn *c, clock_time_t t)
133 stunicast_send_stubborn(
struct stunicast_conn *c,
const rimeaddr_t *receiver,
134 clock_time_t rxmittime)
137 queuebuf_free(c->buf);
139 c->buf = queuebuf_new_from_packetbuf();
146 PRINTF(
"%d.%d: stunicast_send_stubborn to %d.%d\n",
148 c->receiver.u8[0],c->receiver.u8[1]);
149 unicast_send(&c->c, &c->receiver);
159 stunicast_send(
struct stunicast_conn *c,
const rimeaddr_t *receiver)
161 PRINTF(
"%d.%d: stunicast_send to %d.%d\n",
163 receiver->u8[0], receiver->u8[1]);
164 return unicast_send(&c->c, receiver);
168 stunicast_cancel(
struct stunicast_conn *c)
172 queuebuf_free(c->buf);