c46777ab8b7924607cf32037cb51e6eb41c30cf9
4 #include <button-sensor.h>
7 PROCESS(pwnage
, "total pwnage!");
8 AUTOSTART_PROCESSES(&pwnage
);
10 void recv(struct broadcast_conn
*ptr
, const rimeaddr_t
* sender
) {
11 char * val
= (char *) packetbuf_dataptr();
12 printf("node %d: recv from %d: %s\n", rimeaddr_node_addr
, *sender
, val
);
15 static struct broadcast_conn bc
;
16 static const struct broadcast_callbacks bccb
= { recv
};
18 PROCESS_THREAD(pwnage
, ev
, data
) {
19 PROCESS_EXITHANDLER(broadcast_close(&bc
));
26 SENSORS_ACTIVATE(button_sensor
);
28 broadcast_open(&bc
, 129, &bccb
);
30 static struct etimer timer
;
33 PROCESS_WAIT_EVENT_UNTIL(ev
== sensors_event
&& data
== &button_sensor
);
35 // debounce for 250 ms
36 etimer_set(&timer
, CLOCK_SECOND
* 0.25);
37 PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&timer
));
39 char foo
[] = "Spam, Spam, Wonderful Spam!";
40 packetbuf_copyfrom(foo
, sizeof(foo
));
42 printf("node %d: broadcast sent\n", rimeaddr_node_addr
, i
);
This page took 0.040469 seconds and 3 git commands to generate.