Advertisement
Guest User

Untitled

a guest
Sep 1st, 2017
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. #include <ESP8266WiFi.h>
  2.  
  3. extern "C" {
  4. #include "user_interface.h"
  5. #include "wpa2_enterprise.h"
  6. }
  7.  
  8. // SSID to connect to
  9. static const char* ssid = "eduroam";
  10. // Username for authentification
  11. static const char* username = "myusername@myinstitution";
  12. // Password for authentication
  13. static const char* password = "mypassword";
  14.  
  15. void setup() {
  16. // put your setup code here, to run once:
  17. Serial.begin(115200);
  18.  
  19. // Setting ESP into STATION mode only (no AP mode or dual mode)
  20. wifi_set_opmode(STATION_MODE);
  21.  
  22. struct station_config wifi_config;
  23.  
  24. memset(&wifi_config, 0, sizeof(wifi_config));
  25. strcpy((char*)wifi_config.ssid, ssid);
  26.  
  27. wifi_station_set_config(&wifi_config);
  28.  
  29. wifi_station_clear_cert_key();
  30. wifi_station_clear_enterprise_ca_cert();
  31.  
  32. wifi_station_set_wpa2_enterprise_auth(1);
  33. wifi_station_set_enterprise_identity((uint8*)username, strlen(username));
  34. wifi_station_set_enterprise_username((uint8*)username, strlen(username));
  35. wifi_station_set_enterprise_password((uint8*)password, strlen(password));
  36.  
  37. wifi_station_connect();
  38.  
  39. // Wait for connection AND IP address from DHCP
  40. Serial.println();
  41. Serial.println("Waiting for connection and IP Address from DHCP");
  42. while (WiFi.status() != WL_CONNECTED) {
  43. delay(2000);
  44. Serial.print(".");
  45. }
  46. Serial.println("");
  47. Serial.println("WiFi connected");
  48. Serial.println("IP address: ");
  49. Serial.println(WiFi.localIP());
  50. }
  51.  
  52. void loop() {
  53. // put your main code here, to run repeatedly:
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement