Refactoring
This commit is contained in:
@@ -24,6 +24,7 @@ const char* getServerURL = "http://145.92.8.132:443/get-ip";
|
||||
String ipAddress = ""; // string that will hold the server's IP address
|
||||
|
||||
const char* Connectivity::fetchIPAddress() {
|
||||
char* ipAddress = NULL; // Declare ipAddress as a char*
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
HTTPClient http;
|
||||
WiFiClient client;
|
||||
@@ -33,7 +34,7 @@ const char* Connectivity::fetchIPAddress() {
|
||||
if (httpCode > 0) {
|
||||
if (httpCode == HTTP_CODE_OK) {
|
||||
// If successful (code 200), read the response body and store the IP address
|
||||
ipAddress = http.getString();
|
||||
ipAddress = strdup(http.getString().c_str());
|
||||
}
|
||||
} else {
|
||||
Serial.printf("GET request failed, error: %s\n", http.errorToString(httpCode).c_str());
|
||||
|
Reference in New Issue
Block a user