예제 #1
0
파일: cdc_ecm.c 프로젝트: 13416795/contiki
void
cdc_ecm_notify_connection_speed_change(uint32_t upstream,uint32_t downstream) {
#if CDC_ECM_USES_INTERRUPT_ENDPOINT
	Usb_select_endpoint(INT_EP);

	if(!Is_usb_endpoint_enabled())
		return;

	if(usb_endpoint_wait_for_IN_ready()!=0)
		return;

	Usb_send_control_in();

	Usb_write_byte(0x51); // 10100001b
	Usb_write_byte(CDC_NOTIFY_CONNECTION_SPEED_CHANGE);
	Usb_write_word(0x0000);
	Usb_write_word(ECM_INTERFACE0_NB);
	Usb_write_word(0x0008);

	Usb_send_in();

	if(usb_endpoint_wait_for_write_enabled()!=0)
		return;

	Usb_write_long(upstream);
	Usb_write_long(downstream);
	Usb_send_in();

	PRINTF_P(PSTR("cdc_ecm: CDC_NOTIFY_CONNECTION_SPEED_CHANGE UP:%d DOWN:%d\n"),upstream,downstream);
#endif
}
예제 #2
0
파일: cdc_ecm.c 프로젝트: 13416795/contiki
void
cdc_ecm_notify_network_connection(uint8_t value) {
#if CDC_ECM_USES_INTERRUPT_ENDPOINT
	Usb_select_endpoint(INT_EP);

	if(!Is_usb_endpoint_enabled()) {
		//PRINTF_P(PSTR("cdc_ecm: cdc_ecm_notify_network_connection: endpoint not enabled\n"));
		return;
	}

	if(usb_endpoint_wait_for_IN_ready()!=0) {
		//PRINTF_P(PSTR("cdc_ecm: cdc_ecm_notify_network_connection: Timeout waiting for interrupt endpoint to be available\n"));
		return;
	}

	Usb_send_control_in();

	Usb_write_byte(0x51); // 10100001b
	Usb_write_byte(CDC_NOTIFY_NETWORK_CONNECTION);
	Usb_write_byte(value);
	Usb_write_byte(0x00);
	Usb_write_word(ECM_INTERFACE0_NB);
	Usb_write_word(0x0000);

	Usb_send_in();
	PRINTF_P(PSTR("cdc_ecm: CDC_NOTIFY_NETWORK_CONNECTION %d\n"),value);
#endif
}
예제 #3
0
파일: cdc_ecm.c 프로젝트: 13416795/contiki
void
cdc_ecm_set_ethernet_packet_filter(void) {
	usb_ecm_packet_filter = Usb_read_word();

  	Usb_ack_receive_setup();
	Usb_send_control_in();
	usb_endpoint_wait_for_read_control_enabled();
	
	PRINTF_P(PSTR("cdc_ecm: Received SET_ETHERNET_PACKET_FILTER: (0x%04X) "),usb_ecm_packet_filter);
	if(usb_ecm_packet_filter & PACKET_TYPE_PROMISCUOUS) {
		PRINTF_P(PSTR("PROMISCUOUS "));
		USB_ETH_HOOK_SET_PROMISCIOUS_MODE(true);
	} else {
		USB_ETH_HOOK_SET_PROMISCIOUS_MODE(false);
	}

	if(usb_ecm_packet_filter & PACKET_TYPE_ALL_MULTICAST)
		PRINTF_P(PSTR("ALL_MULTICAST "));
	if(usb_ecm_packet_filter & PACKET_TYPE_DIRECTED)
		PRINTF_P(PSTR("DIRECTED "));
	if(usb_ecm_packet_filter & PACKET_TYPE_BROADCAST)
		PRINTF_P(PSTR("BROADCAST "));
	if(usb_ecm_packet_filter & PACKET_TYPE_MULTICAST)
		PRINTF_P(PSTR("MULTICAST "));
		
	PRINTF_P(PSTR("\n"));
}
예제 #4
0
static void printtxpower(void) {
    uint8_t power=rf230_get_txpower()&0xf;
    char sign=(power<6?'+':'-');
    char tens=(power>14?'1':'0');
    char ones=pgm_read_byte(&txonesdigit[power]);
    char tenths=pgm_read_byte(&txtenthsdigit[power]);
    if (tens=='0') {tens=sign;sign=' ';}
    PRINTF_P(PSTR("%c%c%c.%cdBm"),sign,tens,ones,tenths);
}
예제 #5
0
static void
ipaddr_add(const uip_ipaddr_t *addr)
{
  uint16_t a;
  int8_t i, f;
  for(i = 0, f = 0; i < sizeof(uip_ipaddr_t); i += 2) {
    a = (addr->u8[i] << 8) + addr->u8[i + 1];
    if(a == 0 && f >= 0) {
      if(f++ == 0) PRINTF_P(PSTR("::"));
    } else {
      if(f > 0) {
        f = -1;
      } else if(i > 0) {
	    PRINTF_P(PSTR(":"));
      }
	  PRINTF_P(PSTR("%x"),a);
    }
  }
}
예제 #6
0
/**
 \brief Process incomming char on debug port
 */
void menu_process(char c)
{

	static enum menustate_enum            /* Defines an enumeration type    */
	{
		normal,
		channel,
        txpower
	} 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':		
								
				if (channel_string_i)  {
					channel_string[channel_string_i] = 0;
					tempchannel = atoi(channel_string);

#if RF230BB
					if ((tempchannel < 11) || (tempchannel > 26))  {
						PRINTF_P(PSTR("\n\rInvalid input\n\r"));
					} else {
						rf230_set_channel(tempchannel);
#else
					if(radio_set_operating_channel(tempchannel)!=RADIO_SUCCESS) {
						PRINTF_P(PSTR("\n\rInvalid input\n\r"));
					} else {
#endif
#if JACKDAW_CONF_USE_SETTINGS
						if(settings_set_uint8(SETTINGS_KEY_CHANNEL, tempchannel)==SETTINGS_STATUS_OK) {                       
                            PRINTF_P(PSTR("\n\rChannel changed to %d and stored in EEPROM.\n\r"),tempchannel);
						} else {
                            PRINTF_P(PSTR("\n\rChannel changed to %d, but unable to store in EEPROM!\n\r"),tempchannel);
                        }
#else
						PRINTF_P(PSTR("\n\rChannel changed to %d.\n\r"),tempchannel);
#endif
					}
				} else {
					PRINTF_P(PSTR("\n\rChannel unchanged.\n\r"));
				}

				menustate = normal;
				break;
		
			case '\b':
			
				if (channel_string_i) {
					channel_string_i--;
					PRINTF_P(PSTR("\b \b"));
				}
				break;
					
			case '0':
			case '1':
			case '2':
			case '3':
			case '4':
			case '5':
			case '6':
			case '7':
			case '8':
			case '9':
				if (channel_string_i > 1) {
					// This time the user has gone too far.
					// Beep at them.
					putc('\a', stdout);
					//uart_usb_putchar('\a');
					break;
				}
				putc(c, stdout);
				//uart_usb_putchar(c);
				
				channel_string[channel_string_i] = c;
				channel_string_i++;
				break;

			default:
				break;
		}
	} else if (menustate == txpower) {
예제 #7
0
/**
 \brief Print debug menu
 */
void menu_print(void)
{
		PRINTF_P(PSTR("\n\r*********** Jackdaw Menu **********\n\r"));
		PRINTF_P(PSTR("        [Built "__DATE__"]      \n\r"));
//		PRINTF_P(PSTR("*                                 *\n\r"));
		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("*  p        Set RF power          *\n\r"));
		PRINTF_P(PSTR("*  6        Toggle 6lowpan        *\n\r"));
		PRINTF_P(PSTR("*  r        Toggle raw mode       *\n\r"));
#if USB_CONF_RS232
		PRINTF_P(PSTR("*  d        Toggle RS232 output   *\n\r"));
#endif
#if RF230BB && RF230_CONF_SNEEZER
		PRINTF_P(PSTR("*  S        Enable sneezer mode   *\n\r"));
#endif
#if UIP_CONF_IPV6_RPL
		PRINTF_P(PSTR("*  N        RPL Neighbors         *\n\r"));
		PRINTF_P(PSTR("*  G        RPL Global Repair     *\n\r"));
#endif
		PRINTF_P(PSTR("*  e        Energy Scan           *\n\r"));
#if USB_CONF_STORAGE
		PRINTF_P(PSTR("*  u        Switch to mass-storage*\n\r"));
#endif
		if(bootloader_is_present())
		PRINTF_P(PSTR("*  D        Switch to DFU mode    *\n\r"));
		PRINTF_P(PSTR("*  R        Reset (via WDT)       *\n\r"));
		PRINTF_P(PSTR("*  h,?      Print this menu       *\n\r"));
		PRINTF_P(PSTR("*                                 *\n\r"));
		PRINTF_P(PSTR("* Make selection at any time by   *\n\r"));
		PRINTF_P(PSTR("* pressing your choice on keyboard*\n\r"));
		PRINTF_P(PSTR("***********************************\n\r"));
}
예제 #8
0
/**
 \brief Process incomming char on debug port
 */
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);
					eeprom_write_byte(9, tempchannel);   //Write channel
					eeprom_write_byte(10, ~tempchannel); //Bit inverse as check
				}

				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':
			case '\n':
				break;

			case 'h':
			case '?':
				menu_print();
				break;

			case 's':
				PRINTF_P(PSTR("Jackdaw now in sniffer mode\n\r"));
				usbstick_mode.sendToRf = 0;
				usbstick_mode.translate = 0;
				break;

			case 'n':
				PRINTF_P(PSTR("Jackdaw now in network mode\n\r"));
				usbstick_mode.sendToRf = 1;
				usbstick_mode.translate = 1;
				break;

			case '6':
				if (usbstick_mode.sicslowpan) {
					PRINTF_P(PSTR("Jackdaw does not perform 6lowpan translation\n\r"));
					usbstick_mode.sicslowpan = 0;
				} else {
					PRINTF_P(PSTR("Jackdaw now performs 6lowpan translations\n\r"));
					usbstick_mode.sicslowpan = 1;
				}	
				
				break;

			case 'r':
				if (usbstick_mode.raw) {
					PRINTF_P(PSTR("Jackdaw does not capture raw frames\n\r"));
					usbstick_mode.raw = 0;
				} else {
					PRINTF_P(PSTR("Jackdaw now captures raw frames\n\r"));
					usbstick_mode.raw = 1;
				}	
				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 "));
				if (usbstick_mode.sendToRf == 0) { PRINTF_P(PSTR("not "));}
				PRINTF_P(PSTR("send data over RF\n\r  * Will "));
				if (usbstick_mode.translate == 0) { PRINTF_P(PSTR("not "));}
				PRINTF_P(PSTR("change link-local addresses inside IP messages\n\r  * Will "));
				if (usbstick_mode.sicslowpan == 0) { PRINTF_P(PSTR("not "));}
				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':

				//Mass storage mode
				usb_mode = mass_storage;

				//No more serial port
				stdout = NULL;

				//RNDIS is over
				rndis_state = 	rndis_uninitialized;
				Leds_off();

				//Deatch USB
				Usb_detach();

				//Wait a few seconds
				for(i = 0; i < 50; i++)
					_delay_ms(100);

				//Attach USB
				Usb_attach();


				break;

			default:
				PRINTF_P(PSTR("%c is not a valid option! h for menu\n\r"), c);
				break;
		}


	}

	return;

}
예제 #9
0
/**
 \brief Print debug menu
 */
void menu_print(void)
{
		PRINTF_P(PSTR("\n\n\r********** Jackdaw Menu ******************\n\r"));
		PRINTF_P(PSTR("*                                        *\n\r"));
		PRINTF_P(PSTR("* Main Menu:                             *\n\r"));
		PRINTF_P(PSTR("*  h,?             Print this menu       *\n\r"));
		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"));
		PRINTF_P(PSTR("*                                        *\n\r"));
		PRINTF_P(PSTR("* Make selection at any time by pressing *\n\r"));
		PRINTF_P(PSTR("* your choice on keyboard.               *\n\r"));
		PRINTF_P(PSTR("******************************************\n\r"));
}
예제 #10
0
void menu_process(char c)
{
  static enum menustate_enum            /* Defines an enumeration type    */
  {
      normal,
      channel,
      txpower
  } 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':
      if (channel_string_i) {
        channel_string[channel_string_i] = 0;
        tempchannel = atoi(channel_string);

        if ((tempchannel < 11) || (tempchannel > 26)) {
          PRINTF_P(PSTR("\n\rInvalid input\n\r"));
        } else {
          rf230_set_channel(tempchannel);

#if CONTIKI_CONF_SETTINGS_MANAGER
          if(settings_set_uint8(SETTINGS_KEY_CHANNEL, tempchannel) == SETTINGS_STATUS_OK) {
            PRINTF_P(PSTR("\n\rChannel changed to %d and stored in EEPROM.\n\r"), tempchannel);
          } else {
            PRINTF_P(PSTR("\n\rChannel changed to %d, but unable to store in EEPROM!\n\r"), tempchannel);
          }
#else
          PRINTF_P(PSTR("\n\rChannel changed to %d.\n\r"), tempchannel);
#endif
        }
      } else {
        PRINTF_P(PSTR("\n\rChannel unchanged.\n\r"));
      }

      menustate = normal;
      break;

    case '\b':
      if (channel_string_i) {
        channel_string_i--;
        PRINTF_P(PSTR("\b \b"));
      }
      break;

    case '0':
    case '1':
    case '2':
    case '3':
    case '4':
    case '5':
    case '6':
    case '7':
    case '8':
    case '9':
      if (channel_string_i > 1) {
        // This time the user has gone too far.
        // Beep at them.
        putc('\a', stdout);
        break;
      }
      putc(c, stdout);
      channel_string[channel_string_i] = c;
      channel_string_i++;
      break;

    default:
      break;
    }

  } else if (menustate == txpower) {

    switch(c) {
    case '\r':
    case '\n':
      if (channel_string_i) {
        channel_string[channel_string_i] = 0;
        tempchannel = atoi(channel_string);

        if ((tempchannel < 0) || (tempchannel > 15))  {
          PRINTF_P(PSTR("\n\rInvalid input\n\r"));
        } else {
          PRINTF_P(PSTR(" ")); //for some reason needs a print here to clear the string input...
          rf230_set_txpower(tempchannel);

#if CONTIKI_CONF_SETTINGS_MANAGER
          if(settings_set_uint8(SETTINGS_KEY_TXPOWER, tempchannel) == SETTINGS_STATUS_OK) {
            PRINTF_P(PSTR("\n\rTransmit power changed to %d, and stored in EEPROM.\n\r"), tempchannel);
          } else {
            PRINTF_P(PSTR("\n\rTransmit power changed to %d, but unable to store in EEPROM!\n\r"), tempchannel);
          }
#else
          PRINTF_P(PSTR("\n\rTransmit power changed to %d.\n\r"), tempchannel);
#endif
        }
      } else {
        PRINTF_P(PSTR("\n\rTransmit power unchanged.\n\r"));
      }

      menustate = normal;
      break;

    case '\b':
      if (channel_string_i) {
        channel_string_i--;
        PRINTF_P(PSTR("\b \b"));
      }
      break;

    case '0':
    case '1':
    case '2':
    case '3':
    case '4':
    case '5':
    case '6':
    case '7':
    case '8':
    case '9':
      if (channel_string_i > 1) {
        // This time the user has gone too far.
        // Beep at them.
        putc('\a', stdout);
        break;
      }
      putc(c, stdout);
      channel_string[channel_string_i] = c;
      channel_string_i++;
      break;

    default:
      break;
    }

  } else {
    uint8_t i;

    switch(c) {
    case '\r':
    case '\n':
      break;

    case 'h':
    case '?':
      menu_print();
      break;

    case 'd':
      if (mx_console_mode.debugOn) {
        PRINTF_P(PSTR("Node does not output debug strings\n\r"));
        mx_console_mode.debugOn = 0;
      } else {
        PRINTF_P(PSTR("Node now outputs debug strings\n\r"));
        mx_console_mode.debugOn = 1;
      }
      break;

    case 'c':
      PRINTF_P(PSTR("\nSelect 802.15.4 Channel in range 11-26 [%d]: "), rf230_get_channel());
      menustate = channel;
      channel_string_i = 0;
      break;
    case 'p':
      PRINTF_P(PSTR("\nSelect transmit power (0=+3dBm 15=-17.2dBm) [%d]: "), rf230_get_txpower());
      menustate = txpower;
      channel_string_i = 0;
      break;

#if UIP_CONF_IPV6_RPL
#include "rpl.h"
extern uip_ds6_nbr_t uip_ds6_nbr_cache[];
extern uip_ds6_netif_t uip_ds6_if;

    case 'N':
    {
      uint8_t i,j;
      PRINTF_P(PSTR("\n\rAddresses [%u max]\n\r"),UIP_DS6_ADDR_NB);
      for (i=0;i<UIP_DS6_ADDR_NB;i++) {
        if (uip_ds6_if.addr_list[i].isused) {
          ipaddr_add(&uip_ds6_if.addr_list[i].ipaddr);
          PRINTF_P(PSTR("\n\r"));
        }
      }
      PRINTF_P(PSTR("\n\rNeighbors [%u max]\n\r"),UIP_DS6_NBR_NB);
      for(i = 0,j=1; i < UIP_DS6_NBR_NB; i++) {
        if(uip_ds6_nbr_cache[i].isused) {
          ipaddr_add(&uip_ds6_nbr_cache[i].ipaddr);
          PRINTF_P(PSTR("\n\r"));
          j=0;
        }
      }
      if (j) PRINTF_P(PSTR("  <none>"));
      PRINTF_P(PSTR("\n\rRoutes [%u max]\n\r"),UIP_DS6_ROUTE_NB);
      {
        uip_ds6_route_t *r;
        j = 1;
        for(r = uip_ds6_route_list_head();
            r != NULL;
            r = list_item_next(r)) {
          ipaddr_add(&r->ipaddr);
          PRINTF_P(PSTR("/%u (via "), r->length);
          ipaddr_add(&r->nexthop);
          if(r->state.lifetime < 600) {
            PRINTF_P(PSTR(") %lus\n\r"), r->state.lifetime);
          } else {
            PRINTF_P(PSTR(")\n\r"));
          }
          j = 0;
        }
      }

      if (j) PRINTF_P(PSTR("  <none>"));
      PRINTF_P(PSTR("\n\r---------\n\r"));
      break;
    }

    case 'G':
      PRINTF_P(PSTR("Global repair returns %d\n\r"),rpl_repair_root(RPL_DEFAULT_INSTANCE));
      break;

    case 'L':
      rpl_local_repair(rpl_get_any_dag());
      PRINTF_P(PSTR("Local repair initiated\n\r"));
      break;

#endif

    case 'm':
      PRINTF_P(PSTR("Currently running on\n\r"));
      PRINTF_P(PSTR("  * %s\n\r"), CONTIKI_VERSION_STRING);
      PRINTF_P(PSTR("  * NETSTACK_MAC: %s, NETSTACK_RDC: %s\n\r"), NETSTACK_MAC.name, NETSTACK_RDC.name);
#if 1
      {
        int i;
        PRINTF_P(PSTR("  * Address: "));
        for (i = 0; i < 6; i += 2) {
          PRINTF_P(PSTR("%02x%02x:"), uip_lladdr.addr[i], uip_lladdr.addr[i + 1]);
        }
        PRINTF_P(PSTR("%02x%02x\n\r"), uip_lladdr.addr[6], uip_lladdr.addr[7]);
      }
#endif
#if UIP_CONF_IPV6_RPL
      PRINTF_P(PSTR("  * RPL Enabled\n\r"));
#endif
#if UIP_CONF_ROUTER
      PRINTF_P(PSTR("  * Routing Enabled\n\r"));
#endif
#if CONVERTTXPOWER
      PRINTF_P(PSTR("  * Operates on channel %d with TX power "),rf230_get_channel());
      printtxpower();
      PRINTF_P(PSTR("\n\r"));
#else  //just show the raw value
      PRINTF_P(PSTR("  * Operates on channel %d\n\r"), rf230_get_channel());
      PRINTF_P(PSTR("  * TX Power(0=+3dBm, 15=-17.2dBm): %d\n\r"), rf230_get_txpower());
#endif
      if (rf230_smallest_rssi) {
        PRINTF_P(PSTR("  * Current/Last/Smallest RSSI: %d/%d/%ddBm\n\r"), -91+(rf230_rssi()-1), -91+(rf230_last_rssi-1),-91+(rf230_smallest_rssi-1));
        rf230_smallest_rssi=0;
      } else {
        PRINTF_P(PSTR("  * Current/Last/Smallest RSSI: %d/%d/--dBm\n\r"), -91+(rf230_rssi()-1), -91+(rf230_last_rssi-1));
      }

#if CONFIG_STACK_MONITOR
      /* See contiki-raven-main.c for initialization of the magic numbers */
      {
        extern uint16_t __bss_end;
        uint16_t p=(uint16_t)&__bss_end;
        do {
          if (*(uint16_t *)p != 0x4242) {
            printf_P(PSTR("  * Never-used stack > %d bytes\n\r"),p-(uint16_t)&__bss_end);
            break;
          }
          p+=100;
        } while (p<RAMEND-100);
      }
#endif

      break;

    case 'e':
      PRINTF_P(PSTR("Energy Scan:\n"));
      {
        uint8_t i;
        uint16_t j;
        uint8_t previous_channel = rf230_get_channel();
        int8_t RSSI, maxRSSI[17];
        uint16_t accRSSI[17];

        bzero((void*)accRSSI,sizeof(accRSSI));
        bzero((void*)maxRSSI,sizeof(maxRSSI));

        for(j=0;j<(1<<12);j++) {
          for(i=11;i<=26;i++) {
            rf230_listen_channel(i);

            _delay_us(3*10);
            RSSI = rf230_rssi();  //multiplies rssi register by 3 for consistency with energy-detect register
            maxRSSI[i-11]=Max(maxRSSI[i-11],RSSI);
            accRSSI[i-11]+=RSSI;
          }

          if(j&(1<<7)) {
            leds_on(LEDS_RED);
            if(!(j&((1<<7)-1))) {
              PRINTF_P(PSTR("."));
            }
          } else {
            leds_off(LEDS_RED);
          }

          watchdog_periodic();
        }

        rf230_set_channel(previous_channel);

        PRINTF_P(PSTR("\n"));
        for(i=11;i<=26;i++) {
          uint8_t activity=Min(maxRSSI[i-11],accRSSI[i-11]/(1<<7));
          PRINTF_P(PSTR(" %d: %02ddB "),i, -91+(maxRSSI[i-11]-1));
          for(;activity--;maxRSSI[i-11]--) {
            PRINTF_P(PSTR("#"));
          }
          for(;maxRSSI[i-11]>0;maxRSSI[i-11]--) {
            PRINTF_P(PSTR(":"));
          }
          PRINTF_P(PSTR("\n"));
        }
      }

      PRINTF_P(PSTR("Done.\n"));
      break;

    case 'R':
      PRINTF_P(PSTR("Resetting...\n\r"));
      leds_on(LEDS_ALL);
      for(i = 0; i < 20; i++) _delay_ms(100);
      watchdog_reboot();
      break;

    default:
      PRINTF_P(PSTR("%c is not a valid option! h for menu\n\r"), c);
      break;
    }

  }
}
예제 #11
0
void
menu_print(void)
{
  PRINTF_P(PSTR("\n\r*********** MX Console menu **********\n\r"));
  PRINTF_P(PSTR("*      [Built "__DATE__"]       *\n\r"));
  PRINTF_P(PSTR("*                                 *\n\r"));
  PRINTF_P(PSTR("*  m        Print current mode    *\n\r"));
  PRINTF_P(PSTR("*  c        Set RF channel        *\n\r"));
  PRINTF_P(PSTR("*  p        Set RF power          *\n\r"));
  PRINTF_P(PSTR("*  d        Toggle RS232 output   *\n\r"));
#if UIP_CONF_IPV6_RPL
  PRINTF_P(PSTR("*  N        RPL Neighbors         *\n\r"));
  PRINTF_P(PSTR("*  G        RPL Global Repair     *\n\r"));
#endif
  PRINTF_P(PSTR("*  e        Energy Scan           *\n\r"));
  PRINTF_P(PSTR("*  R        Reset (via WDT)       *\n\r"));
  PRINTF_P(PSTR("*  h,?      Print this menu       *\n\r"));
  PRINTF_P(PSTR("*                                 *\n\r"));
  PRINTF_P(PSTR("* Make selection at any time by   *\n\r"));
  PRINTF_P(PSTR("* pressing your choice on keyboard*\n\r"));
  PRINTF_P(PSTR("***********************************\n\r"));
}