-
Notifications
You must be signed in to change notification settings - Fork 7.7k
3.0.0 Network Refactoring #8760
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
Changes from 1 commit
ca7ec90
e42b99a
044da55
f2824bc
74a18b6
0e6d289
0c561bc
0edaa59
dfc59e7
da4d198
105c739
44f899f
f4d8cba
78cc5ec
61b8675
4f087ee
638abc3
7f4b1ec
3a83cfa
c8a4d5a
8ace49a
102a776
864cec1
ae2a889
824d2a0
2085bbe
8c5ae3c
ea1717b
a8b19cd
09910c4
2711182
050a267
43e0564
c44d255
1c580b8
f223ce0
6ce26e9
6691cdb
9716d5d
bcc8e3d
9bd5205
1f5b81d
1e6725a
d8d2f09
4127270
bf97e36
7afd573
cc5765f
0ec3884
a39dcfd
df90716
9db3df9
224e5eb
c3efaa5
29ab925
d5d59d3
8f79cde
7e893e9
fb0041c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1247,9 +1247,75 @@ bool WiFiGenericClass::setDualAntennaConfig(uint8_t gpio_ant1, uint8_t gpio_ant2 | |
| // ------------------------------------------------ Generic Network function --------------------------------------------- | ||
| // ----------------------------------------------------------------------------------------------------------------------- | ||
|
|
||
| /** | ||
| * DNS callback | ||
| * @param name | ||
| * @param ipaddr | ||
| * @param callback_arg | ||
| */ | ||
| static void wifi_dns_found_callback(const char *name, const ip_addr_t *ipaddr, void *callback_arg) | ||
| { | ||
| if(ipaddr) { | ||
| (*reinterpret_cast<IPAddress*>(callback_arg)) = ipaddr->u_addr.ip4.addr; | ||
| } | ||
| xEventGroupSetBits(_arduino_event_group, WIFI_DNS_DONE_BIT); | ||
| } | ||
|
|
||
| typedef struct gethostbynameParameters { | ||
| const char *hostname; | ||
| ip_addr_t addr; | ||
| void *callback_arg; | ||
| } gethostbynameParameters_t; | ||
|
|
||
| /** | ||
| * Callback to execute dns_gethostbyname in lwIP's TCP/IP context | ||
| * @param param Parameters for dns_gethostbyname call | ||
| */ | ||
| static esp_err_t wifi_gethostbyname_tcpip_ctx(void *param) | ||
| { | ||
| gethostbynameParameters_t *parameters = static_cast<gethostbynameParameters_t *>(param); | ||
| return dns_gethostbyname(parameters->hostname, ¶meters->addr, &wifi_dns_found_callback, parameters->callback_arg); | ||
| } | ||
|
|
||
| /** | ||
| * Resolve the given hostname to an IP address. If passed hostname is an IP address, it will be parsed into IPAddress structure. | ||
| * @param aHostname Name to be resolved or string containing IP address | ||
| * @param aResult IPAddress structure to store the returned IP address | ||
| * @return 1 if aIPAddrString was successfully converted to an IP address, | ||
| * else error code | ||
| */ | ||
| int WiFiGenericClass::hostByName(const char* aHostname, IPAddress& aResult) | ||
| { | ||
| if (!aResult.fromString(aHostname)) | ||
| { | ||
| gethostbynameParameters_t params; | ||
| params.hostname = aHostname; | ||
| params.callback_arg = &aResult; | ||
| aResult = static_cast<uint32_t>(0); | ||
| waitStatusBits(WIFI_DNS_IDLE_BIT, 16000); | ||
| clearStatusBits(WIFI_DNS_IDLE_BIT | WIFI_DNS_DONE_BIT); | ||
| err_t err = esp_netif_tcpip_exec(wifi_gethostbyname_tcpip_ctx, ¶ms); | ||
| if(err == ERR_OK && params.addr.u_addr.ip4.addr) { | ||
| aResult = params.addr.u_addr.ip4.addr; | ||
| } else if(err == ERR_INPROGRESS) { | ||
| waitStatusBits(WIFI_DNS_DONE_BIT, 15000); //real internal timeout in lwip library is 14[s] | ||
| clearStatusBits(WIFI_DNS_DONE_BIT); | ||
| } | ||
| setStatusBits(WIFI_DNS_IDLE_BIT); | ||
| if((uint32_t)aResult == 0){ | ||
| log_e("DNS Failed for %s", aHostname); | ||
| } | ||
| } | ||
| return (uint32_t)aResult != 0; | ||
| } | ||
|
|
||
| /* | ||
| * Deprecated Methods | ||
|
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. Can we mark all the newly deprecated functions with the 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. No. There is too much code out there that uses those functions. Let's roll out as-is and re-think deprecation with 3.1. |
||
| */ | ||
| // int WiFiGenericClass::hostByName(const char* aHostname, IPAddress& aResult) | ||
| // { | ||
| // return Network.hostByName(aHostname, aResult); | ||
| // } | ||
|
|
||
| IPAddress WiFiGenericClass::calculateNetworkID(IPAddress ip, IPAddress subnet) { | ||
| IPAddress networkID; | ||
|
|
@@ -1294,11 +1360,6 @@ uint8_t WiFiGenericClass::calculateSubnetCIDR(IPAddress subnetMask) { | |
| return CIDR; | ||
| } | ||
|
|
||
| int WiFiGenericClass::hostByName(const char* aHostname, IPAddress& aResult) | ||
| { | ||
| return Network.hostByName(aHostname, aResult); | ||
| } | ||
|
|
||
| wifi_event_id_t WiFiGenericClass::onEvent(WiFiEventCb cbEvent, arduino_event_id_t event) | ||
| { | ||
| return Network.onEvent(cbEvent, event); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.