mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-25 09:42:35 +00:00
common_components: add wifi connect console commands
This commit is contained in:
@@ -12,14 +12,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "lwip/sys.h"
|
||||
#include <lwip/netdb.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Read and evaluate IP address from stdin
|
||||
*
|
||||
|
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
/* Private Funtions of protocol example common */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if CONFIG_EXAMPLE_CONNECT_IPV6
|
||||
#define NR_OF_IP_ADDRESSES_TO_WAIT_FOR (2)
|
||||
#else
|
||||
#define NR_OF_IP_ADDRESSES_TO_WAIT_FOR (1)
|
||||
#endif
|
||||
|
||||
|
||||
#if CONFIG_EXAMPLE_CONNECT_IPV6
|
||||
#define MAX_IP6_ADDRS_PER_NETIF (5)
|
||||
|
||||
#if defined(CONFIG_EXAMPLE_CONNECT_IPV6_PREF_LOCAL_LINK)
|
||||
#define EXAMPLE_CONNECT_PREFERRED_IPV6_TYPE ESP_IP6_ADDR_IS_LINK_LOCAL
|
||||
#elif defined(CONFIG_EXAMPLE_CONNECT_IPV6_PREF_GLOBAL)
|
||||
#define EXAMPLE_CONNECT_PREFERRED_IPV6_TYPE ESP_IP6_ADDR_IS_GLOBAL
|
||||
#elif defined(CONFIG_EXAMPLE_CONNECT_IPV6_PREF_SITE_LOCAL)
|
||||
#define EXAMPLE_CONNECT_PREFERRED_IPV6_TYPE ESP_IP6_ADDR_IS_SITE_LOCAL
|
||||
#elif defined(CONFIG_EXAMPLE_CONNECT_IPV6_PREF_UNIQUE_LOCAL)
|
||||
#define EXAMPLE_CONNECT_PREFERRED_IPV6_TYPE ESP_IP6_ADDR_IS_UNIQUE_LOCAL
|
||||
#endif // if-elif CONFIG_EXAMPLE_CONNECT_IPV6_PREF_...
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if CONFIG_EXAMPLE_CONNECT_IPV6
|
||||
extern const char *example_ipv6_addr_types_to_str[6];
|
||||
#endif
|
||||
|
||||
void example_wifi_start(void);
|
||||
void example_wifi_stop(void);
|
||||
esp_err_t example_wifi_sta_do_connect(wifi_config_t wifi_config, bool wait);
|
||||
esp_err_t example_wifi_sta_do_disconnect(void);
|
||||
bool example_is_our_netif(const char *prefix, esp_netif_t *netif);
|
||||
void example_print_all_netif_ips(const char *prefix);
|
||||
void example_wifi_shutdown(void);
|
||||
esp_err_t example_wifi_connect(void);
|
||||
void example_ethernet_shutdown(void);
|
||||
esp_err_t example_ethernet_connect(void);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@@ -9,25 +9,32 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_netif.h"
|
||||
#if CONFIG_EXAMPLE_CONNECT_ETHERNET
|
||||
#include "esp_eth.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_netif.h"
|
||||
#include "esp_eth.h"
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_CONNECT_ETHERNET
|
||||
#define EXAMPLE_INTERFACE get_example_netif()
|
||||
#if CONFIG_EXAMPLE_CONNECT_WIFI
|
||||
#define EXAMPLE_NETIF_DESC_STA "example_netif_sta"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_CONNECT_WIFI
|
||||
#define EXAMPLE_INTERFACE get_example_netif()
|
||||
#if CONFIG_EXAMPLE_CONNECT_ETHERNET
|
||||
#define EXAMPLE_NETIF_DESC_ETH "example_netif_eth"
|
||||
#endif
|
||||
|
||||
#if !defined (CONFIG_EXAMPLE_CONNECT_ETHERNET) && !defined (CONFIG_EXAMPLE_CONNECT_WIFI)
|
||||
// This is useful for some tests which do not need a network connection
|
||||
#define EXAMPLE_INTERFACE NULL
|
||||
/* Example default interface, prefer the ethernet one if running in example-test (CI) configuration */
|
||||
#if CONFIG_EXAMPLE_CONNECT_ETHERNET
|
||||
#define EXAMPLE_INTERFACE get_example_netif_from_desc(EXAMPLE_NETIF_DESC_ETH)
|
||||
#define get_example_netif() get_example_netif_from_desc(EXAMPLE_NETIF_DESC_ETH)
|
||||
#elif CONFIG_EXAMPLE_CONNECT_WIFI
|
||||
#define EXAMPLE_INTERFACE get_example_netif_from_desc(EXAMPLE_NETIF_DESC_STA)
|
||||
#define get_example_netif() get_example_netif_from_desc(EXAMPLE_NETIF_DESC_STA)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -60,15 +67,6 @@ esp_err_t example_disconnect(void);
|
||||
*/
|
||||
esp_err_t example_configure_stdin_stdout(void);
|
||||
|
||||
/**
|
||||
* @brief Returns esp-netif pointer created by example_connect()
|
||||
*
|
||||
* @note If multiple interfaces active at once, this API return NULL
|
||||
* In that case the get_example_netif_from_desc() should be used
|
||||
* to get esp-netif pointer based on interface description
|
||||
*/
|
||||
esp_netif_t *get_example_netif(void);
|
||||
|
||||
/**
|
||||
* @brief Returns esp-netif pointer created by example_connect() described by
|
||||
* the supplied desc field
|
||||
@@ -79,7 +77,16 @@ esp_netif_t *get_example_netif(void);
|
||||
*/
|
||||
esp_netif_t *get_example_netif_from_desc(const char *desc);
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_CONNECT_ETHERNET
|
||||
#if CONFIG_EXAMPLE_PROVIDE_WIFI_CONSOLE_CMD
|
||||
/**
|
||||
* @brief Register wifi connect commands
|
||||
*
|
||||
* @note Provide wifi connect commands using esp_console.
|
||||
*/
|
||||
void register_wifi_connect_commands(void);
|
||||
#endif
|
||||
|
||||
#if CONFIG_EXAMPLE_CONNECT_ETHERNET
|
||||
/**
|
||||
* @brief Get the example Ethernet driver handle
|
||||
*
|
||||
|
Reference in New Issue
Block a user