Added exithandlers so that the examples can be run as loadable (and unloadble) modules
This commit is contained in:
parent
4fa44208eb
commit
c3457e82a4
9 changed files with 76 additions and 14 deletions
|
@ -1,6 +1,9 @@
|
|||
|
||||
#include "net/rime/uabc.h"
|
||||
#include "contiki.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(test_uabc_process, "");
|
||||
AUTOSTART_PROCESSES(&test_uabc_process);
|
||||
|
@ -8,7 +11,7 @@ AUTOSTART_PROCESSES(&test_uabc_process);
|
|||
static void
|
||||
recv(struct uabc_conn *c)
|
||||
{
|
||||
printf("recv\n");
|
||||
printf("recv '%s'\n", (char *)rimebuf_dataptr());
|
||||
}
|
||||
static void
|
||||
sent(struct uabc_conn *c)
|
||||
|
@ -25,6 +28,9 @@ static const struct uabc_callbacks callbacks = { recv, sent, dropped };
|
|||
PROCESS_THREAD(test_uabc_process, ev, data)
|
||||
{
|
||||
static struct uabc_conn c;
|
||||
|
||||
PROCESS_EXITHANDLER(uabc_close(&c));
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
uabc_open(&c, 128, &callbacks);
|
||||
|
@ -34,7 +40,7 @@ PROCESS_THREAD(test_uabc_process, ev, data)
|
|||
etimer_set(&et, CLOCK_SECOND * 4);
|
||||
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
|
||||
rimebuf_copyfrom("Hej", 4);
|
||||
uabc_send(&c, CLOCK_SECOND);
|
||||
uabc_send(&c, CLOCK_SECOND * 4);
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue