Files
libretiny/cores/lightning-ln882h/arduino/libraries/WiFi/WiFi.cpp
lamauny 69e7e2debe [lightning-ln882h] Add support for Lightning LN882H family (#312)
* fix mbedtls bad pointer in function call (prototype mismatch)

* fix issue with weak families functions implemented in static library, it will never be linked. fixed by redefining prototypes inside families

* [ln882x] add support for lightning ln882x & ln882h families

* add i2c (wire) support

* add analog (adc) support

* add watchdog support

* [ln882x] changed default uart 0/1 pins; added board wl2s

* [ln882x] fix IRQ & ADC pins

* [ln882x] boards cosmetic

* [ln882x] wifi sta use otp mac addr by default; re-enabled wifi powersave mode

* [ln882x] clang-format clean code

* [ln882x] clang-format clean code

* Update families.json

* Apply suggestions from code review

* [ln882x] reformat json board files

* [ln882x] os_queue cleanup

* [ln882x] removed Beken auto-download command

* [ln882x] removed personal script file

* [ln882x] removed unusefull pi section in debugging.md

* [ln882x] removed Arduino.h and changed private I2C definition

* [ln882x] updated README.md

* [ln882x] changed pin naming scheme to PA/PB

* [ln882x] clean code

* [ln882x] clean code

* [ln882x] add ota image verification

* Update push-dev.yml

* [ln882x] fix boards ADC missing inputs]

* [ln882x] removed reg_xxx fixup files and use include guards instead

* [ln882x] cleanup code

* [ln882x] cleanup code

* [ln882x] fix lt_init weak functions linking

* [ln882x] revert lt_api.h modification, fixed with previous commit

* [ln882x] setup UF2 firmware for flasher with partitions

* [ln882x] update README.md

* [ln882x] include ln_wifi.h and ln_serial.h to avoid including bad headers on case insensitive systems

* [ln882x] Replace RingBuffer by SerialRingBuffer

* [ln882x] clang-format

* [ln882x] update README.md

* Apply suggestions from code review

* Reformat board JSON files

* Add mkdocs link redirect

* Update ltchiptool to v4.12.0

---------

Co-authored-by: Kuba Szczodrzyński <kuba@szczodrzynski.pl>
2025-03-25 17:26:53 +01:00

59 lines
1.4 KiB
C++

/* Copyright (c) Etienne Le Cousin 2024-02-18. */
#include "WiFiPrivate.h"
WiFiClass::WiFiClass() {
data = (WiFiData *)calloc(1, sizeof(WiFiData));
DATA->scanSem = xSemaphoreCreateBinary();
}
WiFiClass::~WiFiClass() {
vSemaphoreDelete(DATA->scanSem);
free(data);
data = NULL;
}
WiFiAuthMode securityTypeToAuthMode(uint8_t type) {
switch (type) {
case LN_WIFI_AUTH_OPEN:
return WIFI_AUTH_OPEN;
case LN_WIFI_AUTH_WEP:
return WIFI_AUTH_WEP;
case LN_WIFI_AUTH_WPA_PSK:
return WIFI_AUTH_WPA_PSK;
case LN_WIFI_AUTH_WPA2_PSK:
return WIFI_AUTH_WPA2_PSK;
case LN_WIFI_AUTH_WPA_WPA2_PSK:
return WIFI_AUTH_WPA_WPA2_PSK;
case LN_WIFI_AUTH_WPA2_ENTERPRISE:
return WIFI_AUTH_WPA2_ENTERPRISE;
case LN_WIFI_AUTH_WPA3_SAE:
return WIFI_AUTH_WPA3_PSK;
case LN_WIFI_AUTH_WPA2_PSK_WPA3_SAE:
return WIFI_AUTH_WPA2_WPA3_PSK;
}
return WIFI_AUTH_INVALID;
}
uint8_t authModeToSecurityType(WiFiAuthMode auth) {
switch (auth) {
case WIFI_AUTH_OPEN:
return LN_WIFI_AUTH_OPEN;
case WIFI_AUTH_WEP:
return LN_WIFI_AUTH_WEP;
case WIFI_AUTH_WPA_PSK:
return LN_WIFI_AUTH_WPA_PSK;
case WIFI_AUTH_WPA2_PSK:
return LN_WIFI_AUTH_WPA2_PSK;
case WIFI_AUTH_WPA_WPA2_PSK:
return LN_WIFI_AUTH_WPA_WPA2_PSK;
case WIFI_AUTH_WPA2_ENTERPRISE:
return LN_WIFI_AUTH_WPA2_ENTERPRISE;
case WIFI_AUTH_WPA3_PSK:
return LN_WIFI_AUTH_WPA3_SAE;
case WIFI_AUTH_WPA2_WPA3_PSK:
return LN_WIFI_AUTH_WPA2_PSK_WPA3_SAE;
}
return WIFI_AUTH_INVALID;
}