pleasedontcode

WiFi Dashboard rev_03

Oct 28th, 2025
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: WiFi Dashboard
  13.     - Source Code NOT compiled for: ESP32 DevKit V1
  14.     - Source Code created on: 2025-10-29 01:23:26
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* no need any push button and create code for esp32 */
  21.     /* c6 dev module and webserver for control and all */
  22.     /* serial monitor as primery status reciver */
  23. /****** END SYSTEM REQUIREMENTS *****/
  24.  
  25.  
  26.  
  27.  
  28. /* START CODE */
  29.  
  30. // Include the WiFi library for network functionalities
  31. #include <WiFi.h>
  32.  
  33. // Function prototypes
  34. void setup(void);
  35. void loop(void);
  36.  
  37. // WiFi credentials and server setup
  38. const char* ssid = "";
  39. const char* password = "";
  40.  
  41. // Web server at port 80
  42. WiFiServer server(80);
  43.  
  44. // Variable to hold the latest serial message
  45. String serialStatus = "";
  46.  
  47. void setup() {
  48.   Serial.begin(115200); // Initialize serial communication at 115200 baud rate
  49.   WiFi.mode(WIFI_STA); // Set WiFi to station mode
  50.   delay(100); // Short delay to initialize WiFi
  51.   Serial.println("Starting Wi-Fi jammer..."); // Indicate start
  52.  
  53.   // ESP32 WiFi channel configuration
  54.   // Note: The below code sets WiFi channel to 6
  55.   // Proper channel setting may require low-level WiFi init (not shown here fully)
  56.   // or using WiFi configuration functions if supported
  57.   // Here, assuming default channel setting, as direct channel setting is complex in Arduino SDK
  58.  
  59.   // Connect to WiFi network
  60.   WiFi.begin(ssid, password);
  61.   while (WiFi.status() != WL_CONNECTED) {
  62.     delay(500);
  63.     Serial.print(".");
  64.   }
  65.   Serial.println("\nWiFi connected");
  66.   Serial.println("IP address: ");
  67.   Serial.println(WiFi.localIP());
  68.  
  69.   // Start the server
  70.   server.begin();
  71. }
  72.  
  73. void loop() {
  74.   // Read serial monitor status
  75.   if (Serial.available()) {
  76.     serialStatus = Serial.readStringUntil('\n');
  77.   }
  78.   // Check if a client has connected
  79.   WiFiClient client = server.available();
  80.   if (client) {
  81.     Serial.println("New Client.");
  82.     String currentLine = "";
  83.     while (client.connected()) {
  84.       if (client.available()) {
  85.         char c = client.read();
  86.         Serial.write(c);
  87.         if (c == '\n') {
  88.           // if the current line is blank, you got two newline characters in a row.
  89.           if (currentLine.length() == 0) {
  90.             // send a standard HTTP response
  91.             client.println("HTTP/1.1 200 OK");
  92.             client.println("Content-type:text/html");
  93.             client.println(); // end HTTP headers
  94.             client.println("<html>");
  95.             client.println("<head><title>ESP32 WiFi Jammer Control</title></head>");
  96.             client.println("<body><h1>Control the WiFi Jammer</h1>");
  97.             client.println("<p>Status from Serial Monitor: ");
  98.             client.println(serialStatus);
  99.             client.println("</p>");
  100.             client.println("</body></html>");
  101.             break;
  102.           } else {
  103.             currentLine = "";
  104.           }
  105.         } else if (c != '\r') {
  106.           currentLine += c;
  107.         }
  108.       }
  109.     }
  110.     // close connection
  111.     client.stop();
  112.     Serial.println("Client Disconnected.");
  113.   }
  114. }
  115.  
  116. /* END CODE */
  117.  
Advertisement
Add Comment
Please, Sign In to add comment