Datasheet
For the stat size, you can use one of the following values:
STATS_SIZE_16 -- stats are 16 bits (wraps at 65536)
STATS_SIZE_32 -- stats are 32 bits (wraps at 4294967296)
STATS_SIZE_64 -- stats are 64-bits
You then need to register the stats entry so that you can access it, which is done via the following function call:
Updating the Stats Values
Incrementing
To increment the stats values, you can use the STATS_INC or STATS_INCN macros, as shown below:
To increment the value a specific number use STATIS_INCN :
Accessing Stats with the Console or newtmgr
Console Access
Assuming that you have enabled named access to stats via STATS_NAME_ENABLE you can access your stats from the
console via:
The stats_init() and stats_register() function calls should occur AFTER the sysinit(); function!
rc = stats_init(
STATS_HDR(g_mystat),
STATS_SIZE_INIT_PARMS(g_mystat, STATS_SIZE_32),
STATS_NAME_INIT_PARMS(my_stat_section));
assert(rc == 0);
NOTE: The name below is the name that you will use when accessing the stats via the console or via the
newtmgr stat command
rc = stats_register("my_stats", STATS_HDR(g_mystat));
assert(rc == 0);
STATS_INC(g_mystat, attempt_stat);
rc = do_task();
if(rc == ERR) {
STATS_INC(g_mystat, error_stat);
}
STATS_INCN(g_mystat, attempt_stat, 5);
stat my_stats
© Adafruit Industries https://learn.adafruit.com/adafruit-nrf52-pro-feather Page 64 of 87










