Merge pull request #2709 from haukepetersen/ng_scnetif_power
shell/sc_netif: added means to control TX power
This commit is contained in:
commit
ff5633e44e
@ -75,6 +75,7 @@ static void _set_usage(char *cmd_name)
|
|||||||
" * \"nid\" - sets the network identifier (or the PAN ID)\n"
|
" * \"nid\" - sets the network identifier (or the PAN ID)\n"
|
||||||
" * \"pan\" - alias for \"nid\"\n"
|
" * \"pan\" - alias for \"nid\"\n"
|
||||||
" * \"pan_id\" - alias for \"nid\"\n"
|
" * \"pan_id\" - alias for \"nid\"\n"
|
||||||
|
" * \"power\" - TX power in dBm\n"
|
||||||
" * \"src_len\" - sets the source address length in byte\n");
|
" * \"src_len\" - sets the source address length in byte\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,6 +138,10 @@ static void _print_netconf(ng_netconf_opt_t opt)
|
|||||||
printf("network identifier");
|
printf("network identifier");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case NETCONF_OPT_TX_POWER:
|
||||||
|
printf("TX power [in dBm]");
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* we don't serve these options here */
|
/* we don't serve these options here */
|
||||||
break;
|
break;
|
||||||
@ -147,6 +152,7 @@ void _netif_list(kernel_pid_t dev)
|
|||||||
{
|
{
|
||||||
uint8_t hwaddr[MAX_ADDR_LEN];
|
uint8_t hwaddr[MAX_ADDR_LEN];
|
||||||
uint16_t u16;
|
uint16_t u16;
|
||||||
|
int16_t i16;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
printf("Iface %2d ", dev);
|
printf("Iface %2d ", dev);
|
||||||
@ -171,6 +177,12 @@ void _netif_list(kernel_pid_t dev)
|
|||||||
printf(" NID: 0x%" PRIx16 " ", u16);
|
printf(" NID: 0x%" PRIx16 " ", u16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
res = ng_netapi_get(dev, NETCONF_OPT_TX_POWER, 0, &i16, sizeof(i16));
|
||||||
|
|
||||||
|
if (res >= 0) {
|
||||||
|
printf(" TX-Power: %" PRIi16 "dBm ", i16);
|
||||||
|
}
|
||||||
|
|
||||||
printf("\n ");
|
printf("\n ");
|
||||||
|
|
||||||
res = ng_netapi_get(dev, NETCONF_OPT_ADDRESS_LONG, 0, hwaddr, sizeof(hwaddr));
|
res = ng_netapi_get(dev, NETCONF_OPT_ADDRESS_LONG, 0, hwaddr, sizeof(hwaddr));
|
||||||
@ -240,6 +252,23 @@ static void _netif_set_u16(kernel_pid_t dev, ng_netconf_opt_t opt,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void _netif_set_i16(kernel_pid_t dev, ng_netconf_opt_t opt,
|
||||||
|
char *i16_str)
|
||||||
|
{
|
||||||
|
int16_t val = (int16_t)atoi(i16_str);
|
||||||
|
|
||||||
|
if (ng_netapi_set(dev, opt, 0, (int16_t *)&val, sizeof(int16_t)) < 0) {
|
||||||
|
printf("error: unable to set ");
|
||||||
|
_print_netconf(opt);
|
||||||
|
puts("");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("success: set ");
|
||||||
|
_print_netconf(opt);
|
||||||
|
printf(" on interface %" PRIkernel_pid " to %i\n", dev, val);
|
||||||
|
}
|
||||||
|
|
||||||
static void _netif_set_addr(kernel_pid_t dev, ng_netconf_opt_t opt,
|
static void _netif_set_addr(kernel_pid_t dev, ng_netconf_opt_t opt,
|
||||||
char *addr_str)
|
char *addr_str)
|
||||||
{
|
{
|
||||||
@ -282,6 +311,9 @@ static void _netif_set(char *cmd_name, kernel_pid_t dev, char *key, char *value)
|
|||||||
(strcmp("pan_id", key) == 0)) {
|
(strcmp("pan_id", key) == 0)) {
|
||||||
_netif_set_u16(dev, NETCONF_OPT_NID, value);
|
_netif_set_u16(dev, NETCONF_OPT_NID, value);
|
||||||
}
|
}
|
||||||
|
else if (strcmp("power", key) == 0) {
|
||||||
|
_netif_set_i16(dev, NETCONF_OPT_TX_POWER, value);
|
||||||
|
}
|
||||||
else if (strcmp("src_len", key) == 0) {
|
else if (strcmp("src_len", key) == 0) {
|
||||||
_netif_set_u16(dev, NETCONF_OPT_SRC_LEN, value);
|
_netif_set_u16(dev, NETCONF_OPT_SRC_LEN, value);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user