mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-11-19 03:05:14 +00:00
Minor style improvement.
This commit is contained in:
parent
6749281a87
commit
a92b31ad21
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \file
|
* \file
|
||||||
* A brief description of what this file is.
|
* An example of how the Mesh primitive can be used.
|
||||||
* \author
|
* \author
|
||||||
* Adam Dunkels <adam@sics.se>
|
* Adam Dunkels <adam@sics.se>
|
||||||
*/
|
*/
|
||||||
@ -48,6 +48,8 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#define MESSAGE "Hello"
|
||||||
|
|
||||||
static struct mesh_conn mesh;
|
static struct mesh_conn mesh;
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
PROCESS(example_mesh_process, "Mesh example");
|
PROCESS(example_mesh_process, "Mesh example");
|
||||||
@ -58,11 +60,13 @@ sent(struct mesh_conn *c)
|
|||||||
{
|
{
|
||||||
printf("packet sent\n");
|
printf("packet sent\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
timedout(struct mesh_conn *c)
|
timedout(struct mesh_conn *c)
|
||||||
{
|
{
|
||||||
printf("packet timedout\n");
|
printf("packet timedout\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
recv(struct mesh_conn *c, const rimeaddr_t *from, uint8_t hops)
|
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],
|
from->u8[0], from->u8[1],
|
||||||
packetbuf_datalen(), (char *)packetbuf_dataptr(), packetbuf_datalen());
|
packetbuf_datalen(), (char *)packetbuf_dataptr(), packetbuf_datalen());
|
||||||
|
|
||||||
packetbuf_copyfrom("Hopp", 4);
|
packetbuf_copyfrom(MESSAGE, strlen(MESSAGE));
|
||||||
mesh_send(&mesh, from);
|
mesh_send(&mesh, from);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,20 +91,15 @@ PROCESS_THREAD(example_mesh_process, ev, data)
|
|||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
rimeaddr_t addr;
|
rimeaddr_t addr;
|
||||||
static struct etimer et;
|
|
||||||
|
|
||||||
/* etimer_set(&et, CLOCK_SECOND * 4);*/
|
/* Wait for button click before sending the first message. */
|
||||||
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et) ||
|
PROCESS_WAIT_EVENT_UNTIL(ev == sensors_event && data == &button_sensor);
|
||||||
(ev == sensors_event && data == &button_sensor));
|
|
||||||
|
|
||||||
printf("Button\n");
|
printf("Button clicked\n");
|
||||||
|
|
||||||
/*
|
/* Send a message to node number 1. */
|
||||||
* Send a message containing "Hej" (3 characters) to node number
|
|
||||||
* 6.
|
|
||||||
*/
|
|
||||||
|
|
||||||
packetbuf_copyfrom("Hej", 3);
|
packetbuf_copyfrom(MESSAGE, strlen(MESSAGE));
|
||||||
addr.u8[0] = 1;
|
addr.u8[0] = 1;
|
||||||
addr.u8[1] = 0;
|
addr.u8[1] = 0;
|
||||||
mesh_send(&mesh, &addr);
|
mesh_send(&mesh, &addr);
|
||||||
|
Loading…
Reference in New Issue
Block a user