Skip to content

Commit

Permalink
Use system clock for local offset, not timekeeping
Browse files Browse the repository at this point in the history
  • Loading branch information
NKelias committed Jun 18, 2019
1 parent cbd266b commit 13077b9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/OTP/hotp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1209,14 +1209,14 @@ time_t now;

// Get the local ATMEL time
time (&now);
current_time = now;

if (slot_no >= NUMBER_OF_TOTP_SLOTS)
return 0;

OTP_slot *slot = (OTP_slot *) get_totp_slot_addr(slot_no);

time_min = current_time / slot->interval_or_counter;
// Add last time stamp from app and elapsed seconds since last set_time operation
time_min = (current_time + now) / slot->interval_or_counter;

if (slot->type != 'T') // unprogrammed slot
return 0;
Expand Down
7 changes: 5 additions & 2 deletions src/OTP/report_protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -2176,9 +2176,12 @@ u32 new_time_minutes = (new_time - 1388534400) / 60; // 1388534400 = 01.01.20
CI_StringOut ("Local time set to = "); itoa (new_time,text); CI_StringOut ((char*)text);
CI_StringOut (" = "); ctime_r ((time_t*)&new_time,(char*)text); CI_StringOut ((char*)text); CI_StringOut ("\r\n"); } */
set_time (new_time);


// Reset runtime counter and store the time offset that was received from the app
set_time (0);
current_time = new_time;

// Write new timestamp to Flash
err = set_time_value (new_time_minutes);
if (err)
{
Expand Down

0 comments on commit 13077b9

Please sign in to comment.