Include information about versions and WiFi connection to controller's json.
This commit is contained in:
parent
196021bef5
commit
001e275131
4
include/main.h
Normal file
4
include/main.h
Normal file
@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
extern uint16_t spiffs_version;
|
||||
void wifi_connect();
|
@ -377,6 +377,23 @@ String Controller::json() {
|
||||
rfid["data"] = _last_rfid_data;
|
||||
json["uptime"] = millis() / 1000;
|
||||
json["free_heap"] = ESP.getFreeHeap();
|
||||
JsonObject versions = json.createNestedObject("versions");
|
||||
versions["spiffs"] = spiffs_version;
|
||||
versions["ota"] = OTA_VERSION;
|
||||
#ifdef VERSION
|
||||
versions["release"] = VERSION;
|
||||
#else
|
||||
versions["release"] = "unknown";
|
||||
#endif
|
||||
|
||||
JsonObject wifi = json.createNestedObject("wifi");
|
||||
if (WiFi.isConnected()) {
|
||||
wifi["connected"] = true;
|
||||
wifi["ssid"] = WiFi.SSID();
|
||||
wifi["rssi"] = WiFi.RSSI();
|
||||
} else {
|
||||
wifi["connected"] = false;
|
||||
}
|
||||
return json.as<String>();
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,8 @@ HTTPServer* http_server;
|
||||
|
||||
uint8_t SPIMaster::state = 0;
|
||||
|
||||
uint16_t spiffs_version = 0;
|
||||
|
||||
bool connect_to_wifi(String ssid, String pass) {
|
||||
TRACE("Connecting to wifi \"%s\"...\n", ssid.c_str());
|
||||
WiFi.mode(WIFI_AP_STA);
|
||||
@ -100,7 +102,6 @@ void setup() {
|
||||
spi->select_sd(false);
|
||||
|
||||
DEBUG("Starting SPIFFS...\n");
|
||||
uint16_t spiffs_version = 0;
|
||||
SPIFFS.begin(true);
|
||||
if (SPIFFS.exists("/_version.txt")) {
|
||||
File f = SPIFFS.open("/_version.txt", "r");
|
||||
|
Loading…
Reference in New Issue
Block a user