1234567891011121314151617181920212223242526272829 |
- void resolveTargetRelayIP(){
- //Resolve the target relay module IP from mDNS broadcast
- if(resolveMdnsService("http", "tcp", TARGET_DEVICE, &target_ip, &target_port)) {
- Serial.printf("got an answer for %s.local!\n", TARGET_DEVICE);
- Serial.println(target_ip);
- Serial.println(target_port);
- } else {
- Serial.printf("Sorry, %s.local not found\n", TARGET_DEVICE);
- }
- }
- void GetRequest(String url) {
- WiFiClient client; // Create a WiFiClient object
- HTTPClient http;
- http.begin(client, url); // Pass the WiFiClient object and the URL to begin()
- int httpCode = http.GET(); // Make the GET request
- if (httpCode > 0) {
- String payload = http.getString(); // Get the response payload
- Serial.println("HTTP Response Code: " + String(httpCode));
- Serial.println("Response Payload: " + payload);
- } else {
- Serial.println("Error on HTTP request");
- }
- http.end(); // Close connection
- }
|