[cli] implement setting/getting cca threshold (#5532)

This commit adds a command to the CLI to be able to set (and get) the
CCA threshold. This is useful when there is a LNA in the radio's RX
path.
This commit is contained in:
Diego Ismirlian
2020-09-21 08:46:19 -07:00
committed by GitHub
parent 787284e3a0
commit f974f38155
4 changed files with 55 additions and 3 deletions
+20
View File
@@ -23,6 +23,7 @@ Done
- [bbr](#bbr)
- [bufferinfo](#bufferinfo)
- [ccathreshold](#ccathreshold)
- [channel](#channel)
- [child](#child-list)
- [childip](#childip)
@@ -321,6 +322,25 @@ coap: 0 0
Done
```
### ccathreshold
Get the CCA threshold in dBm.
```bash
> ccathreshold
-75 dBm
Done
```
### ccathreshold \<ccathreshold\>
Set the CCA threshold.
```bash
> ccathreshold -62
Done
```
### channel
Get the IEEE 802.15.4 Channel value.
+23
View File
@@ -678,6 +678,29 @@ otError Interpreter::ProcessBufferInfo(uint8_t aArgsLength, char *aArgs[])
return OT_ERROR_NONE;
}
otError Interpreter::ProcessCcaThreshold(uint8_t aArgsLength, char *aArgs[])
{
otError error = OT_ERROR_NONE;
if (aArgsLength == 0)
{
int8_t cca;
SuccessOrExit(error = otPlatRadioGetCcaEnergyDetectThreshold(mInstance, &cca));
OutputLine("%d dBm", cca);
}
else
{
long value;
SuccessOrExit(error = ParseLong(aArgs[0], value));
SuccessOrExit(error = otPlatRadioSetCcaEnergyDetectThreshold(mInstance, static_cast<int8_t>(value)));
}
exit:
return error;
}
otError Interpreter::ProcessChannel(uint8_t aArgsLength, char *aArgs[])
{
otError error = OT_ERROR_NONE;
+6 -3
View File
@@ -278,9 +278,11 @@ private:
const Command *FindCommand(const char *aName) const;
otError ParsePingInterval(const char *aString, uint32_t &aInterval);
static otError ParseJoinerDiscerner(char *aString, otJoinerDiscerner &aJoinerDiscerner);
otError ProcessHelp(uint8_t aArgsLength, char *aArgs[]);
otError ProcessBufferInfo(uint8_t aArgsLength, char *aArgs[]);
otError ProcessChannel(uint8_t aArgsLength, char *aArgs[]);
otError ProcessHelp(uint8_t aArgsLength, char *aArgs[]);
otError ProcessCcaThreshold(uint8_t aArgsLength, char *aArgs[]);
otError ProcessBufferInfo(uint8_t aArgsLength, char *aArgs[]);
otError ProcessChannel(uint8_t aArgsLength, char *aArgs[]);
#if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
otError ProcessBackboneRouter(uint8_t aArgsLength, char *aArgs[]);
@@ -549,6 +551,7 @@ private:
{"bbr", &Interpreter::ProcessBackboneRouter},
#endif
{"bufferinfo", &Interpreter::ProcessBufferInfo},
{"ccathreshold", &Interpreter::ProcessCcaThreshold},
{"channel", &Interpreter::ProcessChannel},
#if OPENTHREAD_FTD
{"child", &Interpreter::ProcessChild},
+6
View File
@@ -47,6 +47,12 @@ expect "Done"
send "bufferinfo\n"
expect "Done"
send "ccathreshold -62\n"
expect "Done"
send "ccathreshold\n"
expect -- "-62 dBm"
expect "Done"
send "parent\n"
expect "Done"