Skip to content

ESP Insights silently fails on Ethernet-only devices (no WiFi STA) #63

Description

@DatanoiseTV

Problem

esp_insights gates ALL data posting behind esp_wifi_sta_get_ap_info():

// esp_insights.c:144
static bool is_insights_active(void)
{
    wifi_ap_record_t ap_info;
    bool wifi_connected = esp_wifi_sta_get_ap_info(&ap_info) == ESP_OK;
    return wifi_connected && s_insights_data.enabled;
}

On an Ethernet-only device (ESP32-P4 with RMII PHY, no WiFi STA started), this function always returns false. As a result:

  • esp_insights_init() succeeds and logs "Insights enabled for Node ID ..."
  • The 60-second timer fires
  • But is_insights_active() returns false → data is never encoded or posted
  • No error or warning is logged — the failure is completely silent

The device has a working TCP/IP stack via Ethernet, can reach client.insights.espressif.com, and HTTPS transport is configured. The only missing piece is WiFi STA connectivity, which shouldn't be required for HTTPS posting.

The same issue affects is_wifi_connected() (line 152), used in at least 3 other code paths.

Environment

  • ESP-IDF v5.5
  • ESP32-P4 (RISC-V dual-core)
  • espressif/esp_insights v1.3.x
  • Transport: HTTPS
  • Network: Ethernet (IP101 RMII PHY)
  • CONFIG_ESP_WIFI_REMOTE_ENABLED=y (compiled but WiFi never started)

Workaround

Override esp_wifi_sta_get_ap_info() from the application to return ESP_OK when Ethernet has an IP:

#include "esp_err.h"
#include "esp_wifi_types.h"

// Returns ESP_OK when Ethernet is up, so Insights posts data.
// Linker picks this over the esp_wifi_remote library implementation.
esp_err_t esp_wifi_sta_get_ap_info(wifi_ap_record_t *ap_info)
{
    if (!ethernet_is_up()) return ESP_FAIL;
    if (ap_info) {
        memset(ap_info, 0, sizeof(*ap_info));
        snprintf((char *)ap_info->ssid, sizeof(ap_info->ssid), "eth");
        ap_info->rssi = -30;
    }
    return ESP_OK;
}

This works but is fragile — it fakes WiFi state to satisfy an internal check that shouldn't exist for HTTPS transport.

Suggested Fix

Replace esp_wifi_sta_get_ap_info() checks in is_insights_active() / is_wifi_connected() with a transport-agnostic network connectivity check, e.g. esp_netif_is_netif_up() on the default netif, or skip the check entirely for HTTPS transport (the HTTP POST itself will fail with a clear error if the network is down).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions