Morse Micro IoT SDK  2.9.7
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#endif
42
44#define MMPING_DEFAULT_PING_INTERVAL_MS (1000)
46#define MMPING_DEFAULT_PING_COUNT (0)
48#define MMPING_DEFAULT_DATA_SIZE (56)
50#define MMPING_MIN_DATA_SIZE (8)
52#define MMPING_MAX_DATA_SIZE (1500)
54#define MMPING_MAX_COUNT (0xffff)
56#define MMPING_MAX_RETRIES (2)
58#define MMPING_INITIAL_RETRY_INTERVAL_MS (1000)
59
61#define MMPING_IPADDR_MAXLEN (48)
62
64#define MMPING_ICMP_ECHO_HDR_LEN (8)
65
77{
89 uint32_t ping_count;
91 uint32_t ping_size;
92};
93
95#define MMPING_ARGS_DEFAULT \
96 { \
97 { 0 }, { 0 }, MMPING_DEFAULT_PING_INTERVAL_MS, \
98 MMPING_DEFAULT_PING_COUNT, MMPING_DEFAULT_DATA_SIZE, \
99 }
100
105{
120};
121
129uint16_t mmping_start(const struct mmping_args *args);
130
134void mmping_stop(void);
135
143void mmping_stats(struct mmping_stats *stats);
144
145#ifdef __cplusplus
146}
147#endif
148
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:61
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:77
uint32_t ping_size
Specifies the data packet size in bytes excluding 8 bytes ICMP header.
Definition: mmping.h:91
char ping_src[MMPING_IPADDR_MAXLEN]
String representation of the local IP address.
Definition: mmping.h:79
char ping_target[MMPING_IPADDR_MAXLEN]
String representation of the IP address of the ping target.
Definition: mmping.h:81
uint32_t ping_interval_ms
The time interval between ping requests (in milliseconds)
Definition: mmping.h:83
uint32_t ping_count
This specifies the number of ping requests to send before terminating the session.
Definition: mmping.h:89
Data structure to store ping results.
Definition: mmping.h:105
uint32_t ping_avg_time_ms
The average latency in ms between request sent and response received.
Definition: mmping.h:115
bool ping_is_running
Stores the ping running status.
Definition: mmping.h:119
uint32_t ping_min_time_ms
The minimum latency in ms between request sent and response received.
Definition: mmping.h:113
uint32_t ping_max_time_ms
The maximum latency in ms between request sent and response received.
Definition: mmping.h:117
char ping_receiver[MMPING_IPADDR_MAXLEN]
String representation of the IP address of the ping receiver.
Definition: mmping.h:107
uint32_t ping_recv_count
The number of ping responses received.
Definition: mmping.h:111
uint32_t ping_total_count
Total number of requests sent.
Definition: mmping.h:109