mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-21 19:29:18 +00:00
Updated for the new APIs
This commit is contained in:
parent
de8a3fd507
commit
b731014bc0
@ -28,7 +28,7 @@
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: test-meshroute.c,v 1.1 2007/03/20 12:21:19 adamdunkels Exp $
|
||||
* $Id: test-meshroute.c,v 1.2 2007/03/22 19:03:56 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -40,45 +40,56 @@
|
||||
|
||||
#include "contiki.h"
|
||||
#include "net/rime.h"
|
||||
#include "net/rime/mesh.h"
|
||||
|
||||
#include "dev/button-sensor.h"
|
||||
|
||||
#include "dev/leds.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static struct mesh_conn mesh;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(test_mesh_process, "Mesh test");
|
||||
AUTOSTART_PROCESSES(&test_mesh_process);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
sent(void)
|
||||
sent(struct mesh_conn *c)
|
||||
{
|
||||
|
||||
printf("packet sent\n");
|
||||
}
|
||||
static void
|
||||
recv(rimeaddr_t *from)
|
||||
timedout(struct mesh_conn *c)
|
||||
{
|
||||
printf("Data received from %d: %.*s (%d)\n", from->u16,
|
||||
printf("packet timedout\n");
|
||||
}
|
||||
static void
|
||||
recv(struct mesh_conn *c, rimeaddr_t *from)
|
||||
{
|
||||
printf("Data received from %d: %.*s (%d)\n", from->u16[0],
|
||||
rimebuf_datalen(), (char *)rimebuf_dataptr(), rimebuf_datalen());
|
||||
|
||||
rimebuf_copyfrom("Hopp", 4);
|
||||
mesh_send(from);
|
||||
mesh_send(&mesh, from);
|
||||
}
|
||||
|
||||
const static struct mesh_callbacks callbacks = {sent, recv};
|
||||
const static struct mesh_callbacks callbacks = {recv, sent, timedout};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(test_mesh_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
|
||||
mesh_open(&callbacks, NULL);
|
||||
mesh_open(&mesh, 128, &callbacks);
|
||||
|
||||
button_sensor.activate();
|
||||
|
||||
while(1) {
|
||||
rimeaddr_t addr;
|
||||
|
||||
PROCESS_WAIT_EVENT_UNTIL(ev == sensors_event && data == &button_sensor);
|
||||
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");
|
||||
|
||||
@ -88,8 +99,9 @@ PROCESS_THREAD(test_mesh_process, ev, data)
|
||||
*/
|
||||
|
||||
rimebuf_copyfrom("Hej", 3);
|
||||
addr.u16 = 6;
|
||||
mesh_send(&addr);
|
||||
addr.u8[0] = 161;
|
||||
addr.u8[1] = 161;
|
||||
mesh_send(&mesh, &addr);
|
||||
}
|
||||
PROCESS_END();
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: test-treeroute.c,v 1.1 2007/03/20 12:21:19 adamdunkels Exp $
|
||||
* $Id: test-treeroute.c,v 1.2 2007/03/22 19:03:56 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -40,10 +40,13 @@
|
||||
|
||||
#include "contiki.h"
|
||||
#include "net/rime.h"
|
||||
#include "net/rime/tree.h"
|
||||
#include "dev/leds.h"
|
||||
#include "dev/pir-sensor.h"
|
||||
#include "dev/button-sensor.h"
|
||||
|
||||
static struct tree_conn tc;
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(test_tree_process, "Test tree process");
|
||||
PROCESS(depth_blink_process, "Depth indicator");
|
||||
@ -59,7 +62,7 @@ PROCESS_THREAD(depth_blink_process, ev, data)
|
||||
while(1) {
|
||||
etimer_set(&et, CLOCK_SECOND * 1);
|
||||
PROCESS_WAIT_UNTIL(etimer_expired(&et));
|
||||
count = tree_depth();
|
||||
count = tree_depth(&tc);
|
||||
if(count == TREE_MAX_DEPTH) {
|
||||
leds_on(LEDS_RED);
|
||||
} else {
|
||||
@ -79,11 +82,19 @@ PROCESS_THREAD(depth_blink_process, ev, data)
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
recv(rimeaddr_t *originator, u8_t seqno, u8_t hops, u8_t retransmissions)
|
||||
{
|
||||
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static const struct tree_callbacks callbacks = { recv };
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(test_tree_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
|
||||
tree_open(NULL);
|
||||
tree_open(&tc, 128, &callbacks);
|
||||
|
||||
while(1) {
|
||||
|
||||
@ -92,12 +103,12 @@ PROCESS_THREAD(test_tree_process, ev, data)
|
||||
if(ev == sensors_event) {
|
||||
|
||||
if(data == &pir_sensor) {
|
||||
tree_send();
|
||||
tree_send(&tc);
|
||||
}
|
||||
|
||||
if(data == &button_sensor) {
|
||||
printf("Button\n");
|
||||
tree_set_sink(1);
|
||||
tree_set_sink(&tc, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user