I think I have found a bug in bdb_Reporting.c. The constant 1000 is not treated as a uint32 so the compiler builds the wrong code, which causes the calculations to not work properly. My fixed code with the added "L" on the constants is below:
static uint16 bdb_RepCalculateEventElapsedTime( uint32 remainingTimeoutTimer, uint16 nextEventTimeout ) { uint32 passTimeOfEvent = 0; passTimeOfEvent = nextEventTimeout*1000L >= remainingTimeoutTimer? nextEventTimeout*1000L - remainingTimeoutTimer: 0; uint16 elapsedTime = passTimeOfEvent / 1000L; elapsedTime = elapsedTime + ((passTimeOfEvent % 1000L) >0 ? 1:0); //roundup return elapsedTime; }
Also, in bdb_RepChangedAttrValue() if trying to send another report before consolidatedMinReportInt has passed, it just completely discards the report. I think a better behavior would be to just wait until consolidatedMinReportInt has passed and then send the report, rather than discard it. I have changed my code to reflect this modification as well.