09-27-2024, 02:27 PM
interval:
- interval: 200ms # Shorten the interval to reduce blocking time
then:
- lambda: |-
static std:tring uart_buffer;
uint8_t c;
int count = 0;
const int max_reads = 10; // Limit the number of bytes read per interval
while (id(uart_2).available() && count < max_reads) {
if (id(uart_2).read_byte(&c)) {
uart_buffer += (char)c;
count++;
// Log each received character (optional for debugging)
ESP_LOGD("UART", "Received: %c", (char)c);
// Check if we have received the "RING" signal
if (uart_buffer.find("RING") != std:tring::npos) {
ESP_LOGI("SIM7600", "Incoming call detected, turning on relay 1.");
id(relay_1).turn_on(); // Turn on relay 1
HERE I TURN THE RELAY OFF AFTER 1s BUT IT WILL TURN BACK ON AFTER ANOTHER RING
uart_buffer.clear(); // Clear the buffer after processing
delay(1000);
id(relay_1).turn_off(); // Turn off relay 1
}
// Clear the buffer if it gets too large
if (uart_buffer.length() > 100) {
uart_buffer.clear();
}
}
}
So the ideal would be turn on the relay after the missed call.
also how do I hang up the call?
thanks
- interval: 200ms # Shorten the interval to reduce blocking time
then:
- lambda: |-
static std:tring uart_buffer;
uint8_t c;
int count = 0;
const int max_reads = 10; // Limit the number of bytes read per interval
while (id(uart_2).available() && count < max_reads) {
if (id(uart_2).read_byte(&c)) {
uart_buffer += (char)c;
count++;
// Log each received character (optional for debugging)
ESP_LOGD("UART", "Received: %c", (char)c);
// Check if we have received the "RING" signal
if (uart_buffer.find("RING") != std:tring::npos) {
ESP_LOGI("SIM7600", "Incoming call detected, turning on relay 1.");
id(relay_1).turn_on(); // Turn on relay 1
HERE I TURN THE RELAY OFF AFTER 1s BUT IT WILL TURN BACK ON AFTER ANOTHER RING
uart_buffer.clear(); // Clear the buffer after processing
delay(1000);
id(relay_1).turn_off(); // Turn off relay 1
}
// Clear the buffer if it gets too large
if (uart_buffer.length() > 100) {
uart_buffer.clear();
}
}
}
So the ideal would be turn on the relay after the missed call.
also how do I hang up the call?
thanks