diff --git a/platform/cooja/dev/button-sensor.c b/platform/cooja/dev/button-sensor.c index 85c11f078..8d9b343be 100644 --- a/platform/cooja/dev/button-sensor.c +++ b/platform/cooja/dev/button-sensor.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: button-sensor.c,v 1.5 2010/01/14 16:13:45 joxe Exp $ + * $Id: button-sensor.c,v 1.6 2010/01/14 19:12:31 nifi Exp $ */ #include "lib/sensors.h" @@ -42,7 +42,7 @@ char simButtonChanged; char simButtonIsDown; char simButtonIsActive; /*---------------------------------------------------------------------------*/ -static unsigned int +static int value(int type) { return simButtonIsDown || !timer_expired(&debouncetimer); @@ -53,9 +53,11 @@ configure(int type, int c) { if(type == SENSORS_ACTIVE) { simButtonIsActive = c; + return 1; } else if(type == SENSORS_HW_INIT) { simButtonIsActive = 1; timer_set(&debouncetimer, 0); + return 1; } return 0; } diff --git a/platform/cooja/dev/pir-sensor.c b/platform/cooja/dev/pir-sensor.c index 73842a90b..39dc4bbcd 100644 --- a/platform/cooja/dev/pir-sensor.c +++ b/platform/cooja/dev/pir-sensor.c @@ -26,10 +26,9 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: pir-sensor.c,v 1.1 2006/08/21 12:11:18 fros4943 Exp $ + * $Id: pir-sensor.c,v 1.2 2010/01/14 19:12:31 nifi Exp $ */ -#include "lib/sensors.h" #include "dev/pir-sensor.h" #include "lib/simEnvChange.h" @@ -41,53 +40,36 @@ char simPirChanged; char simPirIsActive; char simPirValue = 0; -/*---------------------------------------------------------------------------*/ -static void -init(void) -{ - simPirIsActive = 1; -} /*---------------------------------------------------------------------------*/ static int -irq(void) -{ - return 0; -} -/*---------------------------------------------------------------------------*/ -static void -activate(void) -{ - simPirIsActive = 1; -} -/*---------------------------------------------------------------------------*/ -static void -deactivate(void) -{ - simPirIsActive = 0; -} -/*---------------------------------------------------------------------------*/ -static int -active(void) -{ - return simPirIsActive; -} -/*---------------------------------------------------------------------------*/ -static unsigned int value(int type) { return simPirValue; } /*---------------------------------------------------------------------------*/ static int -configure(int type, void *c) +configure(int type, int c) { + switch(type) { + case SENSORS_HW_INIT: + simPirIsActive = 0; + return 1; + case SENSORS_ACTIVE: + simPirIsActive = c; + return 1; + } return 0; } /*---------------------------------------------------------------------------*/ -static void * +static int status(int type) { - return NULL; + switch(type) { + case SENSORS_ACTIVE: + case SENSORS_READY: + return simPirIsActive; + } + return 0; } /*---------------------------------------------------------------------------*/ static void @@ -95,7 +77,7 @@ doInterfaceActionsBeforeTick(void) { // Check if PIR value has changed if (simPirIsActive && simPirChanged) { - simPirValue = !simPirValue; + simPirValue++; sensors_changed(&pir_sensor); simPirChanged = 0; @@ -113,5 +95,4 @@ SIM_INTERFACE(pir_interface, doInterfaceActionsAfterTick); SENSORS_SENSOR(pir_sensor, PIR_SENSOR, - init, irq, activate, deactivate, active, - value, configure, status); + value, configure, status); diff --git a/platform/cooja/dev/pir-sensor.h b/platform/cooja/dev/pir-sensor.h index e3aa95ea4..bb27d8488 100644 --- a/platform/cooja/dev/pir-sensor.h +++ b/platform/cooja/dev/pir-sensor.h @@ -26,12 +26,14 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: pir-sensor.h,v 1.1 2006/08/21 12:11:19 fros4943 Exp $ + * $Id: pir-sensor.h,v 1.2 2010/01/14 19:12:31 nifi Exp $ */ #ifndef __PIR_H__ #define __PIR_H__ +#include "lib/sensors.h" + extern const struct sensors_sensor pir_sensor; #define PIR_SENSOR "PIR" diff --git a/platform/cooja/dev/radio-sensor.c b/platform/cooja/dev/radio-sensor.c index c06c0a21b..ffb2a9b0f 100644 --- a/platform/cooja/dev/radio-sensor.c +++ b/platform/cooja/dev/radio-sensor.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: radio-sensor.c,v 1.3 2007/05/29 12:27:00 fros4943 Exp $ + * @(#)$Id: radio-sensor.c,v 1.4 2010/01/14 19:12:31 nifi Exp $ */ #include "lib/sensors.h" @@ -40,54 +40,29 @@ const struct sensors_sensor radio_sensor; extern int simSignalStrength; -// COOJA variables (none - no corresponding part in Java) - -/*---------------------------------------------------------------------------*/ -static void -init(void) -{ -} /*---------------------------------------------------------------------------*/ static int -irq(void) -{ - return 0; -} -/*---------------------------------------------------------------------------*/ -static void -activate(void) -{ -} -/*---------------------------------------------------------------------------*/ -static void -deactivate(void) -{ -} -/*---------------------------------------------------------------------------*/ -static int -active(void) -{ - return 0; -} -/*---------------------------------------------------------------------------*/ -static unsigned int value(int type) { return simSignalStrength; } /*---------------------------------------------------------------------------*/ static int -configure(int type, void *c) +configure(int type, int c) { return 0; } /*---------------------------------------------------------------------------*/ -static void * +static int status(int type) { - return NULL; + switch(type) { + case SENSORS_ACTIVE: + case SENSORS_READY: + return 1; + } + return 0; } /*---------------------------------------------------------------------------*/ SENSORS_SENSOR(radio_sensor, RADIO_SENSOR, - init, irq, activate, deactivate, active, - value, configure, status); + value, configure, status); diff --git a/platform/cooja/dev/vib-sensor.c b/platform/cooja/dev/vib-sensor.c index 3228c8e1e..c94512dca 100644 --- a/platform/cooja/dev/vib-sensor.c +++ b/platform/cooja/dev/vib-sensor.c @@ -26,10 +26,9 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: vib-sensor.c,v 1.1 2006/08/21 12:11:18 fros4943 Exp $ + * $Id: vib-sensor.c,v 1.2 2010/01/14 19:12:31 nifi Exp $ */ -#include "lib/sensors.h" #include "dev/vib-sensor.h" #include "lib/simEnvChange.h" @@ -41,53 +40,36 @@ char simVibChanged; char simVibIsActive; char simVibValue = 0; -/*---------------------------------------------------------------------------*/ -static void -init(void) -{ - simVibIsActive = 1; -} /*---------------------------------------------------------------------------*/ static int -irq(void) -{ - return 0; -} -/*---------------------------------------------------------------------------*/ -static void -activate(void) -{ - simVibIsActive = 1; -} -/*---------------------------------------------------------------------------*/ -static void -deactivate(void) -{ - simVibIsActive = 0; -} -/*---------------------------------------------------------------------------*/ -static int -active(void) -{ - return simVibIsActive; -} -/*---------------------------------------------------------------------------*/ -static unsigned int value(int type) { return simVibValue; } /*---------------------------------------------------------------------------*/ static int -configure(int type, void *c) +configure(int type, int c) { + switch(type) { + case SENSORS_HW_INIT: + simVibIsActive = 0; + return 1; + case SENSORS_ACTIVE: + simVibIsActive = c; + return 1; + } return 0; } /*---------------------------------------------------------------------------*/ -static void * +static int status(int type) { - return NULL; + switch(type) { + case SENSORS_ACTIVE: + case SENSORS_READY: + return simVibIsActive; + } + return 0; } /*---------------------------------------------------------------------------*/ static void @@ -95,7 +77,7 @@ doInterfaceActionsBeforeTick(void) { // Check if Vib value has changed if (simVibIsActive && simVibChanged) { - simVibValue = !simVibValue; + simVibValue++; sensors_changed(&vib_sensor); simVibChanged = 0; @@ -113,5 +95,4 @@ SIM_INTERFACE(vib_interface, doInterfaceActionsAfterTick); SENSORS_SENSOR(vib_sensor, VIB_SENSOR, - init, irq, activate, deactivate, active, - value, configure, status); + value, configure, status); diff --git a/platform/cooja/dev/vib-sensor.h b/platform/cooja/dev/vib-sensor.h index beaa05e5f..c72e13bea 100644 --- a/platform/cooja/dev/vib-sensor.h +++ b/platform/cooja/dev/vib-sensor.h @@ -26,12 +26,14 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: vib-sensor.h,v 1.1 2006/08/21 12:11:18 fros4943 Exp $ + * $Id: vib-sensor.h,v 1.2 2010/01/14 19:12:31 nifi Exp $ */ #ifndef __VIB_H__ #define __VIB_H__ +#include "lib/sensors.h" + extern const struct sensors_sensor vib_sensor; #define VIB_SENSOR "Vibration sensor"