]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Add a translation between imgNum to volumeId. This should allow non-Deluge images...
authorrazvanm <razvanm>
Tue, 15 Jan 2008 20:33:46 +0000 (20:33 +0000)
committerrazvanm <razvanm>
Tue, 15 Jan 2008 20:33:46 +0000 (20:33 +0000)
tos/lib/net/Deluge/DelugeManagerP.nc
tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManagerP.nc

index 15dbeedc0989f9c01178414f57cebba93e275347..2417de6cf5c4cd80c7e1e794a301b0a177bde083 100644 (file)
@@ -55,6 +55,12 @@ implementation
 
   message_t serialMsg;
   DelugeCmd delugeCmd;
+  uint8_t imgNum2volumeId[] = {
+    VOLUME_GOLDENIMAGE,
+    VOLUME_DELUGE1,
+    VOLUME_DELUGE2,
+    VOLUME_DELUGE3
+  };
 
   void sendReply(error_t error)
   {
@@ -85,14 +91,14 @@ implementation
     case DELUGE_CMD_ONLY_DISSEMINATE:
     case DELUGE_CMD_DISSEMINATE_AND_REPROGRAM:
       if (call Resource.immediateRequest() == SUCCESS) {
-       call DelugeMetadata.read(request->imgNum);
+       call DelugeMetadata.read(imgNum2volumeId[request->imgNum]);
       } else {
        sendReply(FAIL);
       }
       break;
     case DELUGE_CMD_REPROGRAM:
     case DELUGE_CMD_REBOOT:
-      delugeCmd.imgNum = request->imgNum;
+      delugeCmd.imgNum = imgNum2volumeId[request->imgNum];
       call DelayTimer.startOneShot(1024);
       sendReply(SUCCESS);
       break;
index 138c6b02ec361cc5316a3fe3fec833d5f11c4515..4ed7a64b9a7bd722e684cc69c5da77731597fb3f 100644 (file)
@@ -87,6 +87,13 @@ implementation
     nx_uint32_t uidhash;
     nx_uint16_t nodeid;
   };
+
+  uint8_t imgNum2volumeId[] = {
+    VOLUME_GOLDENIMAGE,
+    VOLUME_DELUGE1,
+    VOLUME_DELUGE2,
+    VOLUME_DELUGE3
+  };
   
   void sendReply(error_t error, storage_len_t len)
   {
@@ -179,20 +186,7 @@ implementation
     }
 
     // Converts the image number that the user wants to the real image number
-    switch (request->imgNum) {
-      case 0:
-        imgNum = VOLUME_GOLDENIMAGE;
-        break;
-      case 1:
-        imgNum = VOLUME_DELUGE1;
-        break;
-      case 2:
-        imgNum = VOLUME_DELUGE2;
-        break;
-      case 3:
-        imgNum = VOLUME_DELUGE3;
-        break;
-    }
+    imgNum = imgNum2volumeId[request->imgNum];
     
     if (imgNum != 0xFF) {
       error = SUCCESS;