|
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 |
|
@@ -78,6 +79,7 @@ RadioSpinel::RadioSpinel(void)
|
78 | 79 | , mPanId(0xffff)
|
79 | 80 | , mChannel(0)
|
80 | 81 | , mRxSensitivity(0)
|
| 82 | + , mBusLatency(0) |
81 | 83 | , mState(kStateDisabled)
|
82 | 84 | , mIsPromiscuous(false)
|
83 | 85 | , mRxOnWhenIdle(true)
|
@@ -1774,6 +1776,45 @@ void RadioSpinel::GetDiagOutputCallback(otPlatDiagOutputCallback &aCallback, voi
|
1774 | 1776 | aContext = mOutputContext;
|
1775 | 1777 | }
|
1776 | 1778 |
|
| 1779 | +otError RadioSpinel::PlatDiagProcess(uint8_t aArgsLength, char *aArgs[]) |
| 1780 | +{ |
| 1781 | + otError error = OT_ERROR_NONE; |
| 1782 | + char cmd[OPENTHREAD_CONFIG_DIAG_CMD_LINE_BUFFER_SIZE] = {'\0'}; |
| 1783 | + char *cur = cmd; |
| 1784 | + char *end = cmd + sizeof(cmd); |
| 1785 | + |
| 1786 | + if (strcmp(aArgs[0], "buslatency") == 0) |
| 1787 | + { |
| 1788 | + if (aArgsLength == 2) |
| 1789 | + { |
| 1790 | + uint32_t latency; |
| 1791 | + char *endptr; |
| 1792 | + |
| 1793 | + latency = (uint32_t)strtoul(aArgs[1], &endptr, 0); |
| 1794 | + VerifyOrExit(*endptr == '\0', error = OT_ERROR_INVALID_ARGS); |
| 1795 | + |
| 1796 | + SetBusLatency(latency); |
| 1797 | + ExitNow(); |
| 1798 | + } |
| 1799 | + else |
| 1800 | + { |
| 1801 | + uint32_t latency = GetBusLatency(); |
| 1802 | + PlatDiagOutput("%lu\n", ToUlong(latency)); |
| 1803 | + ExitNow(); |
| 1804 | + } |
| 1805 | + } |
| 1806 | + |
| 1807 | + for (uint8_t index = 0; (index < aArgsLength) && (cur < end); index++) |
| 1808 | + { |
| 1809 | + cur += snprintf(cur, static_cast<size_t>(end - cur), "%s ", aArgs[index]); |
| 1810 | + } |
| 1811 | + |
| 1812 | + SuccessOrExit(error = PlatDiagProcess(cmd)); |
| 1813 | + |
| 1814 | +exit: |
| 1815 | + return error; |
| 1816 | +} |
| 1817 | + |
1777 | 1818 | otError RadioSpinel::PlatDiagProcess(const char *aString)
|
1778 | 1819 | {
|
1779 | 1820 | return Set(SPINEL_PROP_NEST_STREAM_MFG, SPINEL_DATATYPE_UTF8_S, aString);
|
@@ -1903,6 +1944,19 @@ uint64_t RadioSpinel::GetNow(void) { return (mIsTimeSynced) ? (otPlatTimeGet() +
|
1903 | 1944 |
|
1904 | 1945 | uint32_t RadioSpinel::GetBusSpeed(void) const { return GetSpinelDriver().GetSpinelInterface()->GetBusSpeed(); }
|
1905 | 1946 |
|
| 1947 | +uint32_t RadioSpinel::GetBusLatency(void) const { return mBusLatency; } |
| 1948 | + |
| 1949 | +void RadioSpinel::SetBusLatency(uint32_t aBusLatency) |
| 1950 | +{ |
| 1951 | + mBusLatency = aBusLatency; |
| 1952 | +#if OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE |
| 1953 | + if (IsEnabled()) |
| 1954 | + { |
| 1955 | + otThreadUpdateFrameRequestAhead(mInstance); |
| 1956 | + } |
| 1957 | +#endif // OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE |
| 1958 | +} |
| 1959 | + |
1906 | 1960 | void RadioSpinel::HandleRcpUnexpectedReset(spinel_status_t aStatus)
|
1907 | 1961 | {
|
1908 | 1962 | OT_UNUSED_VARIABLE(aStatus);
|
|
0 commit comments