-
-
Save reacto11mecha/9763e13a0840c2d0a722f8cfe5f23f2c to your computer and use it in GitHub Desktop.
Login to WIFI UNJ Mahasiswa
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <WiFi.h> | |
| #include <Wire.h> | |
| #include <HTTPClient.h> | |
| #define AP_SSID "UNJ Hotspot (Mahasiswa)" | |
| #define AP_PASSWORD "" // Kosong karena wifi mahasiswa ga ada input pw | |
| const String username = "1111111"; // NIM | |
| const String password = "blahblah"; // Password wifi | |
| void setup() { | |
| // put your setup code here, to run once: | |
| Serial.begin(115200); | |
| // Connecting to the WIFI AP | |
| WiFi.begin(AP_SSID, AP_PASSWORD); | |
| while (WiFi.status() != WL_CONNECTED) { | |
| delay(500); | |
| Serial.println("Connecting to WiFi.."); | |
| } | |
| Serial.println("Connected to the WiFi network"); | |
| // Login to Captive Portal | |
| HTTPClient login; | |
| login.begin("http://192.168.0.1/login.html"); | |
| // Black magic | |
| String body = "username=" + String(username) + "&password=" + String(password) + "&buttonClicked=4&err_flag=0&err_msg=&info_flag=0&info_msg=&redirect_url=&network_name=Guest+Network"; | |
| int res = login.POST(body); | |
| Serial.println(res); | |
| if (res == 200) { | |
| Serial.println("Login ke wifi unj berhasil!"); | |
| } else if (res == 100) { | |
| Serial.println("Udah pernah login, sung aja"); | |
| } | |
| login.end(); | |
| } | |
| void loop() { | |
| // put your main code here, to run repeatedly: | |
| HTTPClient http; | |
| http.begin("https://www.google.com/"); | |
| int res = http.GET(); | |
| Serial.println(res); // status code | |
| Serial.println(http.getString()); // API response | |
| delay(2000); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment