]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Clean up code
authorxuanthanh18 <xuanthanh18>
Thu, 11 Mar 2010 22:34:58 +0000 (22:34 +0000)
committerxuanthanh18 <xuanthanh18>
Thu, 11 Mar 2010 22:34:58 +0000 (22:34 +0000)
tos/lib/net/dhv/Dhv.h
tos/lib/net/dhv/DhvDataP.nc
tos/lib/net/dhv/DhvHSumP.nc
tos/lib/net/dhv/DhvLogicP.nc
tos/lib/net/dhv/DhvSummaryP.nc
tos/lib/net/dhv/DhvVBitP.nc
tos/lib/net/dhv/DhvVectorP.nc
tos/lib/net/dhv/DhvVersionP.nc

index f6ad31d23eec9f9f45b64f8e7aafad058b3d93a5..a3568422ad8fae8475815d04e81f8bbdc62744ae 100755 (executable)
@@ -26,7 +26,7 @@
 #define DHV_VERSION_LENGTH 4
 
 #define VBIT_LENGTH 8
-
+#define INFO_THRESHOLD 1
 enum {
   AM_DHV_TEST_MSG = 0xAB
 };
index b1259dbacc6895efc154cf86dc35bcbb91d49694..5834bda68f7159347396c85b0d002f73a43f6c89 100755 (executable)
@@ -83,7 +83,6 @@ implementation {
     dhv_version_t msgVer;
     dhv_data_msg_t* ddmsg;
 
-    commRate = commRate + 1;
     ddmsg = (dhv_data_msg_t*) payload;
     key = ddmsg->key;
     msgVer = ddmsg->version;
@@ -112,6 +111,7 @@ implementation {
       //keep quite
       call DataLogic.unsetItem(key);
       call VectorLogic.unsetItem(key);
+      commRate = commRate + 1;
       //set bindex to 0
     }
   }
index e550f610906d74de3b50ef0fe7ddcf834325e279..32dd414ad6cf0eaabdf165c510f51fa88a963fa9 100755 (executable)
@@ -78,6 +78,7 @@ implementation{
       local_hash = call DhvHelp.computeHash(0, UQCOUNT_DHV, salt);
       if(rcv_hash == local_hash) {
         call VBitLogic.setSameSummary();
+        commRate = commRate + 1;
       }else{
         call VBitLogic.setVBitState(1);
       }
index de9d3caf0065d1d05aa8f0214e089e112113c9e8..84cacfc76c8a727e6e08e8373a89619293d3142c 100755 (executable)
@@ -18,8 +18,8 @@ module DhvLogicP {
 
   provides interface Init;
   provides interface StdControl;
-       provides interface DhvLogic as VectorLogic;
-       provides interface DhvLogic as DataLogic;
+  provides interface DhvLogic as VectorLogic;
+  provides interface DhvLogic as DataLogic;
   provides interface DhvStateLogic;    
 
   uses interface Boot;
@@ -29,11 +29,11 @@ module DhvLogicP {
   uses interface DhvDecision as DhvDataDecision;
   uses interface DhvDecision as DhvVectorDecision;
   uses interface DhvDecision as DhvSummaryDecision;
-       uses interface DhvDecision as DhvVBitDecision;
+  uses interface DhvDecision as DhvVBitDecision;
   uses interface DhvDecision as DhvHSumDecision;
 
-       uses interface DhvCache as DhvDataCache;
-       uses interface DhvCache as DhvVectorCache;
+  uses interface DhvCache as DhvDataCache;
+  uses interface DhvCache as DhvVectorCache;
   uses interface DhvHelp;
 
 }
@@ -41,10 +41,9 @@ module DhvLogicP {
 implementation {
   uint32_t windowSize;
   uint8_t sendDecision();
-       uint8_t getState();
   uint32_t bitIndex;
   uint8_t hsum_status;
-       uint32_t diffHash;
+  uint32_t diffHash;
 
   command error_t Init.init() {
     windowSize = DHV_TAU_LOW;
@@ -53,7 +52,7 @@ implementation {
   }
 
   event void Boot.booted() {
-               hsum_status = 0;
+    hsum_status = 0;
     bitIndex = 0;
   }
 
@@ -67,203 +66,190 @@ implementation {
   }
 
 
-       /*Logic operation on the vector */      
-       command error_t VectorLogic.setItem(dhv_key_t key){
-               call DhvVectorCache.addItem(key);
-               call DhvTrickleTimer.reset();
-               return SUCCESS;
-       }
-
-       command error_t VectorLogic.setReqItem(dhv_key_t key){
-               call DhvVectorCache.addReqItem(key);
-               call DhvTrickleTimer.reset();
-               return SUCCESS;
-       }
-
-       command error_t VectorLogic.unsetItem(dhv_key_t key){
-               call DhvVectorCache.removeItem(key);
-               call DhvStateLogic.setVBitState(0);
-               return SUCCESS;
-       }
-
-       command uint8_t * VectorLogic.allItem(){
-               return call DhvVectorCache.allItem();
-       }
-
-       command uint8_t VectorLogic.nextItem(){
-               return call DhvVectorCache.nextItem();
-       }
-
-       /*logic operations on the data*/
-       command error_t DataLogic.setItem(dhv_key_t key){
-               call DhvDataCache.addItem( key);
-               call DhvTrickleTimer.reset();
-               return SUCCESS;
-       }
-
-       command error_t DataLogic.setReqItem(dhv_key_t key){
-               call DhvDataCache.addReqItem( key);
-               call DhvTrickleTimer.reset();
-               return SUCCESS;
-       }
-
-       command error_t  DataLogic.unsetItem(dhv_key_t key){
-               call DhvDataCache.removeItem(key);
-               call DhvStateLogic.setVBitState(0);
-               return SUCCESS;
-       }
-
-       command uint8_t* DataLogic.allItem(){
-               return call DhvDataCache.allItem();
-       }
-
-       command uint8_t DataLogic.nextItem(){
-               return call DhvDataCache.nextItem();
-       }
+  /*Logic operation on the vector */   
+  command error_t VectorLogic.setItem(dhv_key_t key){
+    call DhvVectorCache.addItem(key);
+    call DhvTrickleTimer.reset();
+    return SUCCESS;
+  }
+
+  command error_t VectorLogic.setReqItem(dhv_key_t key){
+    call DhvVectorCache.addReqItem(key);
+    call DhvTrickleTimer.reset();
+    return SUCCESS;
+  }
+
+  command error_t VectorLogic.unsetItem(dhv_key_t key){
+    call DhvVectorCache.removeItem(key);
+    call DhvStateLogic.setVBitState(0);
+    return SUCCESS;
+  }
+
+  command uint8_t * VectorLogic.allItem(){
+    return call DhvVectorCache.allItem();
+  }
+
+  command uint8_t VectorLogic.nextItem(){
+    return call DhvVectorCache.nextItem();
+  }
+
+  /*logic operations on the data*/
+  command error_t DataLogic.setItem(dhv_key_t key){
+    call DhvDataCache.addItem( key);
+    call DhvTrickleTimer.reset();
+    return SUCCESS;
+  }
+
+  command error_t DataLogic.setReqItem(dhv_key_t key){
+    call DhvDataCache.addReqItem( key);
+    call DhvTrickleTimer.reset();
+    return SUCCESS;
+  }
+
+  command error_t  DataLogic.unsetItem(dhv_key_t key){
+    call DhvDataCache.removeItem(key);
+    call DhvStateLogic.setVBitState(0);
+    return SUCCESS;
+  }
+
+  command uint8_t* DataLogic.allItem(){
+    return call DhvDataCache.allItem();
+  }
+
+  command uint8_t DataLogic.nextItem(){
+    return call DhvDataCache.nextItem();
+  }
 
   /*logic operation for the summary and vbit*/
   command void DhvStateLogic.setHSumStatus(){
-               hsum_status = 1;
-         call  DhvTrickleTimer.reset();
+    hsum_status = 1;
+    call       DhvTrickleTimer.reset();
   }
-  
+
   command void DhvStateLogic.unsetHSumStatus(){
-               hsum_status = 0;
+    hsum_status = 0;
   }
 
   command uint8_t DhvStateLogic.getHSumStatus(){
-               return hsum_status;
-       }
-
-       command void DhvStateLogic.setDiffSummary(){
-               if(bitIndex == 0){
-                       bitIndex=1;
-               }
-
-         call  DhvTrickleTimer.reset();
-       }
-
-       command void DhvStateLogic.setSameSummary(){
-               bitIndex = 0;
-               hsum_status = 0;
-        //reset all the vector and data status to avoid flooding
-        call DhvDataCache.removeAll();
-        call DhvVectorCache.removeAll();
-       
-       }       
-
-       command void DhvStateLogic.setVBitState(uint32_t state){
-               bitIndex = state;
+    return hsum_status;
+  }
+
+  command void DhvStateLogic.setDiffSummary(){
+    if(bitIndex == 0){
+      bitIndex=1;
+    }
+
+    call       DhvTrickleTimer.reset();
+  }
+
+  command void DhvStateLogic.setSameSummary(){
+    bitIndex = 0;
+    hsum_status = 0;
+    //reset all the vector and data status to avoid flooding
+    call DhvDataCache.removeAll();
+    call DhvVectorCache.removeAll();
+
+  }    
+
+  command void DhvStateLogic.setVBitState(uint32_t state){
+    bitIndex = state;
     if(state != 0){
-                 call  DhvTrickleTimer.reset();
-               }
-       }
+      call     DhvTrickleTimer.reset();
+    }
+  }
 
-       command uint32_t DhvStateLogic.getVBitState(){
-               return bitIndex;
-       }
+  command uint32_t DhvStateLogic.getVBitState(){
+    return bitIndex;
+  }
 
- //unset one bit at index location
- command void DhvStateLogic.unsetVBitIndex(uint8_t dindex){
 //unset one bit at index location
 command void DhvStateLogic.unsetVBitIndex(uint8_t dindex){
     uint32_t mask;
-               mask = 1;
+    mask = 1;
 
     mask = mask << (dindex-1);
-         dbg("TempDebug", "TempDebug: Before mask dindex bitIndex %d %d %d\n", mask, dindex, bitIndex);
-               if((bitIndex & mask) != 0){
-                       bitIndex = bitIndex^mask;
-               }
-         dbg("TempDebug", "TempDebug: After bitIndex %d\n", bitIndex); 
- }
-
- command void DhvStateLogic.setVBitIndex(uint8_t dindex){
+    dbg("TempDebug", "TempDebug: Before mask dindex bitIndex %d %d %d\n", mask, dindex, bitIndex);
+    if((bitIndex & mask) != 0){
+      bitIndex = bitIndex^mask;
+    }
+    dbg("TempDebug", "TempDebug: After bitIndex %d\n", bitIndex); 
 }
+
 command void DhvStateLogic.setVBitIndex(uint8_t dindex){
     uint32_t mask;
-               mask = 1;
+    mask = 1;
     mask = mask << (dindex-1);
-         
-               bitIndex = bitIndex | mask;
-   
-         call  DhvTrickleTimer.reset();
-}
 
-//get the non-zero bit index to extract the vertical bits.
-command uint8_t DhvStateLogic.getVBitIndex(){
-
-  uint32_t mask;
-  uint8_t i;
-  uint32_t xor;
-
-       if(bitIndex == 0){
-               return 0;
-       }else
-       {
-               mask = 1;
-               for(i = 1; i <= 32; i++){
-                       xor = bitIndex & mask;
-                       
-      dbg("TempDebug", "TempDebug: %d  %d  %d  %d \n", i, bitIndex, mask, xor);
-                       if(xor != 0){
-                               return i;
-                       }
-                       mask = mask << 1;                       
-               }
-               return 0;
-       }
-}
+    bitIndex = bitIndex | mask;
+
+    call       DhvTrickleTimer.reset();
+  }
+
+  //get the non-zero bit index to extract the vertical bits.
+  command uint8_t DhvStateLogic.getVBitIndex(){
+
+    uint32_t mask;
+    uint8_t i;
+    uint32_t xor;
+
+    if(bitIndex == 0){
+      return 0;
+    }else
+    {
+      mask = 1;
+      for(i = 1; i <= 32; i++){
+        xor = bitIndex & mask;
+
+        dbg("TempDebug", "TempDebug: %d  %d  %d  %d \n", i, bitIndex, mask, xor);
+        if(xor != 0){
+          return i;
+        }
+        mask = mask << 1;                      
+      }
+      return 0;
+    }
+  }
 
 
 
   command void DisseminationUpdate.change[dhv_key_t key](dhv_data_t* val) {
 
     dbg("DhvLogicP","App notified key %x is new\n", key);
-               
-               //update data: actual reprogramming job
+
+    //update data: actual reprogramming job
     call VersionUpdate.change[key](val);
 
     //set data
-               call DhvDataCache.addItem(key);
+    call DhvDataCache.addItem(key);
 
-               //set to advertise its version
-               call DhvVectorCache.addItem(key);
+    //set to advertise its version
+    call DhvVectorCache.addItem(key);
 
-               //reset bindex
-               call DhvStateLogic.setVBitState(0);     
+    //reset bindex
+    call DhvStateLogic.setVBitState(0);        
 
-               dbg("DhvLogicP","Reset bindex to 0\n");
-               //reset timer             
+    dbg("DhvLogicP","Reset bindex to 0\n");
+    //reset timer                
     call DhvTrickleTimer.reset();
   }
 
   event uint32_t DhvTrickleTimer.requestWindowSize() {
     //TODO: consider if this is neccessary
-               uint8_t decision;
-
-               decision =  sendDecision();
-
-   if(decision == ID_DHV_SUMMARY){
-                               windowSize = windowSize << 1;
-                               if(windowSize > DHV_TAU_HIGH){
-                                       windowSize = DHV_TAU_HIGH;
-                               }
-               }else{
-                        if(decision != ID_DHV_INVALID){
-                                        windowSize = DHV_TAU_LOW;
-                               }
-               }
-
-               /*if(decision == ID_DHV_DATA){
-                       windowSize = DHV_TAU_LOW;
-               }else{
-                       if(decision == ID_DHV_VBIT){
-                               windowSize = DHV_TAU_LOW;
-                       }else{
-                               windowSize = windowSize << 1;
-                               if(windowSize > DHV_TAU_HIGH){
-                                       windowSize = DHV_TAU_HIGH;
-                               }
-                       }
-               }
-               */
+    uint8_t decision;
+
+    decision =  sendDecision();
+
+    if(decision == ID_DHV_SUMMARY){
+      windowSize = windowSize << 1;
+      if(windowSize > DHV_TAU_HIGH){
+        windowSize = DHV_TAU_HIGH;
+      }
+    }else{
+      if(decision != ID_DHV_INVALID){
+        windowSize = DHV_TAU_LOW;
+      }
+    }
+
     dbg("DhvLogicP", "Time window size requested, give %u : send decision %d \n", windowSize, decision);
     return windowSize;
   }
@@ -276,127 +262,91 @@ command uint8_t DhvStateLogic.getVBitIndex(){
     decision = sendDecision();
 
     switch(decision) {
-    case ID_DHV_INVALID:
-      dbg("DhvLogicP", "Decision to SUPPRESS\n");
-      break;
-    case ID_DHV_SUMMARY:
-      dbg("DhvLogicP", "Decision to SUMMARY\n");
-      call DhvSummaryDecision.send();
-      break;
-    case ID_DHV_VECTOR:
-      dbg("DhvLogicP", "Decision to VECTOR\n");
-      call DhvVectorDecision.send();
-      break;
-    case ID_DHV_DATA:
-      dbg("DhvLogicP", "Decision to DATA\n");
-      call DhvDataDecision.send();
-      break;
-               case ID_DHV_VBIT:
-                       dbg("DhvLogicP", "Decision to VSUM\n");
-                       call DhvVBitDecision.send();
-                       break;
-         case ID_DHV_HSUM:
-                       dbg("DhvLogicP", "Decision to HSUM\n");
-                       call DhvHSumDecision.send();
-                       break;
+      case ID_DHV_INVALID:
+        dbg("DhvLogicP", "Decision to SUPPRESS\n");
+        break;
+      case ID_DHV_SUMMARY:
+        dbg("DhvLogicP", "Decision to SUMMARY\n");
+        call DhvSummaryDecision.send();
+        break;
+      case ID_DHV_VECTOR:
+        dbg("DhvLogicP", "Decision to VECTOR\n");
+        call DhvVectorDecision.send();
+        break;
+      case ID_DHV_DATA:
+        dbg("DhvLogicP", "Decision to DATA\n");
+        call DhvDataDecision.send();
+        break;
+      case ID_DHV_VBIT:
+        dbg("DhvLogicP", "Decision to VSUM\n");
+        call DhvVBitDecision.send();
+        break;
+      case ID_DHV_HSUM:
+        dbg("DhvLogicP", "Decision to HSUM\n");
+        call DhvHSumDecision.send();
+        break;
     }
     call DhvDataDecision.resetCommRate();
     call DhvVectorDecision.resetCommRate();
     call DhvSummaryDecision.resetCommRate();
-               call DhvVBitDecision.resetCommRate();
-               call DhvHSumDecision.resetCommRate();
+    call DhvVBitDecision.resetCommRate();
+    call DhvHSumDecision.resetCommRate();
 
-               //set bitstate to zero
-               call DhvStateLogic.setVBitState(0);     
+    //set bitstate to zero
+    call DhvStateLogic.setVBitState(0);        
   }
 
-
-  uint8_t getState() {
-               bool hasItemToSend;
-               uint32_t bindex;
-
-               hasItemToSend = FALSE;
-
-    hasItemToSend = call DhvDataCache.hasItemToSend();
-               if(hasItemToSend){
-                       dbg("DhvLogicP", "has data to send? %u \n", hasItemToSend);
-                       return ID_DHV_DATA;
-               }else{
-                       hasItemToSend = call DhvVectorCache.hasItemToSend();
-                       dbg("DhvLogicP", "has vector to send? %u \n", hasItemToSend);
-                       if(hasItemToSend){
-                               return ID_DHV_VECTOR;
-                       }else{
-                               bindex = call DhvStateLogic.getVBitState();
-                               dbg("DhvLogicP", "send decision bindex %d \n", bindex);         
-                       
-                               if(bindex !=  0){
-                                       return ID_DHV_VBIT;
-                               }else{
-                                       if(hsum_status != 0){
-                                               return ID_DHV_HSUM;
-                                       }else {
-                                               return ID_DHV_SUMMARY;          
-                                       }
-                               }
-                       }
-               }
-       }
-
-
   uint8_t sendDecision() {
 
-               bool hasItemToSend;
-               uint32_t bindex;
+    bool hasItemToSend;
+    uint32_t bindex;
     uint8_t dataCommRate;
     uint8_t vectorCommRate;
     uint8_t summaryCommRate;
-               uint8_t vbitCommRate;
+    uint8_t vbitCommRate;
     uint8_t hsumCommRate;
 
     dataCommRate = call DhvDataDecision.getCommRate();
     vectorCommRate = call DhvVectorDecision.getCommRate();
     summaryCommRate = call DhvSummaryDecision.getCommRate();
-               vbitCommRate    = call DhvVBitDecision.getCommRate();
+    vbitCommRate    = call DhvVBitDecision.getCommRate();
     hsumCommRate    = call DhvHSumDecision.getCommRate();
 
-               hasItemToSend = FALSE;
+    if(dataCommRate > INFO_THRESHOLD){
+      return ID_DHV_INVALID;  
+    }
+
+    hasItemToSend = FALSE;
     hasItemToSend = call DhvDataCache.hasItemToSend();
-               if(hasItemToSend){
-                       dbg("DhvLogicP", "has data to send? %u \n", hasItemToSend);
-                       return ID_DHV_DATA;
-               }
-
-               bindex = call DhvStateLogic.getVBitState();
-               dbg("DhvLogicP", "send decision bindex %d \n", bindex);         
-
-               if(bindex != 0){
-                       return ID_DHV_VBIT;
-               }
-       
-         if(hsum_status != 0){
-                       return ID_DHV_HSUM;
-               }
-
-       if(dataCommRate > 1) {
-                       dbg("DhvLogicP", "Heard data\n");
-       return ID_DHV_INVALID;
-       }
-
-
-               hasItemToSend = call DhvVectorCache.hasItemToSend();
-               dbg("DhvLogicP", "has vector to send? %u \n", hasItemToSend);
-
-               if(hasItemToSend){
-                       return ID_DHV_VECTOR;
-               }
-
-               // didn't send or hear data at this point
-       if(vectorCommRate + summaryCommRate + vbitCommRate > 1) {
-       dbg("DhvLogicP", "Heard an advertisement\n");
-       return ID_DHV_INVALID;
-       }
-
-               return ID_DHV_SUMMARY;          
-       }
+    if(hasItemToSend){
+      dbg("DhvLogicP", "has data to send? %u \n", hasItemToSend);
+      return ID_DHV_DATA;
+    }
+
+    // didn't send or hear data at this point
+    if(dataCommRate + vectorCommRate + summaryCommRate + vbitCommRate + hsumCommRate >= INFO_THRESHOLD) {
+      dbg("DhvLogicP", "Heard an advertisement\n");
+      return ID_DHV_INVALID;
+    }
+
+    hasItemToSend = call DhvVectorCache.hasItemToSend();
+    dbg("DhvLogicP", "has vector to send? %u \n", hasItemToSend);
+
+    if(hasItemToSend){
+      return ID_DHV_VECTOR;
+    }
+
+    bindex = call DhvStateLogic.getVBitState();
+    dbg("DhvLogicP", "send decision bindex %d \n", bindex);            
+
+    if(bindex != 0){
+      return ID_DHV_VBIT;
+    }
+
+    if(hsum_status != 0){
+      return ID_DHV_HSUM;
+    }
+
+    return ID_DHV_SUMMARY;             
+  }
 }
index eb97dd409d0e4ef57783d48fcf6ddb77cbda70ab..5323fb730e95c737af30de43893eb9d0fa22df57 100755 (executable)
@@ -60,7 +60,6 @@ implementation {
     dhv_summary_msg_t* dsmsg;
     uint32_t salt, myHash;
 
-    commRate = commRate + 1;
 
     dsmsg = (dhv_summary_msg_t*) payload;
     salt = dsmsg->salt;
@@ -73,6 +72,7 @@ implementation {
     }
       else {
                                call StateLogic.setSameSummary();
+        commRate = commRate + 1;
         dbg("DhvSummaryP", "Hashes match\n");
     }
   }
index 9ebac2faaf27dc56ec4cbe7cd486c11f8f6e91ad..95e8b825304bc0ffc226b96170f26d7e5aa0a2ee 100755 (executable)
@@ -104,7 +104,7 @@ implementation{
         dbg("DhvVBitP", "bindex %d vbit %d:  0x%02x  0x%02x \n",bindex, i, dvbmsg->vbit[i], versionPtr[i]);
       }
 
-      dbg("DhvVBitP", "Sending vbit of index %d size %d \n", bindex, sizeof(dhv_msg_t) + sizeof(dhv_vbit_msg_t) + msg_size );
+      //dbg("DhvVBitP", "Sending vbit of index %d size %d \n", bindex, sizeof(dhv_msg_t) + sizeof(dhv_vbit_msg_t) + msg_size );
 
       for(i = 0; i < msg_size; i++){
         dbg("DhvVBitP", "vbit to send %d, 0x%02x \n", i, dvbmsg->vbit[i]);
@@ -140,7 +140,6 @@ implementation{
     uint32_t bitIndexValue;
 
     isDiff = FALSE;
-    commRate = 1;
 
     maxDataLength = TOSH_DATA_LENGTH - sizeof(dhv_msg_t) - sizeof(dhv_vbit_msg_t);
     if(UQCOUNT_DHV != 0)
@@ -168,7 +167,7 @@ implementation{
       //some duplicates
       dbg("DhvVBitP", "same summary\n");
       call VBitLogic.setSameSummary();
-
+      commRate = commRate + 1;
     }else{
       vbit = call DhvHelp.getVBits(bindex);    
       if(vindex == numMsg-1){
index 9a3b587016f14b3998274ae9f4a4db4b487750f1..e76348af8a9231e017834730ff71a0bbcb4431c2 100755 (executable)
@@ -81,7 +81,7 @@ implementation {
                dvmsg->unitLen = i;
 
                //TODO: need to fix
-               dbg("DhvVectorP", "Sending vector message out ...unitLen 0x%02x \n", dvmsg->unitLen);
+       //      dbg("DhvVectorP", "Sending vector message out ...unitLen 0x%02x \n", dvmsg->unitLen);
     status = call VectorSend.send(sizeof(dhv_msg_t) + sizeof(dhv_vector_msg_t) +
                                (i*sizeof(uint32_t)));
 
@@ -124,8 +124,7 @@ implementation {
     uint32_t vectorver;
     uint32_t myver;
 
-    commRate = commRate + 1;
-
+    commRate  = commRate + 1;          
                dmsg  = (dhv_msg_t*) payload; 
                type = dmsg->type;
 
@@ -140,23 +139,18 @@ implementation {
       myver = call DhvHelp.keyToVersion(vectorkey);
                        dbg("DhvVectorP", "key 0x%08x  version 0x%08x myver 0x%08x \n", vectorkey, vectorver, myver);
       // TODO: handle the invalid versions
+
       if(myver < vectorver) {
-                                       dbg("DhvVectorP", "I have an older version -> setReqItem \n");
-                                       call VectorLogic.setReqItem(vectorkey);
+                                       dbg("DhvVectorP", "I have an older version -> setItem \n");
+                                       call VectorLogic.setItem(vectorkey);
       }
       else if(myver > vectorver) {
                                        dbg("DhvVectorP", "I have a newer version -> Data.setItem \n");
                                        call DataLogic.setItem(vectorkey);
       }
       else{
-                                       if(type == ID_DHV_VECTOR_REQ){
-                                               dbg("DhvVectorP", "Request msg and I have that version -> Data.setItem \n");
-                                               call DataLogic.setItem(vectorkey);              
-                                       }else{
-                                                       
                                                dbg("DhvVectorP", "Request msg and I have the same version -> keep quite \n");
-                                               call VectorLogic.unsetItem(vectorkey);          
-                                       }                               
+                                               call VectorLogic.unsetItem(vectorkey);                                  
       }
     }
   }
index cc89a2f9f31b07b808b5316211cf4cf507d7796c..0df65c1fc7d943f9b95cc5bc6fcbefff1fd979c5 100755 (executable)
@@ -139,7 +139,7 @@ implementation {
                dhv_index_t i;
 
                i = call DhvHelp.keyToIndex(key);
-               vector_to_send[i] = ID_DHV_REQ;
+               vector_to_send[i] = ID_DHV_ADS;
                
                dbg("DhvVersionP", "Add Item to vector_to_send index %d\n", i);
                printVectorStatus();