1
0

fucking fixes i hate cpp

This commit is contained in:
Jose
2025-04-09 13:14:11 +02:00
parent bd7d56b46e
commit 0c03c052b4
8 changed files with 28 additions and 14 deletions

View File

@@ -1,7 +1,5 @@
#include <ArduinoJson.h> #include <ArduinoJson.h>
#include "HTTPClient.h" #include <HTTPClient.h>
HTTPClient http;
String serializeSensorValue ( String serializeSensorValue (
int sensorId, int sensorId,
@@ -33,13 +31,16 @@ String serializeDevice (
); );
void deserializeSensorValue ( void deserializeSensorValue (
HTTPClient* http,
int httpResponseCode int httpResponseCode
); );
void deserializeActuatorStatus ( void deserializeActuatorStatus (
HTTPClient* http,
int httpResponseCode int httpResponseCode
); );
void deserializeDevice ( void deserializeDevice (
HTTPClient* http,
int httpResponseCode int httpResponseCode
); );

View File

@@ -6,4 +6,4 @@
#include "test.hpp" #include "test.hpp"
#include "mqtt.hpp" #include "mqtt.hpp"
#define LED 2 uint32_t getChipID();

View File

@@ -2,7 +2,6 @@
String response; String response;
String serializeSensorValue(int sensorId, int deviceId, String sensorType, String unit, int sensorStatus, float temperature, float humidity, float carbonMonoxide, float lat, float lon, long timestamp) String serializeSensorValue(int sensorId, int deviceId, String sensorType, String unit, int sensorStatus, float temperature, float humidity, float carbonMonoxide, float lat, float lon, long timestamp)
{ {
DynamicJsonDocument doc(2048); DynamicJsonDocument doc(2048);
@@ -59,7 +58,8 @@ String serializeDevice(int sensorId, int deviceId, String sensorType, int status
return output; return output;
} }
void deserializeSensorValue (int httpResponseCode){ void deserializeSensorValue (HTTPClient http, int httpResponseCode)
{
if (httpResponseCode > 0) if (httpResponseCode > 0)
{ {
@@ -101,7 +101,8 @@ void deserializeSensorValue (int httpResponseCode){
} }
} }
void deserializeActuatorStatus (int httpResponseCode){ void deserializeActuatorStatus (HTTPClient http, int httpResponseCode)
{
if (httpResponseCode > 0) if (httpResponseCode > 0)
{ {
@@ -139,7 +140,8 @@ void deserializeActuatorStatus (int httpResponseCode){
} }
} }
void deserializeDevice (int httpResponseCode){ void deserializeDevice (HTTPClient http, int httpResponseCode)
{
if (httpResponseCode > 0) if (httpResponseCode > 0)
{ {

View File

@@ -1,8 +1,20 @@
#include "main.hpp" #include "main.hpp"
const uint32_t deviceId = getChipID();
uint32_t getChipID()
{
uint32_t chipId;
for (int i = 0; i < 17; i = i + 8) {
chipId |= ((ESP.getEfuseMac() >> (40 - i)) & 0xff) << i;
}
return chipId;
}
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
// WiFi Connection
if(setup_wifi() != 0) if(setup_wifi() != 0)
{ {
Serial.print("Error connecting to WiFI"); Serial.print("Error connecting to WiFI");

View File

@@ -1,4 +1,5 @@
#include "rest.hpp" #include "rest.hpp"
RestClient client = RestClient(SERVER_IP, SERVER_PORT); HTTPClient httpClient;

View File

@@ -1 +0,0 @@
#include "test.hpp"

View File

@@ -1,7 +1,6 @@
#include <wifi.hpp> #include <wifi.hpp>
WiFiClient espClient; WiFiClient wifiClient;
PubSubClient client(espClient);
int setup_wifi() int setup_wifi()
{ {