Esempio n. 1
0
int main(int argc, char *argv[])
{
	if(SIG_ERR == signal(SIGINT, clean_exit))
	{
		perror("signal");
		exit(1);
	}

	int fd = ANT_OpenSerial("/dev/ttyUSB0");

	if(-1 == fd)
	{
		perror("Failed to open serial connection");
		exit(1);
	}

	ANT_SetNetworkKey(fd, 0, NETWORK_KEY);
	read_response(fd);

	ANT_AssignChannel(fd, 0, ANT_RX_CHANNEL, 0, 0);
	read_response(fd);

	ANT_SetChannelID(fd, 0, 0, 0, 0x78, 0);
	read_response(fd);

	ANT_SetRFFrequency(fd, 0, ANT_PLUS_FREQUENCY);
	read_response(fd);

	ANT_SetChannelPeriod(fd, 0, ANT_PLUS_PERIOD_102);
	read_response(fd);

	ANT_OpenRXScanMode(fd);
	read_response(fd);

	read_loop(fd);

	ANT_RequestMessage(fd, 0, SET_CHANNEL_ID);

	do_exit = 0;
	read_loop(fd);

  //ANT_UnassignChannel(fd, 0);
	//read_response(fd);

  ANT_CloseChannel(fd, 0);
	read_response(fd);

	close(fd);
	return 0;
}
Esempio n. 2
0
/////////////////////////////////////////////////////////////////////////////////////////
// Functon: HRMRX_Open
//
// Descrption:
// Opens HRM recieve channel. Once the channel has been properly initialize an HRMRX_EVENT_INIT_COMPLETE
// event will be generated via the callback. A positive response from this function does not
// indicate tha the channel successfully opened. 
//
// Params:
// usDeviceNumber_: Device number to pair to. 0 for wild-card.
//
// returns: TRUE if all configuration messages were correctly setup and queued. FALSE otherwise. 
/////////////////////////////////////////////////////////////////////////////////////////
BOOL HRMRX_Open(UCHAR ucAntChannel_, USHORT usSearchDeviceNumber_, UCHAR ucTransType_)
{

   HRMRX_Init();

   ucAntChannel = ucAntChannel_;
   usDeviceNumber = usSearchDeviceNumber_;
   ucTransType = ucTransType_;
   
   if(!ANT_AssignChannel(ucAntChannel,HRMRX_CHANNEL_TYPE,ANTPLUS_NETWORK_NUMBER ))
      return FALSE;
 
   return(TRUE);
}