iT邦幫忙

0

nodemcu-32s想連到公司wifi(802.1x)

  • 分享至 

  • xImage

以下為程式碼 EAP_IDEAP_USERNAMEEAP_PASSWORDEAP_SSID為遮蓋後的結果,可以確定這些資訊都是對的(這些資訊用手機連到wifi是OK的),但esp32一直都連不到wifi,請問是否哪裡有錯呢?

#include <Arduino.h>
#include <WiFi.h>
#include "esp_wpa2.h"

#define EAP_ID "..."
#define EAP_USERNAME "..."
#define EAP_PASSWORD "..."
const char *EAP_SSID = "...";

void setup() {
    Serial.begin(115200);
    // Initialize
    WiFi.disconnect();
    // Station mode
    WiFi.mode(WIFI_STA);
    Serial.println();
    Serial.print("Connecting to ");
    Serial.println(EAP_SSID);

    // WPA2 enterprise magic starts here
    esp_wifi_sta_wpa2_ent_set_identity((uint8_t *)EAP_ID, strlen(EAP_ID));
    esp_wifi_sta_wpa2_ent_set_username((uint8_t *)EAP_USERNAME, strlen(EAP_USERNAME));
    esp_wifi_sta_wpa2_ent_set_password((uint8_t *)EAP_PASSWORD, strlen(EAP_PASSWORD));
    esp_wpa2_config_t config = WPA2_CONFIG_INIT_DEFAULT();
    esp_wifi_sta_wpa2_ent_enable(&config);
    Serial.println("MAC address: ");
    Serial.println(WiFi.macAddress());
    Serial.println(EAP_ID);
    Serial.println(EAP_PASSWORD);
    WiFi.begin(EAP_SSID);
    // Check connection status
    while (WiFi.status() != WL_CONNECTED) {
        delay(1000);
        Serial.print(".");
    }    
    Serial.println("WiFi connected !");
    Serial.print("Local IP: ");
    Serial.println(WiFi.localIP());
}

void loop() {
    delay(10000);
}
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答