/* * Copyright (c) 2000-2002 The Regents of the University of California. * and Copyright (c) 2002 Intel Corporation * All rights reserved. * * Implementation for Blink application. Toggle the red LED when the * clock fires. */ module BlinkM { provides interface StdControl; uses interface Clock; uses interface Leds; } implementation { bool state; /* the state of the red LED (on or off) */ /* Initialize the component. * @return Always returns SUCCESS */ command result_t StdControl.init() { state = FALSE; call Leds.init(); return SUCCESS; } /* Start things up. This just sets the rate for the clock component. * @return Always returns SUCCESS */ command result_t StdControl.start() { return call Clock.setRate(TOS_I1PS, TOS_S1PS); } /* Halt execution of the application. * This just disables the clock component. * @return Always returns SUCCESS */ command result_t StdControl.stop() { return call Clock.setRate(TOS_I0PS, TOS_S0PS); } /* Toggle the red LED in response to the Clock.fire event. * @return Always returns SUCCESS */ event result_t Clock.fire() { state = !state; if (state) { call Leds.redOn(); } else { call Leds.redOff(); } return SUCCESS; } }