1
0

Update WiFi credentials, modify DEVICE_ROLE to SENSOR, and refactor GROUP_ID initialization; enhance MQ7_Read_Fake logic

This commit is contained in:
Jose
2025-06-03 22:16:22 +02:00
parent fb53c0fb83
commit 24802271bb
5 changed files with 28 additions and 13 deletions

View File

@@ -2,10 +2,10 @@
const uint32_t DEVICE_ID = getChipID();
const String mqttId = "CUS-" + String(DEVICE_ID, HEX);
const int GROUP_ID = 1;
int GROUP_ID;
TaskTimer globalTimer{0, 60000};
TaskTimer mqttTimer{0, 5000};
TaskTimer globalTimer{0, 10000};
TaskTimer mqttTimer{0, 2500};
#if DEVICE_ROLE == ACTUATOR
TaskTimer matrixTimer{0, 25};
@@ -39,6 +39,7 @@ void setup()
{
#if DEVICE_ROLE == SENSOR
GROUP_ID = getGroupId(DEVICE_ID);
BME280_Init();
Serial.println("Sensor BME280 inicializado");
GPS_Init();
@@ -119,7 +120,8 @@ void loop()
void writeMatrix(const char *message)
{
#ifdef DEBUG
Serial.println("Escribiendo mensaje: "); Serial.print(message);
Serial.println("Escribiendo mensaje: ");
Serial.print(message);
#endif
MAX7219_DisplayText(message, PA_LEFT, 50, 0);
}
@@ -139,7 +141,7 @@ void readBME280()
void readGPS()
{
gpsData = GPS_Read_Fake();
gpsData = GPS_Read();
}
void printAllData()
@@ -218,3 +220,11 @@ uint32_t getChipID()
#endif
return chipId;
}
int getGroupId(int deviceId)
{
String url = String(API_URI) + "groups/" + GROUP_ID + "/devices/" + String(DEVICE_ID, HEX) + "/actuators/" + MAX7219_ID + "/status";
getRequest(url, response);
MAX7219Status_t statusData = deserializeActuatorStatus(httpClient, httpClient.GET());
currentMessage = statusData.actuatorStatus;
}