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; }
///////////////////////////////////////////////////////////////////////////////////////// // Functon: HRMRX_Close // // Description: // Closes HRM recieve channel and initializes all state variables. Once the channel has // been successfuly closed, an HRMRX_EVENT_CHANNEL_CLOSED event will be generated via the // callback function/ // // Params: // N/A // // Returns: TRUE if message was successfully sent to ANT, FALSE otherwise. // ///////////////////////////////////////////////////////////////////////////////////////// BOOL HRMRX_Close() { ANT_CloseChannel(ucAntChannel); return(TRUE); }