I had a code that has been running for a while, but as soon as I updated to this version of IDF it stopped working.
The program is running a task called main which checks for connectivity by pinging the gateway address (because I'm using ethernet interface and there is no lost_ip event.
In this task I basically have this running in a loop:
Code: Select all
while (true) {
ESP_ERROR_CHECK(tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_ETH/*ESP_IF_ETH*/, &ip));
if (connection_mode_wifi)
{
ping_deinit();
}
if (!connection_mode_wifi && (ip.gw.addr != 0) && !waiting_results && ((xEventGroupGetBits(blah_event_group) & INTERNET_ACTIVE_BIT) != 0)) {uint32_t ping_count = 25; //how many pings per report
uint32_t ping_timeout = 500; //mS till we consider it timed out
uint32_t ping_delay = 1000; //mS between pings
esp_ping_set_target(PING_TARGET_IP_ADDRESS_COUNT, &ping_count, sizeof(uint32_t));
esp_ping_set_target(PING_TARGET_RCV_TIMEO, &ping_timeout, sizeof(uint32_t));
esp_ping_set_target(PING_TARGET_DELAY_TIME, &ping_delay, sizeof(uint32_t));
esp_ping_set_target(PING_TARGET_IP_ADDRESS, &ip.gw.addr, sizeof(uint32_t));
esp_ping_set_target(PING_TARGET_RES_FN, (void*)ðGwPingResults, sizeof(esp_err_t));
ping_init();
waiting_results = true;
ESP_LOGI(main_tag, "Resetting Ping ...");
and here is the call back:
Code: Select all
esp_err_t ethGwPingResults(ping_target_id_t msgType, esp_ping_found * pf) {
ESP_LOGI(gw_ping_tag, "AvgTime:%.1fmS Sent:%d Rec:%d Err:%d min(mS):%d max(mS):%d ", (float)pf->total_time / pf->recv_count, pf->send_count, pf->recv_count, pf->err_count, pf->min_time, pf->max_time);
ESP_LOGI(gw_ping_tag, "Resp(mS):%d Timeouts:%d Total Time:%d\n", pf->resp_time, pf->timeout_count, pf->total_time);
if(pf->send_count >= 25)
waiting_results = false;
if (pf->timeout_count >= 10 && !connection_mode_wifi) // We lost ETH connection
{
xEventGroupClearBits(blah_event_group, INTERNET_ACTIVE_BIT);
xEventGroupSetBits(eth_event_group, DHCP_LOST_BIT);
}
return ESP_OK;
}
and there is another task which is just a sniffer.
The sniffer stops working unless I comment out the ping! I also tried connecting to wifi and that doesn't work anymore neither.
The sniffer task and wifi stack are pinned to core 0 and everything else and emac is pinned to core 1. The sniffer task has high priority (18) , emac has priority 10, and ping task has priority 2.
Can someone else confirm this please?