mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
gnrc_gomach: add duty-cycle printing command
This commit is contained in:
parent
4e7ff0df28
commit
24f746ceec
50
examples/gnrc_networking_mac/mac.c
Normal file
50
examples/gnrc_networking_mac/mac.c
Normal file
@ -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 <zhuosgzju@gmail.com>
|
||||||
|
*
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
#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;
|
||||||
|
}
|
@ -29,9 +29,11 @@
|
|||||||
static msg_t _main_msg_queue[MAIN_QUEUE_SIZE];
|
static msg_t _main_msg_queue[MAIN_QUEUE_SIZE];
|
||||||
|
|
||||||
extern int udp_cmd(int argc, char **argv);
|
extern int udp_cmd(int argc, char **argv);
|
||||||
|
extern int mac_cmd(int argc, char **argv);
|
||||||
|
|
||||||
static const shell_command_t shell_commands[] = {
|
static const shell_command_t shell_commands[] = {
|
||||||
{ "udp", "send data over UDP and listen on UDP ports", udp_cmd },
|
{ "udp", "send data over UDP and listen on UDP ports", udp_cmd },
|
||||||
|
{ "mac", "get MAC protocol's internal information", mac_cmd },
|
||||||
{ NULL, NULL, NULL }
|
{ NULL, NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user