replace shell commands for different transceivers with one transceiver command
This commit is contained in:
parent
355f6610d5
commit
062a5b93f4
@ -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)))
|
||||||
SRC += sc_cc1100.c
|
ifeq (,$(findstring transceiver,$(USEMODULE)))
|
||||||
endif
|
SRC += sc_cc1100.c
|
||||||
ifneq (,$(findstring nativenet,$(USEMODULE)))
|
endif
|
||||||
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},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user