[diag] add radio sleep / receive mode for RF certification (#3657)

Bug: 127894959
This commit is contained in:
Yuzhuo Yang
2019-03-11 09:37:52 -07:00
committed by Jonathan Hui
parent 58f144a7f7
commit da9ba9cbdc
3 changed files with 44 additions and 6 deletions
+15 -4
View File
@@ -13,7 +13,7 @@ The diagnostics module supports common diagnostics features that are listed belo
* [diag power](#diag-power)
* [diag send](#diag-send-packets-length)
* [diag repeat](#diag-repeat-delay-length)
* [diag sleep](#diag-sleep)
* [diag radio](#diag-radio)
* [diag stats](#diag-stats)
* [diag stop](#diag-stop)
@@ -105,13 +105,24 @@ repeated packet transmission is stopped
status 0x00
```
### diag sleep
### diag radio sleep
Enter radio sleep mode.
```bash
> diag sleep
sleeping now...
> diag radio sleep
set radio from receive to sleep
status 0x00
```
### diag radio receive
Set radio from sleep mode to receive mode.
```bash
> diag radio receive
set radio from sleep to receive on channel 11
status 0x00
```
### diag stats
+28 -2
View File
@@ -46,8 +46,9 @@ namespace ot {
namespace Diagnostics {
const struct Diag::Command Diag::sCommands[] = {
{"start", &ProcessStart}, {"stop", &ProcessStop}, {"channel", &ProcessChannel}, {"power", &ProcessPower},
{"send", &ProcessSend}, {"repeat", &ProcessRepeat}, {"stats", &ProcessStats}, {NULL, NULL},
{"start", &ProcessStart}, {"stop", &ProcessStop}, {"channel", &ProcessChannel},
{"power", &ProcessPower}, {"send", &ProcessSend}, {"repeat", &ProcessRepeat},
{"stats", &ProcessStats}, {"radio", &ProcessRadio}, {NULL, NULL},
};
struct Diag::DiagStats Diag::sStats;
@@ -309,6 +310,31 @@ exit:
AppendErrorResult(error, aOutput, aOutputMaxLen);
}
void Diag::ProcessRadio(int aArgCount, char *aArgVector[], char *aOutput, size_t aOutputMaxLen)
{
otError error = OT_ERROR_INVALID_ARGS;
VerifyOrExit(otPlatDiagModeGet(), error = OT_ERROR_INVALID_STATE);
VerifyOrExit(aArgCount > 0, error = OT_ERROR_INVALID_ARGS);
if (strcmp(aArgVector[0], "sleep") == 0)
{
SuccessOrExit(error = otPlatRadioSleep(sInstance));
snprintf(aOutput, aOutputMaxLen, "set radio from receive to sleep \r\nstatus 0x%02x\r\n", error);
}
else if (strcmp(aArgVector[0], "receive") == 0)
{
SuccessOrExit(error = otPlatRadioReceive(sInstance, sChannel));
otPlatDiagChannelSet(sChannel);
snprintf(aOutput, aOutputMaxLen, "set radio from sleep to receive on channel %d\r\nstatus 0x%02x\r\n", sChannel,
error);
}
exit:
AppendErrorResult(error, aOutput, aOutputMaxLen);
}
void Diag::DiagTransmitDone(otInstance *aInstance, otError aError)
{
VerifyOrExit(aInstance == sInstance);
+1
View File
@@ -78,6 +78,7 @@ private:
static void ProcessSend(int aArgCount, char *aArgVector[], char *aOutput, size_t aOutputMaxLen);
static void ProcessRepeat(int aArgCount, char *aArgVector[], char *aOutput, size_t aOutputMaxLen);
static void ProcessStats(int aArgCount, char *aArgVector[], char *aOutput, size_t aOutputMaxLen);
static void ProcessRadio(int aArgCount, char *aArgVector[], char *aOutput, size_t aOutputMaxLen);
static void ProcessChannel(int aArgCount, char *aArgVector[], char *aOutput, size_t aOutputMaxLen);
static void ProcessPower(int aArgCount, char *aArgVector[], char *aOutput, size_t aOutputMaxLen);
static void TxPacket(void);