Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

Commit 76a0fd9

Browse files
authored
v1.10.0 to fix multiple-definitions linker error
### Releases v1.10.0 1. Fix `multiple-definitions` linker error and weird bug related to `src_cpp`. Check [Different behaviour using the src_cpp or src_h lib #80](#80) 2. Optimize library code by using `reference-passing` instead of `value-passing`
1 parent 5e8eaa9 commit 76a0fd9

File tree

2 files changed

+26
-25
lines changed

2 files changed

+26
-25
lines changed

src/ESPAsync_WiFiManager-Impl.h

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ ESPAsync_WMParameter::ESPAsync_WMParameter(const char *id, const char *placehold
7474
}
7575

7676
// KH, using struct
77-
ESPAsync_WMParameter::ESPAsync_WMParameter(WMParam_Data WMParam_data)
77+
ESPAsync_WMParameter::ESPAsync_WMParameter(const WMParam_Data& WMParam_data)
7878
{
7979
init(WMParam_data._id, WMParam_data._placeholder, WMParam_data._value, WMParam_data._length, "", WMParam_data._labelPlacement);
8080
}
@@ -111,7 +111,7 @@ ESPAsync_WMParameter::~ESPAsync_WMParameter()
111111
}
112112

113113
// Using Struct to get/set whole data at once
114-
void ESPAsync_WMParameter::setWMParam_Data(WMParam_Data WMParam_data)
114+
void ESPAsync_WMParameter::setWMParam_Data(const WMParam_Data& WMParam_data)
115115
{
116116
LOGINFO(F("setWMParam_Data"));
117117

@@ -1011,7 +1011,7 @@ int ESPAsync_WiFiManager::reconnectWifi()
10111011

10121012
//////////////////////////////////////////
10131013

1014-
int ESPAsync_WiFiManager::connectWifi(String ssid, String pass)
1014+
int ESPAsync_WiFiManager::connectWifi(const String& ssid, const String& pass)
10151015
{
10161016
// Add option if didn't input/update SSID/PW => Use the previous saved Credentials.
10171017
// But update the Static/DHCP options if changed.
@@ -1251,7 +1251,7 @@ int ESPAsync_WiFiManager::setConfigPortalChannel(int channel)
12511251

12521252
//////////////////////////////////////////
12531253

1254-
void ESPAsync_WiFiManager::setAPStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn)
1254+
void ESPAsync_WiFiManager::setAPStaticIPConfig(const IPAddress& ip, const IPAddress& gw, const IPAddress& sn)
12551255
{
12561256
LOGINFO(F("setAPStaticIPConfig"));
12571257
_WiFi_AP_IPconfig._ap_static_ip = ip;
@@ -1262,7 +1262,7 @@ void ESPAsync_WiFiManager::setAPStaticIPConfig(IPAddress ip, IPAddress gw, IPAdd
12621262
//////////////////////////////////////////
12631263

12641264
// KH, new using struct
1265-
void ESPAsync_WiFiManager::setAPStaticIPConfig(WiFi_AP_IPConfig WM_AP_IPconfig)
1265+
void ESPAsync_WiFiManager::setAPStaticIPConfig(const WiFi_AP_IPConfig& WM_AP_IPconfig)
12661266
{
12671267
LOGINFO(F("setAPStaticIPConfig"));
12681268

@@ -1280,7 +1280,7 @@ void ESPAsync_WiFiManager::getAPStaticIPConfig(WiFi_AP_IPConfig &WM_AP_IPconfig
12801280

12811281
//////////////////////////////////////////
12821282

1283-
void ESPAsync_WiFiManager::setSTAStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn)
1283+
void ESPAsync_WiFiManager::setSTAStaticIPConfig(const IPAddress& ip, const IPAddress& gw, const IPAddress& sn)
12841284
{
12851285
LOGINFO(F("setSTAStaticIPConfig"));
12861286
_WiFi_STA_IPconfig._sta_static_ip = ip;
@@ -1290,7 +1290,7 @@ void ESPAsync_WiFiManager::setSTAStaticIPConfig(IPAddress ip, IPAddress gw, IPAd
12901290

12911291
//////////////////////////////////////////
12921292

1293-
void ESPAsync_WiFiManager::setSTAStaticIPConfig(WiFi_STA_IPConfig WM_STA_IPconfig)
1293+
void ESPAsync_WiFiManager::setSTAStaticIPConfig(const WiFi_STA_IPConfig& WM_STA_IPconfig)
12941294
{
12951295
LOGINFO(F("setSTAStaticIPConfig"));
12961296

@@ -1310,7 +1310,8 @@ void ESPAsync_WiFiManager::getSTAStaticIPConfig(WiFi_STA_IPConfig &WM_STA_IPconf
13101310
//////////////////////////////////////////
13111311

13121312
#if USE_CONFIGURABLE_DNS
1313-
void ESPAsync_WiFiManager::setSTAStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn, IPAddress dns_address_1, IPAddress dns_address_2)
1313+
void ESPAsync_WiFiManager::setSTAStaticIPConfig(const IPAddress& ip, const IPAddress& gw, const IPAddress& sn,
1314+
const IPAddress& dns_address_1, const IPAddress& dns_address_2)
13141315
{
13151316
LOGINFO(F("setSTAStaticIPConfig for USE_CONFIGURABLE_DNS"));
13161317
_WiFi_STA_IPconfig._sta_static_ip = ip;
@@ -2283,7 +2284,7 @@ int ESPAsync_WiFiManager::getRSSIasQuality(int RSSI)
22832284
//////////////////////////////////////////
22842285

22852286
// Is this an IP?
2286-
bool ESPAsync_WiFiManager::isIp(String str)
2287+
bool ESPAsync_WiFiManager::isIp(const String& str)
22872288
{
22882289
for (unsigned int i = 0; i < str.length(); i++)
22892290
{
@@ -2294,15 +2295,17 @@ bool ESPAsync_WiFiManager::isIp(String str)
22942295
return false;
22952296
}
22962297
}
2298+
22972299
return true;
22982300
}
22992301

23002302
//////////////////////////////////////////
23012303

23022304
// IP to String
2303-
String ESPAsync_WiFiManager::toStringIp(IPAddress ip)
2305+
String ESPAsync_WiFiManager::toStringIp(const IPAddress& ip)
23042306
{
23052307
String res = "";
2308+
23062309
for (int i = 0; i < 3; i++)
23072310
{
23082311
res += String((ip >> (8 * i)) & 0xFF) + ".";

src/ESPAsync_WiFiManager.h

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -348,19 +348,17 @@ class ESPAsync_WMParameter
348348
public:
349349

350350
ESPAsync_WMParameter(const char *custom);
351-
//ESPAsync_WMParameter(const char *id, const char *placeholder, const char *defaultValue, int length);
352-
//ESPAsync_WMParameter(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom);
353351
ESPAsync_WMParameter(const char *id, const char *placeholder, const char *defaultValue, int length,
354352
const char *custom = "", int labelPlacement = WFM_LABEL_BEFORE);
355353

356354
// KH, using struct
357-
ESPAsync_WMParameter(WMParam_Data WMParam_data);
355+
ESPAsync_WMParameter(const WMParam_Data& WMParam_data);
358356
//////
359357

360358
~ESPAsync_WMParameter();
361359

362360
// Using Struct
363-
void setWMParam_Data(WMParam_Data WMParam_data);
361+
void setWMParam_Data(const WMParam_Data& WMParam_data);
364362
void getWMParam_Data(WMParam_Data &WMParam_data);
365363
//////
366364

@@ -465,24 +463,24 @@ class ESPAsync_WiFiManager
465463
//////
466464

467465
//sets a custom ip /gateway /subnet configuration
468-
void setAPStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn);
466+
void setAPStaticIPConfig(const IPAddress& ip, const IPAddress& gw, const IPAddress& sn);
469467

470468
// KH, new using struct
471-
void setAPStaticIPConfig(WiFi_AP_IPConfig WM_AP_IPconfig);
469+
void setAPStaticIPConfig(const WiFi_AP_IPConfig& WM_AP_IPconfig);
472470
void getAPStaticIPConfig(WiFi_AP_IPConfig &WM_AP_IPconfig);
473471
//////
474472

475473
//sets config for a static IP
476-
void setSTAStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn);
474+
void setSTAStaticIPConfig(const IPAddress& ip, const IPAddress& gw, const IPAddress& sn);
477475

478476
// KH, new using struct
479-
void setSTAStaticIPConfig(WiFi_STA_IPConfig WM_STA_IPconfig);
477+
void setSTAStaticIPConfig(const WiFi_STA_IPConfig& WM_STA_IPconfig);
480478
void getSTAStaticIPConfig(WiFi_STA_IPConfig &WM_STA_IPconfig);
481479
//////
482480

483481
#if USE_CONFIGURABLE_DNS
484-
void setSTAStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn,
485-
IPAddress dns_address_1, IPAddress dns_address_2);
482+
void setSTAStaticIPConfig(const IPAddress& ip, const IPAddress& gw, const IPAddress& sn,
483+
const IPAddress& dns_address_1, const IPAddress& dns_address_2);
486484
#endif
487485

488486
//called when AP mode and config portal is started
@@ -635,7 +633,7 @@ class ESPAsync_WiFiManager
635633
return _timezoneName;
636634
}
637635

638-
void setTimezoneName(String& inTimezoneName)
636+
void setTimezoneName(const String& inTimezoneName)
639637
{
640638
_timezoneName = inTimezoneName;
641639
}
@@ -670,7 +668,7 @@ class ESPAsync_WiFiManager
670668
}
671669

672670

673-
const char * getTZ(String& timezoneName)
671+
const char * getTZ(const String& timezoneName)
674672
{
675673
return getTZ(timezoneName.c_str());
676674
}
@@ -763,7 +761,7 @@ class ESPAsync_WiFiManager
763761
int reconnectWifi();
764762
//////
765763

766-
int connectWifi(String ssid = "", String pass = "");
764+
int connectWifi(const String& ssid = "", const String& pass = "");
767765

768766
wl_status_t waitForConnectResult();
769767

@@ -788,8 +786,8 @@ class ESPAsync_WiFiManager
788786

789787
//helpers
790788
int getRSSIasQuality(int RSSI);
791-
bool isIp(String str);
792-
String toStringIp(IPAddress ip);
789+
bool isIp(const String& str);
790+
String toStringIp(const IPAddress& ip);
793791

794792
bool connect;
795793
bool stopConfigPortal = false;

0 commit comments

Comments
 (0)