Commit Graph

60 Commits

Author SHA1 Message Date
canisLupus1313 126e232ad5 [link-metrics] split OPENTHREAD_CONFIG_MLE_LINK_METRICS_ENABLE macro (#6716)
This commit splits OPENTHREAD_CONFIG_MLE_LINK_METRICS_ENABLE macro
into two subsequent ones:
- OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE
- OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE
2021-06-22 10:49:53 -07:00
Eduardo Montoya 5cd088cd76 [low-power] extend EnableCsl API (#6675)
Include the peer's short address together with the extended address
when enabling the CSL link. This removes the need for the platform
to guess it.
2021-05-25 15:21:38 -07:00
Eduardo Montoya fa171812d3 [low-power] adaptative CSL window duration (#6311)
Make CSL receive window dependent on the accuracy of the crystals
used for scheduling and on the elapsed time since last synchronization.

CSL Receive window scheduling
=============================

          a   b  c              d      e              f  g
          |   |  |              |      |              |  |
-------------------------------------------------------------------->

a-b:  kCslReceiveTimeAhead
b-c:  -mCslParentUncert
c-d:  -(mCslParentDrift + otPlatRadioGetCslAccuracy)
d:    mCslSampleTime
d-e:  kMinCslWindow
e-f:  +(mCslParentDrift + otPlatRadioGetCslAccuracy)
f-g:  +mCslParentUncert
2021-03-30 18:39:09 -07:00
kangping 31746000e8 [heap] fix external heap configuration (#6123)
The Instance::HeapCAlloc() method can not be used in constructors when
EXTERNAL_HEAP is enabled but works well when internal heap is
used. This is because the external heap methods are set by public
otHeapSetCAllocFree API after the OT instance is constructed.

This commit fixes this issue by having Instance::HeapCAlloc() using
otPlatCAlloc when EXTERNAL_HEAP is enabled. It also fixes build issues
when MULTIPLE_INSTANCE and EXTERNAL_HEAP are used together.
2021-02-05 10:15:13 -08:00
kangping 995ad66846 [border-router] initial implementation of prefix/route management (#5856)
This is the initial implementation of Thread Border Router
prefix/route management with:

- Create & publish off-mesh routable (OMR) prefix for Thread network
  - configure the BR as default route.
  - converge to the smallest OMR prefix if multiple prefixes are
    present at the same time.
- Create & advertise on-link prefix for infrastructure network
  - monitor RA messages on infra link and stops myself if there is
    someone else advertising an on-link prefix.

It currently supports single infrastructure link with possibly
multiple BRs. Support for multiple infrastructure links is left for
future.
2020-12-23 15:19:12 -08:00
kangping 677e2f01ec [tests] add "return" for dummy test platform API (#6000) 2020-12-22 20:37:34 -08:00
Abtin Keshavarzian 89cc2ef432 [test] add 'otPlatEntropyGet()' using TRNG for unit test (#5945) 2020-12-12 11:05:21 -08:00
Li Cao ae07fe27ff [low-power] implement enhanced-ack based probing (#5780)
This commit implements Enhanced-ACK Probing (on simulation platform).

- Add a new public API otLinkMetricsConfigEnhAckProbing which sends
  Link Metrics Management Request to configure the probing. This is
  called on Probing Initiator side.

- Add a new radio platform API otPlatRadioConfigureEnhAckProbing. This
  API should be called on Probing Subject side when handling the
  requests from Initiators. This API notifies the radio to start/stop
  aggregating link metrics info and include the data into Vendor IE in
  enhanced-ACK for the specific neighbor. As discussed in #5746, the
  code for doing such thing should be put in radio driver.

- Add a util module util/link_metrics, which provides a group of APIs
  to implement Probing Subject side logic for Enh-ACK Probing. Any
  platform could use this module to implement the feature easily in
  radio driver.

- Add new util APIs in util/mac_frame to generate Enh-ACK Probing IE
  (Vendor IE with Thread OUI and SubType = 0) and set value for this
  IE.

- Update the implementation in simulation/radio.c to support Probing
  Subject side logic for Enh-ACK Probing, using APIs in
  util/link_metrics and util/mac_frame.

- Add a test
  v1_2_LowPower_7_1_01_SingleProbeLinkMetricsWithEnhancedAcks.py for
  testing.

Misc:

  - Add check for all the public Link Metrics APIs (Initiator side) to
    ensure that the Subject is a neighbor of the Initiator. If the
    address is not link-local or the neighbor is not found, an error
    UNKNOWN_NEIGHBOR would be returned.

  - Update PrepareEmptyFrame so that when it's called for reference
    device, its frame version would be set to 2015.
2020-12-10 23:31:41 -08:00
Abtin Keshavarzian 2d36853fe6 [trel] implementing Thread Radio Encapsulation Link (TREL) (#4440)
This commit implements TREL protocol to encapsulate and exchange IEEE
802.15.4 frames over a packet switched network (e.g., a wireless LAN).
This commit also provides a TREL IPv6/UDP interface implementation
(using link-local IPv6 unicast/multicast addresses to communicate over
a subnet). It defines a platform abstraction (`otPlatTrelUdp6*`) for
TREL over IPv6/UDP.

This commit also provides an implementation of the TREL platform under
`examples/posix` focusing on simulating the behavior of the link.
2020-12-10 11:46:07 -08:00
Jonathan Hui b9c956174e [clang-tidy] readability-else-after-return (#5808) 2020-11-16 08:52:10 -08:00
Jonathan Hui ef4f33cb22 [clang-tidy] readability-inconsistent-declaration-parameter-name (#5796) 2020-11-11 10:35:36 -08:00
Jonathan Hui 81688a0447 [clang-tidy] modernize-use-nullptr (#5715) 2020-10-27 11:39:35 -07:00
Li Cao 7db8c6815c [low-power] add csl feature for Thread 1.2 (#4557)
This commit implements the CSL feature in Thread 1.2.

- Add macro definitions for low power to control the compiling of
  source code.

- Add data and methods for running CSL in Mac and SubMac. This mainly
  includes setting CSL parameters, starting/stopping CSL, and the
  timer handling process.

- Add otPlatTimeGetAPI and implementation.

- Add CSL transmission implementation. CSL transmission is a new kind
  of transmission, the related definition and implementaion for the
  whole transmitting process is added.

- Add calling of start/stop CSL in certain cases.

- Implement CSL synchronization maintainence. If a CSL cordinator
  didn't get a frame containing CSL IE for CSLTimeout, the CSL
  receiver is regarded as de-synchronized.

- Add Cli interface for using CSL.

- Implement enhanced Ack with IE. The original code can only generate
  auto ack for Imm-Ack. As CSL requires CSL IE included in enhanced
  ack. This PR implements it.

- Add basic functional test for CSL transmission. More tests
  corresponding to test plan would be added later.
2020-08-18 10:55:33 -07:00
Jonathan Hui 1326d64a64 [style] replace NULL with nullptr (#5109) 2020-06-17 22:44:54 -07:00
Yakun Xu 2b9e8facba [test] cover micro timer in unittest (#5030) 2020-06-01 22:05:42 -07:00
Simon Lin bdfafb437e [github-actions] add test to verify OTNS works (#4847) 2020-05-20 20:34:19 -07:00
Jonathan Hui c1f0856adb [style] remove const from uint16_t function/method params (#4901) 2020-04-27 12:59:24 -07:00
Jonathan Hui 8eeb1e83eb [cli] change aArgsLength type from int to uint8_t (#4718) 2020-03-23 00:12:09 -07:00
Jonathan Hui a6a93d688d [cli] change 'argc' -> 'aArgsLength', 'argv' -> 'aArgs' (#4718) 2020-03-23 00:12:09 -07:00
Jonathan Hui b3d05af6ff [flash] implement flash storage driver for settings (#4552) 2020-03-18 20:51:41 -07:00
Abtin Keshavarzian 5cddf90389 [link-quality] remove aNoiseFloor param from LinkQualityInfo methods (#4569) 2020-02-20 09:36:34 -08:00
Jonathan Hui 02da206f39 [config] remaining configure options (#4020) 2019-07-31 14:16:30 -07:00
Jonathan Hui 926b9e8661 [config] time sync (#4020) 2019-07-31 14:16:30 -07:00
Jonathan Hui e87bc42184 [diag] move factory diags into core (#4010)
- Simplifies make files by not having to deal with separate library.
- Combine factory diags source into single source file.
2019-07-23 08:47:16 -07:00
Zhanglong Xia c1a64613d6 [settings] remove useless functions (#3971) 2019-07-10 06:13:49 -07:00
Zhanglong Xia 8de5fbeae7 [posix-app] close the settings file when reset (#3958)
Currently, the Setting file won't be closed after ot-ncp is reset.
Once ot-ncp receives a RESET command from wpantund, it will reopen
the Setting file and create a new file Id.

This commit closes the Setting file when ot-ncp is reset.
2019-07-08 21:21:14 -07:00
Kamil Sroka c14cc60962 [windows] remove unsupported platform (#3878) 2019-06-06 11:55:18 -07:00
Kamil Sroka 56fa9ac9cd [entropy] allow for entropy source sharing (#3818) 2019-05-17 12:41:03 -07:00
Jonathan Hui aaaae937d3 [style] prefer OT_UNUSED_VARIABLE (#3696) 2019-03-19 21:17:33 -07:00
Yakun Xu e68e86317e [ci] test with time sync and header ie (#3514)
This commit adds the missing test with ie present by enabling TIME_SYNC
feature, so that IE code are covered.
2019-02-01 16:08:43 -08:00
Jonathan Hui 69d98d4a53 [code-style] apply clang-format 2018-02-09 21:43:42 +00:00
Jonathan Hui 741941e271 [radio] remove transmit power config from core (#2352)
Thread (and OpenThread) does not employ any form of transmit power control.
As a result, while OpenThread provides APIs to control transmit power, it
simply buffers and passes the transmit power value straight through to the
radio.

Currently, the transmit power APIs allow specifying an int8_t in units of
dBm.  This is overly constraining for platforms that have more advanced ways
of configuring the transmit power.

This commit removes the transmit power configuration from the core.  This
provides better flexibility in platform-specific ways to configure transmit
power.
2017-11-28 17:33:32 +00:00
Abtin Keshavarzian 02c876ef62 [instance] define ot::Instance class (#2307)
This commit makes the following changes: It defines the public
`otInstance` as an empty opaque structure which is used by all public
C OpenThread APIs. It defines a new class `ot::Instance` (inheriting
from `otInstance) which is then used in core source files. The
functionality related to the instance is also moved/added into the
newly added `Instance` class (as class/static or member methods).
2017-11-13 08:27:57 -08:00
Shu Chen 588613ba65 [posix] add microsecond timer support (#2086) 2017-08-10 10:08:17 -07:00
Jonathan Hui 5d7a03334f [radio] unify around otExtAddress type (#2029) 2017-07-28 08:05:06 -07:00
Abtin Keshavarzian fc72e4e719 [instance-locator] use instance reference instead of pointer (#2007)
This commit changes the `InstanceLocator` class to keep track of a
reference to `otInstance` (instead of a pointer) to make it behave
similar to other `ObjectLocator` classes. The method `GetInstance()`
in all locator objects is updated to provide a reference (instead
of a pointer) to `otInstance`.

The logging macros are updated such that a reference to `otInstance`
is passed as the first argument (with the exception of
`otLog<Level>Plat()` macros which are used by platform code in C
domain). The documentation for log macros are also updated.
2017-07-25 15:06:14 -07:00
Shu Chen 129c419107 [timer] multiple microseconds timer support (#1962)
* [timer] multiple microseconds timer support

* Remove TimerSchedulerLocator, Timer inherit from Ip6Locator instead to get TimerScheduler.

* Add separate UsecTimer and UsecTimerScheduler for multiple microseconds timer support.

* [timer] refine Timer names

* Rename alarm header files to alarm-milli.h and alarm-micro.h

* Rename alarm APIs to start with otPlatAlarmMilli and otPlatAlarmMicro

* Rename Timer classes to TimerMilli/TimerMilliScheduler and TimerMicro/TimerMicroScheduler

* [Timer] Refactor Timer code structure

* Create TimerBase and TimerSchedulerBase class for common functions;

* Use TimerMilli/TimerMicro and TimerMilliScheduler/TimerMicroScheduler for different functions;

* Define AlarmApi, so then TimerMilliScheduler/TimerMicroScheduler could use different AlarmApi.
2017-07-10 16:01:27 -07:00
Shu Chen 93f892bdbe [tests] Fix some unit tests random fail issue (#1966) 2017-07-07 06:40:07 -07:00
Abtin Keshavarzian bbab3074ed [instance] single OpenThread instance optimizations (#1926)
This commit new configuration option `enable-multiple-instances` and
its corresponding option `OPENTHREAD_ENABLE_MULTIPLE_INSTANCES`. When
enabled OpenThread supports handling of multiple instances. By default
this is disabled.

This commit also adds two optimizations for single instance case to
simplify the code and also help reduce memory/RAM usage:

(1) OpenThread objects/classes typically keep a reference to a higher
level object (e.g., many classes keep track of owning `ThreadNetif`)
to be able to access other objects/methods within OpenThread class
hierarchy. In single instance mode, the reference member variables are
removed and instead global functions are used to access the singleton
objects from one class to the other. To implement this, a group of
`<Object>Locator` classes are defined (e.g., `ThreadNetifLocator`,
etc.) which are then used as base class of other OpenThread classes.

(2) OpenThread objects which provide a callback/handler (e.g.,
`Timer`, `Tasklet`, etc.) have `void *mContext` member variable which
is used to keep track of the owner of the object. In single instance
mode the `mConext` member variables are removed since the owner is
expected to be a singleton and can be uniquely determined from the
callback function.

To implement this, two changes are made: First the handler methods are
modified to provide a reference to the object (e.g., `Timer` handler
will provide a `Timer &aTimer` as a parameter of its handler
callback). Second, a new base class `Context` is introduced which
hides the implementation providing an arbitrary context information. A
new static method `GetOwner(aContext)` is added to classes which own a
callback providing objects. This method help convert a `Context` to
the reference of the owner class object.
2017-06-30 11:48:26 -07:00
Shu Chen 2de6f35f72 Diag: Refine diag send codes (#1858)
* Diag module should continue to send next packet even if the last transmission failed

* Remove unnecessary aFramePending parameter from diag transmit done callback
2017-06-01 08:58:06 -07:00
Jonathan Hui 48a9a63252 Clean up radio names. (#1837) 2017-05-27 21:27:06 -07:00
Jonathan Hui 9073d0d99a Cleanup reset reason names. (#1824) 2017-05-25 09:08:45 -07:00
Jonathan Hui 48b9299544 Clean up error names. (#1764) 2017-05-23 09:34:35 -07:00
Shu Chen 66f6e7088d Add otPlatRadioGetReceiveSensitivity() API (#1715)
* Add otPlatRadioGetReceiveSensitivity() API

* Add a new otPlatRadioGetReceiveSensitivity() API to get sensitivity value;

* Use the receive sensitivity value as the noise floor for link metric computation;

* Remove some unused noise floor related functions.

* Add SPINEL_PROP_PHY_RX_SENSITIVITY Spinel/NCP property
2017-05-04 20:38:37 -07:00
Jonathan Hui 115b52e6c4 Require platform TRNG to provide requested output length or error. (#1650) 2017-04-25 09:22:53 -07:00
Buke Po 145a3adfc1 fix code style issue make pretty founds. (#1622) 2017-04-19 21:35:25 -07:00
pvanhorn 04caca7cc8 Implement the use of otPlatRadioDefaultTxPower API. (#1417)
* Implement the use of otPlatRadioDefaultTxPower API.

* Add implementation of otPlatRadioSetDefaultTxPower for windows.
2017-03-03 11:09:33 -08:00
Jonathan Hui 77bc491c56 Tasklet API cleanup. 2017-03-02 10:24:55 -08:00
Jorge Vergara f3817e76cf Enable mbedTLS dynamic memory allocation in user mode on Windows (#1373)
* change user mode openthread to enable dynamic memory allocation in mbedtls

* complete merge by adding OPENTHREAD_MULTIPLE_INSTANCE to last file

* remove some extraneous changes that got pulled in accidentally

* fix spacing

* fix crash in existing tests due to this change

* fix x86 build
2017-02-23 22:01:59 -08:00
Nick Banks 53bcbb9012 Add otLinkRaw* API (#1181) 2017-01-24 11:16:32 -08:00