From 621306e610fe3490ce0ec2b8cc3ae95a5cf0c20f Mon Sep 17 00:00:00 2001 From: Jm Date: Sun, 27 Dec 2020 15:03:32 -0800 Subject: [PATCH] Add IP address and rssi to /json/report --- platformio.ini | 4 ++-- src/meshwifi/meshhttp.cpp | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/platformio.ini b/platformio.ini index 50d381c8..14e6ddbd 100644 --- a/platformio.ini +++ b/platformio.ini @@ -38,8 +38,8 @@ build_flags = -Wno-missing-field-initializers -Isrc -Isrc/mesh -Isrc/gps -Ilib/n ;upload_port = /dev/ttyUSB0 ;monitor_port = /dev/ttyUSB0 -;upload_port = /dev/cu.SLAB_USBtoUART -;monitor_port = /dev/cu.SLAB_USBtoUART +upload_port = /dev/cu.SLAB_USBtoUART +monitor_port = /dev/cu.SLAB_USBtoUART ; the default is esptool ; upload_protocol = esp-prog diff --git a/src/meshwifi/meshhttp.cpp b/src/meshwifi/meshhttp.cpp index 851499a0..d6d2e22b 100644 --- a/src/meshwifi/meshhttp.cpp +++ b/src/meshwifi/meshhttp.cpp @@ -1117,8 +1117,20 @@ void handleReport(HTTPRequest *req, HTTPResponse *res) res->println("},"); - res->println("\"something\": 123,"); - res->println("\"something_else\": 123"); + res->println("\"wifi\": {"); + + res->println("\"rssi\": " + String(WiFi.RSSI()) + ","); + + if (radioConfig.preferences.wifi_ap_mode || isSoftAPForced()) { + res->println("\"ip\": \"" + String(WiFi.softAPIP().toString().c_str()) + "\""); + } else { + res->println("\"ip\": \"" + String(WiFi.localIP().toString().c_str()) + "\""); + } + + + res->println("},"); + + res->println("\"test\": 123"); res->println("},");