pleasedontcode

Network Monitor rev_01

Oct 28th, 2025
248
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: Network Monitor
  13.     - Source Code NOT compiled for: ESP32 DevKit V1
  14.     - Source Code created on: 2025-10-29 01:07:23
  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. /* START CODE */
  27.  
  28. // Include the WiFi library for network functionalities
  29. #include <WiFi.h>
  30.  
  31. // Function prototypes
  32. void setup(void);
  33. void loop(void);
  34.  
  35. // WiFi credentials and server setup
  36. const char* ssid = "";
  37. const char* password = "";
  38.  
  39. // Web server at port 80
  40. WiFiServer server(80);
  41.  
  42. // Variable to hold the latest serial message
  43. String serialStatus = "";
  44.  
  45. void setup() {
  46.   Serial.begin(115200); // Initialize serial communication at 115200 baud rate
  47.   WiFi.mode(WIFI_STA); // Set WiFi to station mode
  48.   delay(100); // Short delay to initialize WiFi
  49.   Serial.println("Starting Wi-Fi jammer..."); // Indicate start
  50.  
  51.   // ESP32 WiFi channel configuration
  52.   // Note: The below code sets WiFi channel to 6
  53.   // Proper channel setting may require low-level WiFi init (not shown here fully)
  54.   // or using WiFi configuration functions if supported
  55.   // Here, assuming default channel setting, as direct channel setting is complex in Arduino SDK
  56.  
  57.   // Connect to WiFi network
  58.   WiFi.begin(ssid, password);
  59.   while (WiFi.status() != WL_CONNECTED) {
  60.     delay(500);
  61.     Serial.print(".");
  62.   }
  63.   Serial.println("\nWiFi connected");
  64.   Serial.println("IP address: ");
  65.   Serial.println(WiFi.localIP());
  66.  
  67.   // Start the server
  68.   server.begin();
  69. }
  70.  
  71. void loop() {
  72.   // Read serial monitor status
  73.   if (Serial.available()) {
  74.     serialStatus = Serial.readStringUntil('\n');
  75.   }
  76.   // Check if a client has connected
  77.   WiFiClient client = server.available();
  78.   if (client) {
  79.     Serial.println("New Client.");
  80.     String currentLine = "";
  81.     while (client.connected()) {
  82.       if (client.available()) {
  83.         char c = client.read();
  84.         Serial.write(c);
  85.         if (c == '\n') {
  86.           // if the current line is blank, you got two newline characters in a row.
  87.           if (currentLine.length() == 0) {
  88.             // send a standard HTTP response
  89.             client.println("HTTP/1.1 200 OK");
  90.             client.println("Content-type:text/html");
  91.             client.println(); // end HTTP headers
  92.             client.println("<html>");
  93.             client.println("<head><title>ESP32 WiFi Jammer Control</title></head>");
  94.             client.println("<body><h1>Control the WiFi Jammer</h1>");
  95.             client.println("<p>Status from Serial Monitor: ");
  96.             client.println(serialStatus);
  97.             client.println("</p>");
  98.             client.println("</body></html>");
  99.             break;
  100.           } else {
  101.             currentLine = "";
  102.           }
  103.         } else if (c != '\r') {
  104.           currentLine += c;
  105.         }
  106.       }
  107.     }
  108.     // close connection
  109.     client.stop();
  110.     Serial.println("Client Disconnected.");
  111.   }
  112. }
  113.  
  114. /* END CODE */
  115.  
Advertisement
Add Comment
Please, Sign In to add comment