allow sending infrared signal through MQTT

This commit is contained in:
Siwat Sirichai 2023-12-02 01:25:36 +07:00
parent 3b146b3bdf
commit a9181c90e6
2 changed files with 18 additions and 1 deletions

View File

@ -91,6 +91,11 @@ char AC_ROOM_TEMPERATURE_TOPIC[75];
char AC_HUMIDITY_TOPIC[75];
#endif
#ifdef ENABLE_IR_MODULE
uint16_t ir_buffer[IR_RAW_BUFFER_LENGTH];
uint16_t ir_buffer_length = 0;
#endif
#ifdef ENABLE_ANALOG_MODULE
#define DAC_COUNT 4
#define ADC_COUNT 8
@ -677,6 +682,18 @@ void mqtt_callback(char *topic, byte *payload, unsigned int length)
{
dac_set_value_callback(topic_trim, topic_length, payload_nt, length);
}
#endif
#ifdef ENABLE_IR_MODULE
else if (!strcmp(topic_trim, "/ir/send"))
{
const char* delimiter = ",";
char* token = strtok(const_cast<char*>(payload_nt), delimiter);
while (token != nullptr && ir_buffer_length < IR_RAW_BUFFER_LENGTH) {
ir_buffer[ir_buffer_length++] = atoi(token);
token = strtok(nullptr, delimiter);
}
IrSender.sendRaw(ir_buffer,ir_buffer_length ,NEC_KHZ);
}
#endif
else if (!strcmp(topic, STATE_REQUEST_TOPIC))
{

View File

@ -23,7 +23,7 @@
#define IR_RECIEVE_PIN 35
#define IR_SEND_PIN 17
#define MARK_EXCESS_MICROS 20
#define RAW_BUFFER_LENGTH 750
#define IR_RAW_BUFFER_LENGTH 750
#define AC_MAX_TEMPERATURE 30
#define AC_MIN_TEMPERATURE 15
#define DHT22_PIN 32