Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
[platform-api] overriding default weak otPlatTimeGet (#12)
Browse files Browse the repository at this point in the history
Later OpenThread added a default weak implementation of otPlatTimeGet
API in radio_platform.cpp. But the strong implementation in
ot-esp32/src/time.c failed to override the default one. This is
because there is no other unresolved symbols in src/time.c and the
linker will discard the entire .o file.

This commit moves otPlatTimeGet to a file includes other unresolved
symbols, and src/alarm.c seems to be a good candidate (since they are
both about time).
  • Loading branch information
wgtdkp authored Jul 7, 2020
1 parent 8e70c31 commit 4ab4c43
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 54 deletions.
10 changes: 10 additions & 0 deletions src/alarm.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ static uint64_t sAlarmT0 = 0;
static uint64_t sAlarmDt = 0;
static bool sIsRunning = false;

uint64_t otPlatTimeGet(void)
{
struct timeval tv_now;

int err = gettimeofday(&tv_now, NULL);
VerifyOrDie(err == 0, OT_EXIT_FAILURE);

return (uint64_t)tv_now.tv_sec * OT_US_PER_S + tv_now.tv_usec;
}

void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
{
OT_UNUSED_VARIABLE(aInstance);
Expand Down
54 changes: 0 additions & 54 deletions src/time.c

This file was deleted.

0 comments on commit 4ab4c43

Please sign in to comment.