]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/chips/cc1000/CC1000CsmaP.nc
lpl fixes:
[tinyos-2.x.git] / tos / chips / cc1000 / CC1000CsmaP.nc
index 8449652e9f1ddad82190fae084370ba81a2d3233..905ff6c87e9989dfb4b969c9e9d61cb12fc52feb 100644 (file)
@@ -153,8 +153,8 @@ implementation
   }
 
   void radioOff() {
-    call ByteRadio.off();
     call CC1000Control.off();
+    call ByteRadio.off();
   }
 
   /* LPL preamble length and sleep time computation */
@@ -234,11 +234,13 @@ implementation
       {
       case IDLE_STATE:
        /* Timer already running means that we have a noise floor
-          measurement scheduled. */
+          measurement scheduled. If we just set a new alarm here, we
+          might indefinitely delay noise floor measurements if we're,
+          e,g, transmitting frequently. */
        if (!call WakeupTimer.isRunning())
          if (call CC1000Squelch.settled())
            {
-             if (lplRxPower == 0 || f.txPending)
+             if (lplRxPower == 0)
                call WakeupTimer.startOneShot(CC1K_SquelchIntervalSlow);
              else
                // timeout for receiving a message after an lpl check
@@ -341,6 +343,7 @@ implementation
     */
     if (data > call CC1000Squelch.get() - (call CC1000Squelch.get() >> 2))
       {
+       post sleepCheck();
        // don't be too agressive (ignore really quiet thresholds).
        if (data < call CC1000Squelch.get() + (call CC1000Squelch.get() >> 3))
          {
@@ -348,7 +351,6 @@ implementation
            rssiForSquelch = data;
            post adjustSquelch();
          }
-       post sleepCheck();
       }
     else if (count++ > 5)
       {