Skip to content

Commit

Permalink
tests/drivers/nrf802154: test if Beacons can be received
Browse files Browse the repository at this point in the history
  • Loading branch information
lulu254b committed Nov 18, 2024
1 parent b9ba3ee commit 5adb5e7
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
3 changes: 3 additions & 0 deletions tests/drivers/nrf802154/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
37 changes: 36 additions & 1 deletion tests/drivers/nrf802154/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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;
}

0 comments on commit 5adb5e7

Please sign in to comment.