|
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,57 @@ 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 | + // RadioSpinel-specific diag sub-commands |
| 1788 | + if (strcmp(aArgs[0], "radiospinel") == 0) |
| 1789 | + { |
| 1790 | + aArgs++; |
| 1791 | + aArgsLength--; |
| 1792 | + |
| 1793 | + VerifyOrExit(aArgsLength > 0, error = OT_ERROR_INVALID_ARGS); |
| 1794 | + |
| 1795 | + if (strcmp(aArgs[0], "buslatency") == 0) |
| 1796 | + { |
| 1797 | + if (aArgsLength == 1) |
| 1798 | + { |
| 1799 | + PlatDiagOutput("%lu\n", ToUlong(GetBusLatency())); |
| 1800 | + } |
| 1801 | + else if (aArgsLength == 2) |
| 1802 | + { |
| 1803 | + uint32_t busLatency; |
| 1804 | + char *endptr; |
| 1805 | + |
| 1806 | + busLatency = static_cast<uint32_t>(strtoul(aArgs[1], &endptr, 0)); |
| 1807 | + VerifyOrExit(*endptr == '\0', error = OT_ERROR_INVALID_ARGS); |
| 1808 | + |
| 1809 | + SetBusLatency(busLatency); |
| 1810 | + } |
| 1811 | + else |
| 1812 | + { |
| 1813 | + error = OT_ERROR_INVALID_ARGS; |
| 1814 | + } |
| 1815 | + } |
| 1816 | + |
| 1817 | + ExitNow(); |
| 1818 | + } |
| 1819 | + |
| 1820 | + for (uint8_t index = 0; (index < aArgsLength) && (cur < end); index++) |
| 1821 | + { |
| 1822 | + cur += snprintf(cur, static_cast<size_t>(end - cur), "%s ", aArgs[index]); |
| 1823 | + } |
| 1824 | + |
| 1825 | + SuccessOrExit(error = PlatDiagProcess(cmd)); |
| 1826 | + |
| 1827 | +exit: |
| 1828 | + return error; |
| 1829 | +} |
| 1830 | + |
1778 | 1831 | otError RadioSpinel::PlatDiagProcess(const char *aString)
|
1779 | 1832 | {
|
1780 | 1833 | return Set(SPINEL_PROP_NEST_STREAM_MFG, SPINEL_DATATYPE_UTF8_S, aString);
|
@@ -1904,6 +1957,19 @@ uint64_t RadioSpinel::GetNow(void) { return (mIsTimeSynced) ? (otPlatTimeGet() +
|
1904 | 1957 |
|
1905 | 1958 | uint32_t RadioSpinel::GetBusSpeed(void) const { return GetSpinelDriver().GetSpinelInterface()->GetBusSpeed(); }
|
1906 | 1959 |
|
| 1960 | +uint32_t RadioSpinel::GetBusLatency(void) const { return mBusLatency; } |
| 1961 | + |
| 1962 | +void RadioSpinel::SetBusLatency(uint32_t aBusLatency) |
| 1963 | +{ |
| 1964 | + mBusLatency = aBusLatency; |
| 1965 | +#if OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE |
| 1966 | + if (IsEnabled()) |
| 1967 | + { |
| 1968 | + otThreadUpdateFrameRequestAhead(mInstance); |
| 1969 | + } |
| 1970 | +#endif // OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE |
| 1971 | +} |
| 1972 | + |
1907 | 1973 | void RadioSpinel::HandleRcpUnexpectedReset(spinel_status_t aStatus)
|
1908 | 1974 | {
|
1909 | 1975 | OT_UNUSED_VARIABLE(aStatus);
|
|
0 commit comments