From 5adb5e7ac795a5329d90eaf478941846b02c10a2 Mon Sep 17 00:00:00 2001 From: lulu254b Date: Wed, 13 Nov 2024 11:12:03 +0100 Subject: [PATCH] tests/drivers/nrf802154: test if Beacons can be received --- tests/drivers/nrf802154/README.md | 3 +++ tests/drivers/nrf802154/main.c | 37 ++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/tests/drivers/nrf802154/README.md b/tests/drivers/nrf802154/README.md index 6d0620ccaca2..44bc5d65254a 100644 --- a/tests/drivers/nrf802154/README.md +++ b/tests/drivers/nrf802154/README.md @@ -4,3 +4,6 @@ This is a manual test application for the NRF802154 radio driver. # Usage For testing the radio driver you can use the ifconfig and txtsnd shell commands that are included in this application. + +For testing beacon frame acceptance you can flash this test onto two nrf52 devices +and use the send command to send a beacon frame. The opponent should print the received frame details. \ No newline at end of file diff --git a/tests/drivers/nrf802154/main.c b/tests/drivers/nrf802154/main.c index 32a3f4f9c8ce..6761d29291c2 100644 --- a/tests/drivers/nrf802154/main.c +++ b/tests/drivers/nrf802154/main.c @@ -52,6 +52,41 @@ int netdev_ieee802154_minimal_init_devs(netdev_event_cb_t cb) { return 0; } +int send_beacon(int argc, char **argv) +{ + (void)argv; + (void)argc; + + puts("Testing Beacon Frame Acceptance"); + + uint8_t size = 8; + uint16_t pan_id = nrf802154.dev.pan; + uint8_t buffer[size]; + memset(buffer, 0, size*sizeof(uint8_t)); + + buffer[0] = 0x00; /* Frame Type is Beacon*/ + buffer[1] = 0x80; /* Source Address Mode is set to 16-Bit Short Address*/ + buffer[2] = 0x42; /* Arbitrary Sequence Number*/ + buffer[3] = pan_id & 0xff; /* Little Endian PAN ID*/ + buffer[4] = (pan_id >> 8); + + iolist_t iol = { + .iol_base = buffer, + .iol_len = size, + .iol_next = NULL, + }; + + puts("Sending Beacon Frame"); + netdev_ieee802154_minimal_send(&nrf802154.dev.netdev, &iol); + + return 0; +} + +static const shell_command_t shell_commands[] = { + { "send", "sending Beacon", send_beacon}, + {NULL,NULL,NULL} +}; + int main(void) { puts("Test application for NRF802154 IEEE 802.15.4 device driver"); @@ -66,7 +101,7 @@ int main(void) puts("Initialization successful - starting the shell now"); char line_buf[SHELL_DEFAULT_BUFSIZE]; - shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE); + shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE); return 0; }