Changed to use the light-sensor and sht11-sensor instead of directory interfacing the drivers

This commit is contained in:
nifi 2010-01-15 10:32:36 +00:00
parent bf04174bb3
commit c5508f9f88
2 changed files with 21 additions and 12 deletions

View file

@ -26,14 +26,14 @@
* 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: radio-test.c,v 1.5 2009/03/12 21:58:21 adamdunkels Exp $ * $Id: radio-test.c,v 1.6 2010/01/15 10:32:36 nifi Exp $
* *
* ----------------------------------------------------------------- * -----------------------------------------------------------------
* *
* Author : Adam Dunkels, Joakim Eriksson, Niclas Finne * Author : Adam Dunkels, Joakim Eriksson, Niclas Finne
* Created : 2006-03-07 * Created : 2006-03-07
* Updated : $Date: 2009/03/12 21:58:21 $ * Updated : $Date: 2010/01/15 10:32:36 $
* $Revision: 1.5 $ * $Revision: 1.6 $
* *
* Simple application to indicate connectivity between two nodes: * Simple application to indicate connectivity between two nodes:
* *
@ -128,7 +128,7 @@ PROCESS_THREAD(radio_test_process, ev, data)
abc_open(&abc, PORT, &abc_call); abc_open(&abc, PORT, &abc_call);
etimer_set(&send_timer, CLOCK_SECOND); etimer_set(&send_timer, CLOCK_SECOND);
button_sensor.activate(); SENSORS_ACTIVATE(button_sensor);
while(1) { while(1) {
PROCESS_WAIT_EVENT(); PROCESS_WAIT_EVENT();

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: sky-collect.c,v 1.9 2009/03/12 21:58:21 adamdunkels Exp $ * $Id: sky-collect.c,v 1.10 2010/01/15 10:32:36 nifi Exp $
*/ */
/** /**
@ -44,10 +44,10 @@
#include "net/rime/collect.h" #include "net/rime/collect.h"
#include "dev/leds.h" #include "dev/leds.h"
#include "dev/button-sensor.h" #include "dev/button-sensor.h"
#include "dev/light-sensor.h"
#include "dev/sht11-sensor.h"
#include "dev/light.h"
#include "dev/cc2420.h" #include "dev/cc2420.h"
#include "dev/sht11.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "contiki-net.h" #include "contiki-net.h"
@ -192,7 +192,7 @@ PROCESS_THREAD(test_collect_process, ev, data)
PROCESS_EXITHANDLER(goto exit;) PROCESS_EXITHANDLER(goto exit;)
PROCESS_BEGIN(); PROCESS_BEGIN();
button_sensor.activate(); SENSORS_ACTIVATE(button_sensor);
collect_open(&tc, 128, &callbacks); collect_open(&tc, 128, &callbacks);
@ -213,14 +213,19 @@ PROCESS_THREAD(test_collect_process, ev, data)
struct sky_collect_msg *msg; struct sky_collect_msg *msg;
struct neighbor *n; struct neighbor *n;
/* leds_toggle(LEDS_BLUE);*/ /* leds_toggle(LEDS_BLUE);*/
SENSORS_ACTIVATE(light_sensor);
SENSORS_ACTIVATE(sht11_sensor);
packetbuf_clear(); packetbuf_clear();
msg = (struct sky_collect_msg *)packetbuf_dataptr(); msg = (struct sky_collect_msg *)packetbuf_dataptr();
packetbuf_set_datalen(sizeof(struct sky_collect_msg)); packetbuf_set_datalen(sizeof(struct sky_collect_msg));
msg->light1 = sensors_light1(); msg->light1 = light_sensor.value(LIGHT_SENSOR_PHOTOSYNTHETIC);
msg->light2 = sensors_light2(); msg->light2 = light_sensor.value(LIGHT_SENSOR_TOTAL_SOLAR);
msg->temperature = sht11_temp(); msg->temperature = sht11_sensor.value(SHT11_SENSOR_TEMP);
msg->humidity = sht11_humidity(); msg->humidity = sht11_sensor.value(SHT11_SENSOR_HUMIDITY);
msg->rssi = do_rssi(); msg->rssi = do_rssi();
msg->energy_lpm = energest_type_time(ENERGEST_TYPE_LPM); msg->energy_lpm = energest_type_time(ENERGEST_TYPE_LPM);
msg->energy_cpu = energest_type_time(ENERGEST_TYPE_CPU); msg->energy_cpu = energest_type_time(ENERGEST_TYPE_CPU);
msg->energy_rx = energest_type_time(ENERGEST_TYPE_LISTEN); msg->energy_rx = energest_type_time(ENERGEST_TYPE_LISTEN);
@ -255,6 +260,10 @@ PROCESS_THREAD(test_collect_process, ev, data)
msg->lltx = rimestats.lltx; msg->lltx = rimestats.lltx;
msg->llrx = rimestats.llrx; msg->llrx = rimestats.llrx;
msg->timestamp = timesynch_time(); msg->timestamp = timesynch_time();
SENSORS_DEACTIVATE(light_sensor);
SENSORS_DEACTIVATE(sht11_sensor);
collect_send(&tc, REXMITS); collect_send(&tc, REXMITS);
} }
} }