- Implemented GPS functionality with initialization and reading latitude and longitude. - Added MAX7219 display support, including initialization, text display, animation control, and brightness settings. - Integrated BME280 sensor for reading temperature, pressure, and humidity. - Developed MQ7 sensor interface for reading gas concentration values. - Created HTTP client for GET and POST requests. - Implemented MQTT client for message handling and connection management. - Added JSON serialization and deserialization functions for sensor and actuator data. - Established WiFi connection setup for network communication.
28 lines
715 B
C++
28 lines
715 B
C++
#include "RestClient.hpp"
|
|
|
|
HTTPClient httpClient; // HTTP client object
|
|
|
|
void getRequest(const String url, String &response)
|
|
{
|
|
httpClient.begin(url);
|
|
int httpCode = httpClient.GET();
|
|
if (httpCode > 0) {
|
|
response = httpClient.getString();
|
|
} else {
|
|
response = "Error: " + String(httpCode);
|
|
}
|
|
httpClient.end();
|
|
}
|
|
|
|
void postRequest(const String url, String &payload, String &response)
|
|
{
|
|
httpClient.begin(url);
|
|
httpClient.addHeader("Content-Type", "application/json");
|
|
int httpCode = httpClient.POST(payload);
|
|
if (httpCode > 0) {
|
|
response = httpClient.getString();
|
|
} else {
|
|
response = "Error: " + String(httpCode);
|
|
}
|
|
httpClient.end();
|
|
} |