photontelemetry: publish events, ignoring duplicates
This commit is contained in:
parent
354b72f160
commit
15682ae9d2
@ -54,7 +54,6 @@ PhotonTelemetry::loop()
|
||||
void
|
||||
PhotonTelemetry::handleEvent(const InputEvent &evt)
|
||||
{
|
||||
m_lastEvent = evt;
|
||||
if (evt.intent == InputEvent::NetworkStatus) {
|
||||
onConnected();
|
||||
}
|
||||
@ -118,8 +117,17 @@ PhotonTelemetry::handleEvent(const InputEvent &evt)
|
||||
char buf[255];
|
||||
snprintf(buf, sizeof(buf), "{\"intent\": \"%s\", \"value\": %s}", sourceName, valueBuf);
|
||||
if (m_online) {
|
||||
if (evt.intent != m_lastEvent.intent) {
|
||||
if (m_duplicateEvents > 0) {
|
||||
Log.info("Suppressed reporting %d duplicate events.", m_duplicateEvents);
|
||||
}
|
||||
Log.info("Event: %s", buf);
|
||||
m_duplicateEvents = 0;
|
||||
m_lastEvent = evt;
|
||||
Particle.publish("renderbug/event", buf, PRIVATE);
|
||||
} else {
|
||||
m_duplicateEvents++;
|
||||
}
|
||||
} else {
|
||||
Log.info("[offline] Event: %s", buf);
|
||||
}
|
||||
|
@ -12,12 +12,13 @@ private:
|
||||
|
||||
int m_frameIdx;
|
||||
String m_serviceList;
|
||||
InputEvent m_lastEvent;
|
||||
uint32_t m_currentBrightness;
|
||||
LEDStatus m_ledStatus = LEDStatus(0, LED_PATTERN_FADE, LED_SPEED_FAST);
|
||||
uint32_t m_rgbPulseFrame = 0;
|
||||
uint32_t m_pixelCount = 0;
|
||||
uint32_t m_startPixel = 0;
|
||||
uint32_t m_fps = 0;
|
||||
uint32_t m_duplicateEvents = 0;
|
||||
InputEvent m_lastEvent;
|
||||
bool m_online = false;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user