Skip to content

Commit

Permalink
Usage - send data
Browse files Browse the repository at this point in the history
  • Loading branch information
netmindz committed Dec 3, 2024
1 parent 467f2e4 commit cc6de12
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions usermods/Usage/usermod_usage.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,22 @@ class UsageUsermod : public Usermod {
void loop() override {
// if usermod is disabled or called during strip updating just exit
// NOTE: on very long strips strip.isUpdating() may always return true so update accordingly
if (!enabled || strip.isUpdating()) return;
if(!isConnected) return;

if (millis() - lastTime > 1000) { // TODO: set interval
//Serial.println("I'm alive!");
lastTime = millis();

usagePacket.uptime = millis() / 1000;
usagePacket.totalLEDs = strip.getLengthTotal();
usagePacket.isMatrix = strip.isMatrix;
}
}
if (!enabled || strip.isUpdating()) return;
if(!isConnected) return;

if (millis() - lastTime > 1000) {
lastTime = millis();
usagePacket.uptime = 123; //millis(); // / 1000;
usagePacket.totalLEDs = 456; //strip.getLengthTotal();
usagePacket.isMatrix = strip.isMatrix;

if(wifiUDP.beginPacket(IPAddress(192, 168, 178, 50), port)) {
wifiUDP.write(reinterpret_cast<uint8_t *>(&usagePacket), sizeof(usagePacket));
wifiUDP.endPacket();
Serial.printf("Send usage packet to %s:%u\n", wifiUDP.remoteIP().toString().c_str(), wifiUDP.remotePort());
}
}
}

/*
* addToJsonInfo() can be used to add custom entries to the /json/info part of the JSON API.
Expand Down

0 comments on commit cc6de12

Please sign in to comment.