- /**
- * Configure this outgoing message so it can be transmitted to a neighbor mote
- * with the specified Rx duty cycle rate.
- * Duty cycle is in units of [percentage*100], i.e. 0.25% duty cycle = 25.
- *
- * @param msg Pointer to the message that will be sent
- * @param dutyCycle The duty cycle of the receiving mote, in units of
- * [percentage*100]
- */
- command void LowPowerListening.setRxDutyCycle(message_t *msg,
- uint16_t dutyCycle) {
- (call CC2420PacketBody.getMetadata(msg))->rxInterval =
- call LowPowerListening.dutyCycleToSleepInterval(dutyCycle);
- }
-
-
- /**
- * @return the destination node's duty cycle configured in this message
- * in units of [percentage*100]
- */
- command uint16_t LowPowerListening.getRxDutyCycle(message_t *msg) {
- return call LowPowerListening.sleepIntervalToDutyCycle(
- (call CC2420PacketBody.getMetadata(msg))->rxInterval);
- }
-
- /**
- * Convert a duty cycle, in units of [percentage*100], to
- * the sleep interval of the mote in milliseconds
- * @param dutyCycle The duty cycle in units of [percentage*100]
- * @return The equivalent sleep interval, in units of [ms]
- */
- command uint16_t LowPowerListening.dutyCycleToSleepInterval(
- uint16_t dutyCycle) {
- dutyCycle = getActualDutyCycle(dutyCycle);
-
- if(dutyCycle == 10000) {
- return 0;
- }
-
- return ((uint32_t)DUTY_ON_TIME * (10000 - dutyCycle)) / dutyCycle;
- }
-
- /**
- * Convert a sleep interval, in units of [ms], to a duty cycle
- * in units of [percentage*100]
- * @param sleepInterval The sleep interval in units of [ms]
- * @return The duty cycle in units of [percentage*100]
- */
- command uint16_t LowPowerListening.sleepIntervalToDutyCycle(
- uint16_t sleepInterval) {
- if(sleepInterval == 0) {
- return 10000;
- }
-
- return getActualDutyCycle(((uint32_t)DUTY_ON_TIME * 10000)
- / (sleepInterval + DUTY_ON_TIME));
- }
-
-