Merge pull request #278 from LudwigOrtmann/transeiver_command
unify tranceiver shell commands
This commit is contained in:
commit
3ba156883b
@ -10,9 +10,11 @@
|
|||||||
|
|
||||||
#ifndef MACA_H_
|
#ifndef MACA_H_
|
||||||
#define MACA_H_
|
#define MACA_H_
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "radio/types.h"
|
||||||
|
|
||||||
#include "maca_packet.h"
|
#include "maca_packet.h"
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
/*********************************************************/
|
/*********************************************************/
|
||||||
/* function definitions */
|
/* function definitions */
|
||||||
@ -29,8 +31,8 @@ void maca_check ( void );
|
|||||||
/* functions to configure MACA */
|
/* functions to configure MACA */
|
||||||
void maca_set_power ( uint8_t power );
|
void maca_set_power ( uint8_t power );
|
||||||
void maca_set_channel ( uint8_t channel );
|
void maca_set_channel ( uint8_t channel );
|
||||||
uint16_t maca_set_address ( uint16_t addr );
|
radio_address_t maca_set_address (radio_address_t addr );
|
||||||
uint16_t maca_get_address ( void );
|
radio_address_t maca_get_address ( void );
|
||||||
uint16_t maca_set_pan(uint16_t pan);
|
uint16_t maca_set_pan(uint16_t pan);
|
||||||
uint16_t maca_get_pan(void);
|
uint16_t maca_get_pan(void);
|
||||||
|
|
||||||
|
|||||||
@ -7,12 +7,12 @@
|
|||||||
*
|
*
|
||||||
* This file is part of RIOT.
|
* This file is part of RIOT.
|
||||||
*/
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "maca.h"
|
#include "maca.h"
|
||||||
#include "maca_packet.h"
|
#include "maca_packet.h"
|
||||||
#include "nvm.h"
|
#include "nvm.h"
|
||||||
#include "mc1322x.h"
|
#include "mc1322x.h"
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
// number of packets in the maca_packet_pool
|
// number of packets in the maca_packet_pool
|
||||||
#ifndef MACA_NUM_PACKETS
|
#ifndef MACA_NUM_PACKETS
|
||||||
@ -897,7 +897,7 @@ void maca_set_channel ( uint8_t chan ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t maca_set_address ( uint16_t addr ) {
|
radio_address_t maca_set_address (radio_address_t addr) {
|
||||||
safe_irq_disable ( INT_NUM_MACA );
|
safe_irq_disable ( INT_NUM_MACA );
|
||||||
|
|
||||||
MACA->MAC16ADDR = addr;
|
MACA->MAC16ADDR = addr;
|
||||||
@ -910,7 +910,7 @@ uint16_t maca_set_address ( uint16_t addr ) {
|
|||||||
return MACA->MAC16ADDR;
|
return MACA->MAC16ADDR;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t maca_get_address ( void ) {
|
radio_address_t maca_get_address ( void ) {
|
||||||
return MACA->MAC16ADDR;
|
return MACA->MAC16ADDR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -90,7 +90,7 @@ void at86rf231_rx_irq(void)
|
|||||||
at86rf231_rx_handler();
|
at86rf231_rx_handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t at86rf231_set_address(uint16_t address)
|
radio_address_t at86rf231_set_address(radio_address_t address)
|
||||||
{
|
{
|
||||||
radio_address = address;
|
radio_address = address;
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ uint16_t at86rf231_set_address(uint16_t address)
|
|||||||
return radio_address;
|
return radio_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t at86rf231_get_address(void)
|
radio_address_t at86rf231_get_address(void)
|
||||||
{
|
{
|
||||||
return radio_address;
|
return radio_address;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -124,7 +124,7 @@ uint16_t cc2420_get_channel(void)
|
|||||||
return ((cc2420_read_reg(CC2420_REG_FSCTRL) - 357) / 5) + 11;
|
return ((cc2420_read_reg(CC2420_REG_FSCTRL) - 357) / 5) + 11;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t cc2420_set_address(uint16_t addr)
|
radio_address_t cc2420_set_address(radio_address_t addr)
|
||||||
{
|
{
|
||||||
uint8_t buf[2];
|
uint8_t buf[2];
|
||||||
buf[0] = (uint8_t)(addr & 0xFF);
|
buf[0] = (uint8_t)(addr & 0xFF);
|
||||||
@ -149,7 +149,7 @@ uint64_t cc2420_set_address_long(uint64_t addr)
|
|||||||
return addr;
|
return addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t cc2420_get_address(void)
|
radio_address_t cc2420_get_address(void)
|
||||||
{
|
{
|
||||||
uint16_t addr;
|
uint16_t addr;
|
||||||
cc2420_read_ram(CC2420_RAM_SHORTADR, (uint8_t *)&addr, sizeof(addr));
|
cc2420_read_ram(CC2420_RAM_SHORTADR, (uint8_t *)&addr, sizeof(addr));
|
||||||
|
|||||||
@ -4,6 +4,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "radio/types.h"
|
||||||
|
|
||||||
#include "ieee802154_frame.h"
|
#include "ieee802154_frame.h"
|
||||||
|
|
||||||
#include "at86rf231_arch.h"
|
#include "at86rf231_arch.h"
|
||||||
@ -42,8 +44,8 @@ uint8_t at86rf231_get_channel(void);
|
|||||||
uint16_t at86rf231_set_pan(uint16_t pan);
|
uint16_t at86rf231_set_pan(uint16_t pan);
|
||||||
uint16_t at86rf231_get_pan(void);
|
uint16_t at86rf231_get_pan(void);
|
||||||
|
|
||||||
uint16_t at86rf231_set_address(uint16_t address);
|
radio_address_t at86rf231_set_address(radio_address_t address);
|
||||||
uint16_t at86rf231_get_address(void);
|
radio_address_t at86rf231_get_address(void);
|
||||||
uint64_t at86rf231_get_address_long(void);
|
uint64_t at86rf231_get_address_long(void);
|
||||||
uint64_t at86rf231_set_address_long(uint64_t address);
|
uint64_t at86rf231_set_address_long(uint64_t address);
|
||||||
|
|
||||||
|
|||||||
@ -79,6 +79,8 @@ Frame type value:
|
|||||||
#include "ieee802154_frame.h"
|
#include "ieee802154_frame.h"
|
||||||
#include "cc2420_settings.h"
|
#include "cc2420_settings.h"
|
||||||
|
|
||||||
|
#include "radio/types.h"
|
||||||
|
|
||||||
#define CC2420_MAX_PKT_LENGTH 127
|
#define CC2420_MAX_PKT_LENGTH 127
|
||||||
#define CC2420_MAX_DATA_LENGTH (118)
|
#define CC2420_MAX_DATA_LENGTH (118)
|
||||||
|
|
||||||
@ -144,7 +146,7 @@ uint16_t cc2420_get_channel(void);
|
|||||||
*
|
*
|
||||||
* @return The set address after calling.
|
* @return The set address after calling.
|
||||||
*/
|
*/
|
||||||
uint16_t cc2420_set_address(uint16_t addr);
|
radio_address_t cc2420_set_address(radio_address_t addr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Gets the current short address of the cc2420.
|
* @brief Gets the current short address of the cc2420.
|
||||||
@ -152,7 +154,7 @@ uint16_t cc2420_set_address(uint16_t addr);
|
|||||||
* @return The current short address.
|
* @return The current short address.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
uint16_t cc2420_get_address(void);
|
radio_address_t cc2420_get_address(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Sets the IEEE long address of the cc2420.
|
* @brief Sets the IEEE long address of the cc2420.
|
||||||
|
|||||||
@ -1,16 +1,12 @@
|
|||||||
SRC = shell_commands.c sc_id.c
|
SRC = shell_commands.c sc_id.c
|
||||||
|
|
||||||
ifneq (,$(findstring cc110x_ng,$(USEMODULE)))
|
ifneq (,$(findstring transceiver,$(USEMODULE)))
|
||||||
SRC += sc_cc110x_ng.c
|
SRC += sc_transceiver.c
|
||||||
endif
|
|
||||||
ifneq (,$(findstring cc2420,$(USEMODULE)))
|
|
||||||
SRC += sc_cc2420.c
|
|
||||||
endif
|
endif
|
||||||
ifneq (,$(findstring cc110x,$(USEMODULE)))
|
ifneq (,$(findstring cc110x,$(USEMODULE)))
|
||||||
|
ifeq (,$(findstring transceiver,$(USEMODULE)))
|
||||||
SRC += sc_cc1100.c
|
SRC += sc_cc1100.c
|
||||||
endif
|
endif
|
||||||
ifneq (,$(findstring nativenet,$(USEMODULE)))
|
|
||||||
SRC += sc_nativenet.c
|
|
||||||
endif
|
endif
|
||||||
ifneq (,$(findstring mci,$(USEMODULE)))
|
ifneq (,$(findstring mci,$(USEMODULE)))
|
||||||
SRC += sc_disk.c
|
SRC += sc_disk.c
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Shell commands for cc110x driver
|
* Shell commands for the cc110x driver without a transceiver
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 INRIA.
|
* Copyright (C) 2013 INRIA.
|
||||||
*
|
*
|
||||||
@ -10,106 +10,19 @@
|
|||||||
* @ingroup shell_commands
|
* @ingroup shell_commands
|
||||||
* @{
|
* @{
|
||||||
* @file sc_cc1100.c
|
* @file sc_cc1100.c
|
||||||
* @brief provides shell commands to configure cc110x driver
|
* @brief provides shell commands to configure the cc110x driver
|
||||||
* @author Oliver Hahm <oliver.hahm@inria.fr>
|
* @author Oliver Hahm <oliver.hahm@inria.fr>
|
||||||
|
* @author Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "cc110x.h"
|
#include "cc110x.h"
|
||||||
|
|
||||||
#ifdef MODULE_CC110X
|
|
||||||
#include "msg.h"
|
|
||||||
#include "transceiver.h"
|
|
||||||
|
|
||||||
#ifdef MODULE_TRANSCEIVER
|
|
||||||
#define TEXT_SIZE CC1100_MAX_DATA_LENGTH
|
|
||||||
|
|
||||||
char text_msg[TEXT_SIZE];
|
|
||||||
msg_t mesg;
|
|
||||||
transceiver_command_t tcmd;
|
|
||||||
|
|
||||||
void _cc1100_get_set_address_handler(char *addr)
|
|
||||||
{
|
|
||||||
int16_t a;
|
|
||||||
|
|
||||||
tcmd.transceivers = TRANSCEIVER_CC1100;
|
|
||||||
tcmd.data = &a;
|
|
||||||
mesg.content.ptr = (char *) &tcmd;
|
|
||||||
a = atoi(addr + 5);
|
|
||||||
|
|
||||||
if (strlen(addr) > 5) {
|
|
||||||
printf("[cc110x] Trying to set address %i\n", a);
|
|
||||||
mesg.type = SET_ADDRESS;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
mesg.type = GET_ADDRESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
msg_send_receive(&mesg, &mesg, transceiver_pid);
|
|
||||||
printf("[cc110x] Got address: %i\n", a);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _cc1100_get_set_channel_handler(char *chan)
|
|
||||||
{
|
|
||||||
int16_t c;
|
|
||||||
|
|
||||||
tcmd.transceivers = TRANSCEIVER_CC1100;
|
|
||||||
tcmd.data = &c;
|
|
||||||
mesg.content.ptr = (char *) &tcmd;
|
|
||||||
c = atoi(chan + 5);
|
|
||||||
|
|
||||||
if (strlen(chan) > 5) {
|
|
||||||
printf("[cc110x] Trying to set channel %i\n", c);
|
|
||||||
mesg.type = SET_CHANNEL;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
mesg.type = GET_CHANNEL;
|
|
||||||
}
|
|
||||||
|
|
||||||
msg_send_receive(&mesg, &mesg, transceiver_pid);
|
|
||||||
printf("[cc110x] Got channel: %i\n", c);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _cc1100_send_handler(char *pkt)
|
|
||||||
{
|
|
||||||
radio_packet_t p;
|
|
||||||
uint32_t response;
|
|
||||||
uint16_t addr;
|
|
||||||
char *tok;
|
|
||||||
|
|
||||||
tcmd.transceivers = TRANSCEIVER_CC1100;
|
|
||||||
tcmd.data = &p;
|
|
||||||
|
|
||||||
tok = strtok(pkt + 7, " ");
|
|
||||||
|
|
||||||
if (tok) {
|
|
||||||
addr = atoi(tok);
|
|
||||||
tok = strtok(NULL, " ");
|
|
||||||
|
|
||||||
if (tok) {
|
|
||||||
memset(text_msg, 0, TEXT_SIZE);
|
|
||||||
memcpy(text_msg, tok, strlen(tok));
|
|
||||||
/* if (sscanf(pkt, "txtsnd %hu %s", &(addr), text_msg) == 2) {*/
|
|
||||||
p.data = (uint8_t *) text_msg;
|
|
||||||
p.length = strlen(text_msg) + 1;
|
|
||||||
p.dst = addr;
|
|
||||||
mesg.type = SND_PKT;
|
|
||||||
mesg.content.ptr = (char *) &tcmd;
|
|
||||||
printf("[cc110x] Sending packet of length %u to %hu: %s\n", p.length, p.dst, (char *) p.data);
|
|
||||||
msg_send_receive(&mesg, &mesg, transceiver_pid);
|
|
||||||
response = mesg.content.value;
|
|
||||||
printf("[cc110x] Packet sent: %lu\n", response);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
puts("Usage:\ttxtsnd <ADDR> <MSG>");
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
void _cc110x_get_set_address_handler(char *addr)
|
void _cc110x_get_set_address_handler(char *addr)
|
||||||
{
|
{
|
||||||
int16_t a;
|
int16_t a;
|
||||||
@ -153,5 +66,3 @@ void _cc110x_get_set_channel_handler(char *addr)
|
|||||||
printf("[cc1100] Got address: %i\n", cc1100_get_channel());
|
printf("[cc1100] Got address: %i\n", cc1100_get_channel());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|||||||
@ -1,126 +0,0 @@
|
|||||||
/**
|
|
||||||
* Shell commands for cc110x_ng driver
|
|
||||||
*
|
|
||||||
* Copyright (C) 2013 INRIA.
|
|
||||||
*
|
|
||||||
* This file is subject to the terms and conditions of the GNU Lesser General
|
|
||||||
* Public License. See the file LICENSE in the top level directory for more
|
|
||||||
* details.
|
|
||||||
*
|
|
||||||
* @ingroup shell_commands
|
|
||||||
* @{
|
|
||||||
* @file sc_cc110x_ng.c
|
|
||||||
* @brief provides shell commands to configure cc110x_ng driver
|
|
||||||
* @author Oliver Hahm <oliver.hahm@inria.fr>
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include "transceiver.h"
|
|
||||||
#include "cc110x_ng.h"
|
|
||||||
#include "msg.h"
|
|
||||||
|
|
||||||
#define TEXT_SIZE CC1100_MAX_DATA_LENGTH
|
|
||||||
|
|
||||||
char text_msg[TEXT_SIZE];
|
|
||||||
msg_t mesg;
|
|
||||||
transceiver_command_t tcmd;
|
|
||||||
|
|
||||||
void _cc110x_ng_get_set_address_handler(char *addr)
|
|
||||||
{
|
|
||||||
int16_t a;
|
|
||||||
|
|
||||||
tcmd.transceivers = TRANSCEIVER_CC1100;
|
|
||||||
tcmd.data = &a;
|
|
||||||
mesg.content.ptr = (char *) &tcmd;
|
|
||||||
a = atoi(addr + 5);
|
|
||||||
|
|
||||||
if (strlen(addr) > 5) {
|
|
||||||
printf("[cc110x] Trying to set address %i\n", a);
|
|
||||||
mesg.type = SET_ADDRESS;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
mesg.type = GET_ADDRESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
msg_send_receive(&mesg, &mesg, transceiver_pid);
|
|
||||||
printf("[cc110x] Got address: %i\n", a);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _cc110x_ng_get_set_channel_handler(char *chan)
|
|
||||||
{
|
|
||||||
int16_t c;
|
|
||||||
|
|
||||||
tcmd.transceivers = TRANSCEIVER_CC1100;
|
|
||||||
tcmd.data = &c;
|
|
||||||
mesg.content.ptr = (char *) &tcmd;
|
|
||||||
c = atoi(chan + 5);
|
|
||||||
|
|
||||||
if (strlen(chan) > 5) {
|
|
||||||
printf("[cc110x] Trying to set channel %i\n", c);
|
|
||||||
mesg.type = SET_CHANNEL;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
mesg.type = GET_CHANNEL;
|
|
||||||
}
|
|
||||||
|
|
||||||
msg_send_receive(&mesg, &mesg, transceiver_pid);
|
|
||||||
printf("[cc110x] Got channel: %i\n", c);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _cc110x_ng_send_handler(char *pkt)
|
|
||||||
{
|
|
||||||
radio_packet_t p;
|
|
||||||
uint32_t response;
|
|
||||||
uint16_t addr;
|
|
||||||
char *tok;
|
|
||||||
|
|
||||||
tcmd.transceivers = TRANSCEIVER_CC1100;
|
|
||||||
tcmd.data = &p;
|
|
||||||
|
|
||||||
tok = strtok(pkt + 7, " ");
|
|
||||||
|
|
||||||
if (tok) {
|
|
||||||
addr = atoi(tok);
|
|
||||||
tok = strtok(NULL, " ");
|
|
||||||
|
|
||||||
if (tok) {
|
|
||||||
memset(text_msg, 0, TEXT_SIZE);
|
|
||||||
memcpy(text_msg, tok, strlen(tok));
|
|
||||||
p.data = (uint8_t *) text_msg;
|
|
||||||
p.length = strlen(text_msg) + 1;
|
|
||||||
p.dst = addr;
|
|
||||||
mesg.type = SND_PKT;
|
|
||||||
mesg.content.ptr = (char *)&tcmd;
|
|
||||||
printf("[cc110x] Sending packet of length %u to %u: %s\n", p.length, p.dst, (char*) p.data);
|
|
||||||
msg_send_receive(&mesg, &mesg, transceiver_pid);
|
|
||||||
response = mesg.content.value;
|
|
||||||
printf("[cc110x] Packet sent: %" PRIu32 "\n", response);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
puts("Usage:\ttxtsnd <ADDR> <MSG>");
|
|
||||||
}
|
|
||||||
|
|
||||||
void _cc110x_ng_monitor_handler(char *mode)
|
|
||||||
{
|
|
||||||
unsigned int m;
|
|
||||||
|
|
||||||
tcmd.transceivers = TRANSCEIVER_CC1100;
|
|
||||||
tcmd.data = &m;
|
|
||||||
mesg.content.ptr = (char *) &tcmd;
|
|
||||||
m = atoi(mode + 8);
|
|
||||||
|
|
||||||
if (strlen(mode) > 8) {
|
|
||||||
printf("Setting monitor mode: %u\n", m);
|
|
||||||
mesg.type = SET_MONITOR;
|
|
||||||
msg_send(&mesg, transceiver_pid, 1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
puts("Usage:\nmonitor <MODE>");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,135 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2013 Milan Babel <babel@inf.fu-berlin.de>
|
|
||||||
*
|
|
||||||
* This file is subject to the terms and conditions of the GNU Lesser General
|
|
||||||
* Public License. See the file LICENSE in the top level directory for more
|
|
||||||
* details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ingroup shell_commands
|
|
||||||
* @{
|
|
||||||
*
|
|
||||||
* @file
|
|
||||||
* @brief provides shell commands to configure cc2420 driver
|
|
||||||
*
|
|
||||||
* @author Milan Babel <babel@inf.fu-berlin.de>
|
|
||||||
*
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "transceiver.h"
|
|
||||||
#include "cc2420.h"
|
|
||||||
#include "msg.h"
|
|
||||||
|
|
||||||
#define TEXT_SIZE CC2420_MAX_DATA_LENGTH
|
|
||||||
|
|
||||||
char text_msg[TEXT_SIZE];
|
|
||||||
msg_t mesg;
|
|
||||||
transceiver_command_t tcmd;
|
|
||||||
|
|
||||||
void _cc2420_get_set_address_handler(char *addr) {
|
|
||||||
uint16_t a;
|
|
||||||
|
|
||||||
tcmd.transceivers = TRANSCEIVER_CC2420;
|
|
||||||
tcmd.data = &a;
|
|
||||||
mesg.content.ptr = (char*) &tcmd;
|
|
||||||
a = atoi(addr+5);
|
|
||||||
if (strlen(addr) > 5) {
|
|
||||||
printf("[cc2420] Trying to set address %i\n", a);
|
|
||||||
mesg.type = SET_ADDRESS;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
mesg.type = GET_ADDRESS;
|
|
||||||
}
|
|
||||||
msg_send_receive(&mesg, &mesg, transceiver_pid);
|
|
||||||
printf("[cc2420] Got address: %i\n", a);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _cc2420_get_set_channel_handler(char *chan) {
|
|
||||||
int16_t c;
|
|
||||||
|
|
||||||
tcmd.transceivers = TRANSCEIVER_CC2420;
|
|
||||||
tcmd.data = &c;
|
|
||||||
mesg.content.ptr = (char*) &tcmd;
|
|
||||||
c = atoi(chan+5);
|
|
||||||
if (strlen(chan) > 5) {
|
|
||||||
printf("[cc2420] Trying to set channel %i\n", c);
|
|
||||||
mesg.type = SET_CHANNEL;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
mesg.type = GET_CHANNEL;
|
|
||||||
}
|
|
||||||
msg_send_receive(&mesg, &mesg, transceiver_pid);
|
|
||||||
printf("[cc2420] Got channel: %i\n", c);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _cc2420_get_set_pan_handler(char *pan) {
|
|
||||||
uint16_t p;
|
|
||||||
|
|
||||||
tcmd.transceivers = TRANSCEIVER_CC2420;
|
|
||||||
tcmd.data = &p;
|
|
||||||
mesg.content.ptr = (char*) &tcmd;
|
|
||||||
p = atoi(pan+4);
|
|
||||||
if (strlen(pan) > 4) {
|
|
||||||
printf("[cc2420] Trying to set pan %i\n", p);
|
|
||||||
mesg.type = SET_PAN;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
mesg.type = GET_PAN;
|
|
||||||
}
|
|
||||||
msg_send_receive(&mesg, &mesg, transceiver_pid);
|
|
||||||
printf("[cc2420] Got pan: %i\n", p);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _cc2420_send_handler(char *pkt) {
|
|
||||||
radio_packet_t p;
|
|
||||||
uint32_t response;
|
|
||||||
uint16_t addr;
|
|
||||||
char *tok;
|
|
||||||
|
|
||||||
tcmd.transceivers = TRANSCEIVER_CC2420;
|
|
||||||
tcmd.data = &p;
|
|
||||||
|
|
||||||
tok = strtok(pkt+7, " ");
|
|
||||||
if (tok) {
|
|
||||||
addr = atoi(tok);
|
|
||||||
tok = strtok(NULL, " ");
|
|
||||||
if (tok) {
|
|
||||||
memset(text_msg, 0, TEXT_SIZE);
|
|
||||||
memcpy(text_msg, tok, strlen(tok));
|
|
||||||
/* if (sscanf(pkt, "txtsnd %hu %s", &(addr), text_msg) == 2) {*/
|
|
||||||
p.data = (uint8_t*) text_msg;
|
|
||||||
p.length = strlen(text_msg) + 1;
|
|
||||||
p.dst = addr;
|
|
||||||
mesg.type = SND_PKT;
|
|
||||||
mesg.content.ptr = (char*) &tcmd;
|
|
||||||
printf("[cc2420] Sending packet of length %u to %u: %s\n", p.length, p.dst, (char*) p.data);
|
|
||||||
msg_send_receive(&mesg, &mesg, transceiver_pid);
|
|
||||||
response = mesg.content.value;
|
|
||||||
printf("[cc2420] Packet sent: %lu\n", response);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
puts("Usage:\ttxtsnd <ADDR> <MSG>");
|
|
||||||
}
|
|
||||||
|
|
||||||
void _cc2420_monitor_handler(char *mode) {
|
|
||||||
unsigned int m;
|
|
||||||
|
|
||||||
tcmd.transceivers = TRANSCEIVER_CC2420;
|
|
||||||
tcmd.data = &m;
|
|
||||||
mesg.content.ptr = (char*) &tcmd;
|
|
||||||
m = atoi(mode+8);
|
|
||||||
if (strlen(mode) > 8) {
|
|
||||||
printf("Setting monitor mode: %u\n", m);
|
|
||||||
mesg.type = SET_MONITOR;
|
|
||||||
msg_send(&mesg, transceiver_pid, 1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
puts("Usage:\nmonitor <MODE>");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,133 +0,0 @@
|
|||||||
/**
|
|
||||||
* Shell commands for native transceiver
|
|
||||||
*
|
|
||||||
* Copyright (C) 2013 Ludwig Ortmann.
|
|
||||||
*
|
|
||||||
* This file is subject to the terms and conditions of the GNU Lesser General
|
|
||||||
* Public License. See the file LICENSE in the top level directory for more
|
|
||||||
* details.
|
|
||||||
*
|
|
||||||
* @ingroup shell_commands
|
|
||||||
* @{
|
|
||||||
* @file sc_nativenet.c
|
|
||||||
* @brief provides shell commands to configure nativenet transceiver
|
|
||||||
* @author Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
|
|
||||||
#include "transceiver.h"
|
|
||||||
#include "nativenet.h"
|
|
||||||
#include "msg.h"
|
|
||||||
|
|
||||||
#define TEXT_SIZE (255) /* XXX: this aint enough for everybody */
|
|
||||||
|
|
||||||
void _nativenet_get_set_address_handler(char *addr)
|
|
||||||
{
|
|
||||||
msg_t mesg;
|
|
||||||
transceiver_command_t tcmd;
|
|
||||||
uint16_t a;
|
|
||||||
|
|
||||||
tcmd.transceivers = TRANSCEIVER_NATIVE;
|
|
||||||
tcmd.data = &a;
|
|
||||||
mesg.content.ptr = (char *) &tcmd;
|
|
||||||
a = atoi(addr + 5);
|
|
||||||
|
|
||||||
if (strlen(addr) > 5) {
|
|
||||||
printf("[nativenet] trying to set address %"PRIu16"\n", a);
|
|
||||||
mesg.type = SET_ADDRESS;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
mesg.type = GET_ADDRESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
msg_send_receive(&mesg, &mesg, transceiver_pid);
|
|
||||||
printf("[nativenet] got address: %"PRIu16"\n", a);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _nativenet_get_set_channel_handler(char *chan)
|
|
||||||
{
|
|
||||||
msg_t mesg;
|
|
||||||
transceiver_command_t tcmd;
|
|
||||||
uint8_t c;
|
|
||||||
|
|
||||||
tcmd.transceivers = TRANSCEIVER_NATIVE;
|
|
||||||
tcmd.data = &c;
|
|
||||||
mesg.content.ptr = (char *) &tcmd;
|
|
||||||
c = atoi(chan + 5);
|
|
||||||
|
|
||||||
if (strlen(chan) > 5) {
|
|
||||||
printf("[nativenet] Trying to set channel %"PRIu8"\n", c);
|
|
||||||
mesg.type = SET_CHANNEL;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
mesg.type = GET_CHANNEL;
|
|
||||||
}
|
|
||||||
|
|
||||||
msg_send_receive(&mesg, &mesg, transceiver_pid);
|
|
||||||
printf("[nativenet] Got channel: %"PRIu8"\n", c);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _nativenet_send_handler(char *pkt)
|
|
||||||
{
|
|
||||||
msg_t mesg;
|
|
||||||
transceiver_command_t tcmd;
|
|
||||||
char text_msg[TEXT_SIZE];
|
|
||||||
|
|
||||||
radio_packet_t p;
|
|
||||||
uint32_t response;
|
|
||||||
uint16_t addr;
|
|
||||||
char *tok;
|
|
||||||
|
|
||||||
tcmd.transceivers = TRANSCEIVER_NATIVE;
|
|
||||||
tcmd.data = &p;
|
|
||||||
|
|
||||||
tok = strtok(pkt + 7, " ");
|
|
||||||
|
|
||||||
if (tok) {
|
|
||||||
addr = atoi(tok);
|
|
||||||
tok = strtok(NULL, " ");
|
|
||||||
|
|
||||||
if (tok) {
|
|
||||||
memset(text_msg, 0, TEXT_SIZE);
|
|
||||||
memcpy(text_msg, tok, strlen(tok));
|
|
||||||
p.data = (uint8_t *) text_msg;
|
|
||||||
p.length = strlen(text_msg) + 1;
|
|
||||||
p.dst = addr;
|
|
||||||
mesg.type = SND_PKT;
|
|
||||||
mesg.content.ptr = (char *)&tcmd;
|
|
||||||
printf("[nativenet] Sending packet of length %"PRIu16" to %"PRIu16": %s\n", p.length, p.dst, (char*) p.data);
|
|
||||||
msg_send_receive(&mesg, &mesg, transceiver_pid);
|
|
||||||
response = mesg.content.value;
|
|
||||||
printf("[nativenet] Packet sent: %"PRIi8"\n", response);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
puts("Usage:\ttxtsnd <ADDR> <MSG>");
|
|
||||||
}
|
|
||||||
|
|
||||||
void _nativenet_monitor_handler(char *mode)
|
|
||||||
{
|
|
||||||
msg_t mesg;
|
|
||||||
transceiver_command_t tcmd;
|
|
||||||
uint8_t m;
|
|
||||||
|
|
||||||
tcmd.transceivers = TRANSCEIVER_NATIVE;
|
|
||||||
tcmd.data = &m;
|
|
||||||
mesg.content.ptr = (char *) &tcmd;
|
|
||||||
m = atoi(mode + 8);
|
|
||||||
|
|
||||||
if (strlen(mode) > 8) {
|
|
||||||
printf("Setting monitor mode: %"PRIu8"\n", m);
|
|
||||||
mesg.type = SET_MONITOR;
|
|
||||||
msg_send(&mesg, transceiver_pid, 1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
puts("Usage:\nmonitor <MODE>");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
249
sys/shell/commands/sc_transceiver.c
Normal file
249
sys/shell/commands/sc_transceiver.c
Normal file
@ -0,0 +1,249 @@
|
|||||||
|
/**
|
||||||
|
* Shell commands for transceiver module
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Ludwig Ortmann.
|
||||||
|
*
|
||||||
|
* This file is subject to the terms and conditions of the GNU Lesser General
|
||||||
|
* Public License. See the file LICENSE in the top level directory for more
|
||||||
|
* details.
|
||||||
|
*
|
||||||
|
* @ingroup shell_commands
|
||||||
|
* @{
|
||||||
|
* @file sc_transceiver.c
|
||||||
|
* @brief provides shell commands to configure the transceiver
|
||||||
|
* @author Oliver Hahm <oliver.hahm@inria.fr>
|
||||||
|
* @author Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
#include "transceiver.h"
|
||||||
|
#include "msg.h"
|
||||||
|
|
||||||
|
#if defined( MODULE_CC110X )
|
||||||
|
#include "cc1100-interface.h"
|
||||||
|
#define TEXT_SIZE CC1100_MAX_DATA_LENGTH
|
||||||
|
#define _TC_TYPE TRANSCEIVER_CC1100
|
||||||
|
|
||||||
|
#elif defined( MODULE_CC110X_NG )
|
||||||
|
#include "cc110x_ng.h"
|
||||||
|
#define TEXT_SIZE CC1100_MAX_DATA_LENGTH
|
||||||
|
#define _TC_TYPE TRANSCEIVER_CC1100
|
||||||
|
|
||||||
|
#elif defined( MODULE_CC2420 )
|
||||||
|
#include "cc2420.h"
|
||||||
|
#define TEXT_SIZE CC2420_MAX_DATA_LENGTH
|
||||||
|
#define _TC_TYPE TRANSCEIVER_CC2420
|
||||||
|
|
||||||
|
#elif defined( MODULE_NATIVENET )
|
||||||
|
#include "nativenet.h"
|
||||||
|
#define TEXT_SIZE NATIVE_MAX_DATA_LENGTH
|
||||||
|
#define _TC_TYPE TRANSCEIVER_NATIVE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* checked for type safety */
|
||||||
|
void _transceiver_get_set_address_handler(char *addr)
|
||||||
|
{
|
||||||
|
msg_t mesg;
|
||||||
|
transceiver_command_t tcmd;
|
||||||
|
radio_address_t a;
|
||||||
|
|
||||||
|
if (transceiver_pid < 0) {
|
||||||
|
puts("Transceiver not initialized");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
tcmd.transceivers = _TC_TYPE;
|
||||||
|
tcmd.data = &a;
|
||||||
|
mesg.content.ptr = (char *) &tcmd;
|
||||||
|
|
||||||
|
if (strlen(addr) > 5) {
|
||||||
|
a = atoi(addr + 5);
|
||||||
|
printf("[transceiver] trying to set address %"PRIu16"\n", a);
|
||||||
|
mesg.type = SET_ADDRESS;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mesg.type = GET_ADDRESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
msg_send_receive(&mesg, &mesg, transceiver_pid);
|
||||||
|
printf("[transceiver] got address: %"PRIu16"\n", a);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* checked for type safety */
|
||||||
|
void _transceiver_get_set_channel_handler(char *chan)
|
||||||
|
{
|
||||||
|
msg_t mesg;
|
||||||
|
transceiver_command_t tcmd;
|
||||||
|
int32_t c;
|
||||||
|
|
||||||
|
if (transceiver_pid < 0) {
|
||||||
|
puts("Transceiver not initialized");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
tcmd.transceivers = _TC_TYPE;
|
||||||
|
tcmd.data = &c;
|
||||||
|
mesg.content.ptr = (char *) &tcmd;
|
||||||
|
|
||||||
|
if (strlen(chan) > 5) {
|
||||||
|
c = atoi(chan + 5);
|
||||||
|
printf("[transceiver] Trying to set channel %"PRIi32"\n", c);
|
||||||
|
mesg.type = SET_CHANNEL;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mesg.type = GET_CHANNEL;
|
||||||
|
}
|
||||||
|
|
||||||
|
msg_send_receive(&mesg, &mesg, transceiver_pid);
|
||||||
|
if (c == -1) {
|
||||||
|
puts("[transceiver] Error setting/getting channel");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("[transceiver] Got channel: %"PRIi32"\n", c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _transceiver_send_handler(char *pkt)
|
||||||
|
{
|
||||||
|
msg_t mesg;
|
||||||
|
transceiver_command_t tcmd;
|
||||||
|
char text_msg[TEXT_SIZE];
|
||||||
|
|
||||||
|
radio_packet_t p;
|
||||||
|
int8_t response;
|
||||||
|
radio_address_t addr;
|
||||||
|
char *tok;
|
||||||
|
|
||||||
|
if (transceiver_pid < 0) {
|
||||||
|
puts("Transceiver not initialized");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
tcmd.transceivers = _TC_TYPE;
|
||||||
|
tcmd.data = &p;
|
||||||
|
|
||||||
|
tok = strtok(pkt + 7, " ");
|
||||||
|
|
||||||
|
if (tok) {
|
||||||
|
addr = atoi(tok);
|
||||||
|
tok = strtok(NULL, " ");
|
||||||
|
|
||||||
|
if (tok) {
|
||||||
|
memset(text_msg, 0, TEXT_SIZE);
|
||||||
|
memcpy(text_msg, tok, strlen(tok));
|
||||||
|
p.data = (uint8_t *) text_msg;
|
||||||
|
p.length = strlen(text_msg) + 1;
|
||||||
|
p.dst = addr;
|
||||||
|
mesg.type = SND_PKT;
|
||||||
|
mesg.content.ptr = (char *)&tcmd;
|
||||||
|
printf("[transceiver] Sending packet of length %"PRIu16" to %"PRIu16": %s\n", p.length, p.dst, (char*) p.data);
|
||||||
|
msg_send_receive(&mesg, &mesg, transceiver_pid);
|
||||||
|
response = mesg.content.value;
|
||||||
|
printf("[transceiver] Packet sent: %"PRIi8"\n", response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
puts("Usage:\ttxtsnd <ADDR> <MSG>");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* checked for type safety */
|
||||||
|
void _transceiver_monitor_handler(char *mode)
|
||||||
|
{
|
||||||
|
msg_t mesg;
|
||||||
|
transceiver_command_t tcmd;
|
||||||
|
uint8_t m;
|
||||||
|
|
||||||
|
if (transceiver_pid < 0) {
|
||||||
|
puts("Transceiver not initialized");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
tcmd.transceivers = _TC_TYPE;
|
||||||
|
tcmd.data = &m;
|
||||||
|
mesg.content.ptr = (char *) &tcmd;
|
||||||
|
|
||||||
|
if (strlen(mode) > 8) {
|
||||||
|
m = atoi(mode + 8);
|
||||||
|
printf("Setting monitor mode: %"PRIu8"\n", m);
|
||||||
|
mesg.type = SET_MONITOR;
|
||||||
|
msg_send(&mesg, transceiver_pid, 1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
puts("Usage:\nmonitor <MODE>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* checked for type safety */
|
||||||
|
void _transceiver_get_set_pan_handler(char *pan) {
|
||||||
|
transceiver_command_t tcmd;
|
||||||
|
msg_t mesg;
|
||||||
|
int32_t p;
|
||||||
|
|
||||||
|
if (transceiver_pid < 0) {
|
||||||
|
puts("Transceiver not initialized");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
tcmd.transceivers = _TC_TYPE;
|
||||||
|
tcmd.data = &p;
|
||||||
|
mesg.content.ptr = (char*) &tcmd;
|
||||||
|
if (strlen(pan) > 4) {
|
||||||
|
p = atoi(pan+4);
|
||||||
|
printf("[transceiver] Trying to set pan %"PRIi32"\n", p);
|
||||||
|
mesg.type = SET_PAN;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mesg.type = GET_PAN;
|
||||||
|
}
|
||||||
|
msg_send_receive(&mesg, &mesg, transceiver_pid);
|
||||||
|
if (p == -1) {
|
||||||
|
puts("[transceiver] Error setting/getting pan");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("[transceiver] Got pan: %"PRIi32"\n", p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* checked for type safety */
|
||||||
|
#ifdef DBG_IGNORE
|
||||||
|
void _transceiver_set_ignore_handler(char *addr)
|
||||||
|
{
|
||||||
|
transceiver_command_t tcmd;
|
||||||
|
msg_t mesg;
|
||||||
|
radio_address_t a;
|
||||||
|
int16_t response;
|
||||||
|
|
||||||
|
if (transceiver_pid < 0) {
|
||||||
|
puts("Transceiver not initialized");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
tcmd.transceivers = _TC_TYPE;
|
||||||
|
tcmd.data = &a;
|
||||||
|
mesg.content.ptr = (char*) &tcmd;
|
||||||
|
|
||||||
|
if (strlen(addr) > 4) {
|
||||||
|
a = atoi(addr + 4);
|
||||||
|
printf("[transceiver] trying to add address %"PRIu16" to the ignore list \n", a);
|
||||||
|
mesg.type = DBG_IGN;
|
||||||
|
msg_send_receive(&mesg, &mesg, transceiver_pid);
|
||||||
|
response = a;
|
||||||
|
if (response == -1) {
|
||||||
|
printf("Error: ignore list full\n");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("Success (added at index %"PRIi16").\n", response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
puts("Usage:\nign <address>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@ -14,6 +14,7 @@
|
|||||||
* @brief sets up the system shell command struct
|
* @brief sets up the system shell command struct
|
||||||
* @author Oliver Hahm <oliver.hahm@inria.fr>
|
* @author Oliver Hahm <oliver.hahm@inria.fr>
|
||||||
* @author Zakaria Kasmi <zkasmi@inf.fu-berlin.de>
|
* @author Zakaria Kasmi <zkasmi@inf.fu-berlin.de>
|
||||||
|
* @author Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>
|
||||||
*
|
*
|
||||||
* @note $Id: shell_commands.c 3855 2013-09-05 12:54:57 kasmi $
|
* @note $Id: shell_commands.c 3855 2013-09-05 12:54:57 kasmi $
|
||||||
* @}
|
* @}
|
||||||
@ -45,42 +46,46 @@ extern void _get_current_handler(char *unused);
|
|||||||
extern void _reset_current_handler(char *unused);
|
extern void _reset_current_handler(char *unused);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULE_CC110X
|
|
||||||
|
/* configure available commands for each transceiver device: */
|
||||||
#ifdef MODULE_TRANSCEIVER
|
#ifdef MODULE_TRANSCEIVER
|
||||||
extern void _cc1100_get_set_address_handler(char *addr);
|
#ifdef DBG_IGNORE
|
||||||
extern void _cc1100_get_set_channel_handler(char *chan);
|
#define _TC_IGN
|
||||||
extern void _cc1100_send_handler(char *pkt);
|
#endif
|
||||||
#else
|
#if (defined(MODULE_CC110X_NG) || defined(MODULE_CC2420) || defined(MODULE_NATIVENET))
|
||||||
|
#define _TC_ADDR
|
||||||
|
#define _TC_CHAN
|
||||||
|
#define _TC_MON
|
||||||
|
#define _TC_SEND
|
||||||
|
#endif
|
||||||
|
#if (defined(MODULE_CC2420) || defined(MODULE_NATIVENET))
|
||||||
|
#define _TC_PAN
|
||||||
|
#endif
|
||||||
|
#else /* WITHOUT MODULE_TRANSCEIVER */
|
||||||
|
#ifdef MODULE_CC110X
|
||||||
extern void _cc110x_get_set_address_handler(char *addr);
|
extern void _cc110x_get_set_address_handler(char *addr);
|
||||||
extern void _cc110x_get_set_channel_handler(char *addr);
|
extern void _cc110x_get_set_channel_handler(char *addr);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULE_TRANSCEIVER
|
#ifdef MODULE_TRANSCEIVER
|
||||||
#ifdef MODULE_CC110X_NG
|
#ifdef _TC_ADDR
|
||||||
extern void _cc110x_ng_get_set_address_handler(char *addr);
|
extern void _transceiver_get_set_address_handler(char *addr);
|
||||||
extern void _cc110x_ng_get_set_channel_handler(char *chan);
|
|
||||||
extern void _cc110x_ng_send_handler(char *pkt);
|
|
||||||
extern void _cc110x_ng_monitor_handler(char *mode);
|
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef _TC_CHAN
|
||||||
|
extern void _transceiver_get_set_channel_handler(char *chan);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef _TC_SEND
|
||||||
#ifdef MODULE_TRANSCEIVER
|
extern void _transceiver_send_handler(char *pkt);
|
||||||
#ifdef MODULE_CC2420
|
|
||||||
extern void _cc2420_get_set_address_handler(char *addr);
|
|
||||||
extern void _cc2420_get_set_channel_handler(char *chan);
|
|
||||||
extern void _cc2420_get_set_pan_handler(char *pan);
|
|
||||||
extern void _cc2420_send_handler(char *pkt);
|
|
||||||
extern void _cc2420_monitor_handler(char *mode);
|
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef _TC_MON
|
||||||
|
extern void _transceiver_monitor_handler(char *mode);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef _TC_PAN
|
||||||
#ifdef MODULE_TRANSCEIVER
|
extern void _transceiver_get_set_pan_handler(char *chan);
|
||||||
#ifdef MODULE_NATIVENET
|
#endif
|
||||||
extern void _nativenet_get_set_address_handler(char *addr);
|
#ifdef _TC_IGN
|
||||||
extern void _nativenet_get_set_channel_handler(char *chan);
|
extern void _transceiver_set_ignore_handler(char *addr);
|
||||||
extern void _nativenet_send_handler(char *pkt);
|
|
||||||
extern void _nativenet_monitor_handler(char *mode);
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -118,41 +123,35 @@ const shell_command_t _shell_command_list[] = {
|
|||||||
{"cur", "Prints current and average power consumption.", _get_current_handler},
|
{"cur", "Prints current and average power consumption.", _get_current_handler},
|
||||||
{"rstcur", "Resets coulomb counter.", _reset_current_handler},
|
{"rstcur", "Resets coulomb counter.", _reset_current_handler},
|
||||||
#endif
|
#endif
|
||||||
#ifdef MODULE_CC110X
|
|
||||||
|
|
||||||
#ifdef MODULE_TRANSCEIVER
|
#ifdef MODULE_TRANSCEIVER
|
||||||
{"addr", "Gets or sets the address for the CC1100 transceiver", _cc1100_get_set_address_handler},
|
#ifdef _TC_ADDR
|
||||||
{"chan", "Gets or sets the channel for the CC1100 transceiver", _cc1100_get_set_channel_handler},
|
{"addr", "Gets or sets the address for the transceiver", _transceiver_get_set_address_handler},
|
||||||
{"txtsnd", "Sends a text message to a given node via the CC1100 transceiver", _cc1100_send_handler},
|
#endif
|
||||||
#else
|
#ifdef _TC_CHAN
|
||||||
|
{"chan", "Gets or sets the channel for the transceiver", _transceiver_get_set_channel_handler},
|
||||||
|
#endif
|
||||||
|
#ifdef _TC_SEND
|
||||||
|
{"txtsnd", "Sends a text message to a given node via the transceiver", _transceiver_send_handler},
|
||||||
|
#endif
|
||||||
|
#ifdef _TC_PAN
|
||||||
|
{"pan", "Gets or sets the pan id for the transceiver", _transceiver_get_set_pan_handler},
|
||||||
|
#endif
|
||||||
|
#ifdef _TC_MON
|
||||||
|
{"monitor", "Enables or disables address checking for the transceiver", _transceiver_monitor_handler},
|
||||||
|
#endif
|
||||||
|
#ifdef _TC_IGN
|
||||||
|
{"ign", "Ignore the address at the transceiver", _transceiver_set_ignore_handler},
|
||||||
|
#endif
|
||||||
|
#else /* WITHOUT MODULE_TRANSCEIVER */
|
||||||
|
#ifdef MODULE_CC110X
|
||||||
{"addr", "Gets or sets the address for the CC1100 transceiver", _cc110x_get_set_address_handler},
|
{"addr", "Gets or sets the address for the CC1100 transceiver", _cc110x_get_set_address_handler},
|
||||||
{"chan", "Gets or sets the channel for the CC1100 transceiver", _cc110x_get_set_channel_handler},
|
{"chan", "Gets or sets the channel for the CC1100 transceiver", _cc110x_get_set_channel_handler},
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#ifdef MODULE_TRANSCEIVER
|
|
||||||
#ifdef MODULE_CC110X_NG
|
|
||||||
{"addr", "Gets or sets the address for the CC1100 transceiver", _cc110x_ng_get_set_address_handler},
|
|
||||||
{"chan", "Gets or sets the channel for the CC1100 transceiver", _cc110x_ng_get_set_channel_handler},
|
|
||||||
{"txtsnd", "Sends a text message to a given node via the CC1100 transceiver", _cc110x_ng_send_handler},
|
|
||||||
{"monitor", "Enables or disables address checking for the CC1100 transceiver", _cc110x_ng_monitor_handler},
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#ifdef MODULE_TRANSCEIVER
|
|
||||||
#ifdef MODULE_CC2420
|
|
||||||
{"addr", "Gets or sets the address for the CC2420 transceiver", _cc2420_get_set_address_handler},
|
|
||||||
{"chan", "Gets or sets the channel for the CC2420 transceiver", _cc2420_get_set_channel_handler},
|
|
||||||
{"pan", "Gets or sets the pan id for the CC2420 transceiver", _cc2420_get_set_pan_handler},
|
|
||||||
{"txtsnd", "Sends a text message to a given node via the C2420 transceiver", _cc2420_send_handler},
|
|
||||||
{"monitor", "Enables or disables address checking for the CC2420 transceiver", _cc2420_monitor_handler},
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#ifdef MODULE_TRANSCEIVER
|
|
||||||
#ifdef MODULE_NATIVENET
|
|
||||||
{"addr", "Gets or sets the address for the native transceiver", _nativenet_get_set_address_handler},
|
|
||||||
{"chan", "Gets or sets the channel for the native transceiver", _nativenet_get_set_channel_handler},
|
|
||||||
{"txtsnd", "Sends a text message to a given node via the native transceiver", _nativenet_send_handler},
|
|
||||||
{"monitor", "Enables or disables address checking for the native transceiver", _nativenet_monitor_handler},
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#ifdef MODULE_MCI
|
#ifdef MODULE_MCI
|
||||||
{DISK_READ_SECTOR_CMD, "Reads the specified sector of inserted memory card", _read_sector},
|
{DISK_READ_SECTOR_CMD, "Reads the specified sector of inserted memory card", _read_sector},
|
||||||
{DISK_READ_BYTES_CMD, "Reads the specified bytes from inserted memory card", _read_bytes},
|
{DISK_READ_BYTES_CMD, "Reads the specified bytes from inserted memory card", _read_bytes},
|
||||||
|
|||||||
@ -120,8 +120,8 @@ void receive_at86rf231_packet(radio_packet_t *trans_p);
|
|||||||
static int8_t send_packet(transceiver_type_t t, void *pkt);
|
static int8_t send_packet(transceiver_type_t t, void *pkt);
|
||||||
static int32_t get_channel(transceiver_type_t t);
|
static int32_t get_channel(transceiver_type_t t);
|
||||||
static int32_t set_channel(transceiver_type_t t, void *channel);
|
static int32_t set_channel(transceiver_type_t t, void *channel);
|
||||||
static int16_t get_address(transceiver_type_t t);
|
static radio_address_t get_address(transceiver_type_t t);
|
||||||
static int16_t set_address(transceiver_type_t t, void *address);
|
static radio_address_t set_address(transceiver_type_t t, void *address);
|
||||||
static int32_t get_pan(transceiver_type_t t);
|
static int32_t get_pan(transceiver_type_t t);
|
||||||
static int32_t set_pan(transceiver_type_t t, void *pan);
|
static int32_t set_pan(transceiver_type_t t, void *pan);
|
||||||
|
|
||||||
@ -283,12 +283,12 @@ void run(void)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case GET_ADDRESS:
|
case GET_ADDRESS:
|
||||||
*((int16_t *) cmd->data) = get_address(cmd->transceivers);
|
*((radio_address_t *) cmd->data) = get_address(cmd->transceivers);
|
||||||
msg_reply(&m, &m);
|
msg_reply(&m, &m);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SET_ADDRESS:
|
case SET_ADDRESS:
|
||||||
*((int16_t *) cmd->data) = set_address(cmd->transceivers, cmd->data);
|
*((radio_address_t *) cmd->data) = set_address(cmd->transceivers, cmd->data);
|
||||||
msg_reply(&m, &m);
|
msg_reply(&m, &m);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -743,6 +743,7 @@ static int32_t get_channel(transceiver_type_t t)
|
|||||||
#ifdef MODULE_MC1322X
|
#ifdef MODULE_MC1322X
|
||||||
case TRANSCEIVER_MC1322X:
|
case TRANSCEIVER_MC1322X:
|
||||||
///< TODO:implement return maca_get_channel();
|
///< TODO:implement return maca_get_channel();
|
||||||
|
return -1;
|
||||||
#endif
|
#endif
|
||||||
#ifdef MODULE_NATIVENET
|
#ifdef MODULE_NATIVENET
|
||||||
case TRANSCEIVER_NATIVE:
|
case TRANSCEIVER_NATIVE:
|
||||||
@ -827,9 +828,11 @@ static int32_t get_pan(transceiver_type_t t) {
|
|||||||
*
|
*
|
||||||
* @param t The transceiver device
|
* @param t The transceiver device
|
||||||
*
|
*
|
||||||
* @return The configured address of the device, -1 on error
|
* @return The configured address of the device
|
||||||
|
*
|
||||||
|
* TODO: define error behavior
|
||||||
*/
|
*/
|
||||||
static int16_t get_address(transceiver_type_t t)
|
static radio_address_t get_address(transceiver_type_t t)
|
||||||
{
|
{
|
||||||
switch(t) {
|
switch(t) {
|
||||||
case TRANSCEIVER_CC1100:
|
case TRANSCEIVER_CC1100:
|
||||||
@ -838,7 +841,7 @@ static int16_t get_address(transceiver_type_t t)
|
|||||||
#elif MODULE_CC110X
|
#elif MODULE_CC110X
|
||||||
return cc1100_get_address();
|
return cc1100_get_address();
|
||||||
#else
|
#else
|
||||||
return -1;
|
return 0; /* XXX see TODO above */
|
||||||
#endif
|
#endif
|
||||||
#ifdef MODULE_CC2420
|
#ifdef MODULE_CC2420
|
||||||
case TRANSCEIVER_CC2420:
|
case TRANSCEIVER_CC2420:
|
||||||
@ -857,7 +860,7 @@ static int16_t get_address(transceiver_type_t t)
|
|||||||
return at86rf231_get_address();
|
return at86rf231_get_address();
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
return -1;
|
return 0; /* XXX see TODO above */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -868,8 +871,10 @@ static int16_t get_address(transceiver_type_t t)
|
|||||||
* @param address Generic pointer to the address to set
|
* @param address Generic pointer to the address to set
|
||||||
*
|
*
|
||||||
* @return The new radio address of the device
|
* @return The new radio address of the device
|
||||||
|
*
|
||||||
|
* TODO: define error behavior
|
||||||
*/
|
*/
|
||||||
static int16_t set_address(transceiver_type_t t, void *address)
|
static radio_address_t set_address(transceiver_type_t t, void *address)
|
||||||
{
|
{
|
||||||
radio_address_t addr = *((radio_address_t *)address);
|
radio_address_t addr = *((radio_address_t *)address);
|
||||||
|
|
||||||
@ -880,7 +885,7 @@ static int16_t set_address(transceiver_type_t t, void *address)
|
|||||||
#elif MODULE_CC110X
|
#elif MODULE_CC110X
|
||||||
return cc1100_set_address(addr);
|
return cc1100_set_address(addr);
|
||||||
#else
|
#else
|
||||||
return -1;
|
return 0; /* XXX see TODO above */
|
||||||
#endif
|
#endif
|
||||||
#ifdef MODULE_CC2420
|
#ifdef MODULE_CC2420
|
||||||
case TRANSCEIVER_CC2420:
|
case TRANSCEIVER_CC2420:
|
||||||
@ -899,7 +904,7 @@ static int16_t set_address(transceiver_type_t t, void *address)
|
|||||||
return at86rf231_set_address(addr);
|
return at86rf231_set_address(addr);
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
return -1;
|
return 0; /* XXX see TODO above */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user