Hi,
can you give some examples on using the ping_start function ?
I can't seem to make it work...
My code is:
struct ping_option pingopt;
void ping(uint32 ip)
{
pingopt.ip=ip;
pingopt.count = 100;
pingopt.coarse_time = 1;
pingopt.recv_function=NULL;
pingopt.sent_function=NULL;
ping_start(&pingopt);
}
uint32 ipaddr = ((uint32)((192) & 0xff) << 24) | \
((uint32)((168) & 0xff) << 16) | \
((uint32)((4) & 0xff) << 8) | \
(uint32)((100) & 0xff);
os_printf("IP: %u\n", ipaddr);
ping(ipaddr);
Thks
Ping_start function
Re: Ping_start function
Postby ESP_Faye » Tue Jun 30, 2015 3:18 pm
Hi,
Please try this
Please try this
Code: Select all
void ICACHE_FLASH_ATTR
user_ping_recv(void *arg, void *pdata)
{
struct ping_resp *ping_resp = pdata;
struct ping_option *ping_opt = arg;
if (ping_resp->ping_err == -1)
os_printf("ping host fail \r\n");
else
os_printf("ping recv: byte = %d, time = %d ms \r\n",ping_resp->bytes,ping_resp->resp_time);
}
void ICACHE_FLASH_ATTR
user_ping_sent(void *arg, void *pdata)
{
os_printf("user ping finish \r\n");
}
void ICACHE_FLASH_ATTR
user_test_ping(void)
{
struct ping_option *ping_opt = NULL;
const char* ping_ip = "192.168.1.114";
ping_opt = (struct ping_option *)os_zalloc(sizeof(struct ping_option));
ping_opt->count = 10; // try to ping how many times
ping_opt->coarse_time = 2; // ping interval
ping_opt->ip = ipaddr_addr(ping_ip);
ping_regist_recv(ping_opt,user_ping_recv);
ping_regist_sent(ping_opt,user_ping_sent);
ping_start(ping_opt);
}
Who is online
Users browsing this forum: No registered users and 21 guests
Login
Newbies Start Here
Are you new to ESP8266?
Unsure what to do?
Dunno where to start?
Start right here!
Latest SDK
Documentation
Complete listing of the official ESP8266 related documentation release by ESPRESSIF!
Must read here!
- All times are UTC+08:00
- Top
- Delete all board cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. We are the manufacturer of ESP8266EX.