-// $Id$\r
-\r
-/*\r
- * IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
- * downloading, copying, installing or using the software you agree to\r
- * this license. If you do not agree to this license, do not download,\r
- * install, copy or use the software.\r
- *\r
- * Copyright (c) 2004-2006 Crossbow Technology, Inc.\r
- * All rights reserved.\r
- *\r
- * Permission to use, copy, modify, and distribute this software and its\r
- * documentation for any purpose, without fee, and without written\r
- * agreement is hereby granted, provided that the above copyright\r
- * notice, the (updated) modification history and the author appear in\r
- * all copies of this source code.\r
- *\r
- * Permission is also granted to distribute this software under the\r
- * standard BSD license as contained in the TinyOS distribution.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A\r
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS\r
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\r
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
- */\r
-\r
-/**\r
- * TinyOS 1.x to TinyOS 2.x translation layer.\r
- *\r
- * @author Alif <rlchen@xbow.com.cn> \r
- */\r
\r
#include "XMTS300.h"\r
#include "mts300.h"\r
\r
// sensorboard devices\r
components new SensorMts300C();\r
- components SounderC;\r
\r
TestMts300P -> MainC.Boot;\r
\r
TestMts300P.MTS300Timer -> MTS300Timer;\r
- TestMts300P.Leds -> NoLedsC;\r
+ TestMts300P.Leds -> LedsC;\r
\r
// communication\r
TestMts300P.RadioControl -> Radio;\r
TestMts300P.UartPacket -> Serial;\r
\r
// sensor components\r
- MainC.SoftwareInit -> SensorMts300C;\r
- TestMts300P.MTS300Control -> SensorMts300C.StdControl;\r
TestMts300P.Vref -> SensorMts300C.Vref;\r
+ TestMts300P.Sounder -> SensorMts300C.Sounder;\r
+ \r
TestMts300P.Light -> SensorMts300C.Light;\r
TestMts300P.Temp -> SensorMts300C.Temp;\r
TestMts300P.Microphone -> SensorMts300C.Microphone;\r
TestMts300P.AccelY -> SensorMts300C.AccelY;\r
TestMts300P.MagX -> SensorMts300C.MagX;\r
TestMts300P.MagY -> SensorMts300C.MagY;\r
-\r
- MainC.SoftwareInit -> SounderC;\r
- TestMts300P.Sounder -> SounderC;\r
}\r
-// $Id$\r
-\r
-/*\r
- * IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
- * downloading, copying, installing or using the software you agree to\r
- * this license. If you do not agree to this license, do not download,\r
- * install, copy or use the software.\r
- *\r
- * Copyright (c) 2004-2006 Crossbow Technology, Inc.\r
- * All rights reserved.\r
- *\r
- * Permission to use, copy, modify, and distribute this software and its\r
- * documentation for any purpose, without fee, and without written\r
- * agreement is hereby granted, provided that the above copyright\r
- * notice, the (updated) modification history and the author appear in\r
- * all copies of this source code.\r
- *\r
- * Permission is also granted to distribute this software under the\r
- * standard BSD license as contained in the TinyOS distribution.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A\r
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS\r
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\r
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
- */\r
-\r
-/**\r
- * TinyOS 1.x to TinyOS 2.x translation layer.\r
- *\r
- * @author Alif <rlchen@xbow.com.cn> \r
- */\r
- \r
#include "Timer.h"\r
#include "XMTS300.h"\r
#include "mts300.h"\r
interface Packet as UartPacket;\r
interface AMSend as UartSend;\r
// sensor components\r
- interface StdControl as MTS300Control;\r
- interface StdControl as Sounder;\r
+ interface Mts300Sounder as Sounder;\r
interface Read<uint16_t> as Vref; //!< voltage\r
interface Read<uint16_t> as Light;\r
interface Read<uint16_t> as Temp;\r
norace uint16_t accel_ave_x, accel_ave_y;\r
norace uint8_t accel_ave_points;\r
\r
+\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+// packet sending\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+ task void send_msg()\r
+ {\r
+ atomic packet_ready = FALSE;\r
+ // check length of the allocated buffer to see if it is enough for our packet\r
+ if (call RadioPacket.maxPayloadLength() < sizeof(Mts300Msg))\r
+ {\r
+ return ;\r
+ }\r
+ // OK, the buffer is large enough\r
+ //pMsg->vref = counter;\r
+ if (call UartSend.send(AM_BROADCAST_ADDR, &packet, sizeof(Mts300Msg)) == SUCCESS)\r
+ {\r
+ sending_packet = TRUE;\r
+ call Leds.led2On();\r
+ }\r
+ }\r
+\r
//////////////////////////////////////////////////////////////////////////////\r
//\r
// basic control routines\r
{\r
if (err == SUCCESS)\r
{\r
- call MTS300Control.start();\r
- call Sounder.start();\r
- call MTS300Timer.startPeriodic( 300 );\r
+ call Sounder.beep(1000);\r
+ call MTS300Timer.startPeriodic( 1000 );\r
}\r
else\r
{\r
}\r
\r
call Leds.led1Toggle();\r
- counter++;\r
-\r
- if(counter==1)\r
- {\r
- call Sounder.stop();\r
- }\r
\r
if (sending_packet) return ;\r
\r
call Vref.read();\r
return ;\r
}\r
-\r
- if (packet_ready)\r
- {\r
- atomic packet_ready = FALSE;\r
- // check length of the allocated buffer to see if it is enough for our packet\r
- if (call RadioPacket.maxPayloadLength() < sizeof(Mts300Msg))\r
- {\r
- return ;\r
- }\r
- // OK, the buffer is large enough\r
- //pMsg->vref = counter;\r
- if (call UartSend.send(AM_BROADCAST_ADDR, &packet, sizeof(Mts300Msg)) == SUCCESS)\r
- {\r
- sending_packet = TRUE;\r
- call Leds.led2On();\r
- }\r
- }\r
}\r
\r
/**\r
{\r
pMsg->vref = 0;\r
}\r
-// atomic packet_ready = TRUE;\r
atomic state = STATE_LIGHT_START;\r
call Light.read();\r
}\r
}\r
atomic state = STATE_TEMP_START;\r
call Temp.read();\r
+// atomic state = STATE_MIC_START;\r
+// call Microphone.read();\r
}\r
\r
-\r
/**\r
* Temperature data read\r
*\r
{\r
pMsg->accelY = 0;\r
}\r
-// atomic packet_ready = TRUE;\r
atomic state = STATE_MAGX_START;\r
call MagX.read();\r
}\r
pMsg->magY = 0;\r
}\r
atomic packet_ready = TRUE;\r
+ post send_msg();\r
}\r
\r
/**\r