10000 Fixes, optimizations and additions to WiFi by Eloquence4 · Pull Request #86 · nkolban/esp32-snippets · GitHub
[go: up one dir, main page]

Skip to content

Fixes, optimizations and additions to WiFi #86

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 5 commits into from
Sep 26, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Frees the memory used by the event handler on destruction
Also a small optimization in the WiFi constructor
  • Loading branch information
Eloquence4 committed Sep 26, 2017
commit fbc7022fc56be09e9e6fbab9df6f95f0b386d2c9
22 changes: 18 additions & 4 deletions cpp_utils/WiFi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,27 @@ static void setDNSServer(char *ip) {
*/


WiFi::WiFi() {
ip = "";
gw = "";
netmask = "";
}
*/

/**
* @brief Creates and uses a default event handler
*/
WiFi::WiFi()
: ip("")
, gw("")
, netmask("")
, wifiEventHandler(nullptr)
{
wifiEventHandler = new WiFiEventHandler();
}

/**
* @brief Deletes the event handler that was used by the class
*/
WiFi::~WiFi() {
delete wifiEventHandler;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to check that wifiEventHandler isn't null before deleting?

Copy link
Contributor Author
@Eloquence4 Eloquence4 Sep 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, C++ does that automatically. If it's null, then delete just does nothing, so the if statement is irrelevant.

}

/**
* @brief Add a reference to a DNS server.
Expand Down
1 change: 1 addition & 0 deletions cpp_utils/WiFi.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class WiFi {

public:
WiFi();
~WiFi();
void addDNSServer(const std::string& ip);
void addDNSServer(const char* ip);
void setDNSServer(int numdns, const std::string& ip);
Expand Down
0