-
Notifications
You must be signed in to change notification settings - Fork 174
Component/net connect #939
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
abhik-roy85
wants to merge
5
commits into
espressif:master
Choose a base branch
from
abhik-roy85:component/net_connect
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c18c062
feat(net_connect): introduce unified network connectivity component
abhik-roy85 2fb9c98
fix(net_connect): improve error handling and memory safety
abhik-roy85 5211944
test(net_connect): add unit tests for net_get_netif_from_desc()
abhik-roy85 b20f0da
fix(net_connect): remove unused utilities and improve resource cleanup
abhik-roy85 ad25b9e
fix(net_connect): improve error handling and resource cleanup
abhik-roy85 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| idf_build_get_property(target IDF_TARGET) | ||
|
|
||
| if(${target} STREQUAL "linux") | ||
| # Header only library for linux | ||
|
|
||
| idf_component_register(INCLUDE_DIRS include) | ||
| return() | ||
| endif() | ||
|
|
||
| set(srcs "stdin_out.c" | ||
| "connect.c" | ||
| "wifi_connect.c") | ||
|
|
||
| if(CONFIG_NET_CONNECT_PROVIDE_WIFI_CONSOLE_CMD) | ||
| list(APPEND srcs "console_cmd.c") | ||
| endif() | ||
|
|
||
| if(CONFIG_NET_CONNECT_ETHERNET) | ||
| list(APPEND srcs "eth_connect.c") | ||
| endif() | ||
|
|
||
| if(CONFIG_NET_CONNECT_THREAD) | ||
| list(APPEND srcs "thread_connect.c") | ||
| endif() | ||
|
|
||
| if(CONFIG_NET_CONNECT_PPP) | ||
| list(APPEND srcs "ppp_connect.c") | ||
| endif() | ||
|
|
||
|
|
||
| idf_component_register(SRCS "${srcs}" | ||
| INCLUDE_DIRS "include" | ||
| PRIV_REQUIRES esp_netif esp_driver_gpio esp_driver_uart esp_wifi vfs openthread) | ||
|
|
||
| if(CONFIG_NET_CONNECT_PROVIDE_WIFI_CONSOLE_CMD) | ||
| idf_component_optional_requires(PRIVATE console) | ||
| endif() | ||
|
|
||
| if(CONFIG_NET_CONNECT_ETHERNET) | ||
| idf_component_optional_requires(PRIVATE esp_eth) | ||
| endif() | ||
|
|
||
| if(CONFIG_NET_CONNECT_THREAD) | ||
| idf_component_optional_requires(PRIVATE openthread) | ||
| endif() | ||
|
|
||
| if(CONFIG_NET_CONNECT_PPP) | ||
| idf_component_optional_requires(PRIVATE esp_tinyusb espressif__esp_tinyusb) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't component manager solve this? |
||
| endif() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,316 @@ | ||
| menu "Net Connect Configuration" | ||
|
|
||
| orsource "$IDF_PATH/examples/common_components/env_caps/$IDF_TARGET/Kconfig.env_caps" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why source from the example? |
||
|
|
||
| config NET_CONNECT_WIFI | ||
| bool "connect using WiFi interface" | ||
| depends on !IDF_TARGET_LINUX && (SOC_WIFI_SUPPORTED || ESP_WIFI_REMOTE_ENABLED || ESP_HOST_WIFI_ENABLED) | ||
| default y if SOC_WIFI_SUPPORTED | ||
| help | ||
| Protocol examples can use Wi-Fi, Ethernet and/or Thread to connect to the network. | ||
| Choose this option to connect with WiFi | ||
|
|
||
| if NET_CONNECT_WIFI | ||
| config NET_CONNECT_WIFI_SSID_PWD_FROM_STDIN | ||
| bool "Get ssid and password from stdin" | ||
| default n | ||
| help | ||
| Give the WiFi SSID and password from stdin. | ||
|
|
||
| config NET_CONNECT_PROVIDE_WIFI_CONSOLE_CMD | ||
| depends on !NET_CONNECT_WIFI_SSID_PWD_FROM_STDIN | ||
| bool "Provide wifi connect commands" | ||
| default y | ||
| help | ||
| Provide wifi connect commands for esp_console. | ||
| Please use `example_register_wifi_connect_commands` to register them. | ||
|
|
||
| config NET_CONNECT_WIFI_SSID | ||
| depends on !NET_CONNECT_WIFI_SSID_PWD_FROM_STDIN | ||
| string "WiFi SSID" | ||
| default "myssid" | ||
| help | ||
| SSID (network name) for the example to connect to. | ||
|
|
||
| config NET_CONNECT_WIFI_PASSWORD | ||
| depends on !NET_CONNECT_WIFI_SSID_PWD_FROM_STDIN | ||
| string "WiFi Password" | ||
| default "mypassword" | ||
| help | ||
| WiFi password (WPA or WPA2) for the example to use. | ||
| Can be left blank if the network has no security set. | ||
|
|
||
| config NET_CONNECT_WIFI_CONN_MAX_RETRY | ||
| int "Maximum retry" | ||
| default 6 | ||
| help | ||
| Set the Maximum retry to avoid station reconnecting to the AP unlimited, | ||
| in case the AP is really inexistent. | ||
|
|
||
| choice NET_CONNECT_WIFI_SCAN_METHOD | ||
| prompt "WiFi Scan Method" | ||
| default NET_CONNECT_WIFI_SCAN_METHOD_ALL_CHANNEL | ||
| help | ||
| WiFi scan method: | ||
|
|
||
| If "Fast" is selected, scan will end after find SSID match AP. | ||
|
|
||
| If "All Channel" is selected, scan will end after scan all the channel. | ||
|
|
||
| config NET_CONNECT_WIFI_SCAN_METHOD_FAST | ||
| bool "Fast" | ||
| config NET_CONNECT_WIFI_SCAN_METHOD_ALL_CHANNEL | ||
| bool "All Channel" | ||
| endchoice | ||
|
|
||
| menu "WiFi Scan threshold" | ||
| config NET_CONNECT_WIFI_SCAN_RSSI_THRESHOLD | ||
| int "WiFi minimum rssi" | ||
| range -127 0 | ||
|
|
||
| default -127 | ||
| help | ||
| The minimum rssi to accept in the scan mode. | ||
|
|
||
| choice NET_CONNECT_WIFI_SCAN_AUTH_MODE_THRESHOLD | ||
| prompt "WiFi Scan auth mode threshold" | ||
| default NET_CONNECT_WIFI_AUTH_OPEN | ||
| help | ||
| The weakest authmode to accept in the scan mode. | ||
|
|
||
| config NET_CONNECT_WIFI_AUTH_OPEN | ||
| bool "OPEN" | ||
| config NET_CONNECT_WIFI_AUTH_WEP | ||
| bool "WEP" | ||
| config NET_CONNECT_WIFI_AUTH_WPA_PSK | ||
| bool "WPA PSK" | ||
| config NET_CONNECT_WIFI_AUTH_WPA2_PSK | ||
| bool "WPA2 PSK" | ||
| config NET_CONNECT_WIFI_AUTH_WPA_WPA2_PSK | ||
| bool "WPA WPA2 PSK" | ||
| config NET_CONNECT_WIFI_AUTH_WPA2_ENTERPRISE | ||
| bool "WPA2 ENTERPRISE" | ||
| config NET_CONNECT_WIFI_AUTH_WPA3_PSK | ||
| bool "WPA3 PSK" | ||
| config NET_CONNECT_WIFI_AUTH_WPA2_WPA3_PSK | ||
| bool "WPA2 WPA3 PSK" | ||
| config NET_CONNECT_WIFI_AUTH_WAPI_PSK | ||
| bool "WAPI PSK" | ||
| endchoice | ||
| endmenu | ||
|
|
||
| choice NET_CONNECT_WIFI_CONNECT_AP_SORT_METHOD | ||
| prompt "WiFi Connect AP Sort Method" | ||
| default NET_CONNECT_WIFI_CONNECT_AP_BY_SIGNAL | ||
| help | ||
| WiFi connect AP sort method: | ||
|
|
||
| If "Signal" is selected, Sort matched APs in scan list by RSSI. | ||
|
|
||
| If "Security" is selected, Sort matched APs in scan list by security mode. | ||
|
|
||
| config NET_CONNECT_WIFI_CONNECT_AP_BY_SIGNAL | ||
| bool "Signal" | ||
| config NET_CONNECT_WIFI_CONNECT_AP_BY_SECURITY | ||
| bool "Security" | ||
| endchoice | ||
| endif | ||
|
|
||
| config NET_CONNECT_ETHERNET | ||
| bool "connect using Ethernet interface" | ||
| depends on !IDF_TARGET_LINUX | ||
| default y if !NET_CONNECT_WIFI && !NET_CONNECT_THREAD | ||
| help | ||
| Protocol examples can use Wi-Fi, Ethernet and/or Thread to connect to the network. | ||
| Choose this option to enable connection with Ethernet. | ||
| Go to `Top -> Ethernet Configuration` to configure the Ethernet interface. | ||
|
|
||
| config NET_CONNECT_DISABLE_ETHERNET_CONFIG | ||
| bool | ||
| select ETHERNET_INIT_OVERRIDE_DISABLE | ||
| default y if !NET_CONNECT_ETHERNET | ||
|
|
||
| config NET_CONNECT_PPP | ||
| bool "connect using Point to Point interface" | ||
| select LWIP_PPP_SUPPORT | ||
| help | ||
| Protocol examples can use PPP connection over serial line. | ||
| Choose this option to connect to the ppp server running | ||
| on your laptop over a serial line (either UART or USB ACM) | ||
|
|
||
| if NET_CONNECT_PPP | ||
| choice NET_CONNECT_PPP_DEVICE | ||
| prompt "Choose PPP device" | ||
| default NET_CONNECT_PPP_DEVICE_USB | ||
| help | ||
| Select which peripheral to use to connect to the PPP server. | ||
|
|
||
| config NET_CONNECT_PPP_DEVICE_USB | ||
| bool "USB" | ||
| depends on SOC_USB_OTG_SUPPORTED | ||
| select TINYUSB_CDC_ENABLED | ||
| help | ||
| Use USB ACM device. | ||
|
|
||
| config NET_CONNECT_PPP_DEVICE_UART | ||
| bool "UART" | ||
| help | ||
| Use UART. | ||
|
|
||
| endchoice | ||
|
|
||
| menu "UART Configuration" | ||
| depends on NET_CONNECT_PPP_DEVICE_UART | ||
| config NET_CONNECT_UART_TX_PIN | ||
| int "TXD Pin Number" | ||
| default 4 | ||
| range 0 31 | ||
| help | ||
| Pin number of UART TX. | ||
|
|
||
| config NET_CONNECT_UART_RX_PIN | ||
| int "RXD Pin Number" | ||
| default 5 | ||
| range 0 31 | ||
| help | ||
| Pin number of UART RX. | ||
|
|
||
| config NET_CONNECT_UART_BAUDRATE | ||
| int "UART Baudrate" | ||
| default 115200 | ||
| range 9600 3000000 | ||
| help | ||
| Baudrate of the UART device | ||
|
|
||
| endmenu | ||
|
|
||
| config NET_CONNECT_PPP_CONN_MAX_RETRY | ||
| int "Maximum retry" | ||
| default 6 | ||
| help | ||
| Set the Maximum retry to avoid station reconnecting if the pppd | ||
| is not available | ||
|
|
||
| endif # NET_CONNECT_PPP | ||
|
|
||
| config NET_CONNECT_THREAD | ||
| bool "Connect using Thread interface" | ||
| depends on !IDF_TARGET_LINUX && OPENTHREAD_ENABLED | ||
| default y if SOC_IEEE802154_SUPPORTED | ||
| select NET_CONNECT_IPV6 | ||
| help | ||
| Protocol examples can use Wi-Fi, Ethernet and/or Thread to connect to the network. | ||
| Choose this option to connect with Thread. | ||
| The operational active dataset of the Thread network can be configured in openthread | ||
| component at '->Components->OpenThread->Thread Core Features->Thread Operational Dataset' | ||
|
|
||
| if NET_CONNECT_THREAD | ||
| config NET_CONNECT_THREAD_TASK_STACK_SIZE | ||
| int "Example Thread task stack size" | ||
| default 8192 | ||
| help | ||
| Thread task stack size | ||
|
|
||
| menu "Radio Spinel Options" | ||
| depends on OPENTHREAD_RADIO_SPINEL_UART || OPENTHREAD_RADIO_SPINEL_SPI | ||
|
|
||
| config NET_CONNECT_THREAD_UART_RX_PIN | ||
| depends on OPENTHREAD_RADIO_SPINEL_UART | ||
| int "Uart Rx Pin" | ||
| default 17 | ||
|
|
||
| config NET_CONNECT_THREAD_UART_TX_PIN | ||
| depends on OPENTHREAD_RADIO_SPINEL_UART | ||
| int "Uart Tx pin" | ||
| default 18 | ||
|
|
||
| config NET_CONNECT_THREAD_UART_BAUD | ||
| depends on OPENTHREAD_RADIO_SPINEL_UART | ||
| int "Uart baud rate" | ||
| default 460800 | ||
|
|
||
| config NET_CONNECT_THREAD_UART_PORT | ||
| depends on OPENTHREAD_RADIO_SPINEL_UART | ||
| int "Uart port" | ||
| default 1 | ||
|
|
||
| config NET_CONNECT_THREAD_SPI_CS_PIN | ||
| depends on OPENTHREAD_RADIO_SPINEL_SPI | ||
| int "SPI CS Pin" | ||
| default 10 | ||
|
|
||
| config NET_CONNECT_THREAD_SPI_SCLK_PIN | ||
| depends on OPENTHREAD_RADIO_SPINEL_SPI | ||
| int "SPI SCLK Pin" | ||
| default 12 | ||
|
|
||
| config NET_CONNECT_THREAD_SPI_MISO_PIN | ||
| depends on OPENTHREAD_RADIO_SPINEL_SPI | ||
| int "SPI MISO Pin" | ||
| default 13 | ||
|
|
||
| config NET_CONNECT_THREAD_SPI_MOSI_PIN | ||
| depends on OPENTHREAD_RADIO_SPINEL_SPI | ||
| int "SPI MOSI Pin" | ||
| default 11 | ||
|
|
||
| config NET_CONNECT_THREAD_SPI_INTR_PIN | ||
| depends on OPENTHREAD_RADIO_SPINEL_SPI | ||
| int "SPI Interrupt Pin" | ||
| default 8 | ||
| endmenu | ||
|
|
||
| endif | ||
|
|
||
| config NET_CONNECT_IPV4 | ||
| bool | ||
| depends on LWIP_IPV4 | ||
| default n if NET_CONNECT_THREAD | ||
| default y | ||
|
|
||
| config NET_CONNECT_IPV6 | ||
| depends on NET_CONNECT_WIFI || NET_CONNECT_ETHERNET || NET_CONNECT_PPP || NET_CONNECT_THREAD | ||
| bool "Obtain IPv6 address" | ||
| default y | ||
| select LWIP_IPV6 | ||
| select LWIP_PPP_ENABLE_IPV6 if NET_CONNECT_PPP | ||
| help | ||
| By default, examples will wait until IPv4 and IPv6 local link addresses are obtained. | ||
| Disable this option if the network does not support IPv6. | ||
| Choose the preferred IPv6 address type if the connection code should wait until other than | ||
| the local link address gets assigned. | ||
| Consider enabling IPv6 stateless address autoconfiguration (SLAAC) in the LWIP component. | ||
|
|
||
| if NET_CONNECT_IPV6 | ||
| choice NET_CONNECT_PREFERRED_IPV6 | ||
| prompt "Preferred IPv6 Type" | ||
| default NET_CONNECT_IPV6_PREF_LOCAL_LINK | ||
| help | ||
| Select which kind of IPv6 address the connect logic waits for. | ||
|
|
||
| config NET_CONNECT_IPV6_PREF_LOCAL_LINK | ||
| bool "Local Link Address" | ||
| help | ||
| Blocks until Local link address assigned. | ||
|
|
||
| config NET_CONNECT_IPV6_PREF_GLOBAL | ||
| bool "Global Address" | ||
| help | ||
| Blocks until Global address assigned. | ||
|
|
||
| config NET_CONNECT_IPV6_PREF_SITE_LOCAL | ||
| bool "Site Local Address" | ||
| help | ||
| Blocks until Site link address assigned. | ||
|
|
||
| config NET_CONNECT_IPV6_PREF_UNIQUE_LOCAL | ||
| bool "Unique Local Link Address" | ||
| help | ||
| Blocks until Unique local address assigned. | ||
|
|
||
| endchoice | ||
|
|
||
| endif | ||
|
|
||
|
|
||
| endmenu | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are all these dependencies necessary?