From 52112f19821f6f667c51f3ac2c68da41365e0b43 Mon Sep 17 00:00:00 2001 From: Sadeep Madurange Date: Fri, 11 Apr 2025 13:25:11 +0800 Subject: wip: some packets are being exchanged, after about 3 packets they fail (WDT) --- dong.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'dong.c') diff --git a/dong.c b/dong.c index 1ef872f..fbe4b19 100644 --- a/dong.c +++ b/dong.c @@ -1,10 +1,13 @@ #include #include + #include +#include #include #include "nrfm.h" #include "uart.h" +#include "util.h" #define RX_PIN PD7 #define RX_DDR DDRD @@ -22,12 +25,14 @@ int main(void) char buf[MAXPDLEN + 1]; uint8_t rxaddr[] = { 194, 178, 83 }; + uint8_t txaddr[] = { 194, 178, 82 }; RX_DDR &= ~(1 << RX_PIN); RX_PORT |= (1 << RX_PIN); PCICR |= (1 << RX_PCIE); RX_PCMSK |= (1 << RX_PCINT); + wdt_stop(); uart_init(); radio_init(rxaddr); radio_print_config(); @@ -37,18 +42,19 @@ int main(void) for (;;) { if (rxdr) { - uart_write_line("IRQ recv, reading data"); n = radio_recv(buf, MAXPDLEN); buf[n] = '\0'; rxdr = 0; - if (n > 0) { + if (strncmp(buf, "SYN", 3) == 0) { uart_write("INFO: "); uart_write_line(buf); + radio_sendto(txaddr, "ACK", 3); } } else { uart_write_line("No IRQ"); - _delay_ms(2000); } + + _delay_ms(1000); } return 0; -- cgit v1.2.3