Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

You are here: Forum Home → ANT+ Forums → ANT+ Heart Rate Monitor → Thread

   

Demo_Net and HRM

Rank

Total Posts: 22

Joined 2013-02-02

PM

I've been reading through the available documents and code for the past couple hours and can't figure out what is going wrong with the DEMO_NET app.

There is no example of how to set channel period, so I figured it out myself. However, I get an error that says "Unhandled response NO_EVENT_0x00 to message CHANNEL_MESG_PERIOD_0x43" and then the app times out. Why isn't there a response for mesg_period? Shouldn't I be seeing "[RX] 00 00 00 00" messages in the console if the app connects to my HRM?      
Rank

Total Posts: 19

Joined 2013-02-13

PM

Make sure you get the order correct. See "What is the sequence of commands that must be sent to configure a single ANT channel?"
http://www.thisisant.com/developer/resources/tech-faq/category/channels-and-configuration/

So call channel0.setChannelPeriod() after you set the radio frequency in the method ConfigureANT.

How are you doing it?      
Rank

Total Posts: 22

Joined 2013-02-02

PM

It turns out I had the period set before setting the frequency. However, it doesn't seem to have helped. I still get the UNHADLED_MSG

Here is my config calls
Console.WriteLine("Setting network key...");
            if (
device0.setNetworkKey(USER_NETWORK_NUMUSER_NETWORK_KEY500))
                
Console.WriteLine("Network key set");
            else
                throw new 
Exception("Error configuring network key");

            
Console.WriteLine("Assigning channel...");
            if (
channel0.assignChannel(channelTypeUSER_NETWORK_NUM500))
                
Console.WriteLine("Channel assigned");
            else
                throw new 
Exception("Error assigning channel");

            
Console.WriteLine("Setting Channel ID...");
            if (
channel0.setChannelID(USER_DEVICENUMfalseUSER_DEVICETYPEUSER_TRANSTYPE500))  // 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_RADIOFREQ500))
                
Console.WriteLine("Radio Frequency set");
            else
                throw new 
Exception("Error configuring Radio Frequency");

   
Console.WriteLine("Setting Period...");
   if (
channel0.setChannelPeriod(8070500))
    
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");
            


Do I have to write a custom handling for that message type? If so, what would it be and is there an example of it somewhere in the DEMO app? Here is the console output


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
     
Avatar
RankRankRankRank

Total Posts: 235

Joined 2012-08-31

PM

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?

     
Rank

Total Posts: 22

Joined 2013-02-02

PM

Kat Kent - 29 March 2013 02:02 PM
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?


I'm using the Ant Managed Demo, utilizing the functions in ANT_Managed_Library.ANT_Channel to create a channel. I'm assuming they package and send high level functions calls as messages to the device. So I am not configuring the channel in byte message like you mentioned.

     
Rank

Total Posts: 22

Joined 2013-02-02

PM

Here is my slightly updated ConfigureAnt function evolved from demo_net

////////////////////////////////////////////////////////////////////////////////
        // 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_NUMUSER_NETWORK_KEY500))
                
Console.WriteLine("Network key set");
            else
                throw new 
Exception("Error configuring network key");

            
Console.WriteLine("Assigning channel...");
            if (
channel0.assignChannel(channelTypeUSER_NETWORK_NUM500))
                
Console.WriteLine("Channel assigned");
            else
                throw new 
Exception("Error assigning channel");

            
Console.WriteLine("Setting Channel ID...");
            if (
channel0.setChannelID(USER_DEVICENUMfalseUSER_DEVICETYPEUSER_TRANSTYPE500))  // 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_RADIOFREQ500))
                
Console.WriteLine("Radio Frequency set");
            else
                throw new 
Exception("Error configuring Radio Frequency");

   
Console.WriteLine("Setting Period...");
   if (
channel0.setChannelPeriod((ushort)8070500))
    
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


I'm not getting any responses back from the HRM.      
Rank

Total Posts: 22

Joined 2013-02-02

PM

This is a crosspost from the General questions as it pertains to the HRM.

I am using the Demo_net console program to try to connect to a Garmin HRM, however I don't get any channel response events except for when the channel times out. So I am effectively not receiving data. I'm not even sure if it found the other device (the HRM strap).

Here is my slightly updated ConfigureAnt function evolved from demo_net

////////////////////////////////////////////////////////////////////////////////
        // 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_NUMUSER_NETWORK_KEY500))
                Console
.WriteLine("Network key set");
            else
                throw new 
Exception("Error configuring network key");

            
Console.WriteLine("Assigning channel...");
            if (
channel0.assignChannel(channelTypeUSER_NETWORK_NUM500))
                
Console.WriteLine("Channel assigned");
            else
                throw new 
Exception("Error assigning channel");

            
Console.WriteLine("Setting Channel ID...");
            if (
channel0.setChannelID(USER_DEVICENUMfalseUSER_DEVICETYPEUSER_TRANSTYPE500))  // 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_RADIOFREQ500))
                
Console.WriteLine("Radio Frequency set");
            else
                throw new 
Exception("Error configuring Radio Frequency");

   
Console.WriteLine("Setting Period...");
   if (
channel0.setChannelPeriod((ushort)8070500))
    
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


I'm not getting any responses back from the HRM.
The original General Questions thread can be found here http://www.thisisant.com/forum/viewthread/3921/      
RankRankRankRank

Total Posts: 156

Joined 2013-01-07

PM

Hi,

Could you please give the values of the constants used in your code. (ex. channelType, USER_DEVICENUM, USER_DEVICETYPE, USER_TRANSTYPE, USER_RADIOFREQ)

Make sure they match the values specified in the channel configuration section of the ANT+ HRM device profile document.

Please leave out the Network Key, as that is confidential. But do make sure that it is the ANT+ Network Key found on our website at:

http://www.thisisant.com/developer/ant-plus/ant-plus-basics/network-keys


If you have another ANT USB stick, have you tried using the Heart Rate simulator found on our website to connect to DEMO_NET. This would give you a more precise method of testing as you will always know when there is HRM data to be received.

Regards,

Usama      
Rank

Total Posts: 22

Joined 2013-02-02

PM

We have an order for another Ant usb stick so I will hopefully have one soon.

I'd like to take a step back and ask a fundamental question: after the channel is opened, should I receive data automatically, e.g. a connection confirmation? Or is the successful opening of the channel confirmation that it connected to another device?      
RankRankRankRank

Total Posts: 156

Joined 2013-01-07

PM

If the slave is properly configured then you should start to receive data automatically.

The channel is opened to begin the search for a master device, so the successful opening of the channel is not confirmation that it connected to another device.

Rather, the receipt of data is confirmation that you have successfully connected to a device.      
Rank

Total Posts: 22

Joined 2013-02-02

PM

device0.setNetworkKey(0USER_NETWORK_KEY500);
channel0.assignChannel(ANT_ReferenceLibrary.ChannelType.BASE_Slave_Receive_0x000500);
channel0.setChannelID(0false1200500);
channel0.setChannelPeriod((ushort)8070500);
channel0.setChannelFreq(57500);
//channel0.setChannelSearchTimeout((byte)12);
channel0.openChannel(500); 
     
RankRankRankRank

Total Posts: 156

Joined 2013-01-07

PM

From the values you have given, you are correctly configuring the slave for an ANT+ HRM channel. I entered your version of ConfigureANT() into demo.cs and tested it with a HRM sensor simulator and it work fine. It seems that the reason you are not receiving any data is probably because the master is not transmitting.

Have you tried to connect your HRM to the display simulator? Knowing when your specific HRM transmits data would definitely help out with the testing (most commercially available HRMs only start transmitting when they detect a heart beat). Are you wearing your HRM when you are testing?

In response to the error message you receive:

"Unhandled response NO_EVENT_0x00 to message CHANNEL_MESG_PERIOD_0x43" 


As you might have noticed, the code in demo.cs does not contain any channel period code.This means that the switch statement in DeviceResponse() drops all the way to the default case (that transmits the "Unhandled Response Message") when you set the channel period. To stop receiving the message you can add a case for the set channel period message (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
     
Rank

Total Posts: 22

Joined 2013-02-02

PM

I now have two USB sticks and I am running the HRM in the Ant Simulator but still not seeing any console messages coming in or a connection happening.

Maybe its my library configuration and build as per the directions:


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.


antfs_host.cpp doesn't have a network key entry within it. Are these directions current?      
RankRankRankRank

Total Posts: 156

Joined 2013-01-07

PM

I am not sure which release version of the ANT_Libraries you are using but those instructions are different from the ones in the library package available on our website.

You should download the latest release version available under the software downloads tab, labelled "ANT Windows Library Package with source code", Version 3.0.

The projects in this version will not build unless you have set all the Network Keys to valid values, and the error list will show you where you can enter them. Also, the instructions in this version tell you to set the Network Keys in the file ANT_LIB\software\ANTFS\antfsmessage.h and DEMO_ANTFS\demo_host.cs not the antfs_host.cpp file.

Give that a try.

     
Rank

Total Posts: 22

Joined 2013-02-02

PM

Deleted my existing working directory and started from scratch and now its working!

I'm trying to reproduce my first steps to see what I did different (I might have not included the ant_net.dll from the right directory) but can't get it to break again. Oh well, at least it's working now. One thing I might have done wrong the first time was setting the FS key to the + key. I also included the ant_net.dll from the BIN directory and not the debug directory the first time so maybe that was an issue.