mirror of
https://github.com/Quill-OS/quill.git
synced 2024-10-31 21:33:22 -07:00
Telemetry: improvements
This commit is contained in:
parent
cc2af329d0
commit
0d8a8daddd
1 changed files with 13 additions and 6 deletions
|
@ -30,9 +30,7 @@ QJsonObject telemetry::collectDeviceInformation() {
|
||||||
bool telemetry::sendDeviceInformation(QJsonObject data) {
|
bool telemetry::sendDeviceInformation(QJsonObject data) {
|
||||||
log("Telemetry data to be sent to server: " + QJsonDocument(data).toJson(QJsonDocument::Compact), className);
|
log("Telemetry data to be sent to server: " + QJsonDocument(data).toJson(QJsonDocument::Compact), className);
|
||||||
|
|
||||||
// NOTE: This URL *will* change in the future
|
QNetworkRequest request(QUrl("http://23.163.0.39:4317/"));
|
||||||
// TODO: Add error-handling
|
|
||||||
QNetworkRequest request(QUrl("http://192.168.3.1:8080/"));
|
|
||||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
||||||
|
|
||||||
QNetworkAccessManager nam;
|
QNetworkAccessManager nam;
|
||||||
|
@ -42,8 +40,14 @@ bool telemetry::sendDeviceInformation(QJsonObject data) {
|
||||||
}
|
}
|
||||||
QByteArray responseData = reply->readAll();
|
QByteArray responseData = reply->readAll();
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
|
QString responseDataQstring = QString(responseData);
|
||||||
|
log("Telemetry server's response data was: '" + responseDataQstring + "'", className);
|
||||||
|
if(responseDataQstring != "Data received successfully") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void telemetry::telemetrySlot() {
|
void telemetry::telemetrySlot() {
|
||||||
|
@ -51,6 +55,9 @@ void telemetry::telemetrySlot() {
|
||||||
if(sendDeviceInformation(data)) {
|
if(sendDeviceInformation(data)) {
|
||||||
writeFile("/mnt/onboard/.adds/inkbox/.config/24-telemetry/asked", "true");
|
writeFile("/mnt/onboard/.adds/inkbox/.config/24-telemetry/asked", "true");
|
||||||
writeFile("/mnt/onboard/.adds/inkbox/.config/24-telemetry/enabled", "true");
|
writeFile("/mnt/onboard/.adds/inkbox/.config/24-telemetry/enabled", "true");
|
||||||
showToast("Data successfully sent\nThank you!");
|
showToast("Data sent successfully\nThank you!");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
showToast("Error while sending data");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue