4 #include <dev/button-sensor.h>
7 PROCESS(led_remote_control_rime
, "binary LED counter via button over Rime");
8 AUTOSTART_PROCESSES(&led_remote_control_rime
);
10 void recv(struct broadcast_conn
*ptr
, const rimeaddr_t
* sender
) {
11 char * val
= (char *) packetbuf_dataptr();
12 printf("node %d: recv from %d: %d\n", rimeaddr_node_addr
, *sender
, *val
);
22 leds_off(LEDS_YELLOW
);
25 printf("toggled LEDs\n");
28 static struct broadcast_conn bc
;
29 static const struct broadcast_callbacks bccb
= { recv
};
31 PROCESS_THREAD(led_remote_control_rime
, ev
, data
) {
32 PROCESS_EXITHANDLER(broadcast_close(&bc
));
39 SENSORS_ACTIVATE(button_sensor
);
41 broadcast_open(&bc
, 129, &bccb
);
43 static struct etimer timer
;
46 PROCESS_WAIT_EVENT_UNTIL(ev
== sensors_event
&& data
== &button_sensor
);
48 // debounce for 250 ms
49 etimer_set(&timer
, CLOCK_SECOND
* 0.25);
50 PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&timer
));
52 packetbuf_copyfrom(&i
, sizeof(i
));
54 printf("node %d: broadcast sent: %d\n", rimeaddr_node_addr
, i
);
This page took 0.043774 seconds and 5 git commands to generate.