|
39 | 39 | #include <stdlib.h>
|
40 | 40 |
|
41 | 41 | #include <openthread/logging.h>
|
| 42 | +#include <openthread/thread_ftd.h> |
42 | 43 | #include <openthread/platform/diag.h>
|
43 | 44 | #include <openthread/platform/time.h>
|
44 | 45 |
|
@@ -79,6 +80,7 @@ RadioSpinel::RadioSpinel(void)
|
79 | 80 | , mPanId(0xffff)
|
80 | 81 | , mChannel(0)
|
81 | 82 | , mRxSensitivity(0)
|
| 83 | + , mBusLatency(0) |
82 | 84 | , mState(kStateDisabled)
|
83 | 85 | , mIsPromiscuous(false)
|
84 | 86 | , mRxOnWhenIdle(true)
|
@@ -1775,6 +1777,41 @@ void RadioSpinel::GetDiagOutputCallback(otPlatDiagOutputCallback &aCallback, voi
|
1775 | 1777 | aContext = mOutputContext;
|
1776 | 1778 | }
|
1777 | 1779 |
|
| 1780 | +otError RadioSpinel::SpinelDiagProcess(uint8_t aArgsLength, char *aArgs[]) |
| 1781 | +{ |
| 1782 | + otError error = OT_ERROR_NONE; |
| 1783 | + |
| 1784 | + VerifyOrExit(aArgsLength > 0, error = OT_ERROR_INVALID_ARGS); |
| 1785 | + |
| 1786 | + aArgs++; |
| 1787 | + aArgsLength--; |
| 1788 | + |
| 1789 | + if (strcmp(aArgs[0], "buslatency") == 0) |
| 1790 | + { |
| 1791 | + if (aArgsLength == 1) |
| 1792 | + { |
| 1793 | + PlatDiagOutput("%lu\n", ToUlong(GetBusLatency())); |
| 1794 | + } |
| 1795 | + else if (aArgsLength == 2) |
| 1796 | + { |
| 1797 | + uint32_t busLatency; |
| 1798 | + char *endptr; |
| 1799 | + |
| 1800 | + busLatency = static_cast<uint32_t>(strtoul(aArgs[1], &endptr, 0)); |
| 1801 | + VerifyOrExit(*endptr == '\0', error = OT_ERROR_INVALID_ARGS); |
| 1802 | + |
| 1803 | + SetBusLatency(busLatency); |
| 1804 | + } |
| 1805 | + else |
| 1806 | + { |
| 1807 | + error = OT_ERROR_INVALID_ARGS; |
| 1808 | + } |
| 1809 | + } |
| 1810 | + |
| 1811 | +exit: |
| 1812 | + return error; |
| 1813 | +} |
| 1814 | + |
1778 | 1815 | otError RadioSpinel::PlatDiagProcess(const char *aString)
|
1779 | 1816 | {
|
1780 | 1817 | return Set(SPINEL_PROP_NEST_STREAM_MFG, SPINEL_DATATYPE_UTF8_S, aString);
|
@@ -1904,6 +1941,19 @@ uint64_t RadioSpinel::GetNow(void) { return (mIsTimeSynced) ? (otPlatTimeGet() +
|
1904 | 1941 |
|
1905 | 1942 | uint32_t RadioSpinel::GetBusSpeed(void) const { return GetSpinelDriver().GetSpinelInterface()->GetBusSpeed(); }
|
1906 | 1943 |
|
| 1944 | +uint32_t RadioSpinel::GetBusLatency(void) const { return mBusLatency; } |
| 1945 | + |
| 1946 | +void RadioSpinel::SetBusLatency(uint32_t aBusLatency) |
| 1947 | +{ |
| 1948 | + mBusLatency = aBusLatency; |
| 1949 | +#if OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE |
| 1950 | + if (IsEnabled()) |
| 1951 | + { |
| 1952 | + otThreadUpdateFrameRequestAhead(mInstance); |
| 1953 | + } |
| 1954 | +#endif // OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE |
| 1955 | +} |
| 1956 | + |
1907 | 1957 | void RadioSpinel::HandleRcpUnexpectedReset(spinel_status_t aStatus)
|
1908 | 1958 | {
|
1909 | 1959 | OT_UNUSED_VARIABLE(aStatus);
|
|
0 commit comments