Changed names of the Rime examples from test-* to example-* and added examples for ruc and uc

This commit is contained in:
adamdunkels 2008-01-25 18:00:50 +00:00
parent c576b7b01c
commit 44d7d9a9a4
15 changed files with 461 additions and 47 deletions

View File

@ -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 */

View File

@ -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

View File

@ -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 <stdio.h>
/*---------------------------------------------------------------------------*/
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);
}

View File

@ -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();

View File

@ -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();

View File

@ -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 <adam@sics.se>
*/
#include "contiki.h"
#include "net/rime.h"
#include "net/rime/meshconn.h"
#include "dev/button-sensor.h"
#include "dev/leds.h"
#include <stdio.h>
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();
}
/*---------------------------------------------------------------------------*/

View File

@ -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 <adam@sics.se>
*/
#include "contiki.h"
#include "net/rime.h"
#include "dev/button-sensor.h"
#include "dev/leds.h"
#include <stdio.h>
/*---------------------------------------------------------------------------*/
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();
}
/*---------------------------------------------------------------------------*/

View File

@ -5,8 +5,8 @@
#include <stdio.h>
/*---------------------------------------------------------------------------*/
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;

104
examples/rime/example-ruc.c Normal file
View File

@ -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 <adam@sics.se>
*/
#include "contiki.h"
#include "net/rime.h"
#include "dev/button-sensor.h"
#include "dev/leds.h"
#include <stdio.h>
#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();
}
/*---------------------------------------------------------------------------*/

View File

@ -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();

View File

@ -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;

View File

@ -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;

View File

@ -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);)

View File

@ -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 <adam@sics.se>
*/
@ -47,8 +47,8 @@
#include <stdio.h>
/*---------------------------------------------------------------------------*/
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();

View File

@ -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 <adam@sics.se>
*/
#include "contiki.h"
#include "net/rime.h"
#include "dev/button-sensor.h"
#include "dev/leds.h"
#include <stdio.h>
/*---------------------------------------------------------------------------*/
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();
}
/*---------------------------------------------------------------------------*/