2007-03-20 12:21:17 +00:00
|
|
|
|
2007-05-22 21:04:00 +00:00
|
|
|
#include "net/rime/polite.h"
|
2007-03-20 12:21:17 +00:00
|
|
|
#include "contiki.h"
|
2007-03-25 12:10:29 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2007-03-20 12:21:17 +00:00
|
|
|
/*---------------------------------------------------------------------------*/
|
2008-01-25 18:00:50 +00:00
|
|
|
PROCESS(example_polite_process, "");
|
|
|
|
AUTOSTART_PROCESSES(&example_polite_process);
|
2007-03-20 12:21:17 +00:00
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
static void
|
2007-05-22 21:04:00 +00:00
|
|
|
recv(struct polite_conn *c)
|
2007-03-20 12:21:17 +00:00
|
|
|
{
|
2009-03-12 21:58:20 +00:00
|
|
|
printf("recv '%s'\n", (char *)packetbuf_dataptr());
|
2007-03-20 12:21:17 +00:00
|
|
|
}
|
|
|
|
static void
|
2007-05-22 21:04:00 +00:00
|
|
|
sent(struct polite_conn *c)
|
2007-03-20 12:21:17 +00:00
|
|
|
{
|
|
|
|
printf("sent\n");
|
|
|
|
}
|
|
|
|
static void
|
2007-05-22 21:04:00 +00:00
|
|
|
dropped(struct polite_conn *c)
|
2007-03-20 12:21:17 +00:00
|
|
|
{
|
|
|
|
printf("dropped\n");
|
|
|
|
}
|
2007-05-22 21:04:00 +00:00
|
|
|
static const struct polite_callbacks callbacks = { recv, sent, dropped };
|
2007-03-20 12:21:17 +00:00
|
|
|
/*---------------------------------------------------------------------------*/
|
2008-01-25 18:00:50 +00:00
|
|
|
PROCESS_THREAD(example_polite_process, ev, data)
|
2007-03-20 12:21:17 +00:00
|
|
|
{
|
2007-05-22 21:04:00 +00:00
|
|
|
static struct polite_conn c;
|
2007-03-25 12:10:29 +00:00
|
|
|
|
2007-05-22 21:04:00 +00:00
|
|
|
PROCESS_EXITHANDLER(polite_close(&c));
|
2007-03-25 12:10:29 +00:00
|
|
|
|
2007-03-20 12:21:17 +00:00
|
|
|
PROCESS_BEGIN();
|
|
|
|
|
2009-10-18 17:52:08 +00:00
|
|
|
polite_open(&c, 136, &callbacks);
|
2007-03-20 12:21:17 +00:00
|
|
|
|
|
|
|
while(1) {
|
|
|
|
static struct etimer et;
|
|
|
|
etimer_set(&et, CLOCK_SECOND * 4);
|
|
|
|
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
|
2009-03-12 21:58:20 +00:00
|
|
|
packetbuf_copyfrom("Hej", 4);
|
2007-05-22 21:04:00 +00:00
|
|
|
polite_send(&c, CLOCK_SECOND * 4, 4);
|
2007-03-20 12:21:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
PROCESS_END();
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|