samples: boards: remove esp32 wifi sample code
`samples/net/wifi` replaces custom esp32 wifi sample code. Then it can be removed from main repository. Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
This commit is contained in:
parent
a8cacfa530
commit
d524015f82
6 changed files with 0 additions and 225 deletions
|
|
@ -1,9 +0,0 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
cmake_minimum_required(VERSION 3.20.0)
|
||||
|
||||
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
|
||||
project(esp32_wifi_station)
|
||||
|
||||
FILE(GLOB app_sources src/*.c)
|
||||
target_sources(app PRIVATE ${app_sources})
|
||||
|
|
@ -1,101 +0,0 @@
|
|||
.. _esp32_wifi_station:
|
||||
|
||||
Espressif ESP32 WiFi Station
|
||||
############################
|
||||
|
||||
Overview
|
||||
********
|
||||
|
||||
This sample demonstrates how to use ESP32 to connect to a WiFi network as a station device.
|
||||
To configure WiFi credentials, edit ``prj.conf``.
|
||||
Enabling the ``net_shell`` module provides a set of commands to test the connection.
|
||||
See :ref:`network shell <net_shell>` for more details.
|
||||
|
||||
Supported SoCs
|
||||
**************
|
||||
|
||||
The following SoCs are supported by this sample code so far:
|
||||
|
||||
* ESP32
|
||||
* ESP32-S2
|
||||
* ESP32-C3
|
||||
|
||||
Building and Running
|
||||
********************
|
||||
|
||||
Make sure you have the ESP32 connected over USB port.
|
||||
|
||||
The sample can be built and flashed as follows:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
west build -b esp32 samples/boards/esp32/wifi_station
|
||||
west flash
|
||||
|
||||
If using another supported Espressif board, replace the board argument in the above
|
||||
command with your own board (e.g., :ref:`esp32s2_saola` board).
|
||||
|
||||
Sample Output
|
||||
=============
|
||||
|
||||
To check output of this sample, run ``west espressif monitor`` or any other serial console program (i.e. on Linux
|
||||
minicom, putty, screen, etc).
|
||||
This example uses ``west espressif monitor``, which automatically detects the serial port at ``/dev/ttyUSB0``:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ west espressif monitor
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
I (288) boot: Loaded app from partition at offset 0x10000
|
||||
I (288) boot: Disabling RNG early entropy source...
|
||||
I (611) wifi:wifi driver task: 3ffb2be8, prio:2, stack:3584, core=0
|
||||
I (613) wifi:wifi firmware version: 9c89486
|
||||
I (613) wifi:wifi certification version: v7.0
|
||||
I (614) wifi:config NVS flash: disabled
|
||||
I (618) wifi:config nano formatting: disabled
|
||||
I (622) wifi:Init data frame dynamic rx buffer num: 32
|
||||
I (627) wifi:Init management frame dynamic rx buffer num: 32
|
||||
I (632) wifi:Init management short buffer num: 32
|
||||
I (636) wifi:Init dynamic tx buffer num: 32
|
||||
I (640) wifi:Init static rx buffer size: 1600
|
||||
I (645) wifi:Init static rx buffer num: 10
|
||||
I (648) wifi:Init dynamic rx buffer num: 32
|
||||
phy_version: 4350, 18c5e94, Jul 27 2020, 21:04:07, 0, 2
|
||||
I (783) wifi:mode : softAP (24:6f:28:80:32:e9)
|
||||
I (784) wifi:Total power save buffer number: 16
|
||||
I (784) wifi:Init max length of beacon: 752/752
|
||||
I (788) wifi:Init max length of beacon: 752/752
|
||||
*** Booting Zephyr OS build zephyr-v2.4.0-49-g4da59e1678f7 ***
|
||||
I (798) wifi:mode : sta (24:6f:28:80:32:e8)
|
||||
I (1046) wifi:new:<4,1>, old:<1,1>, ap:<255,255>, sta:<4,1>, prof:1
|
||||
I (1694) wifi:state: init -> auth (b0)
|
||||
I (1711) wifi:state: auth -> assoc (0)
|
||||
I (1717) wifi:state: assoc -> run (10)
|
||||
I (1745) wifi:connected with myssid, aid = 4, channel 4, 40U, bssid = d8:07:b6:dd:47:7a
|
||||
I (1745) wifi:security: WPA2-PSK, phy: bgn, rssi: -57
|
||||
I (1747) wifi:pm start, type: 1
|
||||
|
||||
esp_event: WIFI STA start
|
||||
esp_event: WIFI STA connected
|
||||
I (1813) wifi:AP's beacon interval = 102400 us, DTIM period = 1
|
||||
net_dhcpv4: Received: 192.168.68.102
|
||||
esp32_wifi_sta: Your address: 192.168.68.102
|
||||
esp32_wifi_sta: Lease time: 7200 seconds
|
||||
esp32_wifi_sta: Subnet: 255.255.255.0
|
||||
esp32_wifi_sta: Router: 192.168.68.1
|
||||
|
||||
Sample console interaction
|
||||
==========================
|
||||
|
||||
If the :kconfig:option:`CONFIG_NET_SHELL` option is set, network shell functions
|
||||
can be used to check internet connection.
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
shell> net ping 8.8.8.8
|
||||
PING 8.8.8.8
|
||||
28 bytes from 8.8.8.8 to 192.168.68.102: icmp_seq=0 ttl=118 time=19 ms
|
||||
28 bytes from 8.8.8.8 to 192.168.68.102: icmp_seq=1 ttl=118 time=16 ms
|
||||
28 bytes from 8.8.8.8 to 192.168.68.102: icmp_seq=2 ttl=118 time=21 ms
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
CONFIG_HEAP_MEM_POOL_SIZE=37760
|
||||
|
||||
# when enabling NET_SHELL, the following
|
||||
# helps to optimize memory footprint
|
||||
CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=8
|
||||
CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=8
|
||||
CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=8
|
||||
CONFIG_ESP32_WIFI_IRAM_OPT=n
|
||||
CONFIG_ESP32_WIFI_RX_IRAM_OPT=n
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
CONFIG_WIFI=y
|
||||
CONFIG_HEAP_MEM_POOL_SIZE=98304
|
||||
|
||||
CONFIG_NETWORKING=y
|
||||
CONFIG_NET_L2_ETHERNET=y
|
||||
|
||||
CONFIG_NET_IPV6=n
|
||||
CONFIG_NET_IPV4=y
|
||||
CONFIG_NET_DHCPV4=y
|
||||
|
||||
CONFIG_NET_MGMT=y
|
||||
CONFIG_NET_MGMT_EVENT=y
|
||||
|
||||
CONFIG_NET_LOG=y
|
||||
CONFIG_NET_SHELL=n
|
||||
|
||||
CONFIG_MBEDTLS=y
|
||||
CONFIG_MBEDTLS_ENTROPY_ENABLED=y
|
||||
CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED=y
|
||||
CONFIG_MBEDTLS_ECP_ALL_ENABLED=y
|
||||
|
||||
CONFIG_ESP32_WIFI_SSID="myssid"
|
||||
CONFIG_ESP32_WIFI_PASSWORD="mypassword"
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
sample:
|
||||
name: Espressif ESP32 WiFi Station
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Espressif Systems (Shanghai) Co., Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/sys/printk.h>
|
||||
#include <esp_wifi.h>
|
||||
#include <esp_timer.h>
|
||||
#include <esp_event.h>
|
||||
|
||||
#include <zephyr/net/net_if.h>
|
||||
#include <zephyr/net/net_core.h>
|
||||
#include <zephyr/net/net_context.h>
|
||||
#include <zephyr/net/net_mgmt.h>
|
||||
|
||||
#include <zephyr/logging/log.h>
|
||||
LOG_MODULE_REGISTER(esp32_wifi_sta, LOG_LEVEL_DBG);
|
||||
|
||||
static struct net_mgmt_event_callback dhcp_cb;
|
||||
|
||||
static void handler_cb(struct net_mgmt_event_callback *cb,
|
||||
uint32_t mgmt_event, struct net_if *iface)
|
||||
{
|
||||
if (mgmt_event != NET_EVENT_IPV4_DHCP_BOUND) {
|
||||
return;
|
||||
}
|
||||
|
||||
char buf[NET_IPV4_ADDR_LEN];
|
||||
|
||||
LOG_INF("Your address: %s",
|
||||
net_addr_ntop(AF_INET,
|
||||
&iface->config.dhcpv4.requested_ip,
|
||||
buf, sizeof(buf)));
|
||||
LOG_INF("Lease time: %u seconds",
|
||||
iface->config.dhcpv4.lease_time);
|
||||
LOG_INF("Subnet: %s",
|
||||
net_addr_ntop(AF_INET,
|
||||
&iface->config.ip.ipv4->netmask,
|
||||
buf, sizeof(buf)));
|
||||
LOG_INF("Router: %s",
|
||||
net_addr_ntop(AF_INET,
|
||||
&iface->config.ip.ipv4->gw,
|
||||
buf, sizeof(buf)));
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
struct net_if *iface;
|
||||
|
||||
net_mgmt_init_event_callback(&dhcp_cb, handler_cb,
|
||||
NET_EVENT_IPV4_DHCP_BOUND);
|
||||
|
||||
net_mgmt_add_event_callback(&dhcp_cb);
|
||||
|
||||
iface = net_if_get_default();
|
||||
if (!iface) {
|
||||
LOG_ERR("wifi interface not available");
|
||||
return;
|
||||
}
|
||||
|
||||
net_dhcpv4_start(iface);
|
||||
|
||||
if (!IS_ENABLED(CONFIG_ESP32_WIFI_STA_AUTO)) {
|
||||
wifi_config_t wifi_config = {
|
||||
.sta = {
|
||||
.ssid = CONFIG_ESP32_WIFI_SSID,
|
||||
.password = CONFIG_ESP32_WIFI_PASSWORD,
|
||||
},
|
||||
};
|
||||
|
||||
esp_err_t ret = esp_wifi_set_mode(WIFI_MODE_STA);
|
||||
|
||||
ret |= esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config);
|
||||
ret |= esp_wifi_connect();
|
||||
if (ret != ESP_OK) {
|
||||
LOG_ERR("connection failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue