From 44d7d9a9a4fe070a7127fce9db0349ac3faacbc7 Mon Sep 17 00:00:00 2001 From: adamdunkels Date: Fri, 25 Jan 2008 18:00:50 +0000 Subject: [PATCH] Changed names of the Rime examples from test-* to example-* and added examples for ruc and uc --- doc/examples.txt | 19 +-- examples/rime/Makefile | 5 +- examples/rime/{test-abc.c => example-abc.c} | 10 +- .../{test-collect.c => example-collect.c} | 8 +- .../rime/{test-meshroute.c => example-mesh.c} | 8 +- examples/rime/example-meshconn.c | 124 ++++++++++++++++++ examples/rime/example-mh.c | 93 +++++++++++++ .../rime/{test-polite.c => example-polite.c} | 6 +- examples/rime/example-ruc.c | 104 +++++++++++++++ examples/rime/{test-rucb.c => example-rucb.c} | 8 +- .../{test-rudolph0.c => example-rudolph0.c} | 8 +- .../{test-rudolph1.c => example-rudolph1.c} | 8 +- .../{test-rudolph2.c => example-rudolph2.c} | 9 +- .../{test-trickle.c => example-trickle.c} | 10 +- examples/rime/example-uc.c | 88 +++++++++++++ 15 files changed, 461 insertions(+), 47 deletions(-) rename examples/rime/{test-abc.c => example-abc.c} (91%) rename examples/rime/{test-collect.c => example-collect.c} (94%) rename examples/rime/{test-meshroute.c => example-mesh.c} (94%) create mode 100644 examples/rime/example-meshconn.c create mode 100644 examples/rime/example-mh.c rename examples/rime/{test-polite.c => example-polite.c} (89%) create mode 100644 examples/rime/example-ruc.c rename examples/rime/{test-rucb.c => example-rucb.c} (95%) rename examples/rime/{test-rudolph0.c => example-rudolph0.c} (95%) rename examples/rime/{test-rudolph1.c => example-rudolph1.c} (95%) rename examples/rime/{test-rudolph2.c => example-rudolph2.c} (95%) rename examples/rime/{test-trickle.c => example-trickle.c} (91%) create mode 100644 examples/rime/example-uc.c diff --git a/doc/examples.txt b/doc/examples.txt index f570f2b64..6372680fe 100644 --- a/doc/examples.txt +++ b/doc/examples.txt @@ -4,11 +4,14 @@ /** \example example-packet-drv.c */ /** \example example-psock-server.c */ -/** \example test-abc.c */ -/** \example test-meshroute.c */ -/** \example test-rudolph0.c */ -/** \example test-rudolph1.c */ -/** \example test-treeroute.c */ -/** \example test-trickle.c */ -/** \example test-uabc.c */ -/** \example test-uibc.c */ +/** \example example-abc.c */ +/** \example example-collect.c */ +/** \example example-mesh.c */ +/** \example example-ruc.c */ +/** \example example-rucb.c */ +/** \example example-rudolph0.c */ +/** \example example-rudolph1.c */ +/** \example example-rudolph2.c */ +/** \example example-treeroute.c */ +/** \example example-trickle.c */ +/** \example example-uc.c */ diff --git a/examples/rime/Makefile b/examples/rime/Makefile index 3a51bc395..17e63c00c 100644 --- a/examples/rime/Makefile +++ b/examples/rime/Makefile @@ -2,7 +2,8 @@ CONTIKI = ../.. ifndef TARGET TARGET=netsim endif -all: test-abc test-meshroute test-collect test-trickle test-polite \ - test-rudolph0 test-rudolph1 test-rudolph2 test-rucb +all: example-abc example-mesh example-collect example-trickle example-polite \ + example-rudolph0 example-rudolph1 example-rudolph2 example-rucb \ + example-ruc example-uc include $(CONTIKI)/Makefile.include diff --git a/examples/rime/test-abc.c b/examples/rime/example-abc.c similarity index 91% rename from examples/rime/test-abc.c rename to examples/rime/example-abc.c index e05236561..5488e7902 100644 --- a/examples/rime/test-abc.c +++ b/examples/rime/example-abc.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: test-abc.c,v 1.4 2007/09/14 20:07:26 nvt-se Exp $ + * $Id: example-abc.c,v 1.1 2008/01/25 18:00:50 adamdunkels Exp $ */ /** @@ -47,8 +47,8 @@ #include /*---------------------------------------------------------------------------*/ -PROCESS(test_abc_process, "ABC test"); -AUTOSTART_PROCESSES(&test_abc_process); +PROCESS(example_abc_process, "ABC example"); +AUTOSTART_PROCESSES(&example_abc_process); /*---------------------------------------------------------------------------*/ static void abc_recv(struct abc_conn *c) @@ -58,7 +58,7 @@ abc_recv(struct abc_conn *c) static const struct abc_callbacks abc_call = {abc_recv}; static struct abc_conn abc; /*---------------------------------------------------------------------------*/ -PROCESS_THREAD(test_abc_process, ev, data) +PROCESS_THREAD(example_abc_process, ev, data) { PROCESS_EXITHANDLER(abc_close(&abc);) @@ -73,7 +73,7 @@ PROCESS_THREAD(test_abc_process, ev, data) PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); - rimebuf_copyfrom("Hej", 4); + rimebuf_copyfrom("Hello", 6); abc_send(&abc); } diff --git a/examples/rime/test-collect.c b/examples/rime/example-collect.c similarity index 94% rename from examples/rime/test-collect.c rename to examples/rime/example-collect.c index 7005ec4de..ac52b34fd 100644 --- a/examples/rime/test-collect.c +++ b/examples/rime/example-collect.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: test-collect.c,v 1.2 2007/11/29 10:29:03 nifi Exp $ + * $Id: example-collect.c,v 1.1 2008/01/25 18:00:50 adamdunkels Exp $ */ /** @@ -50,9 +50,9 @@ static struct collect_conn tc; /*---------------------------------------------------------------------------*/ -PROCESS(test_collect_process, "Test collect process"); +PROCESS(example_collect_process, "Test collect process"); PROCESS(depth_blink_process, "Depth indicator"); -AUTOSTART_PROCESSES(&test_collect_process, &depth_blink_process); +AUTOSTART_PROCESSES(&example_collect_process, &depth_blink_process); /*---------------------------------------------------------------------------*/ PROCESS_THREAD(depth_blink_process, ev, data) { @@ -98,7 +98,7 @@ recv(rimeaddr_t *originator, u8_t seqno, u8_t hops) /*---------------------------------------------------------------------------*/ static const struct collect_callbacks callbacks = { recv }; /*---------------------------------------------------------------------------*/ -PROCESS_THREAD(test_collect_process, ev, data) +PROCESS_THREAD(example_collect_process, ev, data) { PROCESS_BEGIN(); diff --git a/examples/rime/test-meshroute.c b/examples/rime/example-mesh.c similarity index 94% rename from examples/rime/test-meshroute.c rename to examples/rime/example-mesh.c index 0a5e8bd5a..64a070384 100644 --- a/examples/rime/test-meshroute.c +++ b/examples/rime/example-mesh.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: test-meshroute.c,v 1.3 2007/03/25 12:10:29 adamdunkels Exp $ + * $Id: example-mesh.c,v 1.1 2008/01/25 18:00:50 adamdunkels Exp $ */ /** @@ -50,8 +50,8 @@ static struct mesh_conn mesh; /*---------------------------------------------------------------------------*/ -PROCESS(test_mesh_process, "Mesh test"); -AUTOSTART_PROCESSES(&test_mesh_process); +PROCESS(example_mesh_process, "Mesh example"); +AUTOSTART_PROCESSES(&example_mesh_process); /*---------------------------------------------------------------------------*/ static void sent(struct mesh_conn *c) @@ -75,7 +75,7 @@ recv(struct mesh_conn *c, rimeaddr_t *from) const static struct mesh_callbacks callbacks = {recv, sent, timedout}; /*---------------------------------------------------------------------------*/ -PROCESS_THREAD(test_mesh_process, ev, data) +PROCESS_THREAD(example_mesh_process, ev, data) { PROCESS_EXITHANDLER(mesh_close(&mesh);) PROCESS_BEGIN(); diff --git a/examples/rime/example-meshconn.c b/examples/rime/example-meshconn.c new file mode 100644 index 000000000..748095adf --- /dev/null +++ b/examples/rime/example-meshconn.c @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2007, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of the Contiki operating system. + * + * $Id: example-meshconn.c,v 1.1 2008/01/25 18:00:50 adamdunkels Exp $ + */ + +/** + * \file + * A brief description of what this file is. + * \author + * Adam Dunkels + */ + +#include "contiki.h" +#include "net/rime.h" +#include "net/rime/meshconn.h" + +#include "dev/button-sensor.h" + +#include "dev/leds.h" + +#include + +static struct meshconn_conn meshconn; +/*---------------------------------------------------------------------------*/ +PROCESS(test_meshconn_process, "Meshconnconn test"); +AUTOSTART_PROCESSES(&test_meshconn_process); +/*---------------------------------------------------------------------------*/ +static void +connected(struct meshconn_conn *c) +{ + printf("connected\n"); +} +static void +closed(struct meshconn_conn *c) +{ + printf("closed\n"); +} +static void +reset(struct meshconn_conn *c) +{ + printf("reset\n"); +} +static void +timedout(struct meshconn_conn *c) +{ + printf("timedout\n"); +} +static void +recv(struct meshconn_conn *c) +{ + printf("Data received from %.*s (%d)\n", + rimebuf_datalen(), (char *)rimebuf_dataptr(), rimebuf_datalen()); + + /* meshconn_send(&meshconn, from);*/ +} + +const static struct meshconn_callbacks callbacks = { connected, + recv, + closed, + timedout, + reset }; +/*---------------------------------------------------------------------------*/ +PROCESS_THREAD(test_meshconn_process, ev, data) +{ + PROCESS_EXITHANDLER(meshconn_close(&meshconn);) + PROCESS_BEGIN(); + + meshconn_open(&meshconn, 128, &callbacks); + + /* button_sensor.activate();*/ + + while(1) { + rimeaddr_t addr; + static struct etimer et; + + etimer_set(&et, CLOCK_SECOND * 4); + PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et) || + (ev == sensors_event && data == &button_sensor)); + + printf("Button\n"); + + /* + * Send a message containing "Hej" (3 characters) to node number + * 6. + */ + + addr.u8[0] = 53; + addr.u8[1] = 0; + meshconn_connect(&meshconn, addr); + + rimebuf_copyfrom("Hej", 3); + meshconn_send(&meshconn, &addr); + } + PROCESS_END(); +} +/*---------------------------------------------------------------------------*/ diff --git a/examples/rime/example-mh.c b/examples/rime/example-mh.c new file mode 100644 index 000000000..35e0c1907 --- /dev/null +++ b/examples/rime/example-mh.c @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2007, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of the Contiki operating system. + * + * $Id: example-mh.c,v 1.1 2008/01/25 18:00:50 adamdunkels Exp $ + */ + +/** + * \file + * Testing the multihop forwarding layer (mh) in Rime + * \author + * Adam Dunkels + */ + +#include "contiki.h" +#include "net/rime.h" + +#include "dev/button-sensor.h" + +#include "dev/leds.h" + +#include +/*---------------------------------------------------------------------------*/ +PROCESS(example_mh_process, "mh example"); +AUTOSTART_PROCESSES(&example_mh_process); +/*---------------------------------------------------------------------------*/ +static void +recv(struct mh_conn *c, rimeaddr_t *sender) +{ + printf("mh message received '%s'\n", (char *)rimebuf_dataptr()); +} +static rimeaddr_t * +forward(struct mh_conn *c, rimeaddr_t *originator, rimeaddr_t *dest, + rimeaddr_t *prevhop, u8_t hops) +{ + printf("Forwarding message '%s'\n", (char *)rimebuf_dataptr()); + return NULL; +} +static const struct mh_callbacks mh_call = {recv, forward}; +static struct mh_conn mh; +/*---------------------------------------------------------------------------*/ +PROCESS_THREAD(example_mh_process, ev, data) +{ + PROCESS_EXITHANDLER(mh_close(&mh);) + + PROCESS_BEGIN(); + + mh_open(&mh, 128, &mh_call); + + while(1) { + static struct etimer et; + rimeaddr_t to; + + etimer_set(&et, CLOCK_SECOND); + + PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); + + rimebuf_copyfrom("Hej", 4); + to.u8[0] = 161; + to.u8[1] = 161; + mh_send(&mh, &to); + + } + + PROCESS_END(); +} +/*---------------------------------------------------------------------------*/ diff --git a/examples/rime/test-polite.c b/examples/rime/example-polite.c similarity index 89% rename from examples/rime/test-polite.c rename to examples/rime/example-polite.c index e7bd188e3..ee1b02cbd 100644 --- a/examples/rime/test-polite.c +++ b/examples/rime/example-polite.c @@ -5,8 +5,8 @@ #include /*---------------------------------------------------------------------------*/ -PROCESS(test_polite_process, ""); -AUTOSTART_PROCESSES(&test_polite_process); +PROCESS(example_polite_process, ""); +AUTOSTART_PROCESSES(&example_polite_process); /*---------------------------------------------------------------------------*/ static void recv(struct polite_conn *c) @@ -25,7 +25,7 @@ dropped(struct polite_conn *c) } static const struct polite_callbacks callbacks = { recv, sent, dropped }; /*---------------------------------------------------------------------------*/ -PROCESS_THREAD(test_polite_process, ev, data) +PROCESS_THREAD(example_polite_process, ev, data) { static struct polite_conn c; diff --git a/examples/rime/example-ruc.c b/examples/rime/example-ruc.c new file mode 100644 index 000000000..b08ff4f31 --- /dev/null +++ b/examples/rime/example-ruc.c @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2007, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of the Contiki operating system. + * + * $Id: example-ruc.c,v 1.1 2008/01/25 18:00:51 adamdunkels Exp $ + */ + +/** + * \file + * Reliable single-hop unicast example + * \author + * Adam Dunkels + */ + +#include "contiki.h" +#include "net/rime.h" + +#include "dev/button-sensor.h" + +#include "dev/leds.h" + +#include + +#define MAX_RETRANSMISSIONS 4 + +/*---------------------------------------------------------------------------*/ +PROCESS(test_ruc_process, "ruc test"); +AUTOSTART_PROCESSES(&test_ruc_process); +/*---------------------------------------------------------------------------*/ +static void +recv_ruc(struct ruc_conn *c, rimeaddr_t *from, uint8_t seqno) +{ + printf("ruc message received from %d.%d, seqno %d\n", + from->u8[0], from->u8[1], seqno); +} +static void +sent_ruc(struct ruc_conn *c, rimeaddr_t *to, uint8_t retransmissions) +{ + printf("ruc message sent to %d.%d, retransmissions %d\n", + to->u8[0], to->u8[1], retransmissions); +} +static void +timedout_ruc(struct ruc_conn *c, rimeaddr_t *to, uint8_t retransmissions) +{ + printf("ruc message timed out when sending to %d.%d, retransmissions %d\n", + to->u8[0], to->u8[1], retransmissions); +} +static const struct ruc_callbacks ruc_callbacks = {recv_ruc, + sent_ruc, + timedout_ruc}; +static struct ruc_conn ruc; +/*---------------------------------------------------------------------------*/ +PROCESS_THREAD(test_ruc_process, ev, data) +{ + PROCESS_EXITHANDLER(ruc_close(&ruc);) + + PROCESS_BEGIN(); + + ruc_open(&ruc, 128, &ruc_callbacks); + + while(1) { + static struct etimer et; + rimeaddr_t addr; + + etimer_set(&et, CLOCK_SECOND); + + PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); + + rimebuf_copyfrom("Hello", 5); + addr.u8[0] = 41; + addr.u8[1] = 41; + ruc_send(&ruc, &addr, MAX_RETRANSMISSIONS); + + } + + PROCESS_END(); +} +/*---------------------------------------------------------------------------*/ diff --git a/examples/rime/test-rucb.c b/examples/rime/example-rucb.c similarity index 95% rename from examples/rime/test-rucb.c rename to examples/rime/example-rucb.c index fabeefe6f..c73fd6856 100644 --- a/examples/rime/test-rucb.c +++ b/examples/rime/example-rucb.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: test-rucb.c,v 1.2 2007/11/17 18:09:56 adamdunkels Exp $ + * $Id: example-rucb.c,v 1.1 2008/01/25 18:00:51 adamdunkels Exp $ */ /** @@ -64,8 +64,8 @@ static clock_time_t start_time; extern int profile_max_queuelen; /*---------------------------------------------------------------------------*/ -PROCESS(test_rucb_process, "Rucb test"); -AUTOSTART_PROCESSES(&test_rucb_process); +PROCESS(example_rucb_process, "Rucb example"); +AUTOSTART_PROCESSES(&example_rucb_process); /*---------------------------------------------------------------------------*/ static void write_chunk(struct rucb_conn *c, int offset, int flag, @@ -107,7 +107,7 @@ static struct rucb_conn rucb; /*---------------------------------------------------------------------------*/ #include "node-id.h" -PROCESS_THREAD(test_rucb_process, ev, data) +PROCESS_THREAD(example_rucb_process, ev, data) { PROCESS_EXITHANDLER(rucb_close(&rucb);) PROCESS_BEGIN(); diff --git a/examples/rime/test-rudolph0.c b/examples/rime/example-rudolph0.c similarity index 95% rename from examples/rime/test-rudolph0.c rename to examples/rime/example-rudolph0.c index 526f45b5b..a1abd7172 100644 --- a/examples/rime/test-rudolph0.c +++ b/examples/rime/example-rudolph0.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: test-rudolph0.c,v 1.6 2007/11/17 18:09:56 adamdunkels Exp $ + * $Id: example-rudolph0.c,v 1.1 2008/01/25 18:00:51 adamdunkels Exp $ */ /** @@ -51,8 +51,8 @@ #define FILESIZE 200 /*---------------------------------------------------------------------------*/ -PROCESS(test_rudolph0_process, "Rudolph0 test"); -AUTOSTART_PROCESSES(&test_rudolph0_process); +PROCESS(example_rudolph0_process, "Rudolph0 example"); +AUTOSTART_PROCESSES(&example_rudolph0_process); /*---------------------------------------------------------------------------*/ static void write_chunk(struct rudolph0_conn *c, int offset, int flag, @@ -112,7 +112,7 @@ const static struct rudolph0_callbacks rudolph0_call = {write_chunk, read_chunk}; static struct rudolph0_conn rudolph0; /*---------------------------------------------------------------------------*/ -PROCESS_THREAD(test_rudolph0_process, ev, data) +PROCESS_THREAD(example_rudolph0_process, ev, data) { static int fd; diff --git a/examples/rime/test-rudolph1.c b/examples/rime/example-rudolph1.c similarity index 95% rename from examples/rime/test-rudolph1.c rename to examples/rime/example-rudolph1.c index 2995ddb76..5c2ac14ce 100644 --- a/examples/rime/test-rudolph1.c +++ b/examples/rime/example-rudolph1.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: test-rudolph1.c,v 1.8 2007/11/17 18:09:56 adamdunkels Exp $ + * $Id: example-rudolph1.c,v 1.1 2008/01/25 18:00:51 adamdunkels Exp $ */ /** @@ -59,8 +59,8 @@ #define FILESIZE 2000 /*---------------------------------------------------------------------------*/ -PROCESS(test_rudolph1_process, "Rudolph1 test"); -AUTOSTART_PROCESSES(&test_rudolph1_process); +PROCESS(example_rudolph1_process, "Rudolph1 example"); +AUTOSTART_PROCESSES(&example_rudolph1_process); /*---------------------------------------------------------------------------*/ static void write_chunk(struct rudolph1_conn *c, int offset, int flag, @@ -149,7 +149,7 @@ log_queuelen(struct rtimer *t, void *ptr) } /*---------------------------------------------------------------------------*/ -PROCESS_THREAD(test_rudolph1_process, ev, data) +PROCESS_THREAD(example_rudolph1_process, ev, data) { static int fd; static struct rtimer t; diff --git a/examples/rime/test-rudolph2.c b/examples/rime/example-rudolph2.c similarity index 95% rename from examples/rime/test-rudolph2.c rename to examples/rime/example-rudolph2.c index f295ef807..ed41fb7e0 100644 --- a/examples/rime/test-rudolph2.c +++ b/examples/rime/example-rudolph2.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: test-rudolph2.c,v 1.2 2007/11/17 18:09:56 adamdunkels Exp $ + * $Id: example-rudolph2.c,v 1.1 2008/01/25 18:00:51 adamdunkels Exp $ */ /** @@ -39,6 +39,7 @@ */ #include "contiki.h" +#include "net/rime.h" #include "net/rime/rudolph2.h" #include "dev/button-sensor.h" @@ -57,8 +58,8 @@ #define FILESIZE 2000 /*---------------------------------------------------------------------------*/ -PROCESS(test_rudolph2_process, "Rudolph2 test"); -AUTOSTART_PROCESSES(&test_rudolph2_process); +PROCESS(example_rudolph2_process, "Rudolph2 example"); +AUTOSTART_PROCESSES(&example_rudolph2_process); /*---------------------------------------------------------------------------*/ static void write_chunk(struct rudolph2_conn *c, int offset, int flag, @@ -135,7 +136,7 @@ static struct rudolph2_conn rudolph2; /*---------------------------------------------------------------------------*/ #include "node-id.h" -PROCESS_THREAD(test_rudolph2_process, ev, data) +PROCESS_THREAD(example_rudolph2_process, ev, data) { static int fd; PROCESS_EXITHANDLER(rudolph2_close(&rudolph2);) diff --git a/examples/rime/test-trickle.c b/examples/rime/example-trickle.c similarity index 91% rename from examples/rime/test-trickle.c rename to examples/rime/example-trickle.c index e128cf9d1..b0a821e9a 100644 --- a/examples/rime/test-trickle.c +++ b/examples/rime/example-trickle.c @@ -28,12 +28,12 @@ * * This file is part of the Contiki operating system. * - * $Id: test-trickle.c,v 1.5 2007/05/15 08:10:32 adamdunkels Exp $ + * $Id: example-trickle.c,v 1.1 2008/01/25 18:00:51 adamdunkels Exp $ */ /** * \file - * Testing the trickle code in Rime + * Example for using the trickle code in Rime * \author * Adam Dunkels */ @@ -47,8 +47,8 @@ #include /*---------------------------------------------------------------------------*/ -PROCESS(test_trickle_process, "TRICKLE test"); -AUTOSTART_PROCESSES(&test_trickle_process); +PROCESS(example_trickle_process, "Trickle example"); +AUTOSTART_PROCESSES(&example_trickle_process); /*---------------------------------------------------------------------------*/ static void trickle_recv(struct trickle_conn *c) @@ -60,7 +60,7 @@ trickle_recv(struct trickle_conn *c) const static struct trickle_callbacks trickle_call = {trickle_recv}; static struct trickle_conn trickle; /*---------------------------------------------------------------------------*/ -PROCESS_THREAD(test_trickle_process, ev, data) +PROCESS_THREAD(example_trickle_process, ev, data) { PROCESS_EXITHANDLER(trickle_close(&trickle);) PROCESS_BEGIN(); diff --git a/examples/rime/example-uc.c b/examples/rime/example-uc.c new file mode 100644 index 000000000..d271ca325 --- /dev/null +++ b/examples/rime/example-uc.c @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2007, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of the Contiki operating system. + * + * $Id: example-uc.c,v 1.1 2008/01/25 18:00:51 adamdunkels Exp $ + */ + +/** + * \file + * Best-effort single-hop unicast example + * \author + * Adam Dunkels + */ + +#include "contiki.h" +#include "net/rime.h" + +#include "dev/button-sensor.h" + +#include "dev/leds.h" + +#include + +/*---------------------------------------------------------------------------*/ +PROCESS(test_uc_process, "uc test"); +AUTOSTART_PROCESSES(&test_uc_process); +/*---------------------------------------------------------------------------*/ +static void +recv_uc(struct uc_conn *c, rimeaddr_t *from) +{ + printf("uc message received from %d.%d\n", + from->u8[0], from->u8[1]); +} +static const struct uc_callbacks uc_callbacks = {recv_uc}; +static struct uc_conn uc; +/*---------------------------------------------------------------------------*/ +PROCESS_THREAD(test_uc_process, ev, data) +{ + PROCESS_EXITHANDLER(uc_close(&uc);) + + PROCESS_BEGIN(); + + uc_open(&uc, 128, &uc_callbacks); + + while(1) { + static struct etimer et; + rimeaddr_t addr; + + etimer_set(&et, CLOCK_SECOND); + + PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); + + rimebuf_copyfrom("Hello", 5); + addr.u8[0] = 41; + addr.u8[1] = 41; + uc_send(&uc, &addr); + + } + + PROCESS_END(); +} +/*---------------------------------------------------------------------------*/