Operation

Asset Tracker Template

tags
Asset Tracker Template

Instead of using a state machine, the LED module operates as follows:

  1. When the module receives a message on the led_chan channel, it performs the following steps:

    • Cancels any existing blink pattern.
    • Saves the new LED state, which is the colors and the timing.
    • Turns the LED on with the specified color.
  2. When the message specifies a blinking pattern, which means that repetitions is not 0, the module performs the following steps:

    • Starts a timer with duration_on_msec.
    • Toggles the LED between the on and off states when the timer expires.
    • Alternates the timer between duration_on_msec and duration_off_msec.
    • Continues until the LED has blinked the specified number of repetitions.

When repetitions is -1, the blinking continues indefinitely, or until the module receives a new message.

The module handles error cases gracefully and reports issues through logging.