mirror of
https://github.com/meshtastic/firmware.git
synced 2025-09-19 00:16:59 +00:00
Merge branch 'master' into use-ina-currentflow-for-charging-detection
This commit is contained in:
commit
4e4d46d07d
@ -93,6 +93,7 @@ void registerHandlers(HTTPServer *insecureServer, HTTPSServer *secureServer)
|
|||||||
ResourceNode *nodeJsonScanNetworks = new ResourceNode("/json/scanNetworks", "GET", &handleScanNetworks);
|
ResourceNode *nodeJsonScanNetworks = new ResourceNode("/json/scanNetworks", "GET", &handleScanNetworks);
|
||||||
ResourceNode *nodeJsonBlinkLED = new ResourceNode("/json/blink", "POST", &handleBlinkLED);
|
ResourceNode *nodeJsonBlinkLED = new ResourceNode("/json/blink", "POST", &handleBlinkLED);
|
||||||
ResourceNode *nodeJsonReport = new ResourceNode("/json/report", "GET", &handleReport);
|
ResourceNode *nodeJsonReport = new ResourceNode("/json/report", "GET", &handleReport);
|
||||||
|
ResourceNode *nodeJsonNodes = new ResourceNode("/json/nodes", "GET", &handleNodes);
|
||||||
ResourceNode *nodeJsonFsBrowseStatic = new ResourceNode("/json/fs/browse/static", "GET", &handleFsBrowseStatic);
|
ResourceNode *nodeJsonFsBrowseStatic = new ResourceNode("/json/fs/browse/static", "GET", &handleFsBrowseStatic);
|
||||||
ResourceNode *nodeJsonDelete = new ResourceNode("/json/fs/delete/static", "DELETE", &handleFsDeleteStatic);
|
ResourceNode *nodeJsonDelete = new ResourceNode("/json/fs/delete/static", "DELETE", &handleFsDeleteStatic);
|
||||||
|
|
||||||
@ -112,6 +113,7 @@ void registerHandlers(HTTPServer *insecureServer, HTTPSServer *secureServer)
|
|||||||
secureServer->registerNode(nodeJsonFsBrowseStatic);
|
secureServer->registerNode(nodeJsonFsBrowseStatic);
|
||||||
secureServer->registerNode(nodeJsonDelete);
|
secureServer->registerNode(nodeJsonDelete);
|
||||||
secureServer->registerNode(nodeJsonReport);
|
secureServer->registerNode(nodeJsonReport);
|
||||||
|
secureServer->registerNode(nodeJsonNodes);
|
||||||
// secureServer->registerNode(nodeUpdateFs);
|
// secureServer->registerNode(nodeUpdateFs);
|
||||||
// secureServer->registerNode(nodeDeleteFs);
|
// secureServer->registerNode(nodeDeleteFs);
|
||||||
secureServer->registerNode(nodeAdmin);
|
secureServer->registerNode(nodeAdmin);
|
||||||
@ -680,6 +682,78 @@ void handleReport(HTTPRequest *req, HTTPResponse *res)
|
|||||||
delete value;
|
delete value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void handleNodes(HTTPRequest *req, HTTPResponse *res)
|
||||||
|
{
|
||||||
|
ResourceParameters *params = req->getParams();
|
||||||
|
std::string content;
|
||||||
|
|
||||||
|
if (!params->getQueryParameter("content", content)) {
|
||||||
|
content = "json";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (content == "json") {
|
||||||
|
res->setHeader("Content-Type", "application/json");
|
||||||
|
res->setHeader("Access-Control-Allow-Origin", "*");
|
||||||
|
res->setHeader("Access-Control-Allow-Methods", "GET");
|
||||||
|
} else {
|
||||||
|
res->setHeader("Content-Type", "text/html");
|
||||||
|
res->println("<pre>");
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONArray nodesArray;
|
||||||
|
|
||||||
|
uint32_t readIndex = 0;
|
||||||
|
const meshtastic_NodeInfoLite *tempNodeInfo = nodeDB->readNextMeshNode(readIndex);
|
||||||
|
while (tempNodeInfo != NULL) {
|
||||||
|
if (tempNodeInfo->has_user) {
|
||||||
|
JSONObject node;
|
||||||
|
|
||||||
|
char id[16];
|
||||||
|
snprintf(id, sizeof(id), "!%08x", tempNodeInfo->num);
|
||||||
|
|
||||||
|
node["id"] = new JSONValue(id);
|
||||||
|
node["snr"] = new JSONValue(tempNodeInfo->snr);
|
||||||
|
node["via_mqtt"] = new JSONValue(BoolToString(tempNodeInfo->via_mqtt));
|
||||||
|
node["last_heard"] = new JSONValue((int)tempNodeInfo->last_heard);
|
||||||
|
node["position"] = new JSONValue();
|
||||||
|
|
||||||
|
if (nodeDB->hasValidPosition(tempNodeInfo)) {
|
||||||
|
JSONObject position;
|
||||||
|
position["latitude"] = new JSONValue((float)tempNodeInfo->position.latitude_i * 1e-7);
|
||||||
|
position["longitude"] = new JSONValue((float)tempNodeInfo->position.longitude_i * 1e-7);
|
||||||
|
position["altitude"] = new JSONValue((int)tempNodeInfo->position.altitude);
|
||||||
|
node["position"] = new JSONValue(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONObject user;
|
||||||
|
node["long_name"] = new JSONValue(tempNodeInfo->user.long_name);
|
||||||
|
node["short_name"] = new JSONValue(tempNodeInfo->user.short_name);
|
||||||
|
char macStr[18];
|
||||||
|
snprintf(macStr, sizeof(macStr), "%02X:%02X:%02X:%02X:%02X:%02X", tempNodeInfo->user.macaddr[0],
|
||||||
|
tempNodeInfo->user.macaddr[1], tempNodeInfo->user.macaddr[2], tempNodeInfo->user.macaddr[3],
|
||||||
|
tempNodeInfo->user.macaddr[4], tempNodeInfo->user.macaddr[5]);
|
||||||
|
node["mac_address"] = new JSONValue(macStr);
|
||||||
|
node["hw_model"] = new JSONValue(tempNodeInfo->user.hw_model);
|
||||||
|
|
||||||
|
nodesArray.push_back(new JSONValue(node));
|
||||||
|
}
|
||||||
|
tempNodeInfo = nodeDB->readNextMeshNode(readIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
// collect data to inner data object
|
||||||
|
JSONObject jsonObjInner;
|
||||||
|
jsonObjInner["nodes"] = new JSONValue(nodesArray);
|
||||||
|
|
||||||
|
// create json output structure
|
||||||
|
JSONObject jsonObjOuter;
|
||||||
|
jsonObjOuter["data"] = new JSONValue(jsonObjInner);
|
||||||
|
jsonObjOuter["status"] = new JSONValue("ok");
|
||||||
|
// serialize and write it to the stream
|
||||||
|
JSONValue *value = new JSONValue(jsonObjOuter);
|
||||||
|
res->print(value->Stringify().c_str());
|
||||||
|
delete value;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This supports the Apple Captive Network Assistant (CNA) Portal
|
This supports the Apple Captive Network Assistant (CNA) Portal
|
||||||
*/
|
*/
|
||||||
|
@ -13,6 +13,7 @@ void handleFsBrowseStatic(HTTPRequest *req, HTTPResponse *res);
|
|||||||
void handleFsDeleteStatic(HTTPRequest *req, HTTPResponse *res);
|
void handleFsDeleteStatic(HTTPRequest *req, HTTPResponse *res);
|
||||||
void handleBlinkLED(HTTPRequest *req, HTTPResponse *res);
|
void handleBlinkLED(HTTPRequest *req, HTTPResponse *res);
|
||||||
void handleReport(HTTPRequest *req, HTTPResponse *res);
|
void handleReport(HTTPRequest *req, HTTPResponse *res);
|
||||||
|
void handleNodes(HTTPRequest *req, HTTPResponse *res);
|
||||||
void handleUpdateFs(HTTPRequest *req, HTTPResponse *res);
|
void handleUpdateFs(HTTPRequest *req, HTTPResponse *res);
|
||||||
void handleDeleteFsContent(HTTPRequest *req, HTTPResponse *res);
|
void handleDeleteFsContent(HTTPRequest *req, HTTPResponse *res);
|
||||||
void handleFs(HTTPRequest *req, HTTPResponse *res);
|
void handleFs(HTTPRequest *req, HTTPResponse *res);
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
[env:buildroot]
|
[env:buildroot]
|
||||||
extends = portduino_base
|
extends = portduino_base
|
||||||
; The pkg-config commands below optionally add link flags.
|
; Optional libraries should be appended to `PLATFORMIO_BUILD_FLAGS`
|
||||||
; the || : is just a "or run the null command" to avoid returning an error code
|
; environment variable in the buildroot environment.
|
||||||
build_flags = ${portduino_base.build_flags} -O0 -I variants/portduino-buildroot
|
build_flags = ${portduino_base.build_flags} -O0 -I variants/portduino-buildroot
|
||||||
-std=c++17
|
-std=c++17
|
||||||
!pkg-config --libs libulfius --silence-errors || :
|
|
||||||
!pkg-config --libs openssl --silence-errors || :
|
|
||||||
board = buildroot
|
board = buildroot
|
||||||
lib_deps = ${portduino_base.lib_deps}
|
lib_deps = ${portduino_base.lib_deps}
|
||||||
build_src_filter = ${portduino_base.build_src_filter}
|
build_src_filter = ${portduino_base.build_src_filter}
|
||||||
|
Loading…
Reference in New Issue
Block a user