-
-
Notifications
You must be signed in to change notification settings - Fork 98
Closed
Description
Hi All,
Thanks for great work. I try to sent event from PD (ATTiny3224) to CP (ESP32-WROOM32). I have no ERROR but the event will not be sent. I am using Platformio. Commands from CP to PD are working. Also RS485 communication is working on both sides. Can you please help me solve the problem ? Thank you for yours time.
void send_button_event(OSDP::PeripheralDevice &pd, uint8_t keycode)
{
Serial1.println("Button Pressed");
pd.flush_events();
osdp_event event;
osdp_event *p_event = &event;
p_event->type = OSDP_EVENT_KEYPRESS;
p_event->keypress.reader_no = 0; // 0 - This device
p_event->keypress.length = 1; // Single key press
p_event->keypress.data[0] = keycode; // Keycode of the pressed button
// Set RS485 module to Transmit mode
digitalWrite(RS485_DIRECTION_PIN, RS485_TRANSMIT);
delayMicroseconds(200);
// Notify the event
if (pd.notify_event(p_event) == 0) {
Serial1.println("Button event sent successfully.");
} else {
Serial1.println("Failed to notify button event.");
}
// Flush events and reset RS485 to Receive mode
Serial0.flush();
digitalWrite(RS485_DIRECTION_PIN, RS485_RECEIVE);
}
void loop()
{
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval_2000) {
previousMillis = currentMillis;
send_button_event(pd, 0x30);
}
unsigned long previousDelayMillis = 0;
if (currentMillis - previousDelayMillis >= interval_50) {
previousDelayMillis = currentMillis;
pd.refresh();
}
}
Metadata
Metadata
Assignees
Labels
No labels