Stat system want to return integer #mcumgr

Vince Mulhollon

I have what's probably a very simple question about the stats system, and likely only need a tiny additional kick in the right direction.

What works:

I have stats working for telemetry purposes (counting missed sensor polls, interesting hardware events, that kind of thing).  I have multiple stats and I can clear them, increment them, set them to an arbitrary value.  I can view my stats by telnet into a shell.  I can view my stats by using mcumgr both over serial and over UDP network.  And it works great, and its simple, reliable, and easy to use.

What doesn't work:

There doesn't seem to be anything documented or example code or any terribly obvious getter function or macro to return a stat.  I'm gathering the missed sensor poll counts anyway; would be nice to output the same data in a MQTT packet or print to a LCD display.  The stat system does not do that out of the box, no problem I can send MQTT packets or do LCD stuff all day IF I have an int to output.  So where do I get that int?  Obviously I could replicate the stats system outside the stats system and everywhere I run a STATS_INC for mcumgr I could simultaneously run a some_var++; but that seems a waste to have two counters counting the same hardware event separately for multiple outputs.

/* I want to know the code that performs similar to this in very general concept */
uint32_t missed_sensor_poll_count = STATS_GETTER_UINT32(sensor_group, missed_poll_counts)

Maybe rephrased I'm saying I'm very familiar with the STATS_SET macro and it works great, now where is the STATS_GET macro?

Thanks for your time.  I fear I'm missing something terribly obvious and the harder I stare at the problem the harder it is to see, as it usually goes LOL.

Join to automatically receive all group messages.