mdaskalov / dcf77-clock-sync

Emulate DCF77 time signal on Flipper Zero using the RFID antenna and the A4 GPIO pin
MIT License
9 stars 1 forks source link

Dcf77-clock-sync don't sync the right day of the week #7

Closed Chibaxx closed 2 months ago

Chibaxx commented 3 months ago

Today I used it on my Citizen RC Eco Drive and on an Oregon wall clock to change to CEST. The signal from Germany is too weak due to bad weather. Time sync is ok, but my wristwatch says it's Tuesday, the wall clock says it's Friday, and today is Monday. I checked also the year on both watches, it's correct, 2024. I repeated the synchronization several times without better results. On the wall clock I can manually change year: moving to 2023 and then moving back to 2024 the day was successfully set to Monday, this makes me think that the data received from Flipper has somehow messed up the clock, is it possible?

mdaskalov commented 3 months ago

Please compare the data with this web page - the weekday is send as 3 bits near the end of the minute. Also look if the weekday on the screen is correct. There was an issue with the weekday in older firmwares but they fixed it in the latest release 0.99.1 probably the bug still exists in alternative firmwares... if that's the case- take the old version which has the fix integrated in it.

Chibaxx commented 3 months ago

Thank you for your answer! I compared the data with that of the web page you linked, with the help of the table on wikipedia I determined the bits relating to the day of the week, they have to be added with the following values: bit 42 = +1, bit 43 = +2, bit 44 =+ 4. For example today is Wednesday (April 3rd), Monday is the day 1, Wed. is the day 3, therefore 1+2, the first two bits are true and the third is false. The right set should be 110, but on Flipper it is 011 (Saturday), though the display show rightly Wednesday. If it was a firmware issue shouldn't I also have the wrong day on the display? IMG_4817

mdaskalov commented 3 months ago

Try to start the application few times and see if the submitted weekday changes. If not, try also after rebooting.

If it changes each time you start the application this is a reliable indicator that it's not properly initialized in datetime_timestamp_to_datetime in your firmware.

In the latest release (0.99.1) it's set in line 78 as follows

datetime->weekday = ((days + 3) % 7) + 1;

If this line is missing the weekday is not set and have a random value - ask the maintainer of the firmware to fix it...

Alternatively, you can change line 85 of dcf77_clock_sync.c to:

set_dcf77_time(&app->dt, app->is_dst);

The clock will be one minute behind, but the weekday will be correct. ;)

And finally if nothing helps try release 1.2 with older firmware version.