/* Original program by Keith O'Hara
   Program restructured and comments added by Henry M. Walker
*/

#include <stdio.h>
#include <fcntl.h>

int main(int argc, char **argv){
 
  int fd = open ("/dev/rfcomm0", O_RDWR);
  if (fd == -1){
    fprintf(stderr, "Trouble opening serial port\n");
    return -1;
  }
 
  char ch;
  printf("About to toggle the light on the fluke\n");
  ch = 't'; // 't' is ASCII 116, SET_DONGLE_LED_ON 
  write(fd, &ch, 1); // write takes a base address; use &ch or "t"
  usleep(2*1000*1000); // usleep gives a delay in microseconds
  ch = 'u'; // 'u' is ASCII 117, SET_DONGLE_LED_OFF
  write(fd, &ch, 1); // write takes a base address; use &ch or "u"
  close(fd);
  return 0;
}
