Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

#include <WiFi.

h>

const char* ssid = "your_SSID";


const char* password = "your_PASSWORD";
const char* serverAddress = "35.192.135.4"; // replace with your API server IP
address
const int serverPort = 8017; // replace with your API server port
const int transactionId = 1; // replace with your transaction ID
const int locationId = 1; // replace with your location ID
const int subLocationId = 1; // replace with your sub-location ID
const int machineId = 1; // replace with your machine ID

void setup() {
Serial.begin(9600);
delay(1000);

WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
}

void loop() {
if (WiFi.status() == WL_CONNECTED) {
WiFiClient client;
if (!client.connect(serverAddress, serverPort)) {
Serial.println("Connection failed");
return;
}

String requestUrl = "/api/washing/GetPingHistory?TransactionId=" +


String(transactionId) +
"&LocationId=" + String(locationId) +
"&SubLocationId=" + String(subLocationId) +
"&MachineId=" + String(machineId);
client.print(String("GET ") + requestUrl + " HTTP/1.1\r\n" +
"Host: " + serverAddress + "\r\n" +
"Connection: close\r\n\r\n");

while (!client.available()) {
delay(100);
}

while (client.available()) {
String line = client.readStringUntil('\r');
Serial.println(line);
}

client.stop();
} else {
Serial.println("WiFi Disconnected");
}

delay(5000); // wait for 5 seconds before sending another request


}

You might also like