MCPcopy Create free account
hub / github.com/SmingHub/Sming / onAjaxNetworkList

Function onAjaxNetworkList

samples/HttpServer_ConfigNetwork/app/application.cpp:100–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98}
99
100void onAjaxNetworkList(HttpRequest& request, HttpResponse& response)
101{
102 JsonObjectStream* stream = new JsonObjectStream(4096);
103 JsonObject json = stream->getRoot();
104
105 json["status"] = (bool)true;
106
107 bool connected = WifiStation.isConnected();
108 json["connected"] = connected;
109 if(connected) {
110 // Copy full string to JSON buffer memory
111 json["network"] = WifiStation.getSSID();
112 }
113
114 JsonArray netlist = json.createNestedArray("available");
115 for(auto nw : networks) {
116 if(nw->hidden) {
117 continue;
118 }
119 JsonObject item = netlist.createNestedObject();
120 item["id"] = nw->getHashId();
121 // Copy full string to JSON buffer memory
122 item["title"] = nw->ssid;
123 item["signal"] = nw->rssi;
124 item["encryption"] = nw->getAuthorizationMethodName();
125 }
126
127 response.setAllowCrossDomainOrigin("*");
128 response.sendDataStream(stream, MIME_JSON);
129}
130
131void makeConnection()
132{

Callers

nothing calls this directly

Calls 7

getRootMethod · 0.80
getHashIdMethod · 0.80
isConnectedMethod · 0.45
getSSIDMethod · 0.45
sendDataStreamMethod · 0.45

Tested by

no test coverage detected