Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* Pleasedontcode.com **********
- Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- - Terms and Conditions:
- You have a non-exclusive, revocable, worldwide, royalty-free license
- for personal and commercial use. Attribution is optional; modifications
- are allowed, but you're responsible for code maintenance. We're not
- liable for any loss or damage. For full terms,
- please visit pleasedontcode.com/termsandconditions.
- - Project: WiFi Dashboard
- - Source Code NOT compiled for: ESP32 DevKit V1
- - Source Code created on: 2025-10-29 01:23:26
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* no need any push button and create code for esp32 */
- /* c6 dev module and webserver for control and all */
- /* serial monitor as primery status reciver */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- // Include the WiFi library for network functionalities
- #include <WiFi.h>
- // Function prototypes
- void setup(void);
- void loop(void);
- // WiFi credentials and server setup
- const char* ssid = "";
- const char* password = "";
- // Web server at port 80
- WiFiServer server(80);
- // Variable to hold the latest serial message
- String serialStatus = "";
- void setup() {
- Serial.begin(115200); // Initialize serial communication at 115200 baud rate
- WiFi.mode(WIFI_STA); // Set WiFi to station mode
- delay(100); // Short delay to initialize WiFi
- Serial.println("Starting Wi-Fi jammer..."); // Indicate start
- // ESP32 WiFi channel configuration
- // Note: The below code sets WiFi channel to 6
- // Proper channel setting may require low-level WiFi init (not shown here fully)
- // or using WiFi configuration functions if supported
- // Here, assuming default channel setting, as direct channel setting is complex in Arduino SDK
- // Connect to WiFi network
- WiFi.begin(ssid, password);
- while (WiFi.status() != WL_CONNECTED) {
- delay(500);
- Serial.print(".");
- }
- Serial.println("\nWiFi connected");
- Serial.println("IP address: ");
- Serial.println(WiFi.localIP());
- // Start the server
- server.begin();
- }
- void loop() {
- // Read serial monitor status
- if (Serial.available()) {
- serialStatus = Serial.readStringUntil('\n');
- }
- // Check if a client has connected
- WiFiClient client = server.available();
- if (client) {
- Serial.println("New Client.");
- String currentLine = "";
- while (client.connected()) {
- if (client.available()) {
- char c = client.read();
- Serial.write(c);
- if (c == '\n') {
- // if the current line is blank, you got two newline characters in a row.
- if (currentLine.length() == 0) {
- // send a standard HTTP response
- client.println("HTTP/1.1 200 OK");
- client.println("Content-type:text/html");
- client.println(); // end HTTP headers
- client.println("<html>");
- client.println("<head><title>ESP32 WiFi Jammer Control</title></head>");
- client.println("<body><h1>Control the WiFi Jammer</h1>");
- client.println("<p>Status from Serial Monitor: ");
- client.println(serialStatus);
- client.println("</p>");
- client.println("</body></html>");
- break;
- } else {
- currentLine = "";
- }
- } else if (c != '\r') {
- currentLine += c;
- }
- }
- }
- // close connection
- client.stop();
- Serial.println("Client Disconnected.");
- }
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment