1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#ifndef ESP_PING_H_
#define ESP_PING_H_
#include "esp_err.h"
#ifdef __cplusplus
extern "C" {
#endif
#define ESP_ERR_PING_BASE 0xa000
#define ESP_ERR_PING_INVALID_PARAMS ESP_ERR_PING_BASE + 0x01
#define ESP_ERR_PING_NO_MEM ESP_ERR_PING_BASE + 0x02
#define ESP_PING_CHECK_OPTLEN(optlen, opttype) do { if ((optlen) < sizeof(opttype)) { return ESP_ERR_PING_INVALID_PARAMS; }}while(0)
typedef struct _ping_found {
uint32_t resp_time;
uint32_t timeout_count;
uint32_t send_count;
uint32_t recv_count;
uint32_t err_count;
uint32_t bytes;
uint32_t total_bytes;
uint32_t total_time;
uint32_t min_time;
uint32_t max_time;
int8_t ping_err;
}{ ... } esp_ping_found;
typedef enum {
PING_TARGET_IP_ADDRESS = 50,
PING_TARGET_IP_ADDRESS_COUNT = 51,
PING_TARGET_RCV_TIMEO = 52,
PING_TARGET_DELAY_TIME = 53,
PING_TARGET_ID = 54,
PING_TARGET_RES_FN = 55,
PING_TARGET_RES_RESET = 56,
PING_TARGET_DATA_LEN = 57,
PING_TARGET_IP_TOS = 58,
PING_TARGET_IF_INDEX = 59
}{ ... } ping_target_id_t;
typedef enum {
PING_RES_TIMEOUT = 0,
PING_RES_OK = 1,
PING_RES_FINISH = 2,
}{ ... } ping_res_t;
typedef void (* esp_ping_found_fn)(ping_target_id_t found_id, esp_ping_found *found_val);
/* ... */
esp_err_t esp_ping_set_target(ping_target_id_t opt_id, void *opt_val, uint32_t opt_len);
/* ... */
esp_err_t esp_ping_get_target(ping_target_id_t opt_id, void *opt_val, uint32_t opt_len);
/* ... */
esp_err_t esp_ping_result(uint8_t res_val, uint16_t res_len, uint32_t res_time);
#ifdef __cplusplus
}{...}
#endif
/* ... */
#endif