add power statistics for #635

1.2-legacy
Charles Crossan 2021-01-11 20:25:02 -05:00
rodzic 7a381eaea1
commit fdc9bf5783
1 zmienionych plików z 9 dodań i 1 usunięć

Wyświetl plik

@ -1,6 +1,7 @@
#include "mesh/wifi/WebServer.h"
#include "NodeDB.h"
#include "PowerFSM.h"
#include "power.h"
#include "airtime.h"
#include "main.h"
#include "mesh/wifi/ContentHelper.h"
@ -1169,7 +1170,14 @@ void handleReport(HTTPRequest *req, HTTPResponse *res)
res->println("},");
res->println("\"test\": 123");
res->println("\"power\": {");
#define BoolToString(x) ((x)?"true":"false")
res->printf("\"battery_percent\": %u,\n", powerStatus->getBatteryChargePercent());
res->printf("\"battery_voltage_mv\": %u,\n", powerStatus->getBatteryVoltageMv());
res->printf("\"has_battery\": %s,\n", BoolToString(powerStatus->getHasBattery()));
res->printf("\"has_usb\": %s,\n", BoolToString(powerStatus->getHasUSB()));
res->printf("\"is_charging\": %s\n", BoolToString(powerStatus->getIsCharging()));
res->println("}");
res->println("},");