[diag] add flag to enable CSMA/CA (#10723)

This commit is contained in:
Yakun Xu
2024-09-18 11:20:11 -07:00
committed by GitHub
parent fa3509ebce
commit c6a4657178
3 changed files with 24 additions and 5 deletions
+3 -2
View File
@@ -80,11 +80,12 @@ Done
### diag frame
Usage: `diag frame [-s] <frame>`
Usage: `diag frame [-c] [-s] <frame>`
Set the frame (hex encoded) to be used by `diag send` and `diag repeat`. The frame may be overwritten by `diag send` and `diag repeat`.
Specify `-s` to skip security processing in radio layer.
- Specify `-s` to indicate that tx security is already processed so that it should be skipped in the radio layer.
- Specify `-c` to enable CSMA/CA for this frame in the radio layer.
```bash
> diag frame 11223344
+14 -3
View File
@@ -236,15 +236,25 @@ Error Diags::ProcessFrame(uint8_t aArgsLength, char *aArgs[])
Error error = kErrorNone;
uint16_t size = OT_RADIO_FRAME_MAX_SIZE;
bool securityProcessed = false;
bool csmaCaEnabled = false;
if (aArgsLength >= 1)
while (aArgsLength > 1)
{
if (StringMatch(aArgs[0], "-s"))
{
securityProcessed = true;
aArgs++;
aArgsLength--;
}
else if (StringMatch(aArgs[0], "-c"))
{
csmaCaEnabled = true;
}
else
{
ExitNow(error = kErrorInvalidArgs);
}
aArgs++;
aArgsLength--;
}
VerifyOrExit(aArgsLength == 1, error = kErrorInvalidArgs);
@@ -254,6 +264,7 @@ Error Diags::ProcessFrame(uint8_t aArgsLength, char *aArgs[])
VerifyOrExit(size >= OT_RADIO_FRAME_MIN_SIZE, error = kErrorInvalidArgs);
ResetTxPacket();
mTxPacket->mInfo.mTxInfo.mCsmaCaEnabled = csmaCaEnabled;
mTxPacket->mInfo.mTxInfo.mIsSecurityProcessed = securityProcessed;
mTxPacket->mLength = size;
mIsTxPacketSet = true;
+7
View File
@@ -159,6 +159,13 @@ send "diag send 1\n"
expect "length 0x3"
expect "Done"
send_user "send frame with CSMA/CA enabled\n"
send "diag frame -c 112233\n"
expect "Done"
send "diag send 1\n"
expect "length 0x3"
expect "Done"
send "diag repeat stop\n"
expect "Done"