From a92b31ad21e6975248e2eeb1adb24d9bfe8dc328 Mon Sep 17 00:00:00 2001 From: Nicolas Tsiftes Date: Thu, 23 Jun 2011 15:21:20 +0200 Subject: [PATCH] Minor style improvement. --- examples/rime/example-mesh.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/examples/rime/example-mesh.c b/examples/rime/example-mesh.c index 801ef7b68..f4e58f0b4 100644 --- a/examples/rime/example-mesh.c +++ b/examples/rime/example-mesh.c @@ -33,7 +33,7 @@ /** * \file - * A brief description of what this file is. + * An example of how the Mesh primitive can be used. * \author * Adam Dunkels */ @@ -48,6 +48,8 @@ #include +#define MESSAGE "Hello" + static struct mesh_conn mesh; /*---------------------------------------------------------------------------*/ PROCESS(example_mesh_process, "Mesh example"); @@ -58,11 +60,13 @@ sent(struct mesh_conn *c) { printf("packet sent\n"); } + static void timedout(struct mesh_conn *c) { printf("packet timedout\n"); } + static void recv(struct mesh_conn *c, const rimeaddr_t *from, uint8_t hops) { @@ -70,7 +74,7 @@ recv(struct mesh_conn *c, const rimeaddr_t *from, uint8_t hops) from->u8[0], from->u8[1], packetbuf_datalen(), (char *)packetbuf_dataptr(), packetbuf_datalen()); - packetbuf_copyfrom("Hopp", 4); + packetbuf_copyfrom(MESSAGE, strlen(MESSAGE)); mesh_send(&mesh, from); } @@ -87,20 +91,15 @@ PROCESS_THREAD(example_mesh_process, ev, data) 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)); + /* Wait for button click before sending the first message. */ + PROCESS_WAIT_EVENT_UNTIL(ev == sensors_event && data == &button_sensor); - printf("Button\n"); + printf("Button clicked\n"); - /* - * Send a message containing "Hej" (3 characters) to node number - * 6. - */ + /* Send a message to node number 1. */ - packetbuf_copyfrom("Hej", 3); + packetbuf_copyfrom(MESSAGE, strlen(MESSAGE)); addr.u8[0] = 1; addr.u8[1] = 0; mesh_send(&mesh, &addr);