added comments to Connectivity class
This commit is contained in:
@@ -23,6 +23,7 @@ void Connectivity::connectWiFi(char* ssid, char* pass){
|
|||||||
const char* getServerURL = "http://145.92.8.132:443/get-ip";
|
const char* getServerURL = "http://145.92.8.132:443/get-ip";
|
||||||
String ipAddress = ""; // string that will hold the server's IP address
|
String ipAddress = ""; // string that will hold the server's IP address
|
||||||
|
|
||||||
|
/** Fetch the IP address of pepper from the server */
|
||||||
const char* Connectivity::fetchIPAddress() {
|
const char* Connectivity::fetchIPAddress() {
|
||||||
char* ipAddress = NULL; // Declare ipAddress as a char*
|
char* ipAddress = NULL; // Declare ipAddress as a char*
|
||||||
if (WiFi.status() == WL_CONNECTED) {
|
if (WiFi.status() == WL_CONNECTED) {
|
||||||
@@ -41,14 +42,14 @@ const char* Connectivity::fetchIPAddress() {
|
|||||||
ipAddress = strdup(ip);
|
ipAddress = strdup(ip);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Serial.printf("GET request failed, error: %s\n", http.errorToString(httpCode).c_str());
|
Serial.printf("GET request failed, error: %s\n", http.errorToString(httpCode).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
http.end();
|
http.end();
|
||||||
} else {
|
} else {
|
||||||
Serial.println("WiFi not connected");
|
Serial.println("WiFi not connected");
|
||||||
}
|
}
|
||||||
return ipAddress; // Add this return statement
|
return ipAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Send a POST request to a server with provided data */
|
/** Send a POST request to a server with provided data */
|
||||||
|
@@ -14,8 +14,8 @@
|
|||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
|
||||||
|
|
||||||
|
// declare the class Connectivity with all functions
|
||||||
class Connectivity {
|
class Connectivity {
|
||||||
public:
|
public:
|
||||||
void connectWiFi(char* ssid, char* pass);
|
void connectWiFi(char* ssid, char* pass);
|
||||||
void websocketSetup(char* ip, uint16_t port, char* adress);
|
void websocketSetup(char* ip, uint16_t port, char* adress);
|
||||||
|
Reference in New Issue
Block a user