Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

Battery Status Warning

Avatar
RankRankRankRank

Total Posts: 123

Joined 2013-10-07

PM

Hi guys,

Currently trying to implement battery status warning for all sensors (HR, CAD, SPD, PWR)
-For power, it's good with the new page that handles this well (GLOBAL_PAGE_82)

-For Heart Rate, I used the max time of battery life as the battery warning threshold
if (stPage1Data.ulOperatingTime 33554432 && !alreadyShownBatteryWarning{
                qDebug
() << "Emit signal batterylow";
                
emit batteryLow(tr("Heart Rate"), 1);
                
alreadyShownBatteryWarning true;
            


-For Cadence and Speed however, in the documentation it mentions a page "Data Page 4 – Battery Status" that is supposed to handle that. I checked the "antplus_bike_speed_and_cadence_v1.3.0" source code and it doesn't seem the code there handle theses messages. Would be nice to update it if you guys have the code to save some time decoding theses messages.

Thanks a lot!
Max      

Signature

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

RankRankRankRank

Total Posts: 156

Joined 2013-01-07

PM

Hi,

We don't have plans to update the reference designs in the near future.

The HandleDataMessages() method provides examples on decoding data pages 1 - 3. Using the data page definition from the device profile, it should be simple to create a data structure with the fields you require, and use the data page format to decode the received message.      
Avatar
RankRankRankRank

Total Posts: 123

Joined 2013-10-07

PM

Hi thanks for your reply.

To be honest, I think it's the C style programming that is giving me problem (not used to UCHAR and bit shifting..)

Here is the code I started :

case BSC_PAGE_3:
        
{
            stPage3Data
.ucHwVersion   = (ULONG)stMessage.aucData[ucDataOffset+1];
            
stPage3Data.ucSwVersion   = (ULONG)stMessage.aucData[ucDataOffset+2];
            
stPage3Data.ucModelNumber = (ULONG)stMessage.aucData[ucDataOffset+3];
            break;
        

        
case BSC_PAGE_4:  //Battery Status
        
{
            ULONG ucBatteryStatus
;
            
            
ucBatteryStatus   = (ULONG)stMessage.aucData[ucDataOffset+2];
            
            
//battery status is bit 4-6 of ucBatteryStatus
            //The coarse battery voltage can be found easily by using the bit mask of 0x0F on byte 7 as it requires no bit shifting.
//TODO
            
            
if (ucBatteryStatus == 4{
                qDebug
() << "Battery status low!";
            
}
            
else if (ucBatteryStatus == 5{
                qDebug
() << "Battery status critical!";
            
}
            
break;
        


I will try some trial and error until I get it I guess, thanks!      

Signature

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