Ein Script für den automatischen Login in Wohnheimen, um das lästige Anmelden auf der Loginseite zu umgehen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

64 lines
1.0 KiB

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <ESP8266Ping.h>
#include "credentials.h"
void wifi_connect (){
WiFi.begin(WLAN_ID, WLAN_PASSWORD);
WiFi.mode(WIFI_STA);
while(WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting ...");
}
Serial.println(WiFi.localIP());
}
void setup (){
Serial.begin(115200);
wifi_connect();
}
void login (){
HTTPClient http;
http.begin("http://login.rz.ruhr-uni-bochum.de/cgi-bin/laklogin");
Serial.println("Attempt Login") ;
int httpCode = http.POST("code=1&loginid=" LOGIN_ID "&password=" LOGIN_PASSWORD "&action=Login");
http.end();
}
void loop (){
if(WiFi.status() != WL_CONNECTED){
wifi_connect();
}
IPAddress ip = (1, 1, 1, 1);
bool ret = Ping.ping(ip);
Serial.println(String("Connection state : ") + (ret ? "connected" : "not connected"));
if (ret == false){
Serial.println("Connection check failed");
login();
}
else Serial.println("Still connected");
delay(10000);
}