You are here: Forum Home → ANT Developers Forums → ANT General Questions → Thread
device = new ANT_Device();
channel = ANT_ReferenceLibrary.ChannelType.BASE_Slave_Receive_0x00;
void main()
{
//Initialization...
device0 = new ANT_Device();
//Set the network key
//Assigned the channel
//Set the channel ID
//Set the channel frequency
channel0.setChannelFreq(0, 57); //RF Freq + 2400MHz
//Set the channel period
//Opened the channel
channel0.openChannel(57);
//Assign callback function
channel0.channelResponse += new ANT_Channel.ChannelResponseHandler(this.ChannelResponse);
}
//Called whenever a channel event is received
void ChannelResponse(ANT_Response newResponse)
{
StringBuilder stringToPrint;
//When something is received, display the ID and contents
stringToPrint = new StringBuilder("Received ", 100);
stringToPrint.AppendLine(((ANT_ReferenceLibrary.ANTMessageID)newResponse.responseID).ToString());
//Always print the raw contents in hex, with leading '::' for easy visibility/parsing
stringToPrint.Append(" :: ");
stringToPrint.Append(Convert.ToString(newResponse.responseID, 16));
stringToPrint.Append(", ");
stringToPrint.Append(BitConverter.ToString(newResponse.messageContents));
txtRcvdData.Text = stringToPrint.ToString();
}