Repository navigation
feat(companion): add optional SNMP agent to the Wi-Fi companions - #4
Merged
Merged
Conversation
Port the SNMPv2c agent from the Dutch-MeshCore observer firmware to the Wi-Fi companion so monitoring tools can poll a companion the same way they poll an observer. Same enterprise subtree and .1/.2/.4/.5 layout, so one poller reads both; the observer's MQTT group is left out and companion-only values (clients, contacts, channels, RX air time) go in .6. Battery voltage is .1.4.0, added to the observer at the same time. Compile-flag gated (WITH_SNMP) and only enabled for heltec_v4_companion_radio_usb_tcp and Heltec_v3_companion_radio_usb_tcp. Off by default at runtime: the agent is not allocated until `set snmp on`, so a build that leaves it off costs flash only. Settings live in NVS beside the Wi-Fi settings, so the NodePrefs layout is unchanged, and apply live without a reboot. Size vs the same tree without the flag: V3 +33,556 B flash, +336 B static RAM; V4 +33,340 B flash, +344 B static RAM. Not yet tested on hardware.
This was referenced Oct 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Ports the SNMPv2c agent from the Dutch-MeshCore observer firmware (
dmc-observer-dev) to the Wi-Fi companion. Read-only GET/GETNEXT/GETBULK on UDP 161.examples/companion_radio/CompanionSNMP.{h,cpp}(new): the agent, its OID table and thesnmpCLI commands. The whole file compiles to nothing withoutWITH_SNMP.src/helpers/esp32/WifiRuntimeStore.{h,cpp}:snmp_en(default off) andsnmp_comm(defaultpublic) in the existing NVS namespace.examples/companion_radio/main.cpp: one call per loop, only when Wi-Fi was brought up this session (same rule as the TCP server).examples/companion_radio/MyMesh.cpp: one hook inhandleCommand.src/helpers/esp32/MultiTransportCompanionInterface.h:getTcpConnectedCount()accessor.variants/heltec_v3,variants/heltec_v4,variants/heltec_wireless_paper,variants/xiao_s3_wio:-D WITH_SNMP=1and0neblock/SNMP_Agent @ 2.1.0onHeltec_v3_companion_radio_usb_tcp(and its_boot_debugchild),heltec_v4_companion_radio_usb_tcp,Heltec_Wireless_Paper_companion_radio_usb_tcpandXiao_S3_WIO_companion_radio_usb_tcp.docs/companion_snmp.md(new): commands, OID reference, sizes, how to add it to another env.Why
So monitoring tools (LibreNMS, Zabbix, RTFM-EV's SNMP poller) can poll a companion the same way they poll an observer.
Notes for review
set snmp onallocates the agent and binds UDP 161; until then nothing is allocated. Settings apply live, no reboot. They live in NVS, so the binary NodePrefs layout is untouched.1.3.6.1.4.1.99999) and the same.1system,.2radio,.4memory and.5network layout as the observer, so one poller reads both. The observer's.3MQTT group is left out. Companion-only values go in.6: TCP clients, WebSocket clients, contacts, channels, RX air time..1.4.0(mV). It was added to the observer agent at the same time: feat(snmp): battery, MCU temperature, reset reason, mesh, filter and duty gate OIDs Dutch-MeshCore/MeshCore#16.WIFI_OFF.get snmp.communityis refused over remote CLI, likeget wifi.pwd.How it was tested
pio runwithDISABLE_DEBUG=1, baseline (main) vs this branch:Heltec_v3_companion_radio_usb_tcpheltec_v4_companion_radio_usb_tcpHeltec_Wireless_Paper_companion_radio_usb_tcpXiao_S3_WIO_companion_radio_usb_tcpAll four build with no new warnings. Paper and Xiao start from about 40 KB more static RAM than the V3, so they are the ones to watch for free heap on hardware. Not yet tested on hardware: no
snmpwalkagainst a running companion, and runtime heap with Wi-Fi, BLE and the agent all up is not measured yet (the[snmp] agent upserial line prints free heap when it starts).Firmware and build impact
Only the four envs above change. Adds one library dependency to them. No prefs, protocol or OTA naming change. No version bump.
No issue to close.