Fixed it so it only pulls the ip once
This commit is contained in:
@@ -21,9 +21,9 @@ void Connectivity::connectWiFi(char* ssid, char* pass){
|
||||
// }
|
||||
|
||||
const char* getServerURL = "http://145.92.8.132:443/get-ip";
|
||||
String ipAddress = "";
|
||||
char* ipAddress = "";
|
||||
|
||||
String Connectivity::fetchIPAddress() {
|
||||
const char* Connectivity::fetchIPAddress() {
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
HTTPClient http;
|
||||
WiFiClient client;
|
||||
@@ -32,7 +32,7 @@ String Connectivity::fetchIPAddress() {
|
||||
int httpCode = http.GET();
|
||||
if (httpCode > 0) {
|
||||
if (httpCode == HTTP_CODE_OK) {
|
||||
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