MultiTechSystems / libxDot-dev-mbed5

Bleeding edge development version of the xDot library for mbed 5. This version of the library is not guaranteed to be stable or well tested and should not be used in production or deployment scenarios.
Other
3 stars 0 forks source link

GPS Time overflow #6

Open JhonattanC opened 4 years ago

JhonattanC commented 4 years ago

Hi, in "mDotEvent.h" found that in this function:

virtual void ServerTime(uint32_t seconds, uint8_t sub_seconds) 
{
    logDebug("mDotEvent - ServerTime");
    ServerTimeReceived = true;

    uint64_t current_server_time_ms = static_cast<uint64_t>(seconds) * 1000 +
    static_cast<uint16_t>(sub_seconds) * 4 + _timeSinceTx.read_ms();

    ServerTimeSeconds = static_cast<uint32_t>(current_server_time_ms / 1000);
    ServerTimeMillis = static_cast<uint16_t>(current_server_time_ms % 1000);
}

The current_server_time_ms overflows when doing static_cast<uint64_t>(seconds) * 1000 so the time when parsing the GPS time to String is incorrect. I guess that the getGPSTime() function uses this too, so the time that returns that function is wrong too.

I modified the ServerTime function in my own RadioEvent classs, and found that is not a network server issue. I tested it with Thingpark and a xDot module.

theckmts commented 4 years ago

I have a couple questions to help reproduce this.

Could you provide an example of output you saw when this occurred?

What time do you receive in your modified ServerTime function?