/* Program to test versions of rConnect () 
 *
 * This program and all MyroC software is licensed under the Creative Commons
 * Attribution-Noncommercial-Share Alike 3.0 United States License.
 * Details may be found at http://creativecommons.org/licenses/by-nc-sa/3.0/us/
 */

#include <stdio.h>
#include "MyroC.h"
#include <unistd.h>

int main(int argc, char **argv){

  int perlis, markov, post, wilkes, curry, goldstine, hahn;

   // test use of rfcomm0
  perlis = rConnect ("/dev/tty.Fluke2-0958-Fluke2");
  rBeep (2, 880);
  rBeep (3, 1760);
  rSetName ("perlis");
  sleep (1);

// test use of IPRE number alone
/*
  post = rConnect ("365827");
  rBeep (2, 880);
  rBeep (3, 1760);
  rSetName("post");
  sleep (1);
  */

  // test use of IPRE number alone
  /*
  markov = rConnect ("365688");
  rBeep (2, 880);
  rBeep (3, 1760);
  rSetName("markov");
  sleep (1);
  */

  // test use of Fluke 2 number alone
  /*
  goldstine = rConnect ("0519");
  rBeep (2, 880);
  rBeep (3, 1760);
  rSetName ("goldstine");
  */

  // test use of Fluke 2 number with Fluke-
  /*
  hahn = rConnect ("Fluke2-051F");
  rBeep (2, 880);
  rBeep (3, 1760);
  rSetName ("hahn");
  */

  // test use of IPRE number with IPRE
  //  curry = rConnect ("IPRE6-365897");
  curry = rConnect ("/dev/tty.IPRE6-365897-DevB");
  rBeep (2, 880);
  rBeep (3, 1760);
  rSetName ("curry");
  sleep (1);
  // test use of MAC address
  /*
  wilkes = rConnect ("00:1E:19:01:0E:13");
  rBeep (2, 880);
  rBeep (3, 1760);
  rSetName ("wilkes");
  */

  rSetConnection (perlis);
  rSetName("ddddxyzghijklZAB");
  printf("new name is %s\n", rGetName());
  rSetName ("perlis");
  rSetForwardness("scribbler-forward");
  printf("%s\n", rGetForwardness());
  rBeep (1.0, 880);
  rSetForwardness("fluke-forward");
  printf("%s\n", rGetForwardness());

  /* tell perlis to beep */
  rSetConnection (curry);
  rBeep (2, 1000);

  /* tell markov to beep */
  /*
  rSetConnection (markov);
  rBeep (2, 1000);
  */
  
  rSetConnection (perlis);
  rBeep (2.0, 900);
  rBeep (1.0, 850);
  printf ("disconnecting from %s\n", rGetName());
  rDisconnect();

  /*
  rSetConnection (markov);
  printf ("disconnecting from %s\n", rGetName());
  rDisconnect();
  */
  
  /*
  rSetConnection (post);
  printf ("disconnecting from %s\n", rGetName());
  rDisconnect();
  */

  rSetConnection (curry);
  printf ("disconnecting from %s\n", rGetName());
  rDisconnect();

  /*
  rSetConnection (wilkes);
  printf ("disconnecting from %s\n", rGetName());
  rDisconnect();

  rSetConnection (goldstine);
  printf ("disconnecting from %s\n", rGetName());
  rDisconnect();

  rSetConnection (hahn);
  printf ("disconnecting from %s\n", rGetName());
  rDisconnect();
  */

  return 0;
}
