You are here: Forum Home → ANT+ Forums → ANT+ Heart Rate Monitor → Thread
Console.WriteLine("Setting network key...");
if (device0.setNetworkKey(USER_NETWORK_NUM, USER_NETWORK_KEY, 500))
Console.WriteLine("Network key set");
else
throw new Exception("Error configuring network key");
Console.WriteLine("Assigning channel...");
if (channel0.assignChannel(channelType, USER_NETWORK_NUM, 500))
Console.WriteLine("Channel assigned");
else
throw new Exception("Error assigning channel");
Console.WriteLine("Setting Channel ID...");
if (channel0.setChannelID(USER_DEVICENUM, false, USER_DEVICETYPE, USER_TRANSTYPE, 500)) // Not using pairing bit
Console.WriteLine("Channel ID set");
else
throw new Exception("Error configuring Channel ID");
Console.WriteLine("Setting Radio Frequency...");
if (channel0.setChannelFreq(USER_RADIOFREQ, 500))
Console.WriteLine("Radio Frequency set");
else
throw new Exception("Error configuring Radio Frequency");
Console.WriteLine("Setting Period...");
if (channel0.setChannelPeriod(8070, 500))
Console.WriteLine("Channel Period set");
else
throw new Exception("Error configuring Channel Period");
Console.WriteLine("Opening channel...");
bBroadcasting = true;
if (channel0.openChannel(500))
{
Console.WriteLine("Channel opened");
}
Setting network key...
Network key set
Assigning channel...
Channel assigned
Setting Channel ID...
Channel ID set
Setting Radio Frequency...
Radio Frequency set
Setting Period...
Channel Period set
Opening channel...
Unhandled response NO_EVENT_0x00 to message CHANNEL_MESG_PERIOD_0x43
Channel opened
Enabling extended messages...
Extended messages enabled
Search Timeout
Channel Closed
Unassigning Channel...
Unassigned Channel
Press enter to exit
Hi,
The message you should be sending to configure the channel is [0x43][0x00][0x86][0x1F] to set channel 0x00 to channel period 8070. Is this what you're sending?
////////////////////////////////////////////////////////////////////////////////
// ConfigureANT
//
// Resets the system, configures the ANT channel and starts the demo
////////////////////////////////////////////////////////////////////////////////
private static void ConfigureANT()
{
Console.WriteLine("Resetting module...");
device0.ResetSystem(); // Soft reset
System.Threading.Thread.Sleep(500); // Delay 500ms after a reset
// If you call the setup functions specifying a wait time, you can check the return value for success or failure of the command
// This function is blocking - the thread will be blocked while waiting for a response.
// 500ms is usually a safe value to ensure you wait long enough for any response
// If you do not specify a wait time, the command is simply sent, and you have to monitor the protocol events for the response,
Console.WriteLine("Setting network key...");
if (device0.setNetworkKey(USER_NETWORK_NUM, USER_NETWORK_KEY, 500))
Console.WriteLine("Network key set");
else
throw new Exception("Error configuring network key");
Console.WriteLine("Assigning channel...");
if (channel0.assignChannel(channelType, USER_NETWORK_NUM, 500))
Console.WriteLine("Channel assigned");
else
throw new Exception("Error assigning channel");
Console.WriteLine("Setting Channel ID...");
if (channel0.setChannelID(USER_DEVICENUM, false, USER_DEVICETYPE, USER_TRANSTYPE, 500)) // Not using pairing bit
Console.WriteLine("Channel ID set");
else
throw new Exception("Error configuring Channel ID");
Console.WriteLine("Setting Radio Frequency...");
if (channel0.setChannelFreq(USER_RADIOFREQ, 500))
Console.WriteLine("Radio Frequency set");
else
throw new Exception("Error configuring Radio Frequency");
Console.WriteLine("Setting Period...");
if (channel0.setChannelPeriod((ushort)8070, 500))
Console.WriteLine("Channel Period set");
else
throw new Exception("Error configuring Channel Period");
Console.WriteLine("Setting Search Timeout...");
channel0.setChannelSearchTimeout((byte)12);
Console.WriteLine("Search Timeout set");
Console.WriteLine("Opening channel...");
bBroadcasting = true;
if (channel0.openChannel(500))
{
Console.WriteLine("Channel opened");
}
else
{
bBroadcasting = false;
throw new Exception("Error opening channel");
}
#if (ENABLE_EXTENDED_MESSAGES)
// Extended messages are not supported in all ANT devices, so
// we will not wait for the response here, and instead will monitor
// the protocol events
Console.WriteLine("Enabling extended messages...");
device0.enableRxExtendedMessages(true);
#endif
}
////////////////////////////////////////////////////////////////////////////////
// ConfigureANT
//
// Resets the system, configures the ANT channel and starts the demo
////////////////////////////////////////////////////////////////////////////////
private static void ConfigureANT()
{
Console.WriteLine("Resetting module...");
device0.ResetSystem(); // Soft reset
System.Threading.Thread.Sleep(500); // Delay 500ms after a reset
// If you call the setup functions specifying a wait time, you can check the return value for success or failure of the command
// This function is blocking - the thread will be blocked while waiting for a response.
// 500ms is usually a safe value to ensure you wait long enough for any response
// If you do not specify a wait time, the command is simply sent, and you have to monitor the protocol events for the response,
Console.WriteLine("Setting network key...");
if (device0.setNetworkKey(USER_NETWORK_NUM, USER_NETWORK_KEY, 500))
Console.WriteLine("Network key set");
else
throw new Exception("Error configuring network key");
Console.WriteLine("Assigning channel...");
if (channel0.assignChannel(channelType, USER_NETWORK_NUM, 500))
Console.WriteLine("Channel assigned");
else
throw new Exception("Error assigning channel");
Console.WriteLine("Setting Channel ID...");
if (channel0.setChannelID(USER_DEVICENUM, false, USER_DEVICETYPE, USER_TRANSTYPE, 500)) // Not using pairing bit
Console.WriteLine("Channel ID set");
else
throw new Exception("Error configuring Channel ID");
Console.WriteLine("Setting Radio Frequency...");
if (channel0.setChannelFreq(USER_RADIOFREQ, 500))
Console.WriteLine("Radio Frequency set");
else
throw new Exception("Error configuring Radio Frequency");
Console.WriteLine("Setting Period...");
if (channel0.setChannelPeriod((ushort)8070, 500))
Console.WriteLine("Channel Period set");
else
throw new Exception("Error configuring Channel Period");
Console.WriteLine("Setting Search Timeout...");
channel0.setChannelSearchTimeout((byte)12);
Console.WriteLine("Search Timeout set");
Console.WriteLine("Opening channel...");
bBroadcasting = true;
if (channel0.openChannel(500))
{
Console.WriteLine("Channel opened");
}
else
{
bBroadcasting = false;
throw new Exception("Error opening channel");
}
#if (ENABLE_EXTENDED_MESSAGES)
// Extended messages are not supported in all ANT devices, so
// we will not wait for the response here, and instead will monitor
// the protocol events
Console.WriteLine("Enabling extended messages...");
device0.enableRxExtendedMessages(true);
#endif
}
device0.setNetworkKey(0, USER_NETWORK_KEY, 500);
channel0.assignChannel(ANT_ReferenceLibrary.ChannelType.BASE_Slave_Receive_0x00, 0, 500);
channel0.setChannelID(0, false, 120, 0, 500);
channel0.setChannelPeriod((ushort)8070, 500);
channel0.setChannelFreq(57, 500);
//channel0.setChannelSearchTimeout((byte)12);
channel0.openChannel(500);
"Unhandled response NO_EVENT_0x00 to message CHANNEL_MESG_PERIOD_0x43"
case ANT_ReferenceLibrary.ANTMessageID.NETWORK_KEY_0x46:
case ANT_ReferenceLibrary.ANTMessageID.ASSIGN_CHANNEL_0x42:
case ANT_ReferenceLibrary.ANTMessageID.CHANNEL_ID_0x51:
case ANT_ReferenceLibrary.ANTMessageID.CHANNEL_RADIO_FREQ_0x45:
case ANT_ReferenceLibrary.ANTMessageID.OPEN_CHANNEL_0x4B:
case ANT_ReferenceLibrary.ANTMessageID.UNASSIGN_CHANNEL_0x41:
case ANT_ReferenceLibrary.ANTMessageID.CHANNEL_MESG_PERIOD_0x43:
Download the ANT Windows Library Package with source code.
Unzip the file.
Open the ANT_Libraries.sln solution (Visual C++)
Open the ANT_LIB project, and find the antfs_host.cpp file
Enter the ANT-FS network key, or set it to all 0’s if you are not using ANT-FS.
Right click on the Solution ANT_Libraries and select “Build Solution”.
Open the ANT_NET_Libraries.sln (Visual C#)
Build the entire solution.
Run DEMO_NET. This is a simple console application that shows how to configure and open an ANT channel.