Skip to content

Source: MoonStatsModule.h

MoonStats

It owns what decides whether a report is built, building none itself and sending none.

Consent is the gate, and declining is silent: no connection opens and no identifier is computed.

Enumerations

Name Description
MoonStatsEvent What the report says happened, the first two automatic and the third a button press.

MoonStatsEvent

enum MoonStatsEvent

What the report says happened, the first two automatic and the third a button press.

Value Description
Install
Upgrade
Refresh

Functions

Return Name Description
bool readControl inline Read one control by name, so a rename drops the field rather than emitting its neighbor.
const MoonModule * findModule inline Find a module by name among the roots and their direct children.
void field inline Copy one named control into the report, omitting the key when the control is absent.
const char * factoryScriptOf inline The shipped script a module runs, or null for one a user wrote or none at all.
void reportModules inline Append every user-added enabled module, depth first, each as its role and name.
void buildMoonStatsReport inline

readControl

inline

inline bool readControl(const MoonModule * mod, const char * name, JsonSink & out)

Read one control by name, so a rename drops the field rather than emitting its neighbor.


findModule

inline

inline const MoonModule * findModule(MoonModule *const * root, uint8_t count, const char * name)

Find a module by name among the roots and their direct children.


field

inline

inline void field(JsonSink & sink, const MoonModule * mod, const char * control, const char * key, bool & first)

Copy one named control into the report, omitting the key when the control is absent.


factoryScriptOf

inline

inline const char * factoryScriptOf(const MoonModule * m)

The shipped script a module runs, or null for one a user wrote or none at all.


reportModules

inline

inline void reportModules(JsonSink & sink, const MoonModule *const * mods, uint8_t count, bool & first)

Append every user-added enabled module, depth first, each as its role and name.


buildMoonStatsReport

inline

inline void buildMoonStatsReport(JsonSink & sink, MoonModule *const * root, uint8_t moduleCount, MoonStatsEvent event, const char * installationId, const char * version, const char * previousVersion, uint32_t lightCount = 0, uint32_t totalHeap = 0, uint32_t freeHeap = 0, uint32_t fps = 0)

MoonStatsModule

class MoonStatsModule
src/core/system/MoonStatsModule.h:200

Inherits: MoonModule

Public Methods

inline void setup() override : Read the running version, then publish the consent explanation.

inline void refreshStatus() : Say what this setting exchanges, on the status slot rather than in a control of its own.

inline void onControlChanged(const char * name) override : Refresh the explanation on a consent change, and send on the button.

inline void defineControls() override : Declare the consent, the two version readouts and the send button.

inline bool reportDue() const : Whether a report is due: consent given, and the running version differs from the reported.

inline MoonStatsEvent dueEvent() const : Which kind of report is due.

inline const char * previousVersion() const : The version being replaced, for an upgrade report, or nullptr on a fresh install.

inline void markReported() : Record that a report was sent, on hand-off rather than on success.

inline void setConsent(bool yes) : Record the user's answer, the same way a control write does.

inline bool consent() const : Whether the user has agreed to report.

inline void setRunningVersionForTest(const char * v) : Fake the running version, which setup reads from a constant a test cannot change.

inline void installationId(char * out) const : This installation's id, or empty without consent, so no caller can obtain one to log.

inline void tick1s() override : Send the automatic report once every guard below passes.

inline bool inApMode() const : Whether we serve our own access point, asked of the platform so no copy goes stale.

More info

The trigger is a version comparison rather than a timer. The reported version persists, so a reboot sends nothing and an upgrade sends one. An empty value means a fresh install and a different one an upgrade. No identifier is involved in telling those apart.

Reporting is suppressed in AP mode, where there is no route out. See the privacy policy for what is promised.