diff --git a/examples/gnrc_networking_mac/mac.c b/examples/gnrc_networking_mac/mac.c new file mode 100644 index 0000000000..d5ac8bd0ab --- /dev/null +++ b/examples/gnrc_networking_mac/mac.c @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2018 Shuguo Zhuo + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup examples + * @{ + * + * @file + * @brief MAC shell commands + * + * @author Shuguo Zhuo + * + * @} + */ + +#include +#include + +#include "net/gnrc.h" +#include "net/gnrc/mac/types.h" + +int mac_cmd(int argc, char **argv) +{ + if (argc < 2) { + printf("usage: %s duty\n", argv[0]); + return 1; + } + + if (strcmp(argv[1], "duty") == 0) { +#if (GNRC_MAC_ENABLE_DUTYCYCLE_RECORD == 1) + gnrc_netif_t *netif = NULL; + netif = gnrc_netif_iter(netif); + + msg_t msg; + msg.type = GNRC_MAC_TYPE_GET_DUTYCYCLE; + msg_send(&msg, netif->pid); +#else + puts("MAC: radio duty-cycle unavailable."); +#endif + } + else { + puts("error: invalid command"); + } + return 0; +} diff --git a/examples/gnrc_networking_mac/main.c b/examples/gnrc_networking_mac/main.c index 4b3449bf91..05297ee341 100644 --- a/examples/gnrc_networking_mac/main.c +++ b/examples/gnrc_networking_mac/main.c @@ -29,9 +29,11 @@ static msg_t _main_msg_queue[MAIN_QUEUE_SIZE]; extern int udp_cmd(int argc, char **argv); +extern int mac_cmd(int argc, char **argv); static const shell_command_t shell_commands[] = { { "udp", "send data over UDP and listen on UDP ports", udp_cmd }, + { "mac", "get MAC protocol's internal information", mac_cmd }, { NULL, NULL, NULL } };