b3b9899988cc7d5f9256b22cf3f1e8b21718141c
4 #include <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
);
15 leds_toggle(LEDS_GREEN
);
17 leds_toggle(LEDS_YELLOW
);
18 printf("toggled LEDs\n");
21 static struct broadcast_conn bc
;
22 static const struct broadcast_callbacks bccb
= { recv
};
24 PROCESS_THREAD(led_remote_control_rime
, ev
, data
) {
25 PROCESS_EXITHANDLER(broadcast_close(&bc
));
32 SENSORS_ACTIVATE(button_sensor
);
34 broadcast_open(&bc
, 129, &bccb
);
36 static struct etimer timer
;
39 PROCESS_WAIT_EVENT_UNTIL(ev
== sensors_event
&& data
== &button_sensor
);
41 // debounce for 250 ms
42 etimer_set(&timer
, CLOCK_SECOND
* 0.25);
43 PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&timer
));
45 packetbuf_copyfrom(&i
, sizeof(i
));
47 printf("node %d: broadcast sent: %d\n", rimeaddr_node_addr
, i
);
This page took 0.052454 seconds and 3 git commands to generate.