From 4ffa7b95b745a6efba2be4c9e351e8529b8c2464 Mon Sep 17 00:00:00 2001 From: nifi Date: Thu, 14 Jan 2010 19:19:50 +0000 Subject: [PATCH] Updated to match the new sensors API --- platform/cooja/testapps/testbutton.c | 6 +++--- platform/cooja/testapps/testsensors.c | 10 +++++----- platform/cooja/testapps/testuaodv.c | 6 +++--- platform/cooja/testapps/testuip.c | 8 +++----- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/platform/cooja/testapps/testbutton.c b/platform/cooja/testapps/testbutton.c index 7d7401bef..efb75e3a2 100644 --- a/platform/cooja/testapps/testbutton.c +++ b/platform/cooja/testapps/testbutton.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * 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" @@ -44,12 +44,12 @@ PROCESS_THREAD(test_button_process, ev, data) PROCESS_BEGIN(); printf("Starting Button test process (counter=%i)\n", counter); - button_sensor.activate(); + button_sensor.configure(SENSORS_ACTIVE, 1); while(1) { PROCESS_WAIT_EVENT(); - if (ev == sensors_event && data == &button_sensor && button_sensor.value(0)) { + if(ev == sensors_event && data == &button_sensor) { counter++; printf("Button pressed (counter=%i)\n", counter); } diff --git a/platform/cooja/testapps/testsensors.c b/platform/cooja/testapps/testsensors.c index 7999f268b..be81b5024 100644 --- a/platform/cooja/testapps/testsensors.c +++ b/platform/cooja/testapps/testsensors.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * 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" @@ -45,10 +45,10 @@ PROCESS_THREAD(test_sensors_process, ev, data) PROCESS_BEGIN(); printf("Starting sensors test process\n"); - button_sensor.activate(); - pir_sensor.activate(); - vib_sensor.activate(); - radio_sensor.activate(); + button_sensor.configure(SENSORS_ACTIVE, 1); + pir_sensor.configure(SENSORS_ACTIVE, 1); + vib_sensor.configure(SENSORS_ACTIVE, 1); + radio_sensor.configure(SENSORS_ACTIVE, 1); while(1) { PROCESS_WAIT_EVENT(); diff --git a/platform/cooja/testapps/testuaodv.c b/platform/cooja/testapps/testuaodv.c index 2bb190f10..47ff1a23f 100644 --- a/platform/cooja/testapps/testuaodv.c +++ b/platform/cooja/testapps/testuaodv.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * 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 @@ -62,12 +62,12 @@ PROCESS_THREAD(test_uaodv_process, ev, data) uip_ipaddr(&addr, 10,10,10,4); out_conn = udp_new(&addr, HTONS(COOJA_PORT), NULL); - button_sensor.activate(); + button_sensor.configure(SENSORS_ACTIVE, 1); while(1) { 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; uip_ipaddr(&addr, 10,10,10,4); diff --git a/platform/cooja/testapps/testuip.c b/platform/cooja/testapps/testuip.c index 78c261aa7..95d931420 100644 --- a/platform/cooja/testapps/testuip.c +++ b/platform/cooja/testapps/testuip.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * 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 @@ -50,7 +50,7 @@ PROCESS_THREAD(test_uip_process, ev, data) printf("uIP test process started\n"); broadcast_conn = udp_broadcast_new(COOJA_PORT, NULL); - button_sensor.activate(); + button_sensor.configure(SENSORS_ACTIVE, 1); while(1) { PROCESS_WAIT_EVENT(); @@ -61,14 +61,12 @@ PROCESS_THREAD(test_uip_process, ev, data) 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"); tcpip_poll_udp(broadcast_conn); PROCESS_WAIT_UNTIL(ev == tcpip_event && uip_poll()); 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) { printf("unknown sensor event: %s\n", ((struct sensors_sensor *)data)->type); } else if(ev == tcpip_event && uip_newdata()) {