Beispiel #1
0
void
main_menue (uint8_t cmd)
{
  /* ignore non-printable characters */
  if (cmd <= ' ')
    return;
  /* show key pressed */
  debug_printf ("%c\n", cmd);
  /* map lower case to upper case */
  if (cmd > 'a' && cmd < 'z')
    cmd -= ('a' - 'A');

  switch (cmd)
    {
    case '?':
    case 'H':
      debug_printf ("\n"
		    " *****************************************************\n"
		    " * OpenBeacon USB II - Bluetooth Console             *\n"
		    " * (C) 2010 Milosch Meriac <*****@*****.**>    *\n"
		    " *****************************************************\n"
		    " * H,?          - this help screen\n"
		    " * S            - SPI status\n"
		    " * R            - OpenBeacon nRF24L01 register dump\n"
		    " *****************************************************\n"
		    "\n");
      break;
    case 'R':
      nRFCMD_RegisterDump ();
      break;
    case 'S':
      debug_printf ("\n"
		    " *****************************************************\n"
		    " * OpenBeacon Status Information                     *\n"
		    " *****************************************************\n");
      spi_status ();
      acc_status ();
      storage_status ();
      nRFCMD_Status ();
      debug_printf (" *****************************************************\n"
		    "\n");
      break;
    default:
      debug_printf ("Unknown command '%c' - please press 'H' for help \n",
		    cmd);
    }
  debug_printf ("\n# ");
}
Beispiel #2
0
static inline void
main_menue (uint8_t cmd)
{
  TLogfileBeaconPacket pkt;

  /* ignore non-printable characters */
  if (cmd <= ' ')
    return;
  /* show key pressed */
  debug_printf ("%c\n", cmd);
  /* map lower case to upper case */
  if (cmd > 'a' && cmd < 'z')
    cmd -= ('a' - 'A');

  switch (cmd)
    {
    case '?':
    case 'H':
      debug_printf ("\n"
		    " *****************************************************\n"
		    " * OpenBeacon Tag - Bluetooth Console\n"
		    " *                  Version v" PROGRAM_VERSION "\n"
		    " * (C) 2011 Milosch Meriac <*****@*****.**>\n"
		    " *****************************************************\n"
		    " * H,?          - this help screen\n"
		    " * S            - Show device status\n"
		    " *\n"
		    " * E            - Erase Storage\n"
		    " * W            - Test Write Storage\n"
		    " * R            - Test Read Storage\n"
		    " * F            - Test WriteFill Storage\n"
		    " * M            - write 3 times and read them\n"
		    " *****************************************************\n"
		    "\n");
      break;
    case 'S':
      debug_printf ("\n"
		    " *****************************************************\n"
		    " * OpenBeacon Status Information                     *\n"
		    " *****************************************************\n");
      show_version ();
      spi_status ();
      acc_status ();
      storage_status ();
      debug_printf (" *****************************************************\n"
		    "\n");
      break;
  



    case 'M' :
	{
	uint32_t counter;
	debug_printf ("\nErasing Storage...\n\n");
	storage_erase ();
	debug_printf ("\nWriting Khalil 3 times...\n");
	counter = 0;
	const char data[] = "Khalil";
	const uint8_t buffer[32];
	while(counter < 3)
	{
	  storage_write (counter*sizeof(buffer), sizeof (buffer), &data);
	  counter ++;
	}
	debug_printf ("\n[DONE]\n");

	debug_printf("\n reading the data...\n");

	counter = 0;

	while(counter < 3)
	{
	storage_read (counter*sizeof(buffer), counter*sizeof(buffer) + sizeof (buffer), &buffer);
	hex_dump (buffer,0,sizeof (buffer));
	counter++;
	}

	break;
      }



    case 'E':
      debug_printf ("\nErasing Storage...\n\n");
      storage_erase ();
      g_storage_items = 0;
      break;

    case 'W':
      {
	const char hello[] = "Hello World!";
	debug_printf ("\n * writing '%s' (%i bytes)\n", hello,
		      sizeof (hello));
	storage_write (0, sizeof (hello), &hello);
      }
      break;

    case 'R':
      {
	const uint8_t buffer[32];
	debug_printf ("\n * reading %i bytes\n", sizeof (buffer));
	storage_read (0, sizeof (buffer), &buffer);
	hex_dump (buffer, 0, sizeof (buffer));
      }
      break;

    case 'F':
      {
	uint32_t counter;
	debug_printf ("\nErasing Storage...\n\n");
	storage_erase ();
	debug_printf ("\nFilling Storage...\n");
	counter = 0;
	while(counter < LOGFILE_STORAGE_SIZE)
	{
	  pkt.time = htonl(counter);
	  pkt.oid = htons(counter / sizeof(pkt));
	  pkt.strength = (counter / sizeof(pkt)) % MAX_POWER_LEVELS;
	  pkt.crc = crc8 (((uint8_t *) & pkt), sizeof (pkt) - sizeof (pkt.crc));
	  storage_write (counter, sizeof (pkt), &pkt);

	  counter += sizeof(pkt);
	}
	debug_printf ("\n[DONE]\n");
	break;
      }

    default:
      debug_printf ("Unknown command '%c' - please press 'H' for help \n",
		    cmd);
    }
  debug_printf ("\n# ");
}