diff options
| author | Sadeep Madurange <sadeep@asciimx.com> | 2024-12-10 19:43:38 +0800 |
|---|---|---|
| committer | Sadeep Madurange <sadeep@asciimx.com> | 2024-12-10 19:43:38 +0800 |
| commit | b8103d0b0624ca7fbbccfc7d7b2bef560efd3198 (patch) | |
| tree | c05dea9834bc471cd653c8e9b9049d70338fc4de /rf_test/recv.c | |
| parent | 2c039dc4090ed31b46395ca2026a79061f095597 (diff) | |
| download | smart-home-b8103d0b0624ca7fbbccfc7d7b2bef560efd3198.tar.gz | |
Function to start listening.
Diffstat (limited to 'rf_test/recv.c')
| -rw-r--r-- | rf_test/recv.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/rf_test/recv.c b/rf_test/recv.c index 64451a0..47b8b7e 100644 --- a/rf_test/recv.c +++ b/rf_test/recv.c @@ -1,11 +1,10 @@ +#include <string.h> #include <avr/io.h> #include <avr/interrupt.h> #include "radio.h" #include "serial.h" -#define PAYLOAD_LEN 13 - #define RX_PIN PB0 #define RX_DDR DDRB #define RX_PORT PORTB @@ -14,21 +13,29 @@ #define RX_PCMSK PCMSK0 #define RX_PCINTVEC PCINT0_vect +#define MAX_PAYLOAD_LEN 60 + +static char *s = "hello, world!"; +static uint8_t slen = strlen(s); + int main(void) { struct radio_cfg cfg; - cfg.payload_len = PAYLOAD_LEN; + cfg.netid = 0x01; + cfg.nodeid = 0x01; + cfg.payload_len = slen; RX_DDR &= ~(1 << RX_PIN); PCICR |= (1 << RX_PCIE); RX_PCMSK |= (1 << RX_PCINT); serial_init(); - radio_init(&cfg); - sei(); + radio_init(&cfg); + radio_listen(); + for (;;) ; @@ -38,13 +45,13 @@ int main(void) ISR(RX_PCINTVEC) { uint8_t i, n; - char buf[PAYLOAD_LEN + 1]; + char buf[MAX_PAYLOAD_LEN]; cli(); - serial_write_line("Handling pin change IRQ"); + serial_write_line("Detected pin change IRQ"); - n = radio_recv(buf, PAYLOAD_LEN); + n = radio_recv(buf, MAX_PAYLOAD_LEN - 1); buf[n] = '\0'; for (i = 0; i < n; i++) |
