Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Device Layer: Handle OpenThread API changes #472

Open
jaylogue opened this issue Jan 28, 2020 · 0 comments
Open

Device Layer: Handle OpenThread API changes #472

jaylogue opened this issue Jan 28, 2020 · 0 comments

Comments

@jaylogue
Copy link
Contributor

Presently the OpenThread code-base provides no way to detect breaking changes in the API at compile time. For OpenWeave, this leads to brittleness in the Device Layer when particular device adaptations target different versions of OpenThread.

To resolve this within OpenWeave, the following conditional compilation pattern is proposed:

  • In a common Device Layer header file, conditionally define the preprocessor macro WEAVE_DEVICE_CONFIG_OPENTHREAD_API_REVISION if it is not already defined. The value of the macro should be a date-time in the form yyyymmddHHMMSS.

  • Set the default value for WEAVE_DEVICE_CONFIG_OPENTHREAD_API_REVISION to have the time of the most recent commit to OpenThread known to work with OpenWeave.

  • As breaking API changes occur in OpenThread, wrap the affected code in OpenWeave in #if statements comparing WEAVE_DEVICE_CONFIG_OPENTHREAD_API_REVISION against the time the change was introduced into OpenThread master; specifically, the timestamp of the merge commit. E.g.:

#if WEAVE_DEVICE_CONFIG_OPENTHREAD_API_REVISION >= <...commit time...>
   ... new API code ...
#else
   ... old API code ...
#endif
  • Update the default value for WEAVE_DEVICE_CONFIG_OPENTHREAD_API_REVISION to the most recent compatible commit whenever new conditional code is introduced.

  • For any Device Layer adaptation that uses an earlier version of OpenThread, override WEAVE_DEVICE_CONFIG_OPENTHREAD_API_REVISION for that platform with the commit time of the version being used. This declaration should also be defaulted, so that application developers can override with their own value if they choose to.

  • For extra credit, modify the platform makefiles to fetch the highest master commit date from the OpenThread source directory using the following command and pass it as -DWEAVE_DEVICE_CONFIG_OPENTHREAD_API_REVISION=xxxx in CPPFLAGS to configure when building OpenWeave:

date --utc --date=@`git show -s --format=%ct \`git merge-base HEAD master\`` '+%Y%m%d%H%M%S'
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant