![]() |
Morse Micro IoT SDK
2.9.7
|
Example utilizing WNM sleep to conserve power in between periodic transmissions.
This file demonstrates an example of how WNM sleep can be utilized using the Morse Micro WLAN API. See WNM Sleep management for more details.
The application is based of the ping example application. The difference here is that we will enter WNM sleep after transmitting. We then sleep for a set amount of time before repeating. This can be used to conserve power if you have some data that only needs to be transferred periodically.
See Application helper routines for Wireless LAN interface for details of WLAN and IP stack configuration. Additional configuration options for this application can be found in the config.hjson file.
Definition in file wnm_sleep.c.
#include <string.h>#include "mmhal.h"#include "mmosal.h"#include "mmwlan.h"#include "mmping.h"#include "mmconfig.h"#include "mmipal.h"#include "mm_app_common.h"
Go to the source code of this file.
Macros | |
| #define | DEFAULT_PING_COUNT 10 |
| Number of ping requests to send. More... | |
| #define | DEFAULT_PING_DATA_SIZE 56 |
| Size of the ping request data, excluding 8-byte ICMP header. More... | |
| #define | DEFAULT_PING_INTERVAL_MS 1000 |
| Interval between successive ping requests. More... | |
| #define | DEFAULT_WNM_SLEEP_DURATION_MS 20000 |
| Duration to remain in wnm sleep between transmissions. More... | |
| #define | POST_PING_DELAY_MS 10000 |
| Delay in ms to wait before terminating connection on completion of ping. More... | |
| #define | UPDATE_INTERVAL_MS (5000) |
| Interval (in milliseconds) at which to provide updates when the receive count has not changed. More... | |
Enumerations | |
| enum | debug_state { DEBUG_STATE_INIT = 0x00 , DEBUG_STATE_BOOTING_CHIP = 0x01 , DEBUG_STATE_CONNECTING = 0x03 , DEBUG_STATE_CONNECTED = 0x02 , DEBUG_STATE_CONNECTED_IDLE = 0x00 , DEBUG_STATE_PINGING = 0x02 , DEBUG_STATE_PING_DONE = 0x03 , DEBUG_STATE_IDLE = 0x01 , DEBUG_STATE_TERMINATING = 0x00 , DEBUG_STATE_INIT = 0x00 , DEBUG_STATE_CONNECTING = 0x01 , DEBUG_STATE_CONNECTED = 0x03 , DEBUG_STATE_PINGING_0 = 0x02 , DEBUG_STATE_PING_0_DONE = 0x00 , DEBUG_STATE_WNM_SLEEP = 0x01 , DEBUG_STATE_EXITING_WNM_SLEEP = 0x03 , DEBUG_STATE_WNM_SLEEP_DONE = 0x02 , DEBUG_STATE_PINGING_1 = 0x00 , DEBUG_STATE_PING_1_DONE = 0x01 , DEBUG_STATE_WNM_SLEEP_POWER_DOWN = 0x03 , DEBUG_STATE_EXITING_WNM_SLEEP_POWER_DOWN = 0x02 , DEBUG_STATE_WNM_SLEEP_POWER_DOWN_DONE = 0x00 , DEBUG_STATE_TERMINATING = 0x01 } |
| Enumeration of debug states that will be reflected on debug pins. More... | |
Functions | |
| static void | set_debug_state (enum debug_state state) |
| Perform necessary operation (i.e., setting GPIO pins) upon entering the given debug state. More... | |
| static void | execute_ping_request (int iteration) |
| Function to execute ping request. More... | |
| static void | execute_wnm_sleep (uint32_t wnm_sleep_duration_ms) |
| Function to execute WNM sleep. More... | |
| static void | execute_wnm_sleep_ext (uint32_t wnm_sleep_duration_ms) |
| Function to enter WNM Sleep and power off the MM chip while asleep. More... | |
| void | app_init (void) |
| Main entry point to the application. More... | |
| #define DEFAULT_PING_COUNT 10 |
Number of ping requests to send.
Set to 0 to continue indefinitely.
Definition at line 42 of file wnm_sleep.c.
| #define DEFAULT_PING_DATA_SIZE 56 |
Size of the ping request data, excluding 8-byte ICMP header.
Definition at line 46 of file wnm_sleep.c.
| #define DEFAULT_PING_INTERVAL_MS 1000 |
Interval between successive ping requests.
Definition at line 50 of file wnm_sleep.c.
| #define DEFAULT_WNM_SLEEP_DURATION_MS 20000 |
Duration to remain in wnm sleep between transmissions.
Definition at line 54 of file wnm_sleep.c.
| #define POST_PING_DELAY_MS 10000 |
Delay in ms to wait before terminating connection on completion of ping.
Definition at line 58 of file wnm_sleep.c.
| #define UPDATE_INTERVAL_MS (5000) |
Interval (in milliseconds) at which to provide updates when the receive count has not changed.
Definition at line 63 of file wnm_sleep.c.
| enum debug_state |
Enumeration of debug states that will be reflected on debug pins.
Note that due to limited availability of pins, the values are mapped to 2-bit codes and so are not unique. The code sequence has been chosen to be gray code like in that only one bit changes at a time, but it does not return to zero so a zero code can be used to identify the first state.
Definition at line 72 of file wnm_sleep.c.
| void app_init | ( | void | ) |
Main entry point to the application.
This will be invoked in a thread once operating system and hardware initialization has completed. It may return, but it does not have to.
Definition at line 298 of file wnm_sleep.c.
|
static |
Function to execute ping request.
This function will block until the ping operation has completed.
| iteration | Specifies which iteration (0 or 1) of ping this is so that we can select the correct debug state. |
Definition at line 121 of file wnm_sleep.c.
|
static |
Function to execute WNM sleep.
| wnm_sleep_duration_ms | Duration in milliseconds in WNM sleep. |
Definition at line 204 of file wnm_sleep.c.
|
static |
Function to enter WNM Sleep and power off the MM chip while asleep.
This will achieve lower power consumption during the sleep at the expense of a longer wake-up time.
| wnm_sleep_duration_ms | Duration in milliseconds in WNM sleep. |
Definition at line 250 of file wnm_sleep.c.
|
static |
Perform necessary operation (i.e., setting GPIO pins) upon entering the given debug state.
| state | The debug state to enter. See debug_state. |
Definition at line 109 of file wnm_sleep.c.