mirror of
https://github.com/espressif/openthread.git
synced 2026-07-29 15:17:47 +00:00
[diag] add radio sleep / receive mode for RF certification (#3657)
Bug: 127894959
This commit is contained in:
committed by
Jonathan Hui
parent
58f144a7f7
commit
da9ba9cbdc
+15
-4
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user