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