Bk72xx causes loss of C header file location git include

To me most of esphome is black magic under the covers so apologies if this should be more obvious.

I started using SNMP in ESPHome (https://github.com/aquaticus/esphome-snmp) It works nicely.

I have a few files that include:

bk72xx:
  board: generic-bk7231n-qfn32-tuya

When that is included I get compilation errors (below). Change to an ESP32 board and it works fine. It’s not exactly a syntax error, it appears that the bk72xx board type is doing something to change the c library search path.

Am I missing something? Bug in that (whatever you call bk72xx)?

I’m including a sample file that shows this with esphome 2025.2.2.

I’m baffled where to go with this – not sure if the git project is not constructed correctly, or bk72xx is bad, or I’m doing something else wrongly.

Any pointers?

Linwood

esphome:
  name: testbk72xx
  friendly_name: Testbk72xx

bk72xx:
  board: generic-bk7231n-qfn32-tuya

#esp32: 
#  board: esp32-c3-devkitm-1

logger:

api:

ota:
  - platform: esphome
    password: !secret ota_password

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

external_components:
    # SNMP component
    - source: github://aquaticus/esphome-snmp

snmp:

Log truncated from the top as it’s really long if complete after clean:

.pioenvs/testbk72xx/src/esphome/components/socket/bsd_sockets_impl.cpp.o
In file included from src/esphome/components/snmp/snmp_component.cpp:1:
src/esphome/components/snmp/snmp_component.h:6:10: fatal error: SNMP_Agent.h: No such file or directory

********************************************************************
* Looking for SNMP_Agent.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:SNMP_Agent.h"
* Web  > https://registry.platformio.org/search?q=header:SNMP_Agent.h
*
********************************************************************

    6 | #include "SNMP_Agent.h"
      |          ^~~~~~~~~~~~~~
compilation terminated.
*** [.pioenvs/testbk72xx/src/esphome/components/snmp/snmp_component.cpp.o] Error 1
========================== [FAILED] Took 8.26 seconds ==========================

looking at the code I see:

#ifdef USE_ESP32
#include <WiFi.h>
#include <esp32/himem.h>
#endif
#ifdef USE_ESP8266
#include <ESP8266WiFi.h>
#endif
#include <WiFiUdp.h>

There is no mention of support for tuya devices, so you are likely out of luck in being able to use it with your platform.

The platform docs don’t indicate support for SNMP, so it will take a LOT of work to use it.

So a tuya device is not an esp8266?

If it just didn’t work, OK. What I’m confused by is this (to expand your code snippet slightly):

#pragma once

#include <string>
#include "esphome/core/component.h"
#include "esphome/core/hal.h"
#include "SNMP_Agent.h"

#ifdef USE_ESP32
#include <WiFi.h>
#include <esp32/himem.h>
#endif
#ifdef USE_ESP8266
#include <ESP8266WiFi.h>
#endif
#include <WiFiUdp.h>

The error is that the include of SNMP_Agent.h is not being found. The double quote should search the current file’s folder, which seemingly is where the project’s include would put it.

If the build was failing due to (for example) a lack of a wifi API being included it would make sense. But it’s the actual header for the C module, that should come in at the same time that appears to not be present.

I’m not trying to make the case that if it would compile it would work, or even that it will link and find all the needed pieces, but… why is it that it can’t find the header it just included?

because the MCU platform it is using doesn’t have it. The project you are using has a long list of dependencies. The platform (specific tuya devices) does support at least one of them. The project you are using (from GitHub) doesn’t indicate what it works with, but looking at the code it appears to support both eps8266 and esp32. You are not using either of those, and it doesn’t work. The platform you are using appears to have no SNMP support at all. It might be possible to port the SNMP code from a different platform over to this one, but it seems no one has done that already.

Maybe I’m just dense. Thanks for trying to explain.

But please realize this project IS the snmp support. There’s no built in SNMP support in either esp32 or esp8266 as far as I can find, the project does all the implementation for a limited agent, dependent primarily on the wifi networking existing.

Anyway, I guess the main point is it doesn’t work, so I need to not try to use it.

Thanks for trying.

Linwood

not true. The repo is providing a link to SNMP from esphome. It does NOT implement SNMP. It leaves that to one of its dependencies.

It is likely that the repo you included is using this: GitHub - 0neblock/Arduino_SNMP: SNMP Agent built with Arduino

And here is the issue (no resolution) for your problem: fatal error: SNMP_Agent.h: No such file or directory · Issue #2 · aquaticus/esphome-snmp · GitHub

And, here is the code that shows it will not work for you:

    if CORE.is_esp8266 or CORE.is_esp32:
        cg.add_library(r"https://github.com/aquaticus/Arduino_SNMP.git", "2.1.0")

To be clear, the repo code could do a better job of being clear that it ONLY works with esp chips AND provide a clear message when you try and use it with something else.

One of the reasons there has been a push to external components is that they provide a mechanism for making it clear they won’t work when something is not quite right. But, the documentation on creating external components is not complete enough for most people to follow. There are quite a few places where it essentially says, “it’s a mystery, go read the code to figure it out”. That is a very steep learning curve, more like a high brick wall you have to scale.

I am sorry. You are absolutely correct (but you knew that didn’t you :laughing:).

For reasons lost on me I kept reading that SNMP_Agent.h was not found and that the project was providing SNMP_Agent.h. But the project provides snmp_component.h, not SNMP_Agent.h.

Sigh.

I wish I could claim not to be able to read C, but the problem is my memory doesn’t last the time it takes to go from one screen to the other.

Thank you for banging me beside the head hard enough it would finally sink in.

The author could have done a little better job of mentioning it relied on other SNMP code. But the fault is my failure to pay attention.

Thank you.

Linwood

Maybe you should ask on the LibreTiny Github if the Beken chips support SNMP.

Thanks. I’m thinking I may just remove it. There’s not a whole lot there I can’t do with either just ping checks, or tests in Home Assistant. I trust Zabbix more than home assistant (in terms of always up and reporting).

But yes, I can chase it there, and probably other places I’ll run into if I worked through every device. Thanks for the pointer though to where to look.