mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-22 21:23:07 +03:00
Merge pull request #378 from chadouming/esp8266
Add function overload to config to include DNS
This commit is contained in:
commit
7839de0bb8
@ -40,6 +40,7 @@ extern "C" void esp_yield();
|
|||||||
ESP8266WiFiClass::ESP8266WiFiClass()
|
ESP8266WiFiClass::ESP8266WiFiClass()
|
||||||
: _useApMode(false)
|
: _useApMode(false)
|
||||||
, _useClientMode(false)
|
, _useClientMode(false)
|
||||||
|
, _useStaticIp(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +101,8 @@ int ESP8266WiFiClass::begin(const char* ssid, const char *passphrase, int32_t ch
|
|||||||
wifi_set_channel(channel);
|
wifi_set_channel(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
wifi_station_dhcpc_start();
|
if(!_useStaticIp)
|
||||||
|
wifi_station_dhcpc_start();
|
||||||
return status();
|
return status();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,6 +114,8 @@ uint8_t ESP8266WiFiClass::waitForConnectResult(){
|
|||||||
return status();
|
return status();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// You will have to set the DNS-Server manually later since this will not enable DHCP
|
||||||
void ESP8266WiFiClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subnet)
|
void ESP8266WiFiClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subnet)
|
||||||
{
|
{
|
||||||
struct ip_info info;
|
struct ip_info info;
|
||||||
@ -121,6 +125,26 @@ void ESP8266WiFiClass::config(IPAddress local_ip, IPAddress gateway, IPAddress s
|
|||||||
|
|
||||||
wifi_station_dhcpc_stop();
|
wifi_station_dhcpc_stop();
|
||||||
wifi_set_ip_info(STATION_IF, &info);
|
wifi_set_ip_info(STATION_IF, &info);
|
||||||
|
|
||||||
|
_useStaticIp = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ESP8266WiFiClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns)
|
||||||
|
{
|
||||||
|
struct ip_info info;
|
||||||
|
info.ip.addr = static_cast<uint32_t>(local_ip);
|
||||||
|
info.gw.addr = static_cast<uint32_t>(gateway);
|
||||||
|
info.netmask.addr = static_cast<uint32_t>(subnet);
|
||||||
|
|
||||||
|
wifi_station_dhcpc_stop();
|
||||||
|
wifi_set_ip_info(STATION_IF, &info);
|
||||||
|
|
||||||
|
// Set DNS-Server
|
||||||
|
ip_addr_t d;
|
||||||
|
d.addr = static_cast<uint32_t>(dns);
|
||||||
|
dns_setserver(0,&d);
|
||||||
|
|
||||||
|
_useStaticIp = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ESP8266WiFiClass::disconnect()
|
int ESP8266WiFiClass::disconnect()
|
||||||
|
@ -75,7 +75,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
void softAP(const char* ssid, const char* passphrase, int channel = 1);
|
void softAP(const char* ssid, const char* passphrase, int channel = 1);
|
||||||
|
|
||||||
|
|
||||||
/* Change Ip configuration settings disabling the dhcp client
|
/* Change Ip configuration settings disabling the dhcp client
|
||||||
*
|
*
|
||||||
* param local_ip: Static ip configuration
|
* param local_ip: Static ip configuration
|
||||||
@ -84,6 +83,15 @@ public:
|
|||||||
*/
|
*/
|
||||||
void config(IPAddress local_ip, IPAddress gateway, IPAddress subnet);
|
void config(IPAddress local_ip, IPAddress gateway, IPAddress subnet);
|
||||||
|
|
||||||
|
/* Change Ip configuration settings disabling the dhcp client
|
||||||
|
*
|
||||||
|
* param local_ip: Static ip configuration
|
||||||
|
* param gateway: Static gateway configuration
|
||||||
|
* param subnet: Static Subnet mask
|
||||||
|
* param dns: Defined DNS
|
||||||
|
*/
|
||||||
|
void config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns);
|
||||||
|
|
||||||
/* Configure access point
|
/* Configure access point
|
||||||
*
|
*
|
||||||
* param local_ip: access point IP
|
* param local_ip: access point IP
|
||||||
@ -310,7 +318,8 @@ protected:
|
|||||||
|
|
||||||
bool _useApMode;
|
bool _useApMode;
|
||||||
bool _useClientMode;
|
bool _useClientMode;
|
||||||
|
bool _useStaticIp;
|
||||||
|
|
||||||
static size_t _scanCount;
|
static size_t _scanCount;
|
||||||
static void* _scanResult;
|
static void* _scanResult;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user