Updated to match the new sensors API

This commit is contained in:
nifi 2010-01-14 19:19:50 +00:00
parent 7154b4c68d
commit 4ffa7b95b7
4 changed files with 14 additions and 16 deletions

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: testbutton.c,v 1.2 2008/10/03 09:39:38 fros4943 Exp $ * $Id: testbutton.c,v 1.3 2010/01/14 19:19:50 nifi Exp $
*/ */
#include "contiki.h" #include "contiki.h"
@ -44,12 +44,12 @@ PROCESS_THREAD(test_button_process, ev, data)
PROCESS_BEGIN(); PROCESS_BEGIN();
printf("Starting Button test process (counter=%i)\n", counter); printf("Starting Button test process (counter=%i)\n", counter);
button_sensor.activate(); button_sensor.configure(SENSORS_ACTIVE, 1);
while(1) { while(1) {
PROCESS_WAIT_EVENT(); PROCESS_WAIT_EVENT();
if (ev == sensors_event && data == &button_sensor && button_sensor.value(0)) { if(ev == sensors_event && data == &button_sensor) {
counter++; counter++;
printf("Button pressed (counter=%i)\n", counter); printf("Button pressed (counter=%i)\n", counter);
} }

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: testsensors.c,v 1.2 2008/10/03 09:39:38 fros4943 Exp $ * $Id: testsensors.c,v 1.3 2010/01/14 19:19:50 nifi Exp $
*/ */
#include "contiki.h" #include "contiki.h"
@ -45,10 +45,10 @@ PROCESS_THREAD(test_sensors_process, ev, data)
PROCESS_BEGIN(); PROCESS_BEGIN();
printf("Starting sensors test process\n"); printf("Starting sensors test process\n");
button_sensor.activate(); button_sensor.configure(SENSORS_ACTIVE, 1);
pir_sensor.activate(); pir_sensor.configure(SENSORS_ACTIVE, 1);
vib_sensor.activate(); vib_sensor.configure(SENSORS_ACTIVE, 1);
radio_sensor.activate(); radio_sensor.configure(SENSORS_ACTIVE, 1);
while(1) { while(1) {
PROCESS_WAIT_EVENT(); PROCESS_WAIT_EVENT();

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: testuaodv.c,v 1.2 2008/10/03 09:39:38 fros4943 Exp $ * $Id: testuaodv.c,v 1.3 2010/01/14 19:19:50 nifi Exp $
*/ */
#include <stdlib.h> #include <stdlib.h>
@ -62,12 +62,12 @@ PROCESS_THREAD(test_uaodv_process, ev, data)
uip_ipaddr(&addr, 10,10,10,4); uip_ipaddr(&addr, 10,10,10,4);
out_conn = udp_new(&addr, HTONS(COOJA_PORT), NULL); out_conn = udp_new(&addr, HTONS(COOJA_PORT), NULL);
button_sensor.activate(); button_sensor.configure(SENSORS_ACTIVE, 1);
while(1) { while(1) {
PROCESS_WAIT_EVENT(); PROCESS_WAIT_EVENT();
if(ev == sensors_event && data == &button_sensor && button_sensor.value(0)) { if(ev == sensors_event && data == &button_sensor) {
struct uaodv_rt_entry *route; struct uaodv_rt_entry *route;
uip_ipaddr(&addr, 10,10,10,4); uip_ipaddr(&addr, 10,10,10,4);

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: testuip.c,v 1.3 2009/05/19 17:54:08 fros4943 Exp $ * $Id: testuip.c,v 1.4 2010/01/14 19:19:50 nifi Exp $
*/ */
#include <stdlib.h> #include <stdlib.h>
@ -50,7 +50,7 @@ PROCESS_THREAD(test_uip_process, ev, data)
printf("uIP test process started\n"); printf("uIP test process started\n");
broadcast_conn = udp_broadcast_new(COOJA_PORT, NULL); broadcast_conn = udp_broadcast_new(COOJA_PORT, NULL);
button_sensor.activate(); button_sensor.configure(SENSORS_ACTIVE, 1);
while(1) { while(1) {
PROCESS_WAIT_EVENT(); PROCESS_WAIT_EVENT();
@ -61,14 +61,12 @@ PROCESS_THREAD(test_uip_process, ev, data)
break; break;
} }
if(ev == sensors_event && data == &button_sensor && button_sensor.value(0)) { if(ev == sensors_event && data == &button_sensor) {
printf("button clicked, sending packet\n"); printf("button clicked, sending packet\n");
tcpip_poll_udp(broadcast_conn); tcpip_poll_udp(broadcast_conn);
PROCESS_WAIT_UNTIL(ev == tcpip_event && uip_poll()); PROCESS_WAIT_UNTIL(ev == tcpip_event && uip_poll());
uip_send("cooyah COOJA", 12); uip_send("cooyah COOJA", 12);
} else if(ev == sensors_event && data == &button_sensor && !button_sensor.value(0)) {
printf("button released, ignoring event\n");
} else if(ev == sensors_event) { } else if(ev == sensors_event) {
printf("unknown sensor event: %s\n", ((struct sensors_sensor *)data)->type); printf("unknown sensor event: %s\n", ((struct sensors_sensor *)data)->type);
} else if(ev == tcpip_event && uip_newdata()) { } else if(ev == tcpip_event && uip_newdata()) {