-
-
Notifications
You must be signed in to change notification settings - Fork 186
Fix Static addresses not working after change to ESP_NETIF and network not running with VS debugger #3133
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
Merged
Merged
Fix Static addresses not working after change to ESP_NETIF and network not running with VS debugger #3133
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
152f841
Set IP addresses and tidy
AdrianSoundy 688c9cb
Code style fixes
nfbot 2b6146a
Update code changes suggested by coderabbitai
AdrianSoundy 6261fb2
Fix comment typo
AdrianSoundy dd07729
Static IP fixes, debugger start fix
AdrianSoundy 1d4c78e
Code style fixes
nfbot 5946252
Merge pull request #9 from nanoframework/nfbot/clang-format-fix/539f0…
AdrianSoundy 183cc5c
Code rabbit AI suggested changes
AdrianSoundy f1da0d4
Fix ipv4/6 error on H2 & C6
AdrianSoundy 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
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,113 @@ | ||
| // | ||
| // Copyright (c) .NET Foundation and Contributors | ||
| // See LICENSE file in the project root for full license information. | ||
| // | ||
|
|
||
| // This file includes common method for networking code | ||
|
|
||
| #include "NF_ESP32_Network.h" | ||
| #include "esp_netif_net_stack.h" | ||
| #include "lwIP_Sockets.h" | ||
|
|
||
|
|
||
| // This function retrives the esp_netif ptr from the lwip structure for use else where | ||
| // This is a copy of internal funtion of ESP_NETIF | ||
| esp_netif_t * NF_ESP32_GetEspNetif(struct netif *netif) | ||
| { | ||
| #if LWIP_ESP_NETIF_DATA | ||
| return (esp_netif*)netif_get_client_data(netif); | ||
| #else | ||
| return (esp_netif_t *)netif->state; | ||
| #endif | ||
| } | ||
|
|
||
| // Wait for the network interface to become available | ||
| int NF_ESP32_Wait_NetNumber(int num) | ||
| { | ||
| int number = 0; | ||
| int timeoutMs = 30000; // 30 seconds timeout | ||
| int elapsedMs = 0; | ||
| esp_netif_t *espNetif; | ||
|
|
||
| while (elapsedMs < timeoutMs) | ||
| { | ||
| switch (num) | ||
| { | ||
| case IDF_WIFI_STA_DEF: | ||
| espNetif = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF"); | ||
| break; | ||
|
|
||
| case IDF_WIFI_AP_DEF: | ||
| espNetif = esp_netif_get_handle_from_ifkey("WIFI_AP_DEF"); | ||
| break; | ||
|
|
||
| case IDF_ETH_DEF: | ||
| espNetif = esp_netif_get_handle_from_ifkey("ETH_DEF"); | ||
| break; | ||
|
|
||
| case IDF_OT_DEF: | ||
| espNetif = esp_netif_get_handle_from_ifkey("OT_DEF"); | ||
| break; | ||
|
|
||
| default: | ||
| // can't reach here | ||
| HAL_AssertEx(); | ||
| break; | ||
| } | ||
|
|
||
| if (espNetif != NULL) | ||
| { | ||
| break; | ||
| } | ||
|
|
||
| const int delayMs = 20; | ||
| vTaskDelay(delayMs / portTICK_PERIOD_MS); | ||
| elapsedMs += delayMs; | ||
| } | ||
|
|
||
| if (espNetif == NULL) | ||
| { | ||
| // Return error or default value | ||
| return SOCK_SOCKET_ERROR; | ||
| } | ||
|
|
||
| // Add a delay before picking up "lwip_netif->num" as not been filled in yet on slower processors | ||
| vTaskDelay(50 / portTICK_PERIOD_MS); | ||
|
|
||
| return espNetif->lwip_netif->num; | ||
| } | ||
|
|
||
| HAL_Configuration_NetworkInterface *NF_ESP32_GetNetworkConfigBlock(int index) | ||
| { | ||
| HAL_Configuration_NetworkInterface *networkConfig = | ||
| (HAL_Configuration_NetworkInterface *)platform_malloc(sizeof(HAL_Configuration_NetworkInterface)); | ||
|
|
||
| if (networkConfig != NULL) | ||
| { | ||
| if (ConfigurationManager_GetConfigurationBlock(networkConfig, DeviceConfigurationOption_Network, index)) | ||
| { | ||
| return networkConfig; | ||
| } | ||
| platform_free(networkConfig); | ||
| } | ||
|
|
||
| return NULL; | ||
| } | ||
|
|
||
| esp_err_t NF_ESP32_ConfigureNetworkByConfigIndex(int index) | ||
| { | ||
| esp_err_t ec = ESP_OK; | ||
|
|
||
| HAL_Configuration_NetworkInterface *networkConfig = NF_ESP32_GetNetworkConfigBlock(index); | ||
| if (networkConfig == NULL) | ||
| { | ||
| return ESP_FAIL; | ||
| } | ||
|
|
||
| // Configure network interface | ||
| LWIP_SOCKETS_Driver::UpdateAdapterConfiguration(index, NetworkInterface_UpdateOperation_Dns | NetworkInterface_UpdateOperation_Dhcp, networkConfig); | ||
|
|
||
| platform_free(networkConfig); | ||
|
|
||
| return ec; | ||
| } |
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.