Chapter 2. API Reference
freeaddrinfo(res);
esp_ping_config_t ping_config
ping_config.target_addr
ping_config.count
ping_stop can stop it
→
/* set callback functions */
esp_ping_callbacks_t cbs;
cbs.on_ping_success
cbs.on_ping_timeout
cbs.on_ping_end
cbs.cb_args
=
"foo";
can be NULL
→
cbs.cb_args
=
eth_event_group;
esp_ping_handle_t ping;
esp_ping_new_session(&ping_config, &cbs, &ping);
}
Start and Stop ping session
esp_ping_new_session. Note that, the ping session won't start automatically after creation. If the ping
session is stopped, and restart again, the sequence number in ICMP packets will recount from zero again.
Delete a ping session
esp_ping_delete_session. Please make sure the ping session is in stop state (i.e. you have called
esp_ping_stop before or the ping session has finished all the procedures) when you call this function.
Get runtime statistics
As the example code above, you can call esp_ping_get_profile to get different
runtime statistics of ping session in the callback function.
Application Example
ICMP echo example:
protocols/icmp_echo
API Reference
Header File
•
components/lwip/include/apps/ping/ping_sock.h
Functions
esp_err_t
esp_ping_new_session(const
Create a ping session.
Return
• ESP_ERR_INVALID_ARG: invalid parameters (e.g. configuration is null, etc)
• ESP_ERR_NO_MEM: out of memory
• ESP_FAIL: other internal error (e.g. socket error)
• ESP_OK: create ping session successfully, user can take the ping handle to do follow-on jobs
Parameters
• config: ping configuration
• cbs: a bunch of callback functions invoked by internal ping task
• hdl_out: handle of ping session
Espressif Systems
=
ESP_PING_DEFAULT_CONFIG();
=
target_addr;
=
ESP_PING_COUNT_INFINITE;
=
test_on_ping_success;
=
test_on_ping_timeout;
=
test_on_ping_end;
// arguments that will feed to all callback
You can start and stop ping session with the handle returned by
If a ping session won't be used any more, you can delete it with
esp_ping_config_t
*cbs,
esp_ping_handle_t
Submit Document Feedback
// target IP address
// ping in infinite mode, esp_
*config, const
*hdl_out)
597
(continued from previous page)
functions,␣
esp_ping_callbacks_t
Release v4.4
Need help?
Do you have a question about the ESP32-S2 and is the answer not in the manual?