void Settings::sendSysInfo()
{
	if ( debug )
		{
			Serial.println ( "[I] Getting sysinfo json" );
		}
		
	sendHeader ( 200, "text/json", getSysInfoSize () );
	String  json = "{";
	json += "\"freememory\":\"" + ( String ) ESP.getFreeHeap () + "\",";
	json += "\"deauthpackets\":\"" + ( String ) deauthpackets + "\",";
	json += "\"beaconpackets\":\"" + ( String ) beaconpackets + "\",";
	json += "\"uptime\":\"" + ( String ) millis () + "\",";
	json += "\"ipaddress\":\"" + ( String ) WiFi.localIP ().toString () + "\",";
	json += "\"gateway\":\"" + ( String ) WiFi.gatewayIP ().toString () + "\",";
	json += "\"bootmode\":\"" + ( String ) ESP.getBootMode () + "\",";
	json += "\"bootversion\":\"" + ( String ) ESP.getBootVersion () + "\",";
	json += "\"sdkversion\":\"" + ( String ) ESP.getSdkVersion () + "\",";
	json += "\"chipid\":\"" + ( String ) ESP.getChipId () + "\",";
	json += "\"flashchipid\":\"" + ( String ) ESP.getFlashChipId () + "\",";
	json += "\"flashchipsize\":\"" + ( String ) ESP.getFlashChipSize () + "\",";
	json += "\"flashchiprealsize\":\"" +
		( String ) ESP.getFlashChipRealSize () +
		"\"}";
	sendToBuffer ( json );
	sendBuffer ();
	
	if ( debug )
		{
			Serial.println ( "\n[+] Done" );
		}
}
void Settings::send()
{
	if ( debug )
		{
			Serial.println ( "[I] Getting settings json" );
		}
		
	sendHeader ( 200, "text/json", getSize () );
	String  json = "{";
	json += "\"ssid\":\"" + ssid + "\",";
	json += "\"ssidHidden\":" + ( String ) ssidHidden + ",";
	json += "\"password\":\"" + password + "\",";
	json += "\"apChannel\":" + ( String ) apChannel + ",";
	json += "\"wifiClient\":" + ( String ) wifiClient + ",";
	json += "\"ssidClient\":\"" + ( String ) ssidClient + "\",";
	json += "\"passwordClient\":\"" + ( String ) passwordClient + "\",";
	json += "\"hostname\":\"" + ( String ) hostname + "\",";
	json += "\"macAp\":\"" + macAP.toString () + "\",";
	json += "\"randMacAp\":" + ( String ) isMacAPRand + ",";
	json += "\"apScanHidden\":" + ( String ) apScanHidden + ",";
	json += "\"deauthReason\":" + ( String ) ( int ) deauthReason + ",";
	json += "\"attackTimeout\":" + ( String ) attackTimeout + ",";
	json += "\"attackPacketRate\":" + ( String ) attackPacketRate + ",";
	json += "\"clientScanTime\":" + ( String ) clientScanTime + ",";
	json += "\"useLed\":" + ( String ) useLed + ",";
	json += "\"channelHop\":" + ( String ) channelHop + ",";
	json += "\"multiAPs\":" + ( String ) multiAPs + ",";
	json += "\"multiAttacks\":" + ( String ) multiAttacks + ",";
	json += "\"macInterval\":" + ( String ) macInterval + ",";
	json += "\"beaconInterval\":" + ( String ) beaconInterval + ",";
	json += "\"ledPin\":" + ( String ) ledPin + ",";
	json += "\"darkMode\":" + ( String ) darkMode + ",";
	json += "\"cache\":" + ( String ) cache + ",";
	json += "\"serverCache\":" + ( String ) serverCache + ",";
	json += "\"newUser\":" + ( String ) newUser + ",";
	json += "\"detectorChannel\":" + ( String ) detectorChannel + ",";
	json += "\"detectorAllChannels\":" + ( String ) detectorAllChannels + ",";
	json += "\"alertPin\":" + ( String ) alertPin + ",";
	json += "\"invertAlertPin\":" + ( String ) invertAlertPin + ",";
	json += "\"detectorScanTime\":" + ( String ) detectorScanTime + ",";
	json += "\"pins\":\"" + ( String ) pins + "\",";
	json += "\"pinNames\":\"" + ( String ) pinNames + "\"}";
	sendToBuffer ( json );
	sendBuffer ();
	
	if ( debug )
		{
			Serial.println ( "\ndone" );
		}
}
void Attack::sendResults(){
  size_t _size = getSize();
  if (debug) Serial.print("getting attacks JSON ("+(String)_size+")...");
  sendHeader(200, "text/json", _size);

  String json = "{\"aps\":[";
  
  int _selected = 0;
  for (int i = 0; i < apScan.results; i++) {
    if (apScan.isSelected(i)) {
      json += "\"" + apScan.getAPName(i) + "\",";
      _selected++;
    }
  }
  if (_selected > 0) json.remove(json.length() - 1);
  sendToBuffer(json);

  
  json = "],\"clients\":[";

  _selected = 0;
  for (int i = 0; i < clientScan.results; i++) {
    if (clientScan.getClientSelected(i)) {
      json += "\"" + clientScan.getClientMac(i).toString() + " " + clientScan.getClientVendor(i) + " - " + clientScan.getClientName(i) + "\",";
      _selected++;
    }
  }
  if (_selected == 0) json += "\"FF:FF:FF:FF:FF:FF - BROADCAST\"";
  else json.remove(json.length() - 1);

  sendToBuffer(json);

  json = "],\"attacks\":[";
  for (int i = 0; i < attacksNum; i++) {
    json += "{";
    json += "\"name\":\"" + attackNames[i] + "\",";
    json += "\"status\":\"" + stati[i] + "\",";
    json += "\"running\":" + (String)isRunning[i] + "";
    json += "}";
    if (i != attacksNum - 1) json += ",";
  }
  json += "],";
  sendToBuffer(json);
  
  if(ssidChange){
    json = "\"ssid\":[";
    sendToBuffer(json);
    for (int i = 0; i < ssidList.len; i++) {
      json = "[";
      json += "\"" + ssidList.get(i) + "\",";
      json += (String)ssidList.isEncrypted(i) + "";
      json += "]";
      if (i != ssidList.len - 1) json += ",";
      sendToBuffer(json);
    }
    json = "],";
    sendToBuffer(json);
    ssidChange = false;
  }
  
  json = "\"randomMode\":" + (String)randomMode + "}";
  sendToBuffer(json);
  
  sendBuffer();
  if (debug) Serial.println("done");
}