Guest User

Untitled

a guest
May 27th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. #include "esp_wpa2.h"
  2. #include <WiFi.h>
  3.  
  4. // SSID to connect to
  5. static const char* ssid = "MMBBS-Intern";
  6. // Username for authentification
  7. #define EAP_ID "tuttas"
  8. #define EAP_USERNAME "tuttas"
  9. #define EAP_PASSWORD "geheim"
  10.  
  11. WiFiServer server(80);
  12.  
  13. void setup()
  14. {
  15. Serial.begin(115200);
  16. delay(500);
  17.  
  18. WiFi.disconnect(true);
  19. esp_wifi_sta_wpa2_ent_set_identity((uint8_t *)EAP_ID, strlen(EAP_ID));
  20. esp_wifi_sta_wpa2_ent_set_username((uint8_t *)EAP_USERNAME, strlen(EAP_USERNAME));
  21. esp_wifi_sta_wpa2_ent_set_password((uint8_t *)EAP_PASSWORD, strlen(EAP_PASSWORD));
  22. esp_wpa2_config_t config = WPA2_CONFIG_INIT_DEFAULT();
  23. esp_wifi_sta_wpa2_ent_enable(&config);
  24. WiFi.begin(ssid);
  25.  
  26. // Wait for connection AND IP address from DHCP
  27. Serial.println();
  28. Serial.println("Waiting for connection and IP Address from DHCP");
  29. while (WiFi.status() != WL_CONNECTED)
  30. {
  31. delay(2000);
  32. Serial.print(".");
  33. }
  34. Serial.println("");
  35. Serial.println("WiFi connected");
  36. Serial.println("IP address: ");
  37. Serial.println(WiFi.localIP());
  38. Serial.write("\r\nStarte Webserver");
  39. server.begin();
  40. }
  41.  
  42. void loop()
  43. {
  44. WiFiClient clientS = server.available();
  45. if (clientS)
  46. {
  47. Serial.println("New Client");
  48. String s = "works!";
  49. clientS.print(s);
  50. clientS.flush();
  51. clientS.stop();
  52. }
  53. }
Add Comment
Please, Sign In to add comment