Skip to content

Commit d9e4ec6

Browse files
committed
fix(examples): Add wifi_remote option to common connect example
* Add MQTT test configuration with WiFi on ESP32-P4 * Document esp_wifi_remote workflow in the example's README
1 parent ffe0de9 commit d9e4ec6

File tree

4 files changed

+183
-4
lines changed

4 files changed

+183
-4
lines changed

examples/common_components/protocol_examples_common/Kconfig.projbuild

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ menu "Example Connection Configuration"
44

55
config EXAMPLE_CONNECT_WIFI
66
bool "connect using WiFi interface"
7-
depends on !IDF_TARGET_LINUX && SOC_WIFI_SUPPORTED
8-
default y
7+
depends on !IDF_TARGET_LINUX && (SOC_WIFI_SUPPORTED || ESP_WIFI_REMOTE_ENABLED)
8+
default y if SOC_WIFI_SUPPORTED
99
help
1010
Protocol examples can use Wi-Fi and/or Ethernet to connect to the network.
1111
Choose this option to connect with WiFi
@@ -119,7 +119,7 @@ menu "Example Connection Configuration"
119119
config EXAMPLE_CONNECT_ETHERNET
120120
bool "connect using Ethernet interface"
121121
depends on !IDF_TARGET_LINUX
122-
default y if !SOC_WIFI_SUPPORTED
122+
default y if !EXAMPLE_CONNECT_WIFI
123123
help
124124
Protocol examples can use Wi-Fi and/or Ethernet to connect to the network.
125125
Choose this option to connect with Ethernet
@@ -218,7 +218,7 @@ menu "Example Connection Configuration"
218218
bool "KSZ80xx"
219219
help
220220
With the KSZ80xx series, Microchip offers single-chip 10BASE-T/100BASE-TX
221-
Ethernet Physical Layer Tranceivers (PHY).
221+
Ethernet Physical Layer Transceivers (PHY).
222222
The following chips are supported: KSZ8001, KSZ8021, KSZ8031, KSZ8041,
223223
KSZ8051, KSZ8061, KSZ8081, KSZ8091
224224
Goto https://www.microchip.com for more information about them.

examples/protocols/mqtt/tcp/README.md

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,174 @@ I (5194) MQTT_EXAMPLE: MQTT_EVENT_DATA
5959
TOPIC=/topic/qos0
6060
DATA=data
6161
```
62+
63+
## Using Wi-Fi connection with ESP32P4
64+
65+
It is possible to use Wi-Fi connection on targets that do not support native Wi-Fi peripheral. This example demonstrates using `esp_wifi_remote` on ESP32P4 in the test configuration defined as `sdkconfig.ci.p4_wifi`. This configuration requires another ESP target with native Wi-Fi support physically connected to the ESP32-P4.
66+
67+
### Configure master-slave verification
68+
69+
In order to secure the physical connection between the ESP32-P4 (master) and the slave device, it is necessary to set certificates and keys for each side.
70+
To bootstrap this step, you can use one-time generated self-signed RSA keys and certificates running:
71+
```
72+
./managed_components/espressif__esp_wifi_remote/examples/test_certs/generate_test_certs.sh espressif.local
73+
```
74+
75+
### Configure the slave project
76+
77+
It is recommended to create a new project from `esp_wifi_remote` component's example with
78+
```
79+
idf.py create-project-from-example "espressif/esp_wifi_remote:server"
80+
```
81+
but you can also build and flash the slave project directly from the `managed_components` directory using:
82+
```
83+
idf.py -C managed_components/espressif__esp_wifi_remote/examples/server/ -B build_slave
84+
```
85+
86+
Please follow these steps to setup the slave application:
87+
* `idf.py set-target` -- choose the slave target (must support Wi-Fi)
88+
* `idf.py menuconfig` -- configure the physical connection and verification details:
89+
- `CONFIG_ESP_WIFI_REMOTE_EPPP_CLIENT_CA` -- CA for verifying ESP32-P4 application
90+
- `CONFIG_ESP_WIFI_REMOTE_EPPP_SERVER_CRT` -- slave's certificate
91+
- `CONFIG_ESP_WIFI_REMOTE_EPPP_SERVER_KEY` -- slave's private key
92+
* `idf.py build flash monitor`
93+
94+
### Configure the master project (ESP32-P4)
95+
96+
similarly to the slave project, we have to configure
97+
* the physical connection
98+
* the verification
99+
- `CONFIG_ESP_WIFI_REMOTE_EPPP_SERVER_CA` -- CA for verifying the slave application
100+
- `CONFIG_ESP_WIFI_REMOTE_EPPP_CLIENT_CRT` -- our own certificate
101+
- `CONFIG_ESP_WIFI_REMOTE_EPPP_CLIENT_KEY` -- our own private key
102+
103+
After project configuration, you build and flash the board with
104+
```
105+
idf.py build flash monitor
106+
```
107+
108+
### Example Output of the slave device
109+
110+
```
111+
I (7982) main_task: Returned from app_main()
112+
I (8242) rpc_server: Received header id 2
113+
I (8242) pp: pp rom version: 5b8dcfa
114+
I (8242) net80211: net80211 rom version: 5b8dcfa
115+
I (8252) wifi:wifi driver task: 4082be8c, prio:23, stack:6656, core=0
116+
I (8252) wifi:wifi firmware version: feaf82d
117+
I (8252) wifi:wifi certification version: v7.0
118+
I (8252) wifi:config NVS flash: enabled
119+
I (8262) wifi:config nano formatting: disabled
120+
I (8262) wifi:mac_version:HAL_MAC_ESP32AX_761,ut_version:N, band:0x1
121+
I (8272) wifi:Init data frame dynamic rx buffer num: 32
122+
I (8272) wifi:Init static rx mgmt buffer num: 5
123+
I (8282) wifi:Init management short buffer num: 32
124+
I (8282) wifi:Init dynamic tx buffer num: 32
125+
I (8292) wifi:Init static tx FG buffer num: 2
126+
I (8292) wifi:Init static rx buffer size: 1700 (rxctrl:92, csi:512)
127+
I (8302) wifi:Init static rx buffer num: 10
128+
I (8302) wifi:Init dynamic rx buffer num: 32
129+
I (8302) wifi_init: rx ba win: 6
130+
I (8312) wifi_init: accept mbox: 6
131+
I (8312) wifi_init: tcpip mbox: 32
132+
I (8322) wifi_init: udp mbox: 6
133+
I (8322) wifi_init: tcp mbox: 6
134+
I (8322) wifi_init: tcp tx win: 5760
135+
I (8332) wifi_init: tcp rx win: 5760
136+
I (8332) wifi_init: tcp mss: 1440
137+
I (8342) wifi_init: WiFi IRAM OP enabled
138+
I (8342) wifi_init: WiFi RX IRAM OP enabled
139+
I (8352) wifi_init: WiFi SLP IRAM OP enabled
140+
I (8362) rpc_server: Received header id 11
141+
I (8362) rpc_server: Received header id 4
142+
I (8372) rpc_server: Received header id 6
143+
I (8372) phy_init: phy_version 270,339aa07,Apr 3 2024,16:36:11
144+
I (8492) wifi:enable tsf
145+
I (8492) rpc_server: Received WIFI event 41
146+
I (8502) rpc_server: Received WIFI event 2
147+
I (8732) rpc_server: Received header id 10
148+
I (8742) rpc_server: Received header id 5
149+
I (8752) rpc_server: Received header id 8
150+
I (11452) wifi:new:<6,0>, old:<1,0>, ap:<255,255>, sta:<6,0>, prof:1, snd_ch_cfg:0x0
151+
I (11452) wifi:(connect)dot11_authmode:0x3, pairwise_cipher:0x3, group_cipher:0x1
152+
I (11452) wifi:state: init -> auth (0xb0)
153+
I (11462) rpc_server: Received WIFI event 41
154+
I (11462) wifi:state: auth -> assoc (0x0)
155+
I (11472) wifi:(assoc)RESP, Extended Capabilities length:8, operating_mode_notification:0
156+
I (11472) wifi:(assoc)RESP, Extended Capabilities, MBSSID:0, TWT Responder:0, OBSS Narrow Bandwidth RU In OFDMA Tolerance:0
157+
I (11482) wifi:Extended Capabilities length:8, operating_mode_notification:1
158+
I (11492) wifi:state: assoc -> run (0x10)
159+
I (11492) wifi:(trc)phytype:CBW20-SGI, snr:50, maxRate:144, highestRateIdx:0
160+
W (11502) wifi:(trc)band:2G, phymode:3, highestRateIdx:0, lowestRateIdx:11, dataSchedTableSize:14
161+
I (11512) wifi:(trc)band:2G, rate(S-MCS7, rateIdx:0), ampdu(rate:S-MCS7, schedIdx(0, stop:8)), snr:50, ampduState:wait operational
162+
I (11522) wifi:ifidx:0, rssi:-45, nf:-95, phytype(0x3, CBW20-SGI), phymode(0x3, 11bgn), max_rate:144, he:0, vht:0, ht:1
163+
I (11532) wifi:(ht)max.RxAMPDULenExponent:3(65535 bytes), MMSS:6(8 us)
164+
W (11542) wifi:<ba-add>idx:0, ifx:0, tid:0, TAHI:0x1002cb4, TALO:0x1b942980, (ssn:0, win:64, cur_ssn:0), CONF:0xc0000005
165+
I (11572) wifi:connected with Cermakowifi, aid = 2, channel 6, BW20, bssid = 80:29:94:1b:b4:2c
166+
I (11572) wifi:cipher(pairwise:0x3, group:0x1), pmf:0, security:WPA2-PSK, phy:11bgn, rssi:-45
167+
I (11582) wifi:pm start, type: 1, twt_start:0
168+
169+
I (11582) wifi:pm start, type:1, aid:0x2, trans-BSSID:80:29:94:1b:b4:2c, BSSID[5]:0x2c, mbssid(max-indicator:0, index:0), he:0
170+
I (11592) wifi:dp: 1, bi: 102400, li: 3, scale listen interval from 307200 us to 307200 us
171+
I (11602) wifi:set rx beacon pti, rx_bcn_pti: 10, bcn_timeout: 25000, mt_pti: 10, mt_time: 10000
172+
I (11612) wifi:[ADDBA]TX addba request, tid:0, dialogtoken:1, bufsize:64, A-MSDU:0(not supported), policy:1(IMR), ssn:0(0x0)
173+
I (11622) wifi:[ADDBA]TX addba request, tid:7, dialogtoken:2, bufsize:64, A-MSDU:0(not supported), policy:1(IMR), ssn:0(0x20)
174+
I (11632) wifi:[ADDBA]TX addba request, tid:5, dialogtoken:3, bufsize:64, A-MSDU:0(not supported), policy:1(IMR), ssn:0(0x0)
175+
I (11642) wifi:[ADDBA]RX addba response, status:0, tid:7/tb:0(0x1), bufsize:64, batimeout:0, txa_wnd:64
176+
I (11652) wifi:[ADDBA]RX addba response, status:0, tid:5/tb:0(0x1), bufsize:64, batimeout:0, txa_wnd:64
177+
I (11662) wifi:[ADDBA]RX addba response, status:0, tid:0/tb:1(0x1), bufsize:64, batimeout:0, txa_wnd:64
178+
I (11672) wifi:AP's beacon interval = 102400 us, DTIM period = 1
179+
I (11682) rpc_server: Received WIFI event 4
180+
I (15682) esp_netif_handlers: sta ip: 192.168.0.33, mask: 255.255.255.0, gw: 192.168.0.1
181+
I (15682) rpc_server: Received IP event 0
182+
I (15682) rpc_server: Main DNS:185.162.24.55
183+
I (15682) rpc_server: IP address:192.168.0.33
184+
```
185+
186+
### Example Output of the master device (ESP32-P4)
187+
188+
```
189+
I (445) example_connect: Start example_connect.
190+
I (455) uart: queue free spaces: 16
191+
I (455) eppp_link: Waiting for IP address 0
192+
I (3195) esp-netif_lwip-ppp: Connected
193+
I (3195) eppp_link: Got IPv4 event: Interface "pppos_client(EPPP0)" address: 192.168.11.2
194+
I (3195) esp-netif_lwip-ppp: Connected
195+
I (3195) eppp_link: Connected! 0
196+
I (5475) example_connect: Waiting for IP(s)
197+
I (8405) esp_wifi_remote: esp_wifi_internal_reg_rxcb: sta: 0x4001c68a
198+
I (9445) example_connect: Got IPv6 event: Interface "pppos_client" address: fe80:0000:0000:0000:5632:04ff:fe08:5054, type: ESP_IP6_ADDR_IS_LINK_LOCAL
199+
I (12415) rpc_client: Main DNS:185.162.24.55
200+
I (12415) esp_netif_handlers: pppos_client ip: 192.168.11.2, mask: 255.255.255.255, gw: 192.168.11.1
201+
I (12415) rpc_client: EPPP IP:192.168.11.1
202+
I (12415) example_connect: Got IPv4 event: Interface "pppos_client" address: 192.168.11.2
203+
I (12425) rpc_client: WIFI IP:192.168.0.33
204+
I (12435) example_common: Connected to pppos_client
205+
I (12445) rpc_client: WIFI GW:192.168.0.1
206+
I (12455) example_common: - IPv6 address: fe80:0000:0000:0000:5632:04ff:fe08:5054, type: ESP_IP6_ADDR_IS_LINK_LOCAL
207+
I (12455) rpc_client: WIFI mask:255.255.255.0
208+
I (12465) example_common: Connected to pppos_client
209+
I (12475) example_common: - IPv4 address: 192.168.11.2,
210+
I (12475) example_common: - IPv6 address: fe80:0000:0000:0000:5c3b:1291:05ca:6dc8, type: ESP_IP6_ADDR_IS_LINK_LOCAL
211+
I (12495) mqtt_example: Other event id:7
212+
I (12495) main_task: Returned from app_main()
213+
I (12905) mqtt_example: MQTT_EVENT_CONNECTED
214+
I (12905) mqtt_example: sent publish successful, msg_id=36013
215+
I (12905) mqtt_example: sent subscribe successful, msg_id=44233
216+
I (12905) mqtt_example: sent subscribe successful, msg_id=36633
217+
I (12915) mqtt_example: sent unsubscribe successful, msg_id=15480
218+
I (13115) mqtt_example: MQTT_EVENT_PUBLISHED, msg_id=36013
219+
I (13415) mqtt_example: MQTT_EVENT_SUBSCRIBED, msg_id=44233
220+
I (13415) mqtt_example: sent publish successful, msg_id=0
221+
I (13415) mqtt_example: MQTT_EVENT_SUBSCRIBED, msg_id=36633
222+
I (13415) mqtt_example: sent publish successful, msg_id=0
223+
I (13425) mqtt_example: MQTT_EVENT_DATA
224+
TOPIC=/topic/qos1
225+
DATA=data_3
226+
I (13435) mqtt_example: MQTT_EVENT_UNSUBSCRIBED, msg_id=15480
227+
I (13615) mqtt_example: MQTT_EVENT_DATA
228+
TOPIC=/topic/qos0
229+
DATA=data
230+
I (13925) mqtt_example: MQTT_EVENT_DATA
231+
TOPIC=/topic/qos0
232+
```
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
dependencies:
22
protocol_examples_common:
33
path: ${IDF_PATH}/examples/common_components/protocol_examples_common
4+
espressif/esp_wifi_remote:
5+
version: ">=0.1.12"
6+
rules:
7+
- if: "target in [esp32p4, esp32h2]"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CONFIG_IDF_TARGET="esp32p4"
2+
CONFIG_EXAMPLE_CONNECT_WIFI=y
3+
CONFIG_ESP_WIFI_REMOTE_EPPP_UART_TX_PIN=17
4+
CONFIG_ESP_WIFI_REMOTE_EPPP_UART_RX_PIN=16

0 commit comments

Comments
 (0)