16#define CONNECTING_BLINK_PERIOD_MS 1000
19#define DEPTH_PULSE_MS 150
22#define DEPTH_PULSE_PAUSE_MS 4000
25#define LED_TASK_IDLE_POLL_MS 200
31 RELAY_LED_MODE_CONNECTING,
33 RELAY_LED_MODE_CONNECTED,
35 RELAY_LED_MODE_FAILED,
38static struct mmosal_task *led_task;
41static enum relay_led_mode led_mode = RELAY_LED_MODE_CONNECTING;
50static void led_task_main(
void *arg)
63 case RELAY_LED_MODE_CONNECTING:
70 case RELAY_LED_MODE_CONNECTED:
81 else if (led_depth == 0)
88 uint8_t depth = led_depth;
90 for (
size_t i = 0; i < depth && led_mode == RELAY_LED_MODE_CONNECTED; i++)
101 case RELAY_LED_MODE_FAILED:
119 led_mode = RELAY_LED_MODE_CONNECTING;
124 led_mode = RELAY_LED_MODE_CONNECTED;
129 led_mode = RELAY_LED_MODE_FAILED;
#define LED_OFF
A value of 0 turns OFF an LED.
void mmhal_set_led(uint8_t led, uint8_t level)
Set the specified LED to the requested level.
#define LED_ON
A value of 255 turns an LED ON fully.
#define MMOSAL_ASSERT(expr)
Assert that the given expression evaluates to true and abort execution if not.
struct mmosal_task * mmosal_task_create(mmosal_task_fn_t task_fn, void *argument, enum mmosal_task_priority priority, unsigned stack_size_u32, const char *name)
Create a new task.
void mmosal_task_sleep(uint32_t duration_ms)
Sleep for a period of time, yielding during that time.
@ MMOSAL_TASK_PRI_LOW
Low priority.
#define MM_UNUSED(_x)
Casts the given expression to void to avoid "unused" warnings from the compiler.
#define MMWLAN_RELAY_DEPTH_UNKNOWN
Relay depth value returned when the depth is unknown.
enum mmwlan_sta_state mmwlan_get_sta_state(void)
Gets the current WLAN STA state.
Optional LED status indication for the Relay Mode Example Application.
void relay_led_set_connected(void)
Indicates that the app has connected to Wi-Fi.
void relay_led_set_failed(void)
Indicates that the app has failed to connect.
void relay_led_set_depth(uint8_t depth)
Indicates the current relay depth by pulsing the green LED depth times.
void relay_led_init(void)
Initializes the LED status module and starts its background task.
void relay_led_set_connecting(void)
Indicates that the app is attempting to connect to Wi-Fi.