risc-v/esp32c3: Support ESP32-C3 wireless ioctl cmd

This commit is contained in:
chenwen 2021-03-23 19:48:03 +08:00 committed by Xiang Xiao
parent 09869e5d41
commit 91eb70b5ef
11 changed files with 4546 additions and 536 deletions

View file

@ -337,6 +337,21 @@ endmenu # Real-Time Timer
menu "Wi-Fi configuration"
depends on ESP32C3_WIRELESS
choice
prompt "ESP32-C3 Wi-Fi mode"
default ESP32C3_WIFI_STATION
config ESP32C3_WIFI_STATION
bool "Station mode"
config ESP32C3_WIFI_SOFTAP
bool "SoftAP mode"
config ESP32C3_WIFI_STATION_SOFTAP_COEXISTENCE
bool "Station + SoftAP coexistence"
endchoice # ESP32-C3 Wi-Fi mode
config ESP32C3_WIFI_STATIC_RXBUF_NUM
int "Wi-Fi static RX buffer number"
default 10
@ -361,8 +376,8 @@ config ESP32C3_WIFI_RXBA_AMPDU_WZ
int "Wi-Fi RX BA AMPDU windown size"
default 6
config ESP32C3_WLAN_RXBUF_NUM
int "WLAN netcard RX buffer number"
config ESP32C3_WLAN_PKTBUF_NUM
int "WLAN netcard packet buffer number per netcard"
default 16
config ESP32C3_WIFI_CONNECT_TIMEOUT
@ -371,6 +386,12 @@ config ESP32C3_WIFI_CONNECT_TIMEOUT
help
Max waiting time of connecting to AP.
config ESP32C3_WIFI_SCAN_RESULT_SIZE
int "Scan result buffer"
default 4096
help
Maximum scan result buffer size.
config ESP32C3_WIFI_SAVE_PARAM
bool "Save Wi-Fi Parameters"
default n

View file

@ -117,7 +117,7 @@ clean_context::
INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)esp-wireless-drivers-3rdparty$(DELIM)include)
INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)esp-wireless-drivers-3rdparty$(DELIM)include$(DELIM)esp32c3)
CHIP_CSRCS += esp32c3_wlan.c esp32c3_wifi_adapter.c
CHIP_CSRCS += esp32c3_wlan.c esp32c3_wifi_utils.c esp32c3_wifi_adapter.c
EXTRA_LIBPATHS += -L $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)esp-wireless-drivers-3rdparty$(DELIM)libs$(DELIM)esp32c3
EXTRA_LIBS += -lcore -lnet80211 -lpp -lsmartconfig -lcoexist -lespnow -lphy -lwpa_supplicant -lwapi

File diff suppressed because it is too large Load diff

View file

@ -44,15 +44,39 @@ extern "C"
* Pre-processor Definitions
****************************************************************************/
#if defined(CONFIG_ESP32C3_WIFI_STATION)
# define ESP32C3_WLAN_HAS_STA
# define ESP32C3_WLAN_STA_DEVNO 0
# define ESP32C3_WLAN_DEVS 1
#elif defined(CONFIG_ESP32C3_WIFI_SOFTAP)
# define ESP32C3_WLAN_HAS_SOFTAP
# define ESP32C3_WLAN_SOFTAP_DEVNO 0
# define ESP32C3_WLAN_DEVS 1
#elif defined(CONFIG_ESP32C3_WIFI_STATION_SOFTAP_COEXISTENCE)
# define ESP32C3_WLAN_HAS_STA
# define ESP32C3_WLAN_HAS_SOFTAP
# define ESP32C3_WLAN_STA_DEVNO 0
# define ESP32C3_WLAN_SOFTAP_DEVNO 1
# define ESP32C3_WLAN_DEVS 2
#endif
#define SSID_MAX_LEN (32)
#define PWD_MAX_LEN (64)
/* Wi-Fi event ID */
enum wifi_adpt_evt_e
{
WIFI_ADPT_EVT_STA_START = 0,
WIFI_ADPT_EVT_SCAN_DONE = 0,
WIFI_ADPT_EVT_STA_START,
WIFI_ADPT_EVT_STA_CONNECT,
WIFI_ADPT_EVT_STA_DISCONNECT,
WIFI_ADPT_EVT_STA_AUTHMODE_CHANGE,
WIFI_ADPT_EVT_STA_STOP,
WIFI_ADPT_EVT_AP_START,
WIFI_ADPT_EVT_AP_STOP,
WIFI_ADPT_EVT_AP_STACONNECTED,
WIFI_ADPT_EVT_AP_STADISCONNECTED,
WIFI_ADPT_EVT_MAX,
};
@ -60,8 +84,9 @@ enum wifi_adpt_evt_e
typedef void (*wifi_evt_cb_t)(void *p);
typedef void (* wifi_tx_done_cb_t)(uint8_t ifidx, uint8_t *data,
uint16_t *len, bool txstatus);
/* Wi-Fi TX done callback function */
typedef void (*wifi_txdone_cb_t)(uint8_t *data, uint16_t *len, bool status);
/****************************************************************************
* Public Function Prototypes
@ -71,7 +96,7 @@ typedef void (* wifi_tx_done_cb_t)(uint8_t ifidx, uint8_t *data,
* Name: esp_wifi_adapter_init
*
* Description:
* Initialize ESP32 Wi-Fi adapter
* Initialize Wi-Fi adapter
*
* Input Parameters:
* None
@ -83,74 +108,6 @@ typedef void (* wifi_tx_done_cb_t)(uint8_t ifidx, uint8_t *data,
int esp_wifi_adapter_init(void);
/****************************************************************************
* Name: esp_wifi_notify_subscribe
*
* Description:
* Enable event notification
*
* Input Parameters:
* pid - Task PID
* event - Signal event data pointer
*
* Returned Value:
* 0 if success or -1 if fail
*
****************************************************************************/
int esp_wifi_notify_subscribe(pid_t pid, FAR struct sigevent *event);
/****************************************************************************
* Name: esp_wifi_sta_send_data
*
* Description:
* Use Wi-Fi station interface to send 802.3 frame
*
* Input Parameters:
* pbuf - Packet buffer pointer
* len - Packet length
*
* Returned Value:
* 0 if success or others if fail
*
****************************************************************************/
int esp_wifi_sta_send_data(void *pbuf, uint32_t len);
/****************************************************************************
* Name: esp_wifi_sta_register_recv_cb
*
* Description:
* Register Wi-Fi receive packet callback function
*
* Input Parameters:
* input_cb - Receive callback function
*
* Returned Value:
* 0 if success or others if fail
*
****************************************************************************/
int esp_wifi_sta_register_recv_cb(int (*recv_cb)(void *buffer,
uint16_t len,
void *eb));
/****************************************************************************
* Name: esp_wifi_sta_read_mac
*
* Description:
* Read station interface MAC address from efuse
*
* Input Parameters:
* mac - MAC address buffer pointer
*
* Returned Value:
* 0 if success or -1 if fail
*
****************************************************************************/
int esp_wifi_sta_read_mac(uint8_t *mac);
/****************************************************************************
* Name: esp_wifi_free_eb
*
@ -168,70 +125,696 @@ int esp_wifi_sta_read_mac(uint8_t *mac);
void esp_wifi_free_eb(void *eb);
/****************************************************************************
* Name: esp_wifi_set_password
* Name: esp_wifi_notify_subscribe
*
* Description:
* Set Wi-Fi password
* Enable event notification
*
* Input Parameters:
* pdata - Password buffer pointer
* len - Password length
* pid - Task PID
* event - Signal event data pointer
*
* Returned Value:
* 0 if success or -1 if fail
*
****************************************************************************/
int esp_wifi_set_password(const uint8_t *pdata, uint8_t len);
int esp_wifi_notify_subscribe(pid_t pid, FAR struct sigevent *event);
#ifdef ESP32C3_WLAN_HAS_STA
/****************************************************************************
* Name: esp_wifi_set_ssid
* Name: esp_wifi_sta_start
*
* Description:
* Set Wi-Fi SSID
*
* Input Parameters:
* pdata - SSID buffer pointer
* len - SSID length
*
* Returned Value:
* 0 if success or -1 if fail
*
****************************************************************************/
int esp_wifi_set_ssid(const uint8_t *pdata, uint8_t len);
/****************************************************************************
* Name: esp_wifi_connect_internal
*
* Description:
* Trigger Wi-Fi connection action
* Start Wi-Fi station.
*
* Input Parameters:
* None
*
* Returned Value:
* 0 if success or -1 if fail
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_connect_internal(void);
int esp_wifi_sta_start(void);
/****************************************************************************
* Name: esp_wifi_sta_stop
*
* Description:
* Stop Wi-Fi station.
*
* Input Parameters:
* None
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_sta_stop(void);
/****************************************************************************
* Name: esp_wifi_sta_send_data
*
* Description:
* Use Wi-Fi station interface to send 802.3 frame
*
* Input Parameters:
* pbuf - Packet buffer pointer
* len - Packet length
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_sta_send_data(FAR void *pbuf, size_t len);
/****************************************************************************
* Name: esp_wifi_sta_register_recv_cb
*
* Description:
* Regitser Wi-Fi station receive packet callback function
*
* Input Parameters:
* recv_cb - Receive callback function
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_sta_register_recv_cb(int (*recv_cb)(void *buffer,
uint16_t len,
void *eb));
/****************************************************************************
* Name: esp_wifi_sta_register_txdone_cb
*
* Description:
* Register the txDone callback function of type wifi_tx_done_cb_t
* Register the station TX done callback function.
*
* Input Parameters:
* callback - The callback function
* cb - The callback function
*
* Returned Value:
* None
*
****************************************************************************/
void esp_wifi_sta_register_txdone_cb(wifi_txdone_cb_t cb);
/****************************************************************************
* Name: esp_wifi_sta_read_mac
*
* Description:
* Read station interface MAC address from efuse
*
* Input Parameters:
* mac - MAC address buffer pointer
*
* Returned Value:
* 0 if success or -1 if fail
*
****************************************************************************/
int esp_wifi_sta_register_txdone_cb(void *callback);
int esp_wifi_sta_read_mac(uint8_t *mac);
/****************************************************************************
* Name: esp_wifi_set_password
*
* Description:
* Set/Get Wi-Fi station password
*
* Input Parameters:
* iwr - The argument of the ioctl cmd
* set - true: set data; false: get data
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_sta_password(struct iwreq *iwr, bool set);
/****************************************************************************
* Name: esp_wifi_sta_essid
*
* Description:
* Set/Get Wi-Fi station ESSID
*
* Input Parameters:
* iwr - The argument of the ioctl cmd
* set - true: set data; false: get data
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_sta_essid(struct iwreq *iwr, bool set);
/****************************************************************************
* Name: esp_wifi_sta_bssid
*
* Description:
* Set/Get Wi-Fi station BSSID
*
* Input Parameters:
* iwr - The argument of the ioctl cmd
* set - true: set data; false: get data
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_sta_bssid(struct iwreq *iwr, bool set);
/****************************************************************************
* Name: esp_wifi_sta_connect
*
* Description:
* Trigger Wi-Fi station connection action
*
* Input Parameters:
* None
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_sta_connect(void);
/****************************************************************************
* Name: esp_wifi_sta_disconnect
*
* Description:
* Trigger Wi-Fi station disconnection action
*
* Input Parameters:
* None
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_sta_disconnect(void);
/****************************************************************************
* Name: esp_wifi_sta_mode
*
* Description:
* Set/Get Wi-Fi Station mode code.
*
* Input Parameters:
* iwr - The argument of the ioctl cmd
* set - true: set data; false: get data
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_sta_mode(struct iwreq *iwr, bool set);
/****************************************************************************
* Name: esp_wifi_sta_auth
*
* Description:
* Set/Get station authentication mode params.
*
* Input Parameters:
* iwr - The argument of the ioctl cmd
* set - true: set data; false: get data
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_sta_auth(struct iwreq *iwr, bool set);
/****************************************************************************
* Name: esp_wifi_sta_freq
*
* Description:
* Get station frequency.
*
* Input Parameters:
* iwr - The argument of the ioctl cmd
* set - true: set data; false: get data
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_sta_freq(struct iwreq *iwr, bool set);
/****************************************************************************
* Name: esp_wifi_sta_bitrate
*
* Description:
* Get station default bit rate (Mbps).
*
* Input Parameters:
* iwr - The argument of the ioctl cmd
* set - true: set data; false: get data
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_sta_bitrate(struct iwreq *iwr, bool set);
/****************************************************************************
* Name: esp_wifi_sta_get_txpower
*
* Description:
* Get station transmit power (dBm).
*
* Input Parameters:
* iwr - The argument of the ioctl cmd
* set - true: set data; false: get data
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_sta_txpower(struct iwreq *iwr, bool set);
/****************************************************************************
* Name: esp_wifi_sta_get_channel_range
*
* Description:
* Get station range of channel parameters.
*
* Input Parameters:
* iwr - The argument of the ioctl cmd
* set - true: set data; false: get data
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_sta_channel(struct iwreq *iwr, bool set);
/****************************************************************************
* Name: esp_wifi_sta_country
*
* Description:
* Configure country info.
*
* Input Parameters:
* iwr - The argument of the ioctl cmd
* set - true: set data; false: get data
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_sta_country(struct iwreq *iwr, bool set);
/****************************************************************************
* Name: esp_wifi_sta_rssi
*
* Description:
* Get Wi-Fi sensitivity (dBm).
*
* Input Parameters:
* iwr - The argument of the ioctl cmd
* set - true: set data; false: get data
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_sta_rssi(struct iwreq *iwr, bool set);
#endif
#ifdef ESP32C3_WLAN_HAS_SOFTAP
/****************************************************************************
* Name: esp_wifi_softap_start
*
* Description:
* Start Wi-Fi softAP.
*
* Input Parameters:
* None
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_softap_start(void);
/****************************************************************************
* Name: esp_wifi_softap_stop
*
* Description:
* Stop Wi-Fi softAP.
*
* Input Parameters:
* None
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_softap_stop(void);
/****************************************************************************
* Name: esp_wifi_softap_send_data
*
* Description:
* Use Wi-Fi softAP interface to send 802.3 frame
*
* Input Parameters:
* pbuf - Packet buffer pointer
* len - Packet length
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_softap_send_data(void *pbuf, size_t len);
/****************************************************************************
* Name: esp_wifi_softap_register_recv_cb
*
* Description:
* Regitser Wi-Fi softAP receive packet callback function
*
* Input Parameters:
* recv_cb - Receive callback function
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_softap_register_recv_cb(int (*recv_cb)(void *buffer,
uint16_t len,
void *eb));
/****************************************************************************
* Name: esp_wifi_softap_register_txdone_cb
*
* Description:
* Register the softAP TX done callback function.
*
* Input Parameters:
* cb - The callback function
*
* Returned Value:
* None
*
****************************************************************************/
void esp_wifi_softap_register_txdone_cb(wifi_txdone_cb_t cb);
/****************************************************************************
* Name: esp_wifi_softap_read_mac
*
* Description:
* Read softAP interface MAC address from efuse
*
* Input Parameters:
* mac - MAC address buffer pointer
*
* Returned Value:
* 0 if success or -1 if fail
*
****************************************************************************/
int esp_wifi_softap_read_mac(uint8_t *mac);
/****************************************************************************
* Name: esp_wifi_softap_password
*
* Description:
* Set/Get Wi-Fi SoftAP password
*
* Input Parameters:
* iwr - The argument of the ioctl cmd
* set - true: set data; false: get data
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_softap_password(struct iwreq *iwr, bool set);
/****************************************************************************
* Name: esp_wifi_softap_essid
*
* Description:
* Set/Get Wi-Fi SoftAP ESSID
*
* Input Parameters:
* iwr - The argument of the ioctl cmd
* set - true: set data; false: get data
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_softap_essid(struct iwreq *iwr, bool set);
/****************************************************************************
* Name: esp_wifi_softap_bssid
*
* Description:
* Set/Get Wi-Fi softAP BSSID
*
* Input Parameters:
* iwr - The argument of the ioctl cmd
* set - true: set data; false: get data
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_softap_bssid(struct iwreq *iwr, bool set);
/****************************************************************************
* Name: esp_wifi_softap_connect
*
* Description:
* Trigger Wi-Fi softAP accept connection action
*
* Input Parameters:
* None
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_softap_connect(void);
/****************************************************************************
* Name: esp_wifi_softap_disconnect
*
* Description:
* Trigger Wi-Fi softAP drop connection action
*
* Input Parameters:
* None
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_softap_disconnect(void);
/****************************************************************************
* Name: esp_wifi_softap_mode
*
* Description:
* Set/Get Wi-Fi SoftAP mode code.
*
* Input Parameters:
* iwr - The argument of the ioctl cmd
* set - true: set data; false: get data
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_softap_mode(struct iwreq *iwr, bool set);
/****************************************************************************
* Name: esp_wifi_softap_auth
*
* Description:
* Set/Get authentication mode params.
*
* Input Parameters:
* iwr - The argument of the ioctl cmd
* set - true: set data; false: get data
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_softap_auth(struct iwreq *iwr, bool set);
/****************************************************************************
* Name: esp_wifi_softap_freq
*
* Description:
* Set/Get SoftAP frequency.
*
* Input Parameters:
* iwr - The argument of the ioctl cmd
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_softap_freq(struct iwreq *iwr, bool set);
/****************************************************************************
* Name: esp_wifi_softap_get_bitrate
*
* Description:
* Get SoftAP default bit rate (Mbps).
*
* Input Parameters:
* iwr - The argument of the ioctl cmd
* set - true: set data; false: get data
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_softap_bitrate(struct iwreq *iwr, bool set);
/****************************************************************************
* Name: esp_wifi_softap_txpower
*
* Description:
* Get SoftAP transmit power (dBm).
*
* Input Parameters:
* iwr - The argument of the ioctl cmd
* set - true: set data; false: get data
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_softap_txpower(struct iwreq *iwr, bool set);
/****************************************************************************
* Name: esp_wifi_softap_channel
*
* Description:
* Get SoftAP range of channel parameters.
*
* Input Parameters:
* iwr - The argument of the ioctl cmd
* set - true: set data; false: get data
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_softap_channel(struct iwreq *iwr, bool set);
/****************************************************************************
* Name: esp_wifi_softap_country
*
* Description:
* Configure country info.
*
* Input Parameters:
* iwr - The argument of the ioctl cmd
* set - true: set data; false: get data
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_softap_country(struct iwreq *iwr, bool set);
/****************************************************************************
* Name: esp_wifi_softap_rssi
*
* Description:
* Get Wi-Fi sensitivity (dBm).
*
* Input Parameters:
* iwr - The argument of the ioctl cmd
* set - true: set data; false: get data
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_softap_rssi(struct iwreq *iwr, bool set);
#endif
#ifdef __cplusplus
}

View file

@ -0,0 +1,523 @@
/****************************************************************************
* arch/risc-v/src/esp32c3/esp32c3_wifi_utils.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/kmalloc.h>
#include <nuttx/net/arp.h>
#include <nuttx/wireless/wireless.h>
#include "esp32c3_wifi_adapter.h"
#include "esp32c3_wifi_utils.h"
#include "espidf_wifi.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Helper to get iw_event size */
#define ESP_IW_EVENT_SIZE(field) \
(offsetof(struct iw_event, u) + sizeof(((union iwreq_data *)0)->field))
#ifdef CONFIG_ESP32C3_WIFI_SCAN_RESULT_SIZE
# define WIFI_SCAN_RESULT_SIZE CONFIG_ESP32C3_WIFI_SCAN_RESULT_SIZE
#else
# define WIFI_SCAN_RESULT_SIZE (4096)
#endif
#define SCAN_TIME_SEC (5)
#ifndef MIN
# define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif
/****************************************************************************
* Private Types
****************************************************************************/
enum scan_status_e
{
ESP_SCAN_DISABLED = 0,
ESP_SCAN_RUN,
ESP_SCAN_DONE
};
/* Wi-Fi scan result information */
struct wifi_scan_result_s
{
enum scan_status_e scan_status; /* Scan status */
sem_t scan_signal; /* Scan notification signal */
uint8_t *scan_result; /* Temp buffer that holds results */
unsigned int scan_result_size; /* Current size of temp buffer */
};
/****************************************************************************
* Private Data
****************************************************************************/
static struct wifi_scan_result_s g_scan_priv;
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: esp_wifi_start_scan
*
* Description:
* Scan all available APs.
*
* Input Parameters:
* iwr - The argument of the ioctl cmd
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_start_scan(struct iwreq *iwr)
{
struct wifi_scan_result_s *priv = &g_scan_priv;
wifi_scan_config_t *config = NULL;
struct iw_scan_req *req;
int ret = 0;
uint8_t target_ssid[SSID_MAX_LEN + 1] =
{
0
};
if (iwr == NULL)
{
wlerr("ERROR: Invalid ioctl cmd.\n");
return -EINVAL;
}
if (g_scan_priv.scan_status != ESP_SCAN_DISABLED)
{
return OK;
}
config = kmm_calloc(1, sizeof(wifi_scan_config_t));
if (config == NULL)
{
wlerr("ERROR: Cannot allocate result buffer\n");
return -ENOMEM;
}
if (iwr->u.data.pointer &&
iwr->u.data.length >= sizeof(struct iw_scan_req))
{
req = (struct iw_scan_req *)iwr->u.data.pointer;
config->scan_type = (req->scan_type == IW_SCAN_TYPE_ACTIVE ?
WIFI_SCAN_TYPE_ACTIVE : WIFI_SCAN_TYPE_PASSIVE);
if (iwr->u.data.flags & IW_SCAN_THIS_ESSID &&
req->essid_len < sizeof(target_ssid))
{
/* Scan specific ESSID */
memcpy(&target_ssid[0], req->essid, req->essid_len);
config->ssid = &target_ssid[0];
config->ssid[req->essid_len] = '\0';
}
}
else
{
/* Default scan parameters */
wlinfo("INFO: Use default scan parameters\n");
config->scan_type = WIFI_SCAN_TYPE_ACTIVE; /* Active scan */
}
esp_wifi_start();
esp_wifi_scan_stop();
ret = esp_wifi_scan_start(config, false);
if (ret != OK)
{
wlerr("ERROR: Scan error, ret: %d\n", ret);
}
else
{
/* Allocate buffer to store scan result */
if (priv->scan_result == NULL)
{
priv->scan_result = kmm_malloc(WIFI_SCAN_RESULT_SIZE);
if (priv->scan_result == NULL)
{
wlerr("ERROR: Cannot allocate result buffer\n");
ret = -ENOMEM;
}
else
{
memset(priv->scan_result, 0x0, WIFI_SCAN_RESULT_SIZE);
}
}
}
if (config != NULL)
{
kmm_free(config);
config = NULL;
wlinfo("INFO: start scan\n");
}
g_scan_priv.scan_status = ESP_SCAN_RUN;
return ret;
}
/****************************************************************************
* Name: esp_wifi_get_scan_results
*
* Description:
* Get scan result
*
* Input Parameters:
* iwr - The argument of the ioctl cmd
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_get_scan_results(struct iwreq *iwr)
{
int ret = OK;
struct timespec abstime;
static bool scan_block = false;
struct wifi_scan_result_s *priv = &g_scan_priv;
if (g_scan_priv.scan_status == ESP_SCAN_RUN)
{
irqstate_t irqstate = enter_critical_section();
if (scan_block == false)
{
scan_block = true;
leave_critical_section(irqstate);
clock_gettime(CLOCK_REALTIME, &abstime);
abstime.tv_sec += SCAN_TIME_SEC;
nxsem_timedwait(&priv->scan_signal, &abstime);
scan_block = false;
}
else
{
leave_critical_section(irqstate);
ret = -EINVAL;
goto exit_failed;
}
}
if ((iwr == NULL) || (g_scan_priv.scan_status != ESP_SCAN_DONE))
{
ret = -EINVAL;
goto exit_failed;
}
if (priv->scan_result == NULL)
{
/* Result have already been requested */
ret = OK;
iwr->u.data.length = 0;
goto exit_failed;
}
if (iwr->u.data.pointer == NULL ||
iwr->u.data.length < priv->scan_result_size)
{
/* Stat request, return scan_result_size */
ret = -E2BIG;
iwr->u.data.pointer = NULL;
iwr->u.data.length = priv->scan_result_size;
goto exit_failed;
}
if (priv->scan_result_size <= 0)
{
ret = OK;
iwr->u.data.length = 0;
goto exit_free_buffer;
}
/* Copy result to user buffer */
if (iwr->u.data.length > priv->scan_result_size)
{
iwr->u.data.length = priv->scan_result_size;
}
memcpy(iwr->u.data.pointer, priv->scan_result, iwr->u.data.length);
exit_free_buffer:
/* Free scan result buffer */
kmm_free(priv->scan_result);
priv->scan_result = NULL;
priv->scan_result_size = 0;
g_scan_priv.scan_status = ESP_SCAN_DISABLED;
exit_failed:
if (ret < 0)
{
iwr->u.data.length = 0;
}
return ret;
}
/****************************************************************************
* Name: esp_wifi_scan_event_parse
*
* Description:
* Parse scan information
*
* Input Parameters:
* None
*
* Returned Value:
* None
*
****************************************************************************/
void esp_wifi_scan_event_parse(void)
{
struct wifi_scan_result_s *priv = &g_scan_priv;
wifi_ap_record_t *ap_list_buffer = NULL;
uint16_t bss_total = 0;
uint8_t bss_count = 0;
bool parse_done = false;
esp_wifi_scan_get_ap_num(&bss_total);
if (bss_total == 0)
{
wlinfo("INFO: None AP is scanned\n");
return;
}
ap_list_buffer = kmm_calloc(bss_total, sizeof(wifi_ap_record_t));
if (ap_list_buffer == NULL)
{
wlerr("ERROR: Failed to calloc buffer to print scan results");
return;
}
if (esp_wifi_scan_get_ap_records(&bss_total,
(wifi_ap_record_t *)ap_list_buffer) == OK)
{
struct iw_event *iwe;
unsigned int result_size;
size_t essid_len;
size_t essid_len_aligned;
for (bss_count = 0; bss_count < bss_total; bss_count++)
{
result_size = WIFI_SCAN_RESULT_SIZE - priv->scan_result_size;
/* Copy BSSID */
if (result_size < ESP_IW_EVENT_SIZE(ap_addr))
{
goto scan_result_full;
}
iwe = (struct iw_event *)
&priv->scan_result[priv->scan_result_size];
iwe->len = ESP_IW_EVENT_SIZE(ap_addr);
iwe->cmd = SIOCGIWAP;
memcpy(&iwe->u.ap_addr.sa_data, ap_list_buffer[bss_count].bssid,
sizeof(ap_list_buffer[bss_count].bssid));
iwe->u.ap_addr.sa_family = ARPHRD_ETHER;
priv->scan_result_size += ESP_IW_EVENT_SIZE(ap_addr);
result_size -= ESP_IW_EVENT_SIZE(ap_addr);
/* Copy ESSID */
essid_len = MIN(strlen((const char *)
ap_list_buffer[bss_count].ssid), SSID_MAX_LEN);
essid_len_aligned = (essid_len + 3) & -4;
if (result_size < ESP_IW_EVENT_SIZE(essid) + essid_len_aligned)
{
goto scan_result_full;
}
iwe = (struct iw_event *)
&priv->scan_result[priv->scan_result_size];
iwe->len = ESP_IW_EVENT_SIZE(essid) + essid_len_aligned;
iwe->cmd = SIOCGIWESSID;
iwe->u.essid.flags = 0;
iwe->u.essid.length = essid_len;
/* Special processing for iw_point, set offset in pointer field */
iwe->u.essid.pointer = (FAR void *)sizeof(iwe->u.essid);
memcpy(&iwe->u.essid + 1,
ap_list_buffer[bss_count].ssid, essid_len);
wlinfo("INFO: ssid %s\n", ap_list_buffer[bss_count].ssid);
priv->scan_result_size +=
ESP_IW_EVENT_SIZE(essid) + essid_len_aligned;
result_size -= ESP_IW_EVENT_SIZE(essid) + essid_len_aligned;
/* Copy link quality info */
if (result_size < ESP_IW_EVENT_SIZE(qual))
{
goto scan_result_full;
}
iwe = (struct iw_event *)
&priv->scan_result[priv->scan_result_size];
iwe->len = ESP_IW_EVENT_SIZE(qual);
iwe->cmd = IWEVQUAL;
iwe->u.qual.qual = 0x00;
wlinfo("INFO: signal %d\n", ap_list_buffer[bss_count].rssi);
iwe->u.qual.level = ap_list_buffer[bss_count].rssi;
iwe->u.qual.noise = 0x00;
iwe->u.qual.updated = IW_QUAL_DBM | IW_QUAL_ALL_UPDATED;
priv->scan_result_size += ESP_IW_EVENT_SIZE(qual);
result_size -= ESP_IW_EVENT_SIZE(qual);
/* Copy AP mode */
if (result_size < ESP_IW_EVENT_SIZE(mode))
{
goto scan_result_full;
}
iwe = (struct iw_event *)
&priv->scan_result[priv->scan_result_size];
iwe->len = ESP_IW_EVENT_SIZE(mode);
iwe->cmd = SIOCGIWMODE;
iwe->u.mode = IW_MODE_MASTER;
priv->scan_result_size += ESP_IW_EVENT_SIZE(mode);
result_size -= ESP_IW_EVENT_SIZE(mode);
/* Copy AP encryption mode */
if (result_size < ESP_IW_EVENT_SIZE(data))
{
goto scan_result_full;
}
iwe = (struct iw_event *)
&priv->scan_result[priv->scan_result_size];
iwe->len = ESP_IW_EVENT_SIZE(data);
iwe->cmd = SIOCGIWENCODE;
iwe->u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
iwe->u.data.length = 0;
iwe->u.essid.pointer = NULL;
priv->scan_result_size += ESP_IW_EVENT_SIZE(data);
result_size -= ESP_IW_EVENT_SIZE(data);
/* Copy AP channel */
if (result_size < ESP_IW_EVENT_SIZE(freq))
{
goto scan_result_full;
}
iwe = (struct iw_event *)
&priv->scan_result[priv->scan_result_size];
iwe->len = ESP_IW_EVENT_SIZE(freq);
iwe->cmd = SIOCGIWFREQ;
iwe->u.freq.e = 0;
iwe->u.freq.m = ap_list_buffer[bss_count].primary;
priv->scan_result_size += ESP_IW_EVENT_SIZE(freq);
result_size -= ESP_IW_EVENT_SIZE(freq);
}
parse_done = true;
}
scan_result_full:
/* Continue instead of break to log dropped AP results */
if (parse_done == false)
{
wlerr("ERROR: No more space in scan_result buffer\n");
}
if (ap_list_buffer != NULL)
{
kmm_free(ap_list_buffer);
ap_list_buffer = NULL;
}
g_scan_priv.scan_status = ESP_SCAN_DONE;
nxsem_post(&priv->scan_signal);
}
/****************************************************************************
* Name: esp_wifi_scan_init
*
* Description:
* Initialize Wi-Fi scan parameter.
*
* Input Parameters:
* None
*
* Returned Value:
* OK is returned on success. Otherwise, a negated errno value is returned.
*
****************************************************************************/
int esp_wifi_scan_init(void)
{
int ret;
struct wifi_scan_result_s *scan_priv = &g_scan_priv;
/* Initialize the scan structure */
memset(scan_priv, 0, sizeof(struct wifi_scan_result_s));
/* Init scan signal */
if ((ret = nxsem_init(&scan_priv->scan_signal, 0, 0)) != OK)
{
wlerr("ERROR: Initialization scan signal failed: %d\n", ret);
return ret;
}
if ((ret = nxsem_set_protocol(&scan_priv->scan_signal,
SEM_PRIO_NONE)) != OK)
{
wlerr("ERROR: Set semaphore protocol attribute failed: %d\n", ret);
}
return ret;
}

View file

@ -0,0 +1,120 @@
/****************************************************************************
* arch/risc-v/src/esp32c3/esp32c3_wifi_utils.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#ifndef __ARCH_RISCV_SRC_ESP32C3_ESP32C3_UTILS_H
#define __ARCH_RISCV_SRC_ESP32C3_ESP32C3_UTILS_H
#include <nuttx/config.h>
#include <nuttx/net/netdev.h>
#include <stdint.h>
#ifndef __ASSEMBLY__
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: esp_wifi_start_scan
*
* Description:
* Scan all available APs.
*
* Input Parameters:
* iwr - The argument of the ioctl cmd
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_start_scan(struct iwreq *iwr);
/****************************************************************************
* Name: esp_wifi_get_scan_results
*
* Description:
* Get scan result
*
* Input Parameters:
* req The argument of the ioctl cmd
*
* Returned Value:
* OK on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
int esp_wifi_get_scan_results(struct iwreq *iwr);
/****************************************************************************
* Name: esp_wifi_scan_event_parse
*
* Description:
* Parse scan information
*
* Input Parameters:
* None
*
* Returned Value:
* None
*
****************************************************************************/
void esp_wifi_scan_event_parse(void);
/****************************************************************************
* Name: esp_wifi_scan_init
*
* Description:
* Initialize Wi-Fi scan parameter.
*
* Input Parameters:
* None
*
* Returned Value:
* OK is returned on success. Otherwise, a negated errno value is returned.
*
****************************************************************************/
int esp_wifi_scan_init(void);
#ifdef __cplusplus
}
#endif
#undef EXTERN
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_XTENSA_SRC_ESP32_ESP32_UTILS_H */

File diff suppressed because it is too large Load diff

View file

@ -27,6 +27,8 @@
#include <nuttx/config.h>
#include "esp32c3_wifi_adapter.h"
#ifndef __ASSEMBLY__
#undef EXTERN
@ -38,6 +40,8 @@ extern "C"
#define EXTERN extern
#endif
#ifdef CONFIG_ESP32C3_WIRELESS
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
@ -56,8 +60,29 @@ extern "C"
*
****************************************************************************/
#ifdef ESP32C3_WLAN_HAS_STA
int esp32c3_wlan_sta_initialize(void);
#endif
/****************************************************************************
* Name: esp32c3_wlan_softap_initialize
*
* Description:
* Initialize the ESP32-C3 WLAN softAP netcard driver
*
* Input Parameters:
* None
*
* Returned Value:
* OK on success; Negated errno on failure.
*
****************************************************************************/
#ifdef ESP32C3_WLAN_HAS_SOFTAP
int esp32c3_wlan_softap_initialize(void);
#endif
#endif /* CONFIG_ESP32C3_WIRELESS */
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,82 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_NSH_ARGCAT is not set
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
# CONFIG_NSH_CMDPARMS is not set
CONFIG_ARCH="risc-v"
CONFIG_ARCH_BOARD="esp32c3-devkit"
CONFIG_ARCH_BOARD_ESP32C3_DEVKIT=y
CONFIG_ARCH_CHIP="esp32c3"
CONFIG_ARCH_CHIP_ESP32C3=y
CONFIG_ARCH_CHIP_ESP32C3WROOM02=y
CONFIG_ARCH_INTERRUPTSTACK=1536
CONFIG_ARCH_RISCV=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_BOARD_LOOPSPERMSEC=16717
CONFIG_BUILTIN=y
CONFIG_DEBUG_ASSERTIONS=y
CONFIG_DEBUG_ERROR=y
CONFIG_DEBUG_FEATURES=y
CONFIG_DEBUG_WARN=y
CONFIG_DEBUG_WIRELESS=y
CONFIG_DEBUG_WIRELESS_ERROR=y
CONFIG_DRIVERS_IEEE80211=y
CONFIG_DRIVERS_WIRELESS=y
CONFIG_ESP32C3_MTD_OFFSET=0x110000
CONFIG_ESP32C3_MTD_SIZE=0xf0000
CONFIG_ESP32C3_SPIFLASH=y
CONFIG_ESP32C3_WIFI_SAVE_PARAM=y
CONFIG_ESP32C3_WIFI_STATION_SOFTAP_COEXISTENCE=y
CONFIG_ESP32C3_WIRELESS=y
CONFIG_EXAMPLES_DHCPD=y
CONFIG_EXPERIMENTAL=y
CONFIG_FS_PROCFS=y
CONFIG_FS_SPIFFS=y
CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_IDLETHREAD_STACKSIZE=3072
CONFIG_INTELHEX_BINARY=y
CONFIG_LIBC_FLOATINGPOINT=y
CONFIG_MAX_TASKS=16
CONFIG_MM_REGIONS=3
CONFIG_NETDB_DNSCLIENT=y
CONFIG_NETDEV_LATEINIT=y
CONFIG_NETDEV_PHY_IOCTL=y
CONFIG_NETDEV_WIRELESS_IOCTL=y
CONFIG_NETUTILS_DHCPD=y
CONFIG_NET_BROADCAST=y
CONFIG_NET_ETH_PKTSIZE=1514
CONFIG_NET_ICMP=y
CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_UDP=y
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_LINELEN=64
CONFIG_NSH_READLINE=y
CONFIG_PREALLOC_TIMERS=4
CONFIG_PTHREAD_MUTEX_TYPES=y
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_LPWORK=y
CONFIG_SCHED_WAITPID=y
CONFIG_SDCLONE_DISABLE=y
CONFIG_SIG_DEFAULT=y
CONFIG_SPIFFS_NAME_MAX=48
CONFIG_START_DAY=6
CONFIG_START_MONTH=12
CONFIG_START_YEAR=2011
CONFIG_SYSTEM_DHCPC_RENEW=y
CONFIG_SYSTEM_NSH=y
CONFIG_SYSTEM_PING=y
CONFIG_UART0_SERIAL_CONSOLE=y
CONFIG_USER_ENTRYPOINT="nsh_main"
CONFIG_WIRELESS=y
CONFIG_WIRELESS_WAPI=y
CONFIG_WIRELESS_WAPI_CMDTOOL=y

View file

@ -27,6 +27,7 @@ CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_IDLETHREAD_STACKSIZE=3072
CONFIG_INTELHEX_BINARY=y
CONFIG_LIBC_FLOATINGPOINT=y
CONFIG_NAME_MAX=48
CONFIG_NETDB_DNSCLIENT=y
CONFIG_NETDEV_LATEINIT=y

View file

@ -38,7 +38,8 @@
#include <nuttx/fs/fs.h>
#include "esp32c3_wlan.h"
#include "esp32c3_spiflash.h"
#include "esp32c3_partition.h"
#include "esp32c3-devkit.h"
/****************************************************************************
@ -49,6 +50,46 @@
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: esp32c3_init_wifi_storage
*
* Description:
* Initialization of saved Wi-Fi parameters
*
****************************************************************************/
#ifdef CONFIG_ESP32C3_WIFI_SAVE_PARAM
static int esp32c3_init_wifi_storage(void)
{
int ret;
const char *path = "/dev/mtdblock1";
FAR struct mtd_dev_s *mtd_part;
mtd_part = esp32c3_spiflash_alloc_mtdpart();
if (!mtd_part)
{
syslog(LOG_ERR, "ERROR: Failed to alloc MTD partition of SPI Flash\n");
return -1;
}
ret = register_mtddriver(path, mtd_part, 0777, NULL);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: Failed to register MTD: %d\n", ret);
return -1;
}
ret = nx_mount(path, CONFIG_ESP32C3_WIFI_FS_MOUNTPT, "spiffs", 0, NULL);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: Failed to mount the FS volume: %d\n", ret);
return ret;
}
return 0;
}
#endif
/****************************************************************************
* Name: esp32c3_bringup
*
@ -165,12 +206,36 @@ int esp32c3_bringup(void)
#endif
#ifdef CONFIG_ESP32C3_WIRELESS
#ifdef CONFIG_ESP32C3_WIFI_SAVE_PARAM
ret = esp32c3_init_wifi_storage();
if (ret)
{
syslog(LOG_ERR, "ERROR: Failed to initialize Wi-Fi storage\n");
return ret;
}
#endif
#ifdef CONFIG_NET
#ifdef ESP32C3_WLAN_HAS_STA
ret = esp32c3_wlan_sta_initialize();
if (ret)
{
syslog(LOG_ERR, "ERROR: Failed to initialize Wi-Fi\n");
syslog(LOG_ERR, "ERROR: Failed to initialize Wi-Fi station\n");
return ret;
}
#endif
#ifdef ESP32C3_WLAN_HAS_SOFTAP
ret = esp32c3_wlan_softap_initialize();
if (ret)
{
syslog(LOG_ERR, "ERROR: Failed to initialize Wi-Fi softAP\n");
return ret;
}
#endif
#endif
#endif
/* If we got here then perhaps not all initialization was successful, but