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.

ESP_Login_Ding.ino 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #include <ESP8266WiFi.h>
  2. #include <ESP8266HTTPClient.h>
  3. #include <ESP8266Ping.h>
  4. #include "credentials.h"
  5. void wifi_connect (){
  6. WiFi.begin(WLAN_ID, WLAN_PASSWORD);
  7. WiFi.mode(WIFI_STA);
  8. while(WiFi.status() != WL_CONNECTED) {
  9. delay(1000);
  10. Serial.println("Connecting ...");
  11. }
  12. Serial.println(WiFi.localIP());
  13. }
  14. void setup (){
  15. Serial.begin(115200);
  16. wifi_connect();
  17. }
  18. void login (){
  19. HTTPClient http;
  20. http.begin("http://login.rz.ruhr-uni-bochum.de/cgi-bin/laklogin");
  21. Serial.println("Attempt Login") ;
  22. int httpCode = http.POST("code=1&loginid=" LOGIN_ID "&password=" LOGIN_PASSWORD "&action=Login");
  23. http.end();
  24. }
  25. void loop (){
  26. if(WiFi.status() != WL_CONNECTED){
  27. wifi_connect();
  28. }
  29. IPAddress ip = (1, 1, 1, 1);
  30. bool ret = Ping.ping(ip);
  31. Serial.println(String("Connection state : ") + (ret ? "connected" : "not connected"));
  32. if (ret == false){
  33. Serial.println("Connection check failed");
  34. login();
  35. }
  36. else Serial.println("Still connected");
  37. delay(10000);
  38. }