Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

CSM - Closing Sending Channels

Avatar
RankRankRankRank

Total Posts: 123

Joined 2013-10-07

PM

I use ANT+ CSM to receive/send data, I have to create other channels to send data to sensors.
From what I read, the channel is not really assigned, it is just using the radio resource.

The problem I have, I can assign the channel fine and send data to my sensor, but I am unable to close/unassign the channels once I am done with the sensors.

Any help appreciated,
Here is my code to open/close the CSM sending channels. I get an error when trying to close the CSM channels other than 0, and the channels stay open even after app close for some reason..
--Error closing channel: Code 021
Reopen app and you can still use the send channel again without configuring it!

void Hub::setLoad(int antIDbool fecTrainerdouble load{

        
if (!fecTrainerChanConfigured{
            configureSendChannelFEC
(antID);
        
}
        uint8_t aucTxBuf[ANT_STANDARD_DATA_PAYLOAD_SIZE]
;
        
FEC_Controller::EncodeTrainerTargetPower(aucTxBufload);
        
pclMessageObject->SendAcknowledgedData(constants::fecChannelNumberaucTxBuf);
}


void Hub
::configureSendChannelFEC(int antID{

    qDebug
() << "configureSendChannelFEC";
    
bool bStatus pclMessageObject->AssignChannel(constants::fecChannelNumber0USER_NETWORK_NUM);
    
bStatus pclMessageObject->SetChannelID(constants::fecChannelNumberantIDconstants::fecDeviceTypeconstants::transTypeFec);
    if (
bStatus{
        fecTrainerChanConfigured 
true;
        
vecChannelUsed.append(constants::fecChannelNumber);
    
}
}


void Hub
::closeScanningModeChannel(bool closeShop{

    bool bStatus 
true;

    
// Only close 1 channel (Channel 0), other channel are virtual channels?
    
foreach(int chanvecChannelUsed{

        bStatus 
pclMessageObject->CloseChannel(chan);
        if (
bStatus)
            
qDebug() << "CloseChannel Success" << chan;
        else
            
qDebug() << "CloseChannel Error" << chan;

        
bStatus pclMessageObject->UnAssignChannel(chan);
        if (
bStatus)
            
qDebug() << "UnAssignChannel Success" << chan;
        else
            
qDebug() << "UnAssignChannel Error" << chan;
    
}
     

Signature

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

Avatar
RankRankRankRank

Total Posts: 123

Joined 2013-10-07

PM

Seems like using "configureSendChannelFEC(antID);" every time before sending a message will work. Hopefully doing this every second for many sensors isn't too resource heavy      

Signature

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

Avatar
RankRankRankRank

Total Posts: 123

Joined 2013-10-07

PM

Can send data to FE-C Trainer and Power Meter, but for some reason the KICKR is not accepting my ACK message using this method.. was working before with dedicated channels -_-

I use this to configure the channel to the PM/Kickr before sending:

void Hub::configureSendChannelPM(int antID{

    qDebug
() << "configureSendChannelPM Now";
    
bool bStatus pclMessageObject->AssignChannel(constants::pmChannelNumber0USER_NETWORK_NUM);
    
bStatus pclMessageObject->SetChannelID(constants::pmChannelNumberantIDconstants::powerDeviceTypeconstants::transTypePower);
     

Signature

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

Avatar
RankRankRankRank

Total Posts: 123

Joined 2013-10-07

PM

Turns out you don't need to AssignChannel every time to send a message, if the last send was on the same channel, you just need to replace the ChannelID
Really wish the CSM documentation on how to send data to multiple device would be a bit more complete..
Thank you

void Hub::configureSendChannelFEC(int antID{

    qDebug
() << "configureSendChannelFEC";
    if (
currentSendingChannel != constants::fecChannelNumber{
        pclMessageObject
->AssignChannel(constants::fecChannelNumber0USER_NETWORK_NUM);
        
currentSendingChannel constants::fecChannelNumber;
    
}
    pclMessageObject
->SetChannelID(constants::fecChannelNumberantIDconstants::fecDeviceTypeconstants::transTypeFec);
     

Signature

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