*Added ability to change channel Jackdaw (raven USB) operates on over serial menu

This commit is contained in:
c_oflynn 2008-10-26 01:27:55 +00:00
parent f05ccac0a7
commit ebb335335a
2 changed files with 151 additions and 78 deletions

View file

@ -55,6 +55,7 @@
#include "serial/uart_usb_lib.h"
#include "rndis/rndis_protocol.h"
#include "sicslow_ethernet.h"
#include "radio.h"
#include <stdio.h>
#include <avr/pgmspace.h>
@ -174,6 +175,7 @@ void menu_print(void)
PRINTF_P(PSTR("* m Print current mode *\n\r"));
PRINTF_P(PSTR("* s Set to sniffer mode *\n\r"));
PRINTF_P(PSTR("* n Set to network mode *\n\r"));
PRINTF_P(PSTR("* c Set RF channel *\n\r"));
PRINTF_P(PSTR("* 6 Toggle 6lowpan *\n\r"));
PRINTF_P(PSTR("* r Toggle raw mode *\n\r"));
PRINTF_P(PSTR("* u Switch to mass-storage*\n\r"));
@ -188,6 +190,63 @@ void menu_print(void)
*/
void menu_process(char c)
{
static enum menustate_enum /* Defines an enumeration type */
{
normal,
channel
} menustate = normal;
static char channel_string[3];
static uint8_t channel_string_i = 0;
int tempchannel;
if (menustate == channel) {
switch(c) {
case '\r':
case '\n':
channel_string[channel_string_i] = 0;
//Will return zero in event of error...
tempchannel = atoi(channel_string);
//Bounds check only if user had real input
if ( ((channel_string_i) && (tempchannel < 11)) || (tempchannel > 26)) {
PRINTF_P(PSTR("\n\rInvalid input\n\r"));
}
//If valid input, change it
if (tempchannel) {
radio_set_operating_channel(tempchannel);
}
menustate = normal;
break;
case '\b':
if (channel_string_i)
channel_string_i--;
break;
default:
if (channel_string_i > 1) {
menustate = normal;
PRINTF_P(PSTR("\n\rInput too long!\n\r"));
break;
}
channel_string[channel_string_i] = c;
channel_string_i++;
}
} else {
uint8_t i;
switch(c) {
case '\r':
@ -232,6 +291,13 @@ void menu_process(char c)
}
break;
case 'c':
PRINTF_P(PSTR("Select 802.15.4 Channel in range 11-26 [%d]: "), radio_get_operating_channel());
menustate = channel;
channel_string_i = 0;
break;
case 'm':
PRINTF_P(PSTR("Currently Jackdaw:\n\r * Will "));
@ -243,6 +309,7 @@ void menu_process(char c)
PRINTF_P(PSTR("decompress 6lowpan headers\n\r * Will "));
if (usbstick_mode.raw == 0) { PRINTF_P(PSTR("not "));}
PRINTF_P(PSTR("Output raw 802.15.4 frames\n\r "));
PRINTF_P(PSTR(" * Operates on channel %d\n\r"), radio_get_operating_channel());
break;
case 'u':
@ -276,6 +343,8 @@ void menu_process(char c)
}
}
return;
}

View file

@ -179,6 +179,10 @@ char uart_usb_getchar(void)
data_rx=Usb_read_byte();
rx_counter--;
if (!rx_counter) Usb_ack_receive_out();
//Local echo
uart_usb_putchar(data_rx);
return data_rx;
}