2010-11-24 11:20:27 +01:00
|
|
|
#include <stdio.h>
|
2010-11-26 17:06:54 +01:00
|
|
|
#include <string.h>
|
|
|
|
|
2010-11-19 20:10:09 +01:00
|
|
|
#include <shell.h>
|
|
|
|
#include <board_uart0.h>
|
|
|
|
#include <posix_io.h>
|
|
|
|
#include <thread.h>
|
|
|
|
#include <board.h>
|
|
|
|
#include <hwtimer.h>
|
2010-11-24 11:20:27 +01:00
|
|
|
#include <msg.h>
|
|
|
|
#include <transceiver.h>
|
2010-11-26 17:06:54 +01:00
|
|
|
#include <cc1100_ng.h>
|
2010-11-19 20:10:09 +01:00
|
|
|
|
2010-11-26 17:06:54 +01:00
|
|
|
#define SHELL_STACK_SIZE (2048)
|
|
|
|
#define RADIO_STACK_SIZE (2048)
|
2010-11-19 20:10:09 +01:00
|
|
|
|
2010-11-24 21:45:38 +01:00
|
|
|
int transceiver_pid;
|
2010-11-19 20:10:09 +01:00
|
|
|
char shell_stack_buffer[SHELL_STACK_SIZE];
|
2010-11-24 11:20:27 +01:00
|
|
|
char radio_stack_buffer[RADIO_STACK_SIZE];
|
|
|
|
|
2010-11-27 10:50:18 +01:00
|
|
|
void mon_handler(char *mode);
|
2010-11-24 21:45:38 +01:00
|
|
|
|
2010-11-19 20:10:09 +01:00
|
|
|
shell_t shell;
|
2010-11-24 11:20:27 +01:00
|
|
|
const shell_command_t sc[] = {
|
2010-11-27 10:50:18 +01:00
|
|
|
{"mon", "", mon_handler},
|
2010-11-24 11:20:27 +01:00
|
|
|
{NULL, NULL, NULL}};
|
|
|
|
|
2010-11-27 10:50:18 +01:00
|
|
|
void mon_handler(char *mode) {
|
|
|
|
unsigned int m;
|
2010-11-26 10:23:46 +01:00
|
|
|
|
2010-11-27 10:50:18 +01:00
|
|
|
sscanf(mode, "mon %u", &m);
|
|
|
|
printf("Setting monitor mode: %u\n", m);
|
|
|
|
cc1100_set_monitor(m);
|
2010-11-24 11:20:27 +01:00
|
|
|
}
|
2010-11-19 20:10:09 +01:00
|
|
|
|
|
|
|
void shell_runner(void) {
|
|
|
|
shell_init(&shell, sc, uart0_readc, uart0_putc);
|
|
|
|
posix_open(uart0_handler_pid, 0);
|
|
|
|
shell_run(&shell);
|
|
|
|
}
|
|
|
|
|
2010-11-24 11:20:27 +01:00
|
|
|
void radio(void) {
|
|
|
|
msg m;
|
2010-11-26 17:06:54 +01:00
|
|
|
radio_packet_t *p;
|
|
|
|
uint8_t i;
|
2010-11-24 11:20:27 +01:00
|
|
|
|
|
|
|
while (1) {
|
|
|
|
msg_receive(&m);
|
2010-11-26 17:06:54 +01:00
|
|
|
printf("Received message of type %i:\n", m.type);
|
|
|
|
if (m.type == PKT_PENDING) {
|
|
|
|
p = (radio_packet_t*) m.content.ptr;
|
|
|
|
printf("Packet waiting, process...\n");
|
|
|
|
printf("\tLength:\t%u\n", p->length);
|
|
|
|
printf("\tSrc:\t%u\n", p->src);
|
|
|
|
printf("\tDst:\t%u\n", p->dst);
|
|
|
|
|
|
|
|
for (i = 0; i < p->length; i++) {
|
|
|
|
printf("%02X ", p->data[i]);
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
2010-11-24 11:20:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-19 20:10:09 +01:00
|
|
|
int main(void) {
|
2010-11-26 10:23:46 +01:00
|
|
|
int radio_pid;
|
|
|
|
thread_create(shell_stack_buffer, SHELL_STACK_SIZE, PRIORITY_MAIN-1, CREATE_STACKTEST, shell_runner, "shell");
|
2010-11-24 21:45:38 +01:00
|
|
|
radio_pid = thread_create(radio_stack_buffer, RADIO_STACK_SIZE, PRIORITY_MAIN-2, CREATE_STACKTEST, radio, "radio");
|
2010-11-26 10:23:46 +01:00
|
|
|
transceiver_init(TRANSCEIVER_CC1100);
|
|
|
|
transceiver_pid = transceiver_start();
|
|
|
|
transceiver_register(TRANSCEIVER_CC1100, radio_pid);
|
2010-11-19 20:10:09 +01:00
|
|
|
|
|
|
|
while (1) {
|
2010-11-24 11:20:27 +01:00
|
|
|
// LED_GREEN_TOGGLE;
|
2010-11-19 20:10:09 +01:00
|
|
|
hwtimer_wait(1000 * 1000);
|
|
|
|
}
|
|
|
|
}
|