40#ifndef DEFAULT_PING_COUNT
42#define DEFAULT_PING_COUNT 10
44#ifndef DEFAULT_PING_DATA_SIZE
46#define DEFAULT_PING_DATA_SIZE 56
48#ifndef DEFAULT_PING_INTERVAL_MS
50#define DEFAULT_PING_INTERVAL_MS 1000
52#ifndef DEFAULT_WNM_SLEEP_DURATION_MS
54#define DEFAULT_WNM_SLEEP_DURATION_MS 20000
56#ifndef POST_PING_DELAY_MS
58#define POST_PING_DELAY_MS 10000
60#ifndef UPDATE_INTERVAL_MS
63#define UPDATE_INTERVAL_MS (5000)
136 printf(
"Failed to retrieve IP config\n");
144 printf(
"failed to get local address for PING\n");
162 unsigned last_ping_recv_count = 0;
171 printf(
"(%s) packets transmitted/received = %lu/%lu, "
172 "round-trip min/avg/max = %lu/%lu/%lu ms\n",
192 printf(
"\n--- %s ping statistics ---\n%lu packets transmitted, %lu packets received, ",
194 printf(
"%lu.%03lu%% packet loss\nround-trip min/avg/max = %lu/%lu/%lu ms\n",
208 printf(
"\nEntering WNM sleep with chip power down disabled\n");
209 printf(
"Expected sleep time %lums.\n", wnm_sleep_duration_ms);
220 printf(
"Failed to enable WNM sleep\n");
234 printf(
"\nEnter WNM sleep took %lu ms.\n", wnm_sleep_enable_duration_ms);
239 printf(
"Failed to disable WNM sleep\n");
256 printf(
"\nEntering WNM sleep with chip power down enabled.\n");
257 printf(
"Expected sleep time %lums.\n", wnm_sleep_duration_ms);
270 printf(
"Failed to enable WNM sleep\n");
285 printf(
"\nEnter WNM sleep took %lu ms.\n", wnm_sleep_enable_duration_ms);
290 printf(
"Failed to disable WNM sleep\n");
300 printf(
"\n\nMorse WNM Sleep Demo (Built " __DATE__
" " __TIME__
")\n\n");
int mmconfig_read_string(const char *key, char *buffer, int bufsize)
Returns the persistent store string value identified by the key.
int mmconfig_read_uint32(const char *key, uint32_t *value)
Returns the unsigned integer stored in persistent store identified by the key.
#define MMHAL_ALL_DEBUG_PINS
Bit mask with all debug pins selected.
void mmhal_set_debug_pins(uint32_t mask, uint32_t values)
Set the value one or more debug pins.
#define MMIPAL_IP_CONFIG_DEFAULT
Initializer for mmipal_ip_config.
mmipal_status
Enumeration of status codes returned by MMIPAL functions.
enum mmipal_status mmipal_get_ip_config(struct mmipal_ip_config *config)
Get the IP configurations.
enum mmipal_status mmipal_get_local_addr(mmipal_ip_addr_t local_addr, const mmipal_ip_addr_t dest_addr)
Gets the local address for the MMWLAN interface that is appropriate for a given destination address.
@ MMIPAL_SUCCESS
Completed successfully.
void mmosal_task_sleep(uint32_t duration_ms)
Sleep for a period of time, yielding during that time.
uint32_t mmosal_get_time_ms(void)
Get the system time in milliseconds.
static bool mmosal_time_has_passed(uint32_t t)
Check if the given time has already passed.
#define MMPING_ICMP_ECHO_HDR_LEN
Length of the ICMP echo header in octets.
uint16_t mmping_start(const struct mmping_args *args)
Initialize ping parameters and start ping.
#define MMPING_ARGS_DEFAULT
Initializer for mmping_args.
void mmping_stats(struct mmping_stats *stats)
Get Ping Statistics.
static enum mmwlan_status mmwlan_set_wnm_sleep_enabled(bool wnm_sleep_enabled)
Sets whether WNM sleep mode is enabled.
#define MMWLAN_SET_WNM_SLEEP_ENABLED_ARGS_INIT
Initializer for mmwlan_set_wnm_sleep_enabled_args.
enum mmwlan_status mmwlan_set_wnm_sleep_enabled_ext(const struct mmwlan_set_wnm_sleep_enabled_args *args)
Sets extended WNM sleep mode.
mmwlan_status
Enumeration of status return codes.
@ MMWLAN_SUCCESS
The operation was successful.
@ MMWLAN_ERROR
The operation failed with an unspecified error.
Morse Micro application helper routines for initializing/de-initializing the Wireless LAN interface a...
void app_wlan_stop(void)
Disconnects from Wi-Fi and de-initializes the WLAN interface.
void app_wlan_init(void)
Initializes the WLAN interface (and dependencies) using settings specified in the config store.
void app_wlan_start(void)
Starts the WLAN interface and connects to Wi-Fi using settings specified in the config store.
debug_state
Enumeration of debug states that will be reflected on debug pins.
IPv4 configuration structure.
mmipal_ip_addr_t gateway_addr
Gateway address.
Ping request arguments data structure.
uint32_t ping_size
Specifies the data packet size in bytes excluding 8 bytes ICMP header.
char ping_src[MMPING_IPADDR_MAXLEN]
String representation of the local IP address.
char ping_target[MMPING_IPADDR_MAXLEN]
String representation of the IP address of the ping target.
uint32_t ping_interval_ms
The time interval between ping requests (in milliseconds)
uint32_t ping_count
This specifies the number of ping requests to send before terminating the session.
Data structure to store ping results.
uint32_t ping_avg_time_ms
The average latency in ms between request sent and response received.
bool ping_is_running
Stores the ping running status.
uint32_t ping_min_time_ms
The minimum latency in ms between request sent and response received.
uint32_t ping_max_time_ms
The maximum latency in ms between request sent and response received.
char ping_receiver[MMPING_IPADDR_MAXLEN]
String representation of the IP address of the ping receiver.
uint32_t ping_recv_count
The number of ping responses received.
uint32_t ping_total_count
Total number of requests sent.
Structure for storing WNM sleep extended arguments.
bool wnm_sleep_enabled
Boolean indicating whether WNM sleep is enabled.
bool chip_powerdown_enabled
Boolean indicating whether chip should be powered down during WNM sleep.
static void execute_wnm_sleep(uint32_t wnm_sleep_duration_ms)
Function to execute WNM sleep.
#define DEFAULT_PING_DATA_SIZE
Size of the ping request data, excluding 8-byte ICMP header.
static void set_debug_state(enum debug_state state)
Perform necessary operation (i.e., setting GPIO pins) upon entering the given debug state.
#define DEFAULT_PING_INTERVAL_MS
Interval between successive ping requests.
#define DEFAULT_WNM_SLEEP_DURATION_MS
Duration to remain in wnm sleep between transmissions.
static void execute_ping_request(int iteration)
Function to execute ping request.
#define UPDATE_INTERVAL_MS
Interval (in milliseconds) at which to provide updates when the receive count has not changed.
void app_init(void)
Main entry point to the application.
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.
@ DEBUG_STATE_INIT
Initial state at startup.
@ DEBUG_STATE_WNM_SLEEP_POWER_DOWN
Indicates that WNM sleep is in progress with chip powered down.
@ DEBUG_STATE_PINGING_0
Indicates that the ping is in progress.
@ DEBUG_STATE_WNM_SLEEP_DONE
Indicates that WNM sleep has completed.
@ DEBUG_STATE_PING_0_DONE
Indicates that the ping has completed.
@ DEBUG_STATE_CONNECTED
Indicates we are connected to the AP.
@ DEBUG_STATE_PING_1_DONE
Indicates that the ping has completed.
@ DEBUG_STATE_EXITING_WNM_SLEEP_POWER_DOWN
Indicates that we are exiting WNM sleep with chip powered down.
@ DEBUG_STATE_WNM_SLEEP
Indicates that WNM sleep is in progress.
@ DEBUG_STATE_PINGING_1
Indicates that the ping is in progress.
@ DEBUG_STATE_WNM_SLEEP_POWER_DOWN_DONE
Indicates that WNM sleep with chip powered down has completed.
@ DEBUG_STATE_EXITING_WNM_SLEEP
Indicates that we are exiting WNM sleep.
@ DEBUG_STATE_TERMINATING
Indicates that we are disconnecting from the AP.
@ DEBUG_STATE_CONNECTING
Indicates we are connecting to the AP.
#define DEFAULT_PING_COUNT
Number of ping requests to send.