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

Commit 3ba7bec

Browse files
committed
change NULL to nullptr
1 parent e108af1 commit 3ba7bec

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

src/esp8266-google-home-notifier.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ boolean GoogleHomeNotifier::ip(IPAddress ip, const char *locale, uint16_t port)
5757
}
5858

5959
boolean GoogleHomeNotifier::notify(const char *phrase, WiFiClientSecure* pClient) {
60-
return this->cast(phrase, NULL, pClient);
60+
return this->cast(phrase, nullptr, pClient);
6161
}
6262

6363
boolean GoogleHomeNotifier::play(const char *mp3Url, WiFiClientSecure* pClient) {
64-
return this->cast(NULL, mp3Url, pClient);
64+
return this->cast(nullptr, mp3Url, pClient);
6565
}
6666

6767
boolean GoogleHomeNotifier::cast(const char *phrase, const char *mp3Url, WiFiClientSecure* pClient)
@@ -72,15 +72,14 @@ boolean GoogleHomeNotifier::cast(const char *phrase, const char *mp3Url, WiFiCli
7272
return false;
7373
}
7474
String speechUrl;
75-
if (pClient != NULL) {
76-
if (m_client != NULL) delete m_client;
75+
if (pClient != nullptr) {
7776
m_client = pClient;
7877
m_clientCreated = false;
7978
} else if(!m_client) {
8079
m_client = new WiFiClientSecure();
8180
m_clientCreated = true;
8281
}
83-
if (phrase != NULL) {
82+
if (phrase != nullptr) {
8483
tts.setWiFiClientSecure(m_client);
8584
speechUrl = tts.getSpeechUrl(phrase, m_locale);
8685
delay(1);
@@ -89,17 +88,17 @@ boolean GoogleHomeNotifier::cast(const char *phrase, const char *mp3Url, WiFiCli
8988
this->setLastError("Failed to get TTS url.");
9089
if (m_clientCreated == true) {
9190
delete m_client;
92-
m_client = NULL;
91+
m_client = nullptr;
9392
}
9493
return false;
9594
}
96-
} else if (mp3Url != NULL) {
95+
} else if (mp3Url != nullptr) {
9796
speechUrl = mp3Url;
9897
} else {
99-
this->setLastError("Both TTS phrase and mp3 url are NULL.");
98+
this->setLastError("Both TTS phrase and mp3 url are nullptr.");
10099
if (m_clientCreated == true) {
101100
delete m_client;
102-
m_client = NULL;
101+
m_client = nullptr;
103102
}
104103
return false;
105104
}
@@ -157,7 +156,7 @@ boolean GoogleHomeNotifier::sendMessage(const char *sourceId, const char *destin
157156
message.payload_utf8.funcs.encode = &(GoogleHomeNotifier::encode_string);
158157
message.payload_utf8.arg = (void*)data;
159158

160-
uint8_t* buf = NULL;
159+
uint8_t* buf = nullptr;
161160
uint32_t bufferSize = 0;
162161
uint8_t packetSize[4];
163162
boolean status;
@@ -304,7 +303,7 @@ void GoogleHomeNotifier::disconnect() {
304303
if (m_client->connected()) m_client->stop();
305304
if (m_clientCreated == true) {
306305
delete m_client;
307-
m_client = NULL;
306+
m_client = nullptr;
308307
}
309308
}
310309
}

src/esp8266-google-home-notifier.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ typedef class GoogleHomeNotifier {
5858
void disconnect();
5959
void setLastError(const char *lastError);
6060
boolean sendMessage(const char *sourceId, const char *destinationId, const char *ns, const char *data);
61-
boolean cast(const char *phrase, const char *mp3Url, WiFiClientSecure* pClient = NULL);
61+
boolean cast(const char *phrase, const char *mp3Url, WiFiClientSecure* pClient = nullptr);
6262

6363
public:
6464
boolean ip(IPAddress ip, const char *locale = "en", uint16_t port = 8009);
6565
boolean device(const char *name, const char *locale = "en", int to = 10000);
66-
boolean notify(const char *phrase, WiFiClientSecure* pClient = NULL);
67-
boolean play(const char *mp3Url, WiFiClientSecure* pClient = NULL);
66+
boolean notify(const char *phrase, WiFiClientSecure* pClient = nullptr);
67+
boolean play(const char *mp3Url, WiFiClientSecure* pClient = nullptr);
6868
const IPAddress getIPAddress();
6969
const uint16_t getPort();
7070
const char * getLastError();

0 commit comments

Comments
 (0)