Skip to content

Commit

Permalink
Merge branch 'master' into feature/i2s_sr
Browse files Browse the repository at this point in the history
  • Loading branch information
P-R-O-C-H-Y authored Oct 12, 2023
2 parents cb5a4aa + 7438c6e commit 531adcf
Show file tree
Hide file tree
Showing 9 changed files with 399 additions and 136 deletions.
22 changes: 21 additions & 1 deletion .github/scripts/on-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ echo "Cleaning up folders ..."
find "$PKG_DIR" -name '*.DS_Store' -exec rm -f {} \;
find "$PKG_DIR" -name '*.git*' -type f -delete

##
## TEMP WORKAROUND FOR RV32 LONG PATH ON WINDOWS
##
RVTC_NAME="riscv32-esp-elf-gcc"
RVTC_NEW_NAME="esp-rv32"

# Replace tools locations in platform.txt
echo "Generating platform.txt..."
cat "$GITHUB_WORKSPACE/platform.txt" | \
Expand All @@ -200,7 +206,7 @@ sed 's/tools.xtensa-esp32-elf-gcc.path={runtime.platform.path}\/tools\/xtensa-es
sed 's/tools.xtensa-esp32s2-elf-gcc.path={runtime.platform.path}\/tools\/xtensa-esp32s2-elf/tools.xtensa-esp32s2-elf-gcc.path=\{runtime.tools.xtensa-esp32s2-elf-gcc.path\}/g' | \
sed 's/tools.xtensa-esp32s3-elf-gcc.path={runtime.platform.path}\/tools\/xtensa-esp32s3-elf/tools.xtensa-esp32s3-elf-gcc.path=\{runtime.tools.xtensa-esp32s3-elf-gcc.path\}/g' | \
sed 's/tools.xtensa-esp-elf-gdb.path={runtime.platform.path}\/tools\/xtensa-esp-elf-gdb/tools.xtensa-esp-elf-gdb.path=\{runtime.tools.xtensa-esp-elf-gdb.path\}/g' | \
sed 's/tools.riscv32-esp-elf-gcc.path={runtime.platform.path}\/tools\/riscv32-esp-elf/tools.riscv32-esp-elf-gcc.path=\{runtime.tools.riscv32-esp-elf-gcc.path\}/g' | \
sed "s/tools.riscv32-esp-elf-gcc.path={runtime.platform.path}\\/tools\\/riscv32-esp-elf/tools.riscv32-esp-elf-gcc.path=\\{runtime.tools.$RVTC_NEW_NAME.path\\}/g" | \
sed 's/tools.riscv32-esp-elf-gdb.path={runtime.platform.path}\/tools\/riscv32-esp-elf-gdb/tools.riscv32-esp-elf-gdb.path=\{runtime.tools.riscv32-esp-elf-gdb.path\}/g' | \
sed 's/tools.esptool_py.path={runtime.platform.path}\/tools\/esptool/tools.esptool_py.path=\{runtime.tools.esptool_py.path\}/g' | \
sed 's/debug.server.openocd.path={runtime.platform.path}\/tools\/openocd-esp32\/bin\/openocd/debug.server.openocd.path=\{runtime.tools.openocd-esp32.path\}\/bin\/openocd/g' | \
Expand Down Expand Up @@ -302,6 +308,20 @@ cat "$PACKAGE_JSON_TEMPLATE" | jq "$libs_jq_arg" > "$OUTPUT_DIR/package-$LIBS_PR
# Overwrite the template location with the newly edited one
PACKAGE_JSON_TEMPLATE="$OUTPUT_DIR/package-$LIBS_PROJ_NAME.json"

##
## TEMP WORKAROUND FOR RV32 LONG PATH ON WINDOWS
##
RVTC_VERSION=`cat $PACKAGE_JSON_TEMPLATE | jq -r ".packages[0].platforms[0].toolsDependencies[] | select(.name == \"$RVTC_NAME\") | .version" | cut -d '_' -f 2`
# RVTC_VERSION=`date -j -f '%Y%m%d' "$RVTC_VERSION" '+%y%m'` # MacOS
RVTC_VERSION=`date -d "$RVTC_VERSION" '+%y%m'`
rvtc_jq_arg="\
(.packages[0].platforms[0].toolsDependencies[] | select(.name==\"$RVTC_NAME\")).version = \"$RVTC_VERSION\" |\
(.packages[0].platforms[0].toolsDependencies[] | select(.name==\"$RVTC_NAME\")).name = \"$RVTC_NEW_NAME\" |\
(.packages[0].tools[] | select(.name==\"$RVTC_NAME\")).version = \"$RVTC_VERSION\" |\
(.packages[0].tools[] | select(.name==\"$RVTC_NAME\")).name = \"$RVTC_NEW_NAME\""
cat "$PACKAGE_JSON_TEMPLATE" | jq "$rvtc_jq_arg" > "$OUTPUT_DIR/package-$LIBS_PROJ_NAME-rvfix.json"
PACKAGE_JSON_TEMPLATE="$OUTPUT_DIR/package-$LIBS_PROJ_NAME-rvfix.json"

##
## PACKAGE JSON
##
Expand Down
167 changes: 167 additions & 0 deletions boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3678,6 +3678,8 @@ lilygo_t_display.upload.maximum_size=1310720
lilygo_t_display.upload.maximum_data_size=327680
lilygo_t_display.upload.wait_for_upload_port=true
lilygo_t_display.upload.speed=460800
lilygo_t_display.upload.flags=
lilygo_t_display.upload.extra_flags=

lilygo_t_display.bootloader.tool=esptool_py
lilygo_t_display.bootloader.tool.default=esptool_py
Expand Down Expand Up @@ -5749,6 +5751,171 @@ sparkfun_esp32_iot_redboard.menu.EraseFlash.all.upload.erase_cmd=-e

##############################################################

sparkfun_esp32c6_qwiic_pocket.name=SparkFun ESP32-C6 Qwiic Pocket
sparkfun_esp32c6_qwiic_pocket.vid.0=0x303a
sparkfun_esp32c6_qwiic_pocket.pid.0=0x1001

sparkfun_esp32c6_qwiic_pocket.bootloader.tool=esptool_py
sparkfun_esp32c6_qwiic_pocket.bootloader.tool.default=esptool_py

sparkfun_esp32c6_qwiic_pocket.upload.tool=esptool_py
sparkfun_esp32c6_qwiic_pocket.upload.tool.default=esptool_py
sparkfun_esp32c6_qwiic_pocket.upload.tool.network=esp_ota

sparkfun_esp32c6_qwiic_pocket.upload.maximum_size=1310720
sparkfun_esp32c6_qwiic_pocket.upload.maximum_data_size=327680
sparkfun_esp32c6_qwiic_pocket.upload.flags=
sparkfun_esp32c6_qwiic_pocket.upload.extra_flags=
sparkfun_esp32c6_qwiic_pocket.upload.use_1200bps_touch=false
sparkfun_esp32c6_qwiic_pocket.upload.wait_for_upload_port=false

sparkfun_esp32c6_qwiic_pocket.serial.disableDTR=false
sparkfun_esp32c6_qwiic_pocket.serial.disableRTS=false

sparkfun_esp32c6_qwiic_pocket.build.tarch=riscv32
sparkfun_esp32c6_qwiic_pocket.build.target=esp
sparkfun_esp32c6_qwiic_pocket.build.mcu=esp32c6
sparkfun_esp32c6_qwiic_pocket.build.core=esp32
sparkfun_esp32c6_qwiic_pocket.build.variant=sparkfun_esp32c6_qwiic_pocket
sparkfun_esp32c6_qwiic_pocket.build.board=ESP32C6_QWIIC_POCKET
sparkfun_esp32c6_qwiic_pocket.build.bootloader_addr=0x0

sparkfun_esp32c6_qwiic_pocket.build.cdc_on_boot=0
sparkfun_esp32c6_qwiic_pocket.build.f_cpu=160000000L
sparkfun_esp32c6_qwiic_pocket.build.flash_size=4MB
sparkfun_esp32c6_qwiic_pocket.build.flash_freq=80m
sparkfun_esp32c6_qwiic_pocket.build.flash_mode=qio
sparkfun_esp32c6_qwiic_pocket.build.boot=qio
sparkfun_esp32c6_qwiic_pocket.build.partitions=default
sparkfun_esp32c6_qwiic_pocket.build.defines=

## IDE 2.0 Seems to not update the value
sparkfun_esp32c6_qwiic_pocket.menu.JTAGAdapter.default=Disabled
sparkfun_esp32c6_qwiic_pocket.menu.JTAGAdapter.default.build.copy_jtag_files=0
sparkfun_esp32c6_qwiic_pocket.menu.JTAGAdapter.builtin=Integrated USB JTAG
sparkfun_esp32c6_qwiic_pocket.menu.JTAGAdapter.builtin.build.openocdscript=esp32c6-builtin.cfg
sparkfun_esp32c6_qwiic_pocket.menu.JTAGAdapter.builtin.build.copy_jtag_files=1
sparkfun_esp32c6_qwiic_pocket.menu.JTAGAdapter.external=FTDI Adapter
sparkfun_esp32c6_qwiic_pocket.menu.JTAGAdapter.external.build.openocdscript=esp32c6-ftdi.cfg
sparkfun_esp32c6_qwiic_pocket.menu.JTAGAdapter.external.build.copy_jtag_files=1
sparkfun_esp32c6_qwiic_pocket.menu.JTAGAdapter.bridge=ESP USB Bridge
sparkfun_esp32c6_qwiic_pocket.menu.JTAGAdapter.bridge.build.openocdscript=esp32c6-bridge.cfg
sparkfun_esp32c6_qwiic_pocket.menu.JTAGAdapter.bridge.build.copy_jtag_files=1

sparkfun_esp32c6_qwiic_pocket.menu.CDCOnBoot.default=Enabled
sparkfun_esp32c6_qwiic_pocket.menu.CDCOnBoot.default.build.cdc_on_boot=1
sparkfun_esp32c6_qwiic_pocket.menu.CDCOnBoot.cdc=Disabled
sparkfun_esp32c6_qwiic_pocket.menu.CDCOnBoot.cdc.build.cdc_on_boot=0

sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.default=Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS)
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.default.build.partitions=default
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.defaultffat=Default 4MB with ffat (1.2MB APP/1.5MB FATFS)
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.defaultffat.build.partitions=default_ffat
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.default_8MB=8M with spiffs (3MB APP/1.5MB SPIFFS)
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.default_8MB.build.partitions=default_8MB
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.default_8MB.upload.maximum_size=3342336
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS)
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.minimal.build.partitions=minimal
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS)
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.no_ota.build.partitions=no_ota
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.noota_3g=No OTA (1MB APP/3MB SPIFFS)
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.noota_3g.build.partitions=noota_3g
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.noota_3g.upload.maximum_size=1048576
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.noota_ffat=No OTA (2MB APP/2MB FATFS)
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.noota_ffat.build.partitions=noota_ffat
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.noota_ffat.upload.maximum_size=2097152
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.noota_3gffat=No OTA (1MB APP/3MB FATFS)
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.noota_3gffat.build.partitions=noota_3gffat
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.noota_3gffat.upload.maximum_size=1048576
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.huge_app=Huge APP (3MB No OTA/1MB SPIFFS)
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.huge_app.build.partitions=huge_app
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.huge_app.upload.maximum_size=3145728
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (1.9MB APP with OTA/190KB SPIFFS)
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.fatflash=16M Flash (2MB APP/12.5MB FATFS)
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.fatflash.build.partitions=ffat
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.fatflash.upload.maximum_size=2097152
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.app3M_fat9M_16MB=16M Flash (3MB APP/9.9MB FATFS)
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.app3M_fat9M_16MB.build.partitions=app3M_fat9M_16MB
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.app3M_fat9M_16MB.upload.maximum_size=3145728
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.rainmaker=RainMaker
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.rainmaker.build.partitions=rainmaker
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.rainmaker.upload.maximum_size=3145728
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.custom=Custom
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.custom.build.partitions=
sparkfun_esp32c6_qwiic_pocket.menu.PartitionScheme.custom.upload.maximum_size=16777216

sparkfun_esp32c6_qwiic_pocket.menu.CPUFreq.160=160MHz (WiFi)
sparkfun_esp32c6_qwiic_pocket.menu.CPUFreq.160.build.f_cpu=160000000L
sparkfun_esp32c6_qwiic_pocket.menu.CPUFreq.80=80MHz (WiFi)
sparkfun_esp32c6_qwiic_pocket.menu.CPUFreq.80.build.f_cpu=80000000L
sparkfun_esp32c6_qwiic_pocket.menu.CPUFreq.40=40MHz
sparkfun_esp32c6_qwiic_pocket.menu.CPUFreq.40.build.f_cpu=40000000L
sparkfun_esp32c6_qwiic_pocket.menu.CPUFreq.20=20MHz
sparkfun_esp32c6_qwiic_pocket.menu.CPUFreq.20.build.f_cpu=20000000L
sparkfun_esp32c6_qwiic_pocket.menu.CPUFreq.10=10MHz
sparkfun_esp32c6_qwiic_pocket.menu.CPUFreq.10.build.f_cpu=10000000L

sparkfun_esp32c6_qwiic_pocket.menu.FlashMode.qio=QIO
sparkfun_esp32c6_qwiic_pocket.menu.FlashMode.qio.build.flash_mode=dio
sparkfun_esp32c6_qwiic_pocket.menu.FlashMode.qio.build.boot=qio
sparkfun_esp32c6_qwiic_pocket.menu.FlashMode.dio=DIO
sparkfun_esp32c6_qwiic_pocket.menu.FlashMode.dio.build.flash_mode=dio
sparkfun_esp32c6_qwiic_pocket.menu.FlashMode.dio.build.boot=dio

sparkfun_esp32c6_qwiic_pocket.menu.FlashFreq.80=80MHz
sparkfun_esp32c6_qwiic_pocket.menu.FlashFreq.80.build.flash_freq=80m
sparkfun_esp32c6_qwiic_pocket.menu.FlashFreq.40=40MHz
sparkfun_esp32c6_qwiic_pocket.menu.FlashFreq.40.build.flash_freq=40m

sparkfun_esp32c6_qwiic_pocket.menu.FlashSize.4M=4MB (32Mb)
sparkfun_esp32c6_qwiic_pocket.menu.FlashSize.4M.build.flash_size=4MB
sparkfun_esp32c6_qwiic_pocket.menu.FlashSize.8M=8MB (64Mb)
sparkfun_esp32c6_qwiic_pocket.menu.FlashSize.8M.build.flash_size=8MB
sparkfun_esp32c6_qwiic_pocket.menu.FlashSize.8M.build.partitions=default_8MB
sparkfun_esp32c6_qwiic_pocket.menu.FlashSize.2M=2MB (16Mb)
sparkfun_esp32c6_qwiic_pocket.menu.FlashSize.2M.build.flash_size=2MB
sparkfun_esp32c6_qwiic_pocket.menu.FlashSize.2M.build.partitions=minimal
sparkfun_esp32c6_qwiic_pocket.menu.FlashSize.16M=16MB (128Mb)
sparkfun_esp32c6_qwiic_pocket.menu.FlashSize.16M.build.flash_size=16MB

sparkfun_esp32c6_qwiic_pocket.menu.UploadSpeed.921600=921600
sparkfun_esp32c6_qwiic_pocket.menu.UploadSpeed.921600.upload.speed=921600
sparkfun_esp32c6_qwiic_pocket.menu.UploadSpeed.115200=115200
sparkfun_esp32c6_qwiic_pocket.menu.UploadSpeed.115200.upload.speed=115200
sparkfun_esp32c6_qwiic_pocket.menu.UploadSpeed.256000.windows=256000
sparkfun_esp32c6_qwiic_pocket.menu.UploadSpeed.256000.upload.speed=256000
sparkfun_esp32c6_qwiic_pocket.menu.UploadSpeed.230400.windows.upload.speed=256000
sparkfun_esp32c6_qwiic_pocket.menu.UploadSpeed.230400=230400
sparkfun_esp32c6_qwiic_pocket.menu.UploadSpeed.230400.upload.speed=230400
sparkfun_esp32c6_qwiic_pocket.menu.UploadSpeed.460800.linux=460800
sparkfun_esp32c6_qwiic_pocket.menu.UploadSpeed.460800.macosx=460800
sparkfun_esp32c6_qwiic_pocket.menu.UploadSpeed.460800.upload.speed=460800
sparkfun_esp32c6_qwiic_pocket.menu.UploadSpeed.512000.windows=512000
sparkfun_esp32c6_qwiic_pocket.menu.UploadSpeed.512000.upload.speed=512000

sparkfun_esp32c6_qwiic_pocket.menu.DebugLevel.none=None
sparkfun_esp32c6_qwiic_pocket.menu.DebugLevel.none.build.code_debug=0
sparkfun_esp32c6_qwiic_pocket.menu.DebugLevel.error=Error
sparkfun_esp32c6_qwiic_pocket.menu.DebugLevel.error.build.code_debug=1
sparkfun_esp32c6_qwiic_pocket.menu.DebugLevel.warn=Warn
sparkfun_esp32c6_qwiic_pocket.menu.DebugLevel.warn.build.code_debug=2
sparkfun_esp32c6_qwiic_pocket.menu.DebugLevel.info=Info
sparkfun_esp32c6_qwiic_pocket.menu.DebugLevel.info.build.code_debug=3
sparkfun_esp32c6_qwiic_pocket.menu.DebugLevel.debug=Debug
sparkfun_esp32c6_qwiic_pocket.menu.DebugLevel.debug.build.code_debug=4
sparkfun_esp32c6_qwiic_pocket.menu.DebugLevel.verbose=Verbose
sparkfun_esp32c6_qwiic_pocket.menu.DebugLevel.verbose.build.code_debug=5

sparkfun_esp32c6_qwiic_pocket.menu.EraseFlash.none=Disabled
sparkfun_esp32c6_qwiic_pocket.menu.EraseFlash.none.upload.erase_cmd=
sparkfun_esp32c6_qwiic_pocket.menu.EraseFlash.all=Enabled
sparkfun_esp32c6_qwiic_pocket.menu.EraseFlash.all.upload.erase_cmd=-e

##############################################################

nina_w10.name=u-blox NINA-W10 series (ESP32)

nina_w10.bootloader.tool=esptool_py
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
/*|----------------------------------------------------------|*/
#include <WiFi.h>
#include <HTTPClient.h>
#if __has_include ("esp_eap_client.h")
#include "esp_eap_client.h"
#else
#include "esp_wpa2.h"
#endif
#include <Wire.h>
#define EAP_IDENTITY "identity" //if connecting from another corporation, use [email protected] in Eduroam
#define EAP_PASSWORD "password" //your Eduroam password
Expand Down Expand Up @@ -42,10 +46,17 @@ void setup() {
Serial.println(ssid);
WiFi.disconnect(true); //disconnect form wifi to set new wifi connection
WiFi.mode(WIFI_STA); //init wifi mode
#if __has_include ("esp_eap_client.h")
esp_eap_client_set_identity((uint8_t *)EAP_IDENTITY, strlen(EAP_IDENTITY)); //provide identity
esp_eap_client_set_username((uint8_t *)EAP_IDENTITY, strlen(EAP_IDENTITY)); //provide username
esp_eap_client_set_password((uint8_t *)EAP_PASSWORD, strlen(EAP_PASSWORD)); //provide password
esp_wifi_sta_enterprise_enable();
#else
esp_wifi_sta_wpa2_ent_set_identity((uint8_t *)EAP_IDENTITY, strlen(EAP_IDENTITY)); //provide identity
esp_wifi_sta_wpa2_ent_set_username((uint8_t *)EAP_IDENTITY, strlen(EAP_IDENTITY)); //provide username --> identity and username is same
esp_wifi_sta_wpa2_ent_set_password((uint8_t *)EAP_PASSWORD, strlen(EAP_PASSWORD)); //provide password
esp_wifi_sta_wpa2_ent_enable();
#endif
WiFi.begin(ssid); //connect to wifi
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include <WiFi.h> //Wifi library
#include "esp_wpa2.h" //wpa2 library for connections to Enterprise networks
#define EAP_IDENTITY "login" //if connecting from another corporation, use [email protected] in Eduroam
#define EAP_USERNAME "login" //oftentimes just a repeat of the identity
#define EAP_PASSWORD "password" //your Eduroam password
Expand Down
30 changes: 27 additions & 3 deletions libraries/WiFi/src/WiFiSTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "WiFiGeneric.h"
#include "WiFiSTA.h"

extern "C" {
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
Expand All @@ -42,9 +41,13 @@ extern "C" {
#include "lwip/dns.h"
#include <esp_smartconfig.h>
#include <esp_netif.h>
#include "esp_wpa2.h"
#include "esp_mac.h"
}

#if __has_include ("esp_eap_client.h")
#include "esp_eap_client.h"
#else
#include "esp_wpa2.h"
#endif

// -----------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------- Private functions ------------------------------------------------
Expand Down Expand Up @@ -193,19 +196,40 @@ wl_status_t WiFiSTAClass::begin(const char* wpa2_ssid, wpa2_auth_method_t method
}

if(ca_pem) {
#if __has_include ("esp_eap_client.h")
esp_eap_client_set_ca_cert((uint8_t *)ca_pem, strlen(ca_pem));
#else
esp_wifi_sta_wpa2_ent_set_ca_cert((uint8_t *)ca_pem, strlen(ca_pem));
#endif
}

if(client_crt) {
#if __has_include ("esp_eap_client.h")
esp_eap_client_set_certificate_and_key((uint8_t *)client_crt, strlen(client_crt), (uint8_t *)client_key, strlen(client_key), NULL, 0);
#else
esp_wifi_sta_wpa2_ent_set_cert_key((uint8_t *)client_crt, strlen(client_crt), (uint8_t *)client_key, strlen(client_key), NULL, 0);
#endif
}

#if __has_include ("esp_eap_client.h")
esp_eap_client_set_identity((uint8_t *)wpa2_identity, strlen(wpa2_identity));
#else
esp_wifi_sta_wpa2_ent_set_identity((uint8_t *)wpa2_identity, strlen(wpa2_identity));
#endif
if(method == WPA2_AUTH_PEAP || method == WPA2_AUTH_TTLS) {
#if __has_include ("esp_eap_client.h")
esp_eap_client_set_username((uint8_t *)wpa2_username, strlen(wpa2_username));
esp_eap_client_set_password((uint8_t *)wpa2_password, strlen(wpa2_password));
#else
esp_wifi_sta_wpa2_ent_set_username((uint8_t *)wpa2_username, strlen(wpa2_username));
esp_wifi_sta_wpa2_ent_set_password((uint8_t *)wpa2_password, strlen(wpa2_password));
#endif
}
#if __has_include ("esp_eap_client.h")
esp_wifi_sta_enterprise_enable(); //set config settings to enable function
#else
esp_wifi_sta_wpa2_ent_enable(); //set config settings to enable function
#endif
WiFi.begin(wpa2_ssid); //connect to wifi

return status();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@

#include <WiFi.h>
#include <WiFiClientSecure.h>
#if __has_include ("esp_eap_client.h")
#include "esp_eap_client.h"
#else
#include "esp_wpa2.h"
#endif
#include <Wire.h>
#define EAP_ANONYMOUS_IDENTITY "[email protected]" //anonymous identity
#define EAP_IDENTITY "[email protected]" //user identity
Expand Down Expand Up @@ -64,10 +68,17 @@ void setup() {
Serial.println(ssid);
WiFi.disconnect(true); //disconnect form wifi to set new wifi connection
WiFi.mode(WIFI_STA); //init wifi mode
#if __has_include ("esp_eap_client.h")
esp_eap_client_set_identity((uint8_t *)EAP_ANONYMOUS_IDENTITY, strlen(EAP_ANONYMOUS_IDENTITY)); //provide identity
esp_eap_client_set_username((uint8_t *)EAP_IDENTITY, strlen(EAP_IDENTITY)); //provide username
esp_eap_client_set_password((uint8_t *)EAP_PASSWORD, strlen(EAP_PASSWORD)); //provide password
esp_wifi_sta_enterprise_enable();
#else
esp_wifi_sta_wpa2_ent_set_identity((uint8_t *)EAP_ANONYMOUS_IDENTITY, strlen(EAP_ANONYMOUS_IDENTITY)); //provide identity
esp_wifi_sta_wpa2_ent_set_username((uint8_t *)EAP_IDENTITY, strlen(EAP_IDENTITY)); //provide username
esp_wifi_sta_wpa2_ent_set_password((uint8_t *)EAP_PASSWORD, strlen(EAP_PASSWORD)); //provide password
esp_wifi_sta_wpa2_ent_enable();
#endif
WiFi.begin(ssid); //connect to wifi
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Expand Down
Loading

0 comments on commit 531adcf

Please sign in to comment.