40#define PING_DATA_SIZE 56
42#ifndef PING_INTERVAL_MS
44#define PING_INTERVAL_MS 1000
46#ifndef POST_PING_DELAY_MS
48#define POST_PING_DELAY_MS 10000
50#ifndef UPDATE_INTERVAL_MS
53#define UPDATE_INTERVAL_MS (5000)
56#if defined(ENABLE_PWR_MEAS) && ENABLE_PWR_MEAS
58#define PWR_MEAS_DELAY_MS(delay_ms) mmosal_task_sleep(delay_ms)
60#define SET_DEBUG_STATE(state) mmhal_set_debug_pins(MMHAL_ALL_DEBUG_PINS, state);
63#define PWR_MEAS_DELAY_MS(delay_ms) MM_UNUSED(delay_ms)
65#define SET_DEBUG_STATE(state) MM_UNUSED(state)
108 printf(
"\n\nMorse Ping Demo (Built " __DATE__
" " __TIME__
")\n\n");
139 printf(
"Failed to retrieve IP config\n");
147 printf(
"Failed to get local address for PING\n");
160 printf(
"\nPing %s %lu(%lu) bytes of data.\n",
167 unsigned last_ping_recv_count = 0;
176 printf(
"(%s) packets transmitted/received = %lu/%lu, "
177 "round-trip min/avg/max = %lu/%lu/%lu ms\n",
203 printf(
"\n--- %s ping statistics ---\n%lu packets transmitted, %lu packets received, ",
207 printf(
"%lu.%03lu%% packet loss\nround-trip min/avg/max = %lu/%lu/%lu ms\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 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.
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.
#define PING_COUNT
Number of ping requests to send.
#define SET_DEBUG_STATE(state)
Disable GPIO writing if not measuring power consumption.
#define PWR_MEAS_DELAY_MS(delay_ms)
Disable delays which are only useful for power consumption accuracy.
#define POST_PING_DELAY_MS
Delay in ms to wait before terminating connection on completion of ping.
#define PING_INTERVAL_MS
Interval between successive ping requests.
#define PING_DATA_SIZE
Size of the ping request data, excluding 8-byte ICMP header.
#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.
debug_state
Enumeration of debug states that will be reflected on debug pins.
@ DEBUG_STATE_INIT
Initial state at startup.
@ DEBUG_STATE_BOOTING_CHIP
Indicates that we are booting the MM chip (note that this will also include the host MCU startup time...
@ DEBUG_STATE_CONNECTED
Indicates we are connected to the AP.
@ DEBUG_STATE_PINGING
Indicates that the ping is in progress.
@ DEBUG_STATE_PING_DONE
Indicates that the ping has completed.
@ DEBUG_STATE_IDLE
Indicates that we are idling with WLAN still on.
@ DEBUG_STATE_TERMINATING
Indicates that we are disconnecting from the AP.
@ DEBUG_STATE_CONNECTED_IDLE
Indicates that we have connected to the AP, but have not started the ping yet.
@ DEBUG_STATE_CONNECTING
Indicates we are connecting to the AP.
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.