Advertisement
Guest User

Untitled

a guest
Sep 14th, 2017
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. #include "ESP8266WiFi.h"
  2. extern "C" {
  3. #include "user_interface.h"
  4. #include "wpa2_enterprise.h"
  5. }
  6.  
  7. static const char* ssid = "ssid";
  8. static const char* username = "username";
  9. static const char* password = "password";
  10. const char* host = "host_ip";
  11.  
  12. void setup(){
  13. Serial.begin(115200);
  14.  
  15. Serial.print("Connecting to ");
  16. Serial.println(ssid);
  17. // Setting ESP into STATION mode only (no AP mode or dual mode)
  18. wifi_set_opmode(0x01);
  19.  
  20. struct station_config wifi_config;
  21.  
  22. memset(&wifi_config, 0, sizeof(wifi_config));
  23. strcpy((char*)wifi_config.ssid, ssid);
  24.  
  25. wifi_station_set_config(&wifi_config);
  26.  
  27. wifi_station_clear_cert_key();
  28. wifi_station_clear_enterprise_ca_cert();
  29.  
  30. wifi_station_set_wpa2_enterprise_auth(1);
  31. wifi_station_set_enterprise_username((uint8*)username, strlen(username));
  32. wifi_station_set_enterprise_password((uint8*)password, strlen(password));
  33.  
  34. wifi_station_connect();
  35. Serial.print("Wifi station connect status:");
  36. Serial.println(wifi_station_get_connect_status());
  37.  
  38. // Wait for connection AND IP address from DHCP
  39. while (WiFi.status() != WL_CONNECTED) {
  40. Serial.println(WiFi.status());
  41. delay(2000);
  42. Serial.println("Not connected");
  43. }
  44.  
  45. Serial.println("");
  46. Serial.println("WiFi connected");
  47. Serial.println("IP address: ");
  48. Serial.println(WiFi.localIP());
  49. }
  50.  
  51. void loop()
  52. {
  53. delay(2000);
  54. }
  55.  
  56. Connecting to ssid
  57. Wifi station connect status:1
  58. 6
  59. Not connected
  60. 6
  61. Not connected
  62. .....
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement