#define _DEFAULT_SOURCE
#include <stdio.h>
#include <MyroC.h>
#include <unistd.h> /* Needed for gethostname */

int
main (void)
{
  printf ("program to set the name of the Scribbler 2 robot\n");
  printf ("to match the controlling MathLAN workstation name\n\n");

  char onOff[2];
  printf ("print Bluetooth communications ('y' or 'n')? ");
  scanf ("%s", onOff);
  rSetBluetoothEcho (onOff[0]);

  size_t string_size = 20;
  char hostname [string_size];
  char * newname;
  const char * hostnamecheck;

  gethostname (hostname, string_size);

  printf ("the name of this computer is %s\n", hostname);

  newname = hostname;
  //newname = "abcdefghijklm";

  printf ("setting the robot name to %s\n", newname);

  rConnect ("/dev/rfcomm0"); /* connect to robot */ 

  rSetName (newname);

  hostnamecheck = rGetName();

  rDisconnect();

  printf ("robot name now set to %s\n", hostnamecheck);
} // main
