// Robot-PC communication
// T. Braunl, April 2020

#include "eyebot.h"
#define MAX   8
#define ITER 10

int main ()
{ int  i, num, myid, PC;
  char sbuf[MAX], rbuf[MAX];

  LCDPrintf("Robot-PC Communication\n");
  LCDMenu("","","","END");
  RADIOInit();
  myid = RADIOGetID();
  LCDPrintf("my id is: %d\n", myid);
  LCDPrintf("Waiting for PC request\n");

  for (i=0; i<ITER; i++)
  { RADIOReceive(&PC, rbuf, MAX);
    LCDPrintf("received from %d text %s\n", PC, rbuf);
    num = PSDGet(PSD_FRONT);  // read front distance
    sprintf((char*)sbuf, "%05d", num);
    RADIOSend(PC, sbuf);
  }
  KEYWait(KEY4);
}

