Skip to content

Power Down

The power_down module demonstrates how an application program can place restrictions on when the device powers down.

Build it from project powerDownDemo.

Function Details

The following is an overview of the functions used in the power_down module.

static void powerDownThread(void *opaque) {...}

Use ltrx_ip_address_state() to check if the IP interfaces are up, and while there is no connection, use ltrx_thread_sleep() to pause the thread for 100 ms to give WLAN0 time to come up.

When there is a connection, use ltrx_power_level_application_request_full_power() to request full power until further notice, then use ltrx_timemark() to get a time mark.

Use ltrx_elapsed_time_current_ms() to find the time since the time mark. If the elapsed time is less than the duration specified in s_timeBetweenWorkStartInMilliseconds, calculate the difference between the elapsed time and remaining time. If the difference is greater that 1000 ms, print a message indicating the permitted shutdown time to the trouble log and then permit shutdown for specified time duration using ltrx_power_level_application_permit_shutdown().

Pause the thread with ltrx_thread_sleep() and yield control using ltrx_thread_yield().