Skip to content

Commit

Permalink
update telemetry and fix compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
o0shojo0o committed Aug 22, 2022
1 parent b12ca08 commit 7309a6d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
28 changes: 21 additions & 7 deletions src/PixelIt.ino
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ WiFiClient espClient;
WiFiUDP udp;
PubSubClient client(espClient);
WiFiManager wifiManager;
HttpClient httpClient = HttpClient(espClient, serverAddress, serverPort);
#if defined(ESP8266)
ESP8266WebServer server(80);
ESP8266HTTPUpdateServer httpUpdater;
Expand Down Expand Up @@ -1121,7 +1120,7 @@ void CreateFrames(JsonObject &json)

// Sometimes, mp3Player gets hickups. A brief delay might help - but also might hinder scrolling.
// So, do it only if there are more commands to come.
if (json["sound"]["control"].asString() > "")
if (json["sound"]["control"].as<String>() == "")
{
Log(F("Sound"), F("Changing volume can prevent DFPlayer from executing a control command at the same time. Better make two separate API calls."));
delay(200);
Expand Down Expand Up @@ -1722,19 +1721,36 @@ String GetButtons()
return json;
}

String GetTelemetry()
void SendTelemetry()
{
const String MatrixTypeNames[] = {"Colum major", "Row major", "Tiled 4x 8x8 CJMCU", "MicroMatrix"};
const String TempSensorNames[] = {"none", "BME280", "DHT", "BME680", "BMP280"};
const String LuxSensorNames[] = {"LDR", "BH1750", "Max44009"};

DynamicJsonBuffer jsonBuffer;
JsonObject &root = jsonBuffer.createObject();

root["uuid"] = sha1(GetChipID());
root["version"] = VERSION;
root["type"] = isESP8266 ? "esp8266" : "esp32";

JsonObject &matrix = root.createNestedObject("matrix");
matrix["type"] = matrixType;
matrix["name"] = MatrixTypeNames[matrixType - 1];

JsonArray &sensors = root.createNestedArray("sensors");
sensors.add(LuxSensorNames[luxSensor]);
if (tempSensor > 0)
{
sensors.add(TempSensorNames[tempSensor]);
}

String json;
root.printTo(json);

return json;
HttpClient httpClient = HttpClient(espClient, serverAddress, serverPort);
httpClient.sendHeader("User-Agent", "PixelIt");
httpClient.post("/api/telemetry", "application/json", json);
}

/////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -3214,9 +3230,7 @@ void setup()

if (sendTelemetry == true)
{
Log(F("Setup"), F("Telemetry send"));
httpClient.sendHeader("User-Agent", "PixelIt");
httpClient.post("/api/telemetry", "application/json", GetTelemetry());
SendTelemetry();
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/Tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ boolean IsSummertime(int year, byte month, byte day, byte hour, byte clockTimeZo
{
return true; // Sommerzeit in Apr, Mai, Jun, Jul, Aug, Sep
}
if (month == 3 && (hour + 24 * day) >= (1 + clockTimeZone + 24 * (31 - (5 * year / 4 + 4) % 7)) || month == 10 && (hour + 24 * day) < (1 + clockTimeZone + 24 * (31 - (5 * year / 4 + 1) % 7)))
//if (month == 3 && (hour + 24 * day) >= (1 + clockTimeZone + 24 * (31 - (5 * year / 4 + 4) % 7)) || month == 10 && (hour + 24 * day) < (1 + clockTimeZone + 24 * (31 - (5 * year / 4 + 1) % 7)))
if ((month == 3 && (hour + 24 * day) >= (1 + clockTimeZone + 24 * (31 - (5 * year / 4 + 4) % 7))) || (month == 10 && (hour + 24 * day) < (1 + clockTimeZone + 24 * (31 - (5 * year / 4 + 1) % 7))))
{
return true;
}
Expand Down

0 comments on commit 7309a6d

Please sign in to comment.