implemented sendAPResults by AP id

This commit is contained in:
tobozo
2017-03-04 13:01:13 +01:00
parent 2e5656cfba
commit fcb0e0dc49
3 changed files with 34 additions and 4 deletions

View File

@@ -140,6 +140,28 @@ String APScan::getResults(){
return json;
}
String APScan::getResult(int i){
if(debug) Serial.print("getting AP scan result JSON for ID " + String(i));
String json = "{ \"aps\":[ ";
if(debug) Serial.print(".");
json += "{";
json += "\"i\":"+(String)i+",";
json += "\"c\":"+(String)getAPChannel(i)+",";
json += "\"m\":\""+getAPMac(i)+"\",";
json += "\"ss\":\""+getAPName(i)+"\",";
json += "\"r\":"+(String)getAPRSSI(i)+",";
json += "\"e\":"+(String)encryption[i]+",";
//json += "\"v\":\""+getAPVendor(i)+"\",";
json += "\"se\":"+(String)getAPSelected(i);
json += "}";
json += "] }";
if(debug){
Serial.println(json);
Serial.println("done");
}
return json;
}
void APScan::select(int num){
if(debug) Serial.println("seect "+(String)num+" - "+!selected[num]);
if(selected[num]){
@@ -153,4 +175,4 @@ void APScan::select(int num){
bool APScan::isSelected(int num){
return selected[num];
}
}

View File

@@ -19,6 +19,7 @@ class APScan{
bool start();
String getResults();
String getResult(int i);
void select(int num);
String getAPName(int num);
@@ -48,4 +49,4 @@ class APScan{
bool selected[maxAPScanResults];
};
#endif
#endif

View File

@@ -136,7 +136,14 @@ void startAPScan(){
}
}
void sendAPResults(){ server.send ( 200, "text/json", apScan.getResults()); }
void sendAPResults(){
if(server.hasArg("apid")) {
int apid = server.arg("apid").toInt();
server.send ( 200, "text/json", apScan.getResult(apid));
} else {
server.send ( 200, "text/json", apScan.getResults());
}
}
void selectAP(){
if(server.hasArg("num")) {
@@ -273,4 +280,4 @@ void editClientName(){
server.send( 200, "text/json", "true");
}
}