]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
This commit from Chieh-Jan (Mike) Liang fixes the following issues:
authorrazvanm <razvanm>
Tue, 10 Jul 2007 01:17:39 +0000 (01:17 +0000)
committerrazvanm <razvanm>
Tue, 10 Jul 2007 01:17:39 +0000 (01:17 +0000)
- Add a new command to reprogram the network (instead of motes automatically reprogram after they receive an image).
- Update the documentation to reflect the new command.
- Add README.txt files for the examples.

16 files changed:
apps/tests/deluge/Blink/README.txt [new file with mode: 0644]
apps/tests/deluge/GoldenImage/README.txt [new file with mode: 0644]
apps/tests/deluge/SerialBlink/README.txt [new file with mode: 0644]
doc/html/deluge-t2-manual.css
doc/html/deluge-t2-manual.html
doc/pdf/deluge-t2-manual.pdf
tools/tinyos/misc/tos-deluge
tos/lib/net/Deluge/Deluge.h
tos/lib/net/Deluge/DelugeC.nc
tos/lib/net/Deluge/DelugeMsgs.h
tos/lib/net/Deluge/DelugeP.nc
tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManager.h
tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManagerC.nc
tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManagerP.nc
tos/lib/net/Deluge/ObjectTransferP.nc
tos/lib/net/Deluge/extra/NetProgM.nc

diff --git a/apps/tests/deluge/Blink/README.txt b/apps/tests/deluge/Blink/README.txt
new file mode 100644 (file)
index 0000000..4be92bc
--- /dev/null
@@ -0,0 +1,38 @@
+README for apps/tests/deluge/Blink\r
+Author/Contact:\r
+\r
+Chieh-Jan Mike Liang <cliang4@cs.jhu.edu>\r
+Razvan Musaloiu-E. <razvanm@cs.jhu.edu>\r
+\r
+Description:\r
+\r
+This is a sample application referenced in the Deluge T2 manual to show \r
+some of the basics in reprogramming.\r
+\r
+The burn script performs the following tasks on the basestation:\r
+   1) Compile and load the program normally.\r
+   2) Compile another version of blink that blinks differently.\r
+   3) Upload the new blink to flash volume 0.\r
+   4) Instruct the mote to reprogram with the new blink.\r
+\r
+Alternatively, you can reprogram the whole network (non-basestation \r
+motes) by first uploading the image to the base station. Then, tell the \r
+base station to disseminate the image. For example,\r
+\r
+   tos-deluge /dev/ttyUSB0 telosb -d 0\r
+   \r
+Finally, after the image has been disseminated, instruct the base \r
+station to disseminate the command to reprogram. For example,\r
+\r
+   tos-deluge /dev/ttyUSB0 telosb -r 0\r
+\r
+For a more detailed discussion on Deluge T2, please refer to the Deluge \r
+T2 manual.\r
+\r
+Prerequisites:\r
+\r
+Python 2.4 with pySerial\r
+\r
+References:\r
+\r
+The Deluge T2 manual is available under $TOS_DIR/doc/html/.\r
diff --git a/apps/tests/deluge/GoldenImage/README.txt b/apps/tests/deluge/GoldenImage/README.txt
new file mode 100644 (file)
index 0000000..39dd3f5
--- /dev/null
@@ -0,0 +1,32 @@
+README for apps/tests/deluge/GoldenImage
+Author/Contact:
+
+Chieh-Jan Mike Liang <cliang4@cs.jhu.edu>
+Razvan Musaloiu-E. <razvanm@cs.jhu.edu>
+
+Description:
+
+This is a sample application for Deluge T2. The application is similar 
+to Null, but it includes Deluge T2.
+
+You can reprogram the whole network (non-basestation motes) by first 
+uploading the image to the base station. Then, tell the base station to 
+disseminate the image. Example:
+
+   tos-deluge /dev/ttyUSB0 telosb -d 0
+   
+Finally, after the image has been disseminated, instruct the base 
+station to disseminate the command to reprogram. Example:
+
+   tos-deluge /dev/ttyUSB0 telosb -r 0
+
+For a more detailed discussion on Deluge T2, please refer to the Deluge 
+T2 manual.
+
+Prerequisites:
+
+Python 2.4 with pySerial
+
+References:
+
+The Deluge T2 manual is available under $TOS_DIR/doc/html/.
diff --git a/apps/tests/deluge/SerialBlink/README.txt b/apps/tests/deluge/SerialBlink/README.txt
new file mode 100644 (file)
index 0000000..c5ea55b
--- /dev/null
@@ -0,0 +1,32 @@
+README for apps/tests/deluge/SerialBlink
+Author/Contact:
+
+Chieh-Jan Mike Liang <cliang4@cs.jhu.edu>
+Razvan Musaloiu-E. <razvanm@cs.jhu.edu>
+
+Description:
+
+This is a sample application for Deluge T2. The program blinks and send 
+a serial msg every second.
+
+You can reprogram the whole network (non-basestation motes) by first 
+uploading the image to the base station. Then, tell the base station to 
+disseminate the image. Example:
+
+   tos-deluge /dev/ttyUSB0 telosb -d 0
+   
+Finally, after the image has been disseminated, instruct the base 
+station to disseminate the command to reprogram. Example:
+
+   tos-deluge /dev/ttyUSB0 telosb -r 0
+
+For a more detailed discussion on Deluge T2, please refer to the Deluge 
+T2 manual.
+
+Prerequisites:
+
+Python 2.4 with pySerial
+
+References:
+
+The Deluge T2 manual is available under $TOS_DIR/doc/html/.
index 02a6f88f5a09d0e7b797fec42f70f482bcaf1245..a443e35d7f4064fcca93218f474ec0e1d60c5130 100644 (file)
@@ -16,6 +16,8 @@
                .title {
                font-size: 200%;
                font-weight: normal;
                .title {
                font-size: 200%;
                font-weight: normal;
+               margin-top: 2.8em;
+               text-align: center;
                }
 
                .partheading {
                }
 
                .partheading {
                list-style-type: upper-alpha;
                }
 
                list-style-type: upper-alpha;
                }
 
-               /*
-               .verbatim {
-               color: #4d0000;
-               }
-               */
-
                tt i {
                font-family: serif;
                }
                tt i {
                font-family: serif;
                }
                font-family: serif;
                }
 
                font-family: serif;
                }
 
+               /*
+               .verbatim {
+               color: #4d0000;
+               }
+               */
+
                .scheme em {
                .scheme em {
-               font-family: serif;
                color: black;
                color: black;
+               font-family: serif;
                }
 
                .scheme {
                }
 
                .scheme {
                .colophon {
                color: gray;
                font-size: 80%;
                .colophon {
                color: gray;
                font-size: 80%;
+               font-style: italic;
                text-align: right;
                }
 
                .colophon a {
                color: gray;
                }
                text-align: right;
                }
 
                .colophon a {
                color: gray;
                }
-
                
\ No newline at end of file
                
\ No newline at end of file
index 2248f683a08b603e335bfeb0b1357f5fb4a3b27d..3dd87e3f7224797f52ed44837174f6a2f34e9f9f 100644 (file)
@@ -9,6 +9,8 @@ Deluge T2 - Programming Manual
 <meta name=robots content="index,follow">
 </head>
 <body>
 <meta name=robots content="index,follow">
 </head>
 <body>
+<div id=title>
+<p></p>
 <p>
 
 </p>
 <p>
 
 </p>
@@ -19,11 +21,11 @@ Deluge T2 - Programming Manual
 
 
 </p>
 
 
 </p>
-<h1 class=title align=center><br><br>Deluge T2 - Programming Manual</h1>
+<h1 class=title>Deluge T2 - Programming Manual</h1>
 <p></p>
 <div align=center>
 Chieh-Jan Mike Liang<br>
 <p></p>
 <div align=center>
 Chieh-Jan Mike Liang<br>
-Razvan Musaloiu-E.<p>June 21, 2007</p>
+Razvan Musaloiu-E.<p>July 9, 2007</p>
 </div>
 <p></p>
 <p>
 </div>
 <p></p>
 <p>
@@ -214,7 +216,7 @@ You should see something similar to the output below.</p>
 first test on the base station by issuing the reboot command. For 
 example,
 </p>
 first test on the base station by issuing the reboot command. For 
 example,
 </p>
-<pre class=verbatim>   % tos-deluge /dev/ttyUSB0 telosb -r 1
+<pre class=verbatim>   % tos-deluge /dev/ttyUSB0 telosb -b 1
 </pre><p>
 After a few moments, the mote will begin quickly flashing the LEDs to 
 signify the reprogramming process.</p>
 </pre><p>
 After a few moments, the mote will begin quickly flashing the LEDs to 
 signify the reprogramming process.</p>
@@ -225,10 +227,14 @@ the network. For example,
 <pre class=verbatim>   % tos-deluge /dev/ttyUSB0 telosb -d 1
 </pre><p>
 This command instructs the base station to notify the whole network of 
 <pre class=verbatim>   % tos-deluge /dev/ttyUSB0 telosb -d 1
 </pre><p>
 This command instructs the base station to notify the whole network of 
-the availablility of a new program image. This notification is currently 
+the availability of a new program image. This notification is currently 
 done via TinyOS dissemination service, and it triggers all motes in the 
 done via TinyOS dissemination service, and it triggers all motes in the 
-network to get the new program image. Upon receiving the complete image 
-over-the-air, each node automatically reboots and reprograms itself.</p>
+network to get the new program image. After all motes receive the image 
+over-the-air, you can instruct the base station to disseminate a command 
+to reprogram the network. For example,
+</p>
+<pre class=verbatim>   % tos-deluge /dev/ttyUSB0 telosb -r 1
+</pre><p></p>
 <p>
 </p>
 <a name="node_sec_5"></a>
 <p>
 </p>
 <a name="node_sec_5"></a>
@@ -281,9 +287,8 @@ reprogram themselves.</p>
 directly connected mote.</p>
 <p>
 </p>
 directly connected mote.</p>
 <p>
 </p>
-<div align=right class=colophon>
-<i>Last modified: Thursday, June 21st, 2007<br>
-HTML conversion by <a href="http://www.ccs.neu.edu/~dorai/tex2page/tex2page-doc.html">TeX2page 2004-09-11</a></i>
+<p></p>
+<div align=right class=colophon>Last modified: Monday, July 9th, 2007 8:43:40pm<br><div align=right class=advertisement>HTML conversion by <a href="http://www.ccs.neu.edu/~dorai/tex2page/tex2page-doc.html">TeX2page 20050501</a></div></div>
 </div>
 </body>
 </html>
 </div>
 </body>
 </html>
index 1dccd028c47519f871b1ef6caa01a71b006bee2e..98025dd39fd42b80389aee3f60d8ffe01859eb4d 100644 (file)
Binary files a/doc/pdf/deluge-t2-manual.pdf and b/doc/pdf/deluge-t2-manual.pdf differ
index 88e132b02ca0c7e0f5dba4be5b571756f7b79856..5a3c1bb6791915111f52bf357661d5c6f6d579c6 100755 (executable)
@@ -47,11 +47,12 @@ SERIAL_AMID        = 0xAB
 SERIAL_DATA_LENGTH = 28 - 1 - 1 - 2 - 2
 
 # Serial message types
 SERIAL_DATA_LENGTH = 28 - 1 - 1 - 2 - 2
 
 # Serial message types
-MSG_ERASE  = 0
-MSG_WRITE  = 1
-MSG_READ   = 2
-MSG_REPROG = 5
-MSG_DISS   = 6
+MSG_ERASE     = 0
+MSG_WRITE     = 1
+MSG_READ      = 2
+MSG_REPROG    = 5
+MSG_DISS      = 6
+MSG_REPROG_BS = 7
 
 ERROR_SUCCESS = 0   # T2-compatible
 ERROR_FAIL    = 1   # T2-compatible
 
 ERROR_SUCCESS = 0   # T2-compatible
 ERROR_FAIL    = 1   # T2-compatible
@@ -320,12 +321,12 @@ def op_inject(s, img_num, tos_image_xml):
     
     return False
 
     
     return False
 
-# Requests the mote to reboot and reprogram itself
-def op_reprog(s, img_num):
+# Requests the base station to reprogram itself
+def op_reprog_bs(s, img_num):
     if getMetaData(s, img_num) == None:
         print "ERROR: No proper Deluge image found!"
     else:
     if getMetaData(s, img_num) == None:
         print "ERROR: No proper Deluge image found!"
     else:
-        sreqpkt = SerialReqPacket((MSG_REPROG, img_num, 0, 0, []))
+        sreqpkt = SerialReqPacket((MSG_REPROG_BS, img_num, 0, 0, []))
         success = s.write_packet(SERIAL_AMGROUP, SERIAL_AMID, sreqpkt.payload())
         if success == True:
             packet = s.read_packet(SERIAL_AMGROUP, SERIAL_AMID)
         success = s.write_packet(SERIAL_AMGROUP, SERIAL_AMID, sreqpkt.payload())
         if success == True:
             packet = s.read_packet(SERIAL_AMGROUP, SERIAL_AMID)
@@ -333,12 +334,27 @@ def op_reprog(s, img_num):
             if sreplypkt.error == ERROR_SUCCESS:
                 return True
             else:
             if sreplypkt.error == ERROR_SUCCESS:
                 return True
             else:
-                print "ERROR: Unable to reboot the mote"
+                print "ERROR: Unable to reprogram the base station"
                 return False
             
         print "ERROR: Unable to send the command"
     return False
 
                 return False
             
         print "ERROR: Unable to send the command"
     return False
 
+# Requests the network to reprogram with the specified image number
+def op_reprog(s, img_num):
+    sreqpkt = SerialReqPacket((MSG_REPROG, img_num, 0, 0, []))
+    success = s.write_packet(SERIAL_AMGROUP, SERIAL_AMID, sreqpkt.payload())
+    if success == True:
+        packet = s.read_packet(SERIAL_AMGROUP, SERIAL_AMID)
+        sreplypkt = SerialReplyPacket(packet[1])
+        if sreplypkt.error == ERROR_SUCCESS:
+            return True
+        else:
+            print "ERROR: Unable to reprogram the network"
+            return False
+        
+    print "ERROR: Unable to send the command"
+
 # Requests the mote to disseminate an image
 def op_diss(s, img_num):
     if getMetaData(s, img_num) == None:
 # Requests the mote to disseminate an image
 def op_diss(s, img_num):
     if getMetaData(s, img_num) == None:
@@ -386,7 +402,8 @@ def print_usage():
     print "  -p --ping\n     Provide status of the image in the external flash"
     print "  -i --inject\n     Inject a compiled TinyOS application"
     print "      [options]: tos_image.xml file path"
     print "  -p --ping\n     Provide status of the image in the external flash"
     print "  -i --inject\n     Inject a compiled TinyOS application"
     print "      [options]: tos_image.xml file path"
-    print "  -r --reboot\n     Reboot and reprogram the directly-connected mote"
+    print "  -r --reprogram\n     Reprogram the network"
+    print "  -b --reprogram_bs\n     Reprogram only the directly-connected mote"
     print "  -d --dissemination\n     Disseminate the image in the external flash to the network"
     print "  -e --erase\n     Erase an image in the external flash"
     print "  -s --reset\n     Reset the versioning information for a given image"
     print "  -d --dissemination\n     Disseminate the image in the external flash to the network"
     print "  -e --erase\n     Erase an image in the external flash"
     print "  -s --reset\n     Reset the versioning information for a given image"
@@ -415,9 +432,12 @@ if len(sys.argv) >= num_req_arg:
     elif sys.argv[3] in ["-i", "--inject"] and len(sys.argv) == (num_req_arg + 1):
         print "Pinging node ..."
         op_inject(s, sys.argv[4], sys.argv[5])
     elif sys.argv[3] in ["-i", "--inject"] and len(sys.argv) == (num_req_arg + 1):
         print "Pinging node ..."
         op_inject(s, sys.argv[4], sys.argv[5])
-    elif sys.argv[3] in ["-r", "--reboot"]:
+    elif sys.argv[3] in ["-r", "--reprogram"]:
         if op_reprog(s, sys.argv[4]):
             print "Command sent"
         if op_reprog(s, sys.argv[4]):
             print "Command sent"
+    elif sys.argv[3] in ["-b", "--reprogram_bs"]:
+        if op_reprog_bs(s, sys.argv[4]):
+            print "Command sent"
     elif sys.argv[3] in ["-d", "--dissemination"]:
         if op_diss(s, sys.argv[4]):
             print "Command sent"
     elif sys.argv[3] in ["-d", "--dissemination"]:
         if op_diss(s, sys.argv[4]):
             print "Command sent"
index c9ec9cbeecb7764b58423988b6613c3342edee33..8a9f504f5c44ded2e3b8b591a854ae042f20f46c 100644 (file)
 
 #include "DelugeMetadata.h"
 
 
 #include "DelugeMetadata.h"
 
+#define DISSMSG_DISS   0
+#define DISSMSG_REPROG 1
+
 enum {
   DELUGE_INVALID_UID = 0xffffffff,
   DELUGE_NUM_VOLUMES = 2,
 };
 
 typedef nx_struct DelugeDissemination {
 enum {
   DELUGE_INVALID_UID = 0xffffffff,
   DELUGE_NUM_VOLUMES = 2,
 };
 
 typedef nx_struct DelugeDissemination {
+  nx_uint8_t msg_type;
   nx_uint32_t uid;      // unique id of image
   nx_uint16_t vNum;     // version num of image
   nx_uint8_t  imgNum;   // image number
   nx_uint32_t uid;      // unique id of image
   nx_uint16_t vNum;     // version num of image
   nx_uint8_t  imgNum;   // image number
index caea53054376d40f23b2df9519fb0a9057243e01..4759e4da596dc6cf4c5646c500e2877dc51e9d4f 100644 (file)
@@ -37,7 +37,8 @@ implementation
   components SerialStarterC;
   components new FlashVolumeManagerC(0xAB);
   
   components SerialStarterC;
   components new FlashVolumeManagerC(0xAB);
   
-  DelugeP.ReprogNotify -> FlashVolumeManagerC;
+  DelugeP.DissNotify -> FlashVolumeManagerC.DissNotify;
+  DelugeP.ReprogNotify -> FlashVolumeManagerC.ReprogNotify;
   FlashVolumeManagerC.BlockRead[VOLUME_DELUGE0] -> DelugeStorageC.BlockRead[VOLUME_DELUGE0];
   FlashVolumeManagerC.BlockWrite[VOLUME_DELUGE0] -> DelugeStorageC.BlockWrite[VOLUME_DELUGE0];
   FlashVolumeManagerC.DelugeStorage[VOLUME_DELUGE0] -> DelugeStorageC.DelugeStorage[VOLUME_DELUGE0];
   FlashVolumeManagerC.BlockRead[VOLUME_DELUGE0] -> DelugeStorageC.BlockRead[VOLUME_DELUGE0];
   FlashVolumeManagerC.BlockWrite[VOLUME_DELUGE0] -> DelugeStorageC.BlockWrite[VOLUME_DELUGE0];
   FlashVolumeManagerC.DelugeStorage[VOLUME_DELUGE0] -> DelugeStorageC.DelugeStorage[VOLUME_DELUGE0];
index 82b0b91e70e0db4d6c5cc2a6c13f39e64862ef5f..449bcf1de4d895994ba93ab0974bad41ebd4e76b 100644 (file)
@@ -42,26 +42,26 @@ enum {
 };
 
 typedef nx_struct DelugeAdvMsg {
 };
 
 typedef nx_struct DelugeAdvMsg {
-  nx_uint16_t       sourceAddr;
-  nx_uint8_t        version;    // Deluge Version
-  nx_uint8_t        type;
+  nx_uint16_t    sourceAddr;
+  nx_uint8_t     version;    // Deluge Version
+  nx_uint8_t     type;
   DelugeObjDesc  objDesc;
   DelugeObjDesc  objDesc;
-  nx_uint8_t        reserved;
+  nx_uint8_t     reserved;
 } DelugeAdvMsg;
 
 typedef nx_struct DelugeReqMsg {
 } DelugeAdvMsg;
 
 typedef nx_struct DelugeReqMsg {
-  nx_uint16_t     dest;
-  nx_uint16_t     sourceAddr;
-  nx_object_id_t  objid;
-  nx_page_num_t   pgNum;
-  nx_uint8_t      requestedPkts[DELUGE_PKT_BITVEC_SIZE];
+  nx_uint16_t    dest;
+  nx_uint16_t    sourceAddr;
+  nx_object_id_t objid;
+  nx_page_num_t  pgNum;
+  nx_uint8_t     requestedPkts[DELUGE_PKT_BITVEC_SIZE];
 } DelugeReqMsg;
 
 typedef nx_struct DelugeDataMsg {
   nx_object_id_t objid;
 } DelugeReqMsg;
 
 typedef nx_struct DelugeDataMsg {
   nx_object_id_t objid;
-  nx_page_num_t pgNum;
-  nx_uint8_t    pktNum;
-  nx_uint8_t    data[DELUGE_PKT_PAYLOAD_SIZE];
+  nx_page_num_t  pgNum;
+  nx_uint8_t     pktNum;
+  nx_uint8_t     data[DELUGE_PKT_PAYLOAD_SIZE];
 } DelugeDataMsg;
 
 #endif
 } DelugeDataMsg;
 
 #endif
index d49bac4133f3cc716caccf3205bb6e40d4ec2b29..8adcf1d6b7b749ba98a3db59a3feb3ece4c544d5 100644 (file)
@@ -39,6 +39,7 @@ module DelugeP
     interface SplitControl as RadioSplitControl;
     
 #ifdef DELUGE_BASESTATION
     interface SplitControl as RadioSplitControl;
     
 #ifdef DELUGE_BASESTATION
+    interface Notify<uint8_t> as DissNotify;
     interface Notify<uint8_t> as ReprogNotify;
 #endif
   }
     interface Notify<uint8_t> as ReprogNotify;
 #endif
   }
@@ -46,7 +47,7 @@ module DelugeP
 
 implementation
 {
 
 implementation
 {
-  uint8_t img_num;
+  //uint8_t img_num;
   
   /**
    * Starts the radio
   
   /**
    * Starts the radio
@@ -60,28 +61,42 @@ implementation
   /**
    * Starts disseminating image information
    */
   /**
    * Starts disseminating image information
    */
-  event void ReprogNotify.notify(uint8_t new_img_num)
+  event void DissNotify.notify(uint8_t new_img_num)
   {
   {
-    DelugeDissemination delugeDis;
-    DelugeImgDesc *imgDesc;
-    
-    imgDesc = call DelugeMetadata.getImgDesc(new_img_num);
+    DelugeImgDesc* imgDesc = call DelugeMetadata.getImgDesc(new_img_num);
     if (imgDesc->uid != DELUGE_INVALID_UID) {
     if (imgDesc->uid != DELUGE_INVALID_UID) {
+      DelugeDissemination delugeDis;
+      
       call ObjectTransfer.stop();
       call Leds.led0Toggle();
       call ObjectTransfer.stop();
       call Leds.led0Toggle();
-      img_num = new_img_num;
       
       delugeDis.uid = imgDesc->uid;
       delugeDis.vNum = imgDesc->vNum;
       
       delugeDis.uid = imgDesc->uid;
       delugeDis.vNum = imgDesc->vNum;
-      delugeDis.imgNum = img_num;
+      delugeDis.imgNum = new_img_num;
       delugeDis.size = imgDesc->size;
       delugeDis.size = imgDesc->size;
+      delugeDis.msg_type = DISSMSG_DISS;
       
       
-      call DisseminationUpdate.change(&delugeDis);   // Disseminates image information
+      call DisseminationUpdate.change(&delugeDis);   // Disseminates command
       call ObjectTransfer.publish(delugeDis.uid,
                                   delugeDis.size,
                                   delugeDis.imgNum);   // Prepares to publish image data
     }
   }
       call ObjectTransfer.publish(delugeDis.uid,
                                   delugeDis.size,
                                   delugeDis.imgNum);   // Prepares to publish image data
     }
   }
+  
+  event void ReprogNotify.notify(uint8_t new_img_num)
+  {
+    DelugeDissemination delugeDis;
+    
+    call Leds.led2Toggle();
+    
+    delugeDis.uid = 0;
+    delugeDis.vNum = 0;
+    delugeDis.imgNum = new_img_num;
+    delugeDis.size = 0;
+    delugeDis.msg_type = DISSMSG_REPROG;
+    
+    call DisseminationUpdate.change(&delugeDis);   // Disseminates command
+  }
 #endif
 
   /**
 #endif
 
   /**
@@ -93,26 +108,39 @@ implementation
     const DelugeDissemination *delugeDis = call DisseminationValue.get();
     DelugeImgDesc *imgDesc = call DelugeMetadata.getImgDesc(delugeDis->imgNum);
     
     const DelugeDissemination *delugeDis = call DisseminationValue.get();
     DelugeImgDesc *imgDesc = call DelugeMetadata.getImgDesc(delugeDis->imgNum);
     
-    if (imgDesc->uid == delugeDis->uid) {
-      if (imgDesc->vNum < delugeDis->vNum) {
-        img_num = delugeDis->imgNum;   // Note which image number to boot
-        call ObjectTransfer.receive(delugeDis->uid, delugeDis->size, delugeDis->imgNum);
-      }
-    } else {
-      img_num = delugeDis->imgNum;   // Note which image number to boot
-      call ObjectTransfer.receive(delugeDis->uid, delugeDis->size, delugeDis->imgNum);
+    switch (delugeDis->msg_type) {
+      case DISSMSG_DISS:
+        if (imgDesc->uid == delugeDis->uid && imgDesc->uid != DELUGE_INVALID_UID) {
+          if (imgDesc->vNum < delugeDis->vNum) {
+            call ObjectTransfer.receive(delugeDis->uid, delugeDis->size, delugeDis->imgNum);
+          }
+        } else {
+          call ObjectTransfer.receive(delugeDis->uid, delugeDis->size, delugeDis->imgNum);
+        }
+        
+        break;
+      case DISSMSG_REPROG:
+        if (imgDesc->uid != DELUGE_INVALID_UID) {
+          DelugeNodeDesc nodeDesc;
+          call IFlash.read((uint8_t*)IFLASH_NODE_DESC_ADDR,
+                           &nodeDesc,
+                           sizeof(DelugeNodeDesc));   // Reads which image was just reprogrammed
+          if (nodeDesc.uid != imgDesc->uid || nodeDesc.vNum != imgDesc->vNum) {
+            call NetProg.programImgAndReboot(delugeDis->imgNum);
+          }
+        }
+        
+        break;
     }
   }
     }
   }
-
-  /**
-   * Reboots and reprograms with the newly received image
-   */
+  
   event void ObjectTransfer.receiveDone(error_t error)
   {
   event void ObjectTransfer.receiveDone(error_t error)
   {
+    //call ObjectTransfer.publish(imgDesc->uid, imgDesc->size, imgDesc->imgNum);
     call ObjectTransfer.stop();
     call ObjectTransfer.stop();
-    if (error == SUCCESS) {
-      call NetProg.programImgAndReboot(img_num);
-    }
+//    if (error == SUCCESS) {
+//      call NetProg.programImgAndReboot(img_num);
+//    }
   }
 
   /**
   }
 
   /**
@@ -121,16 +149,16 @@ implementation
   event void RadioSplitControl.startDone(error_t error)
   {
     if (error == SUCCESS) {
   event void RadioSplitControl.startDone(error_t error)
   {
     if (error == SUCCESS) {
-      // Start publishing the current image
-      DelugeImgDesc *imgDesc;
-      DelugeNodeDesc nodeDesc;
-      call IFlash.read((uint8_t*)IFLASH_NODE_DESC_ADDR,
-                       &nodeDesc,
-                       sizeof(DelugeNodeDesc));   // Reads which image was just reprogrammed
-      imgDesc = call DelugeMetadata.getImgDesc(nodeDesc.imgNum);
-      if (nodeDesc.uid == imgDesc->uid && imgDesc->uid != DELUGE_INVALID_UID) {
-        call ObjectTransfer.publish(imgDesc->uid, imgDesc->size, imgDesc->imgNum);
-      }
+//      // Start publishing the current image
+//      DelugeImgDesc *imgDesc;
+//      DelugeNodeDesc nodeDesc;
+//      call IFlash.read((uint8_t*)IFLASH_NODE_DESC_ADDR,
+//                       &nodeDesc,
+//                       sizeof(DelugeNodeDesc));   // Reads which image was just reprogrammed
+//      imgDesc = call DelugeMetadata.getImgDesc(nodeDesc.imgNum);
+//      if (nodeDesc.uid == imgDesc->uid && imgDesc->uid != DELUGE_INVALID_UID) {
+//        call ObjectTransfer.publish(imgDesc->uid, imgDesc->size, imgDesc->imgNum);
+//      }
             
       call StdControlDissemination.start();
     }
             
       call StdControlDissemination.start();
     }
index 5c0a597c64ff03f86e22f7c195456053d1675f9e..9ca55a4508bb7897c02fcec49c0aebd0df895d95 100644 (file)
 #ifndef FLASHVOLUMEMANAGER_H
 #define FLASHVOLUMEMANAGER_H
 
 #ifndef FLASHVOLUMEMANAGER_H
 #define FLASHVOLUMEMANAGER_H
 
-#define SERIALMSG_ERASE  0
-#define SERIALMSG_WRITE  1
-#define SERIALMSG_READ   2
-#define SERIALMSG_CRC    3
-#define SERIALMSG_ADDR   4
-#define SERIALMSG_REPROG 5
-#define SERIALMSG_DISS   6
+#define SERIALMSG_ERASE     0
+#define SERIALMSG_WRITE     1
+#define SERIALMSG_READ      2
+#define SERIALMSG_CRC       3
+#define SERIALMSG_ADDR      4
+#define SERIALMSG_REPROG    5
+#define SERIALMSG_DISS      6
+#define SERIALMSG_REPROG_BS 7
 
 typedef nx_struct SerialReqPacket {
   nx_uint8_t msg_type;
 
 typedef nx_struct SerialReqPacket {
   nx_uint8_t msg_type;
index 12e7779eadc6028df86c2472ff35d58b4998f336..d1f9fbe7d6e9f5cdc472f1b7ba6acec93325e6c7 100644 (file)
@@ -30,7 +30,8 @@
 generic configuration FlashVolumeManagerC(am_id_t AMId)
 {
 #ifdef DELUGE  
 generic configuration FlashVolumeManagerC(am_id_t AMId)
 {
 #ifdef DELUGE  
-  provides interface Notify<uint8_t>;
+  provides interface Notify<uint8_t> as DissNotify;
+  provides interface Notify<uint8_t> as ReprogNotify;
 #endif
   uses {
     interface BlockRead[uint8_t img_num];
 #endif
   uses {
     interface BlockRead[uint8_t img_num];
@@ -63,6 +64,7 @@ implementation
   FlashVolumeManagerP.Timer -> TimerMilliC;
   FlashVolumeManagerP.DelugeStorage[VOLUME_DELUGE0] = DelugeStorage[VOLUME_DELUGE0];
   FlashVolumeManagerP.DelugeStorage[VOLUME_DELUGE1] = DelugeStorage[VOLUME_DELUGE1];
   FlashVolumeManagerP.Timer -> TimerMilliC;
   FlashVolumeManagerP.DelugeStorage[VOLUME_DELUGE0] = DelugeStorage[VOLUME_DELUGE0];
   FlashVolumeManagerP.DelugeStorage[VOLUME_DELUGE1] = DelugeStorage[VOLUME_DELUGE1];
-  Notify = FlashVolumeManagerP.Notify;
+  DissNotify = FlashVolumeManagerP.DissNotify;
+  ReprogNotify = FlashVolumeManagerP.ReprogNotify;
 #endif
 }
 #endif
 }
index 78cda769888c97aca3f55b72ba0abd8c036b6bee..216c00d2f9685dfd93ac91b57d4ca6d3e117f12c 100644 (file)
 generic module FlashVolumeManagerP()
 {
 #ifdef DELUGE
 generic module FlashVolumeManagerP()
 {
 #ifdef DELUGE
-  provides interface Notify<uint8_t>;
+  provides {
+    interface Notify<uint8_t> as DissNotify;
+    interface Notify<uint8_t> as ReprogNotify;
+  }
 #endif
   uses {
     interface BlockRead[uint8_t img_num];
 #endif
   uses {
     interface BlockRead[uint8_t img_num];
@@ -183,14 +186,18 @@ implementation
                                   (uint32_t)call DelugeStorage.getPhysicalAddress[img_num](0);
           sendReply(SUCCESS, sizeof(SerialReplyPacket) + 4);
           break;
                                   (uint32_t)call DelugeStorage.getPhysicalAddress[img_num](0);
           sendReply(SUCCESS, sizeof(SerialReplyPacket) + 4);
           break;
-        case SERIALMSG_REPROG:   // === Reboots and reprograms ===
+        case SERIALMSG_REPROG_BS:   // === Reprograms only the base station ===
           state = S_REPROG;
           sendReply(SUCCESS, sizeof(SerialReplyPacket));
           img_num_reboot = img_num;
           call Timer.startOneShot(1024);
           break;
         case SERIALMSG_DISS:     // === Starts disseminating a volume ===
           state = S_REPROG;
           sendReply(SUCCESS, sizeof(SerialReplyPacket));
           img_num_reboot = img_num;
           call Timer.startOneShot(1024);
           break;
         case SERIALMSG_DISS:     // === Starts disseminating a volume ===
-          signal Notify.notify(img_num);   // Notifies Deluge to start disseminate
+          signal DissNotify.notify(img_num);   // Notifies Deluge to start disseminate
+          sendReply(SUCCESS, sizeof(SerialReplyPacket));
+          break;
+        case SERIALMSG_REPROG:   // === Reprograms the network (except the base station) ===
+          signal ReprogNotify.notify(img_num);
           sendReply(SUCCESS, sizeof(SerialReplyPacket));
           break;
   #endif
           sendReply(SUCCESS, sizeof(SerialReplyPacket));
           break;
   #endif
@@ -215,8 +222,10 @@ implementation
     call NetProg.programImgAndReboot(img_num_reboot);
   }
   
     call NetProg.programImgAndReboot(img_num_reboot);
   }
   
-  command error_t Notify.enable() { return SUCCESS; }
-  command error_t Notify.disable() { return SUCCESS; }
+  command error_t DissNotify.enable() { return SUCCESS; }
+  command error_t DissNotify.disable() { return SUCCESS; }
+  command error_t ReprogNotify.enable() { return SUCCESS; }
+  command error_t ReprogNotify.disable() { return SUCCESS; }
   
   default command storage_addr_t DelugeStorage.getPhysicalAddress[uint8_t img_num](storage_addr_t addr) { return 0; }
 #endif
   
   default command storage_addr_t DelugeStorage.getPhysicalAddress[uint8_t img_num](storage_addr_t addr) { return 0; }
 #endif
index ed9da3ded7e76cc49e186710a1ce0a4a4c89f199..777a6cfab0d225a102051821b45d8abeb4f4b40d 100644 (file)
@@ -112,6 +112,7 @@ implementation
     } else {
       call DelugePageTransfer.setWorkingPage(DELUGE_INVALID_OBJID, DELUGE_INVALID_PGNUM);
       state = S_SYNC;
     } else {
       call DelugePageTransfer.setWorkingPage(DELUGE_INVALID_OBJID, DELUGE_INVALID_PGNUM);
       state = S_SYNC;
+      call ObjectTransfer.stop();
       call BlockWrite.sync[cont_receive_img_num]();
     }
   }
       call BlockWrite.sync[cont_receive_img_num]();
     }
   }
@@ -209,7 +210,6 @@ implementation
     error_t error;
     
     call ObjectTransfer.stop();
     error_t error;
     
     call ObjectTransfer.stop();
-    state = S_STOPPED;
 //call StatsCollector.startStatsCollector();
     
     cont_receive_new_objid = new_objid;
 //call StatsCollector.startStatsCollector();
     
     cont_receive_new_objid = new_objid;
@@ -228,12 +228,13 @@ implementation
   {
     call Timer.stop();
     call DelugePageTransfer.stop();
   {
     call Timer.stop();
     call DelugePageTransfer.stop();
+    state = S_STOPPED;
 //call StatsCollector.stopStatsCollector();
     
 //call StatsCollector.stopStatsCollector();
     
-    state = S_STOPPED;
     curObjDesc.objid = DELUGE_INVALID_OBJID;
     curObjDesc.numPgs = DELUGE_INVALID_PGNUM;
     curObjDesc.numPgsComplete = DELUGE_INVALID_PGNUM;
     curObjDesc.objid = DELUGE_INVALID_OBJID;
     curObjDesc.numPgs = DELUGE_INVALID_PGNUM;
     curObjDesc.numPgsComplete = DELUGE_INVALID_PGNUM;
+    advTimers.periodLog2 = 0;
     
     return SUCCESS;
   }
     
     return SUCCESS;
   }
@@ -248,6 +249,7 @@ implementation
       } else {
         call DelugePageTransfer.setWorkingPage(curObjDesc.objid, curObjDesc.numPgsComplete);
         state = S_SYNC;
       } else {
         call DelugePageTransfer.setWorkingPage(curObjDesc.objid, curObjDesc.numPgsComplete);
         state = S_SYNC;
+        call ObjectTransfer.stop();
         call BlockWrite.sync[cont_receive_img_num]();
       }
     }
         call BlockWrite.sync[cont_receive_img_num]();
       }
     }
@@ -256,9 +258,6 @@ implementation
   event void BlockWrite.syncDone[uint8_t img_num](error_t error)
   {
     if (state == S_SYNC) {
   event void BlockWrite.syncDone[uint8_t img_num](error_t error)
   {
     if (state == S_SYNC) {
-      if (error != SUCCESS) {
-        call Leds.led2On();
-      }
       post signalObjRecvDone();
     }
   }
       post signalObjRecvDone();
     }
   }
@@ -317,7 +316,7 @@ implementation
   }
     
   event void Timer.fired()
   }
     
   event void Timer.fired()
-  {
+  {    
     updateTimers();
     
     if (advTimers.overheard == 0) {
     updateTimers();
     
     if (advTimers.overheard == 0) {
index ab122f4d1ccf3bf88e70db5b77ec82b26eb3aed0..413abc00b9e24801ac6e87350d54825ca3806691 100644 (file)
@@ -122,6 +122,7 @@ implementation {
       imgDesc = call DelugeMetadata.getImgDesc(img_num);
       nodeDesc.uid = imgDesc->uid;
       nodeDesc.imgNum = img_num;
       imgDesc = call DelugeMetadata.getImgDesc(img_num);
       nodeDesc.uid = imgDesc->uid;
       nodeDesc.imgNum = img_num;
+      nodeDesc.vNum = imgDesc->vNum;
       call IFlash.write((uint8_t*)IFLASH_NODE_DESC_ADDR, &nodeDesc, sizeof(nodeDesc));
       
       // reboot
       call IFlash.write((uint8_t*)IFLASH_NODE_DESC_ADDR, &nodeDesc, sizeof(nodeDesc));
       
       // reboot