#!/bin/bash
+python -c '
+import sys
+try:
+ import serial
+except ImportError, e:
+ sys.exit(1)'
+
+if [[ $? != 0 ]]
+then
+ echo "Please install PySerial first."
+ exit 2
+fi
+
TOS_DELUGE=`type -p tos-deluge`
if [[ ! -x ${TOS_DELUGE} ]] ; then
TOS_DELUGE=../../../../tools/tinyos/misc/tos-deluge
fi
-echo ${TOS_DELUGE}
-
if [ $# -ne 2 ]; then
echo "Usage: $0 <port> <platform>"
echo "<port> For example, /dev/ttyUSB0"
exit 2
fi
-if [ $2 != 'micaz' -a $2 != 'telosb' ]; then
- echo "\"$2\" is not a supported platform"
+PORT=$1
+PLATFORM=$2
+
+if [ ${PLATFORM} != 'micaz' -a ${PLATFORM} != 'telosb' ]; then
+ echo "\"${PLATFORM}\" is not a supported platform"
exit 2
fi
-PORT=$1
-PLATFORM=$2
+if ! [ -a ${TOSDIR}/lib/tosboot/build/${PLATFORM}/main.ihex ]
+then
+ echo ========================== Compile tosboot for ${PLATFORM} ===========================
+ ( cd $TOSDIR/lib/tosboot ; make ${PLATFORM} )
+fi
make clean
echo ' +----------------------------------------------------------------+'
echo ' | |'
-echo ' | After pressing enter the following things will take place: |'
-echo ' | - mote will be rebooted |'
+echo ' | In the next step the following things will take place: |'
+echo ' | - the mote will be rebooted |'
echo ' | - all the leds will blink for some time as the |'
echo ' | reprogramming by tosboot takes place. |'
echo ' | - a fading of the leds will indicate the exiting from tosboot. |'
TOS_DELUGE=../../../../tools/tinyos/misc/tos-deluge
fi
-echo ${TOS_DELUGE}
-
if [ $# -ne 2 ]; then
echo "Usage: $0 <platform> <number of motes>"
echo "<platform> \"micaz\", \"telosb\""
NO_MOTES=$2
if [ ${PLATFORM} != 'micaz' -a ${PLATFORM} != 'telosb' ]; then
- echo "\"$2\" is not a supported platform"
+ echo "\"${PLAFTORM}\" is not a supported platform"
exit 2
fi
+if ! [ -a ${TOSDIR}/lib/tosboot/build/${PLATFORM}/main.ihex ]
+then
+ echo ========================== Compile tosboot for ${PLATFORM} ===========================
+ ( cd $TOSDIR/lib/tosboot ; make ${PLATFORM} )
+fi
+
echo ================================ Compile Blink =================================
make clean
CFLAGS=-DDELUGE_BASESTATION make ${PLATFORM}
echo ========= Upload the new image to the external flash of the last mote ==========
${TOS_DELUGE} ${PORT} ${PLATFORM} -i 0 build/${PLATFORM}/tos_image.xml
-echo ' +-----------------------------------------+'
-echo ' | |'
-echo ' | Press ENTER to start the dissemination. |'
-echo ' | |'
-echo ' +-----------------------------------------+'
+echo ' +-----------------------------------------------------+'
+echo ' | |'
+echo ' | In the next step the dissemination will be started. |'
+echo ' | When a node receives a page, the second led (green) |'
+echo ' | will blink. |'
+echo ' | |'
+echo ' | Press ENTER to continue... |'
+echo ' | |'
+echo ' +-----------------------------------------------------+'
+
read
echo ============================= Start dissemination ==============================
${TOS_DELUGE} ${PORT} ${PLATFORM} -d 0
-echo ' +--------------------------------------------------+'
-echo ' | |'
-echo ' | Press ENTER when the second led (green) from all |'
-echo ' | the motes except the last one stops blinking. |'
-echo ' | |'
-echo ' +--------------------------------------------------+'
+echo ' +------------------------------------------------------------+'
+echo ' | |'
+echo ' | The dissemination is completed when the second and third |'
+echo ' | led from all the motes except the last one stops blinking. |'
+echo ' | |'
+echo ' | In the next step the motes will be rebooted to allow the |'
+echo ' | reprogramming to take place. |'
+echo ' | |'
+echo ' | Press ENTER to continue... |'
+echo ' | |'
+echo ' +------------------------------------------------------------+'
read
echo ===================== Trigger the reboot in the new image ======================
#include "Deluge.h"
#include "StorageVolumes.h"
-configuration DelugeC {}
+configuration DelugeC
+{
+ uses interface Leds;
+}
implementation
{
ObjectTransferC.BlockWrite[VOLUME_DELUGE0] -> DelugeStorageC.BlockWrite[VOLUME_DELUGE0];
ObjectTransferC.BlockRead[VOLUME_DELUGE1] -> DelugeStorageC.BlockRead[VOLUME_DELUGE1];
ObjectTransferC.BlockWrite[VOLUME_DELUGE1] -> DelugeStorageC.BlockWrite[VOLUME_DELUGE1];
+ ObjectTransferC.Leds = Leds;
components new DisseminatorC(DelugeDissemination, 0xDE00), DisseminationC;
components ActiveMessageC;
components NetProgC, DelugeP;
components new TimerMilliC() as Timer;
- components LedsC, NoLedsC;
- DelugeP.Leds -> LedsC;
+ DelugeP.Leds = Leds;
DelugeP.DisseminationValue -> DisseminatorC;
DelugeP.DisseminationUpdate -> DisseminatorC;
DelugeP.StdControlDissemination -> DisseminationC;
event void ObjectTransfer.receiveDone(error_t error)
{
+ call Leds.set(LEDS_LED1 | LEDS_LED2);
call ObjectTransfer.publish(recv_uid, recv_size, recv_imgNum);
}
}
event void RadioSplitControl.stopDone(error_t error) {}
+
+ default async void command Leds.set(uint8_t val) {}
}
interface AMSend as SendReqMsg;
interface AMPacket;
interface PacketAcknowledgements;
+ interface Leds;
}
}
DelugePageTransferP.Timer -> Timer;
DelugePageTransferP.BitVecUtils -> BitVecUtilsC;
- components NoLedsC, LedsC;
- DelugePageTransferP.Leds -> LedsC;
+ DelugePageTransferP.Leds = Leds;
// For collecting statistics
//components StatsCollectorC;
default command error_t BlockRead.read[uint8_t img_num](storage_addr_t addr, void* buf, storage_len_t len) { return FAIL; }
default command error_t BlockWrite.write[uint8_t img_num](storage_addr_t addr, void* buf, storage_len_t len) { return FAIL; }
+ default async command void Leds.led1Toggle() {}
}
uses {
interface BlockRead[uint8_t img_num];
interface BlockWrite[uint8_t img_num];
+ interface Leds;
}
}
DelugePageTransferC.SendDataMsg -> SendDataMsg;
DelugePageTransferC.ReceiveDataMsg -> ReceiveDataMsg;
DelugePageTransferC.AMPacket -> SendDataMsg;
+ DelugePageTransferC.Leds = Leds;
ObjectTransferP.BlockWrite[VOLUME_DELUGE0] = BlockWrite[VOLUME_DELUGE0];
ObjectTransferP.BlockWrite[VOLUME_DELUGE1] = BlockWrite[VOLUME_DELUGE1];
- components MainC, LedsC, NoLedsC;
- ObjectTransferP.Leds -> NoLedsC;
-
components RandomC, new TimerMilliC() as Timer;
ObjectTransferP.Random -> RandomC;
ObjectTransferP.Timer -> Timer;