Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

Infinite search - how to stop

Avatar
RankRankRankRank

Total Posts: 123

Joined 2013-10-07

PM

Just some context to explain my question :
My application can pair 5 types of sensor (Hr, Speed, Cadence, Combined S&C, Power).
The value of the sensor id, device type and transmission type are all stored for easy pairing when the user starts a bike workout.

When the workout is started, all necessary channels are opened (up to 4 channels) using the previously stored id of the sensor.
Now because I know that all the sensors ID should be good (user paired them). I set an infinite timeout on the channel search, so the user have time to do whatever he wants before the workout :
bStatus pclMessageObject->SetChannelSearchTimeout(Channel255MESSAGE_TIMEOUT); 


This is all working properly if the channel find a device, but if the channel doesn't find one, I cannot close the channel and the channel is left in an "infinite search" it seems.

Code for closing the channel (the application sends the flag closeChannelNow=true when the workout needs to end and close all channels):
if (closeChannelNow && antThreadRunning{
                
if (!threadStopped{
                    qDebug
() << "OK Closed window,, Closing Channel Now!";
                    
pclMessageObject->CloseChannel(pclMessageObject->GetChannelNumber(&stMessage;), MESSAGE_TIMEOUT);
                    
threadStopped true;
                
}
            } 


Is there a command or a way to end the search manually? Or a way to force a channel close ? My closeChannel command get ignored even if the channel is open.

Thanks in advance!
     

Signature

——————————————————
Free Indoor Cycling Software - https://maximumtrainer.com

Avatar
RankRankRankRank

Total Posts: 296

Joined 0

PM

Did you try to unassign the channel instead of closing it?
Technically speaking the channel isn't open before the search succeeds, so it's not too strange that close() doesn't work.

Cheers,
OMB      
Avatar
RankRankRankRank

Total Posts: 123

Joined 2013-10-07

PM

Thanks for your reply,

In fact it has been resolved now, the problem was on my side.
I suspect I was closing the channel but not stopping the "Demo::MessageThread"

I changed my closing channel code recently not sure what fixed it:
C++ Code:
/// Workout finish, close open channels
            
if (closeChannelNow && antThreadRunning{
                
if (!threadStopped{
                    threadStopped 
true;
                    
qDebug() << "OK Closed window, Closing all open Channel Now!";
                    foreach (
int ilstOpennedChannel{
                        qDebug
() << "Got to close channel:" << i;
                        
pclMessageObject->CloseChannel(iMESSAGE_TIMEOUT);
                    
}
                }
            } 



----------------------------
Log of the channel opening and not finding the device :

WorkoutDialog - Trying to pair Sensors...
SensorHR_ID: 0 SensorType: 120 TransType: 0
SensorCADENCE_ID: 101 SensorType: 121 TransType: 1
SensorSPEED_ID: 101 SensorType: 121 TransType: 1
SensorPOWER_ID: 0 SensorType: 11 TransType: 0

Opening SPEED_CADENCE channel 3...
Network key set

Channel assigned

Channel ID set

Setting Low priority search timeout

Setting search timeout

Radio Frequency and period set

Message Period set

Channel opened
Enabling extended messages...

Extended messages enabled
//[Stays here waiting to find the device...]


//Close windows event :
WorkoutDialog destructor!----------
OK Closed window, Closing all open Channel Now!
Got to close channel: 3
Closing Channel 3

Channel Closed___ 3
trying to unAssignChannel 3

Channel unassigned 3
OK all channel closed, end loop

End messageThread      

Signature

——————————————————
Free Indoor Cycling Software - https://maximumtrainer.com

Rank

Total Posts: 8

Joined 2023-01-06

PM

As soon as the workout begins, the sensor's unique identifier is retrieved from memory and used to open the appropriate channels (up to a maximum of four).
At this point, I am confident that all of the sensors' IDs are functioning properly (user paired them). I made the channel search timeout limitless, giving the user plenty of leeway before the operation timed out. penalty kick online