Morse Micro IoT SDK  2.10.4
mmping.h
1/*
2 * Copyright 2021-2023 Morse Micro
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
34#pragma once
35
36#include <stdint.h>
37#include <stdbool.h>
38
39#ifdef __cplusplus
40extern "C"
41{
42#endif
43
45#define MMPING_DEFAULT_PING_INTERVAL_MS (1000)
47#define MMPING_DEFAULT_PING_COUNT (0)
49#define MMPING_DEFAULT_DATA_SIZE (56)
51#define MMPING_MIN_DATA_SIZE (8)
53#define MMPING_MAX_DATA_SIZE (1500)
55#define MMPING_MAX_COUNT (0xffff)
57#define MMPING_MAX_RETRIES (2)
59#define MMPING_INITIAL_RETRY_INTERVAL_MS (1000)
60
62#define MMPING_IPADDR_MAXLEN (48)
63
65#define MMPING_ICMP_ECHO_HDR_LEN (8)
66
78{
90 uint32_t ping_count;
92 uint32_t ping_size;
93};
94
96#define MMPING_ARGS_DEFAULT \
97 { \
98 { 0 }, \
99 { 0 }, \
100 MMPING_DEFAULT_PING_INTERVAL_MS, \
101 MMPING_DEFAULT_PING_COUNT, \
102 MMPING_DEFAULT_DATA_SIZE, \
103 }
104
109{
124};
125
133uint16_t mmping_start(const struct mmping_args *args);
134
138void mmping_stop(void);
139
147void mmping_stats(struct mmping_stats *stats);
148
149#ifdef __cplusplus
150}
151#endif
152
void mmping_stop(void)
Stop any running ping request.
#define MMPING_IPADDR_MAXLEN
Maximum length of an IP address string including null-terminator.
Definition: mmping.h:62
uint16_t mmping_start(const struct mmping_args *args)
Initialize ping parameters and start ping.
void mmping_stats(struct mmping_stats *stats)
Get Ping Statistics.
Ping request arguments data structure.
Definition: mmping.h:78
uint32_t ping_size
Specifies the data packet size in bytes excluding 8 bytes ICMP header.
Definition: mmping.h:92
char ping_src[MMPING_IPADDR_MAXLEN]
String representation of the local IP address.
Definition: mmping.h:80
char ping_target[MMPING_IPADDR_MAXLEN]
String representation of the IP address of the ping target.
Definition: mmping.h:82
uint32_t ping_interval_ms
The time interval between ping requests (in milliseconds)
Definition: mmping.h:84
uint32_t ping_count
This specifies the number of ping requests to send before terminating the session.
Definition: mmping.h:90
Data structure to store ping results.
Definition: mmping.h:109
uint32_t ping_avg_time_ms
The average latency in ms between request sent and response received.
Definition: mmping.h:119
bool ping_is_running
Stores the ping running status.
Definition: mmping.h:123
uint32_t ping_min_time_ms
The minimum latency in ms between request sent and response received.
Definition: mmping.h:117
uint32_t ping_max_time_ms
The maximum latency in ms between request sent and response received.
Definition: mmping.h:121
char ping_receiver[MMPING_IPADDR_MAXLEN]
String representation of the IP address of the ping receiver.
Definition: mmping.h:111
uint32_t ping_recv_count
The number of ping responses received.
Definition: mmping.h:115
uint32_t ping_total_count
Total number of requests sent.
Definition: mmping.h:113