EasyManuals Logo

Espressif ESP32-S2 User Manual

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #608 background imageLoading...
Page #608 background image
Chapter 2. API Reference
(continued from previous page)
freeaddrinfo(res);
esp_ping_config_t ping_config = ESP_PING_DEFAULT_CONFIG();
ping_config.target_addr = target_addr; // target IP address
ping_config.count = ESP_PING_COUNT_INFINITE; // ping in infinite mode, esp_
,ping_stop can stop it
/* set callback functions */
esp_ping_callbacks_t cbs;
cbs.on_ping_success = test_on_ping_success;
cbs.on_ping_timeout = test_on_ping_timeout;
cbs.on_ping_end = test_on_ping_end;
cbs.cb_args = "foo"; // arguments that will feed to all callback functions,
,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 You can start and stop ping session with the handle returned by
esp_ping_new_session. Note that, the ping session wont 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 If a ping session wont be used any more, you can delete it with
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 dierent
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 esp_ping_config_t *config, const esp_ping_callbacks_t
*cbs, esp_ping_handle_t *hdl_out)
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 597
Submit Document Feedback
Release v4.4

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Espressif ESP32-S2 and is the answer not in the manual?

Espressif ESP32-S2 Specifications

General IconGeneral
BrandEspressif
ModelESP32-S2
CategorySingle board computers
LanguageEnglish