mirror of
https://github.com/espressif/openthread.git
synced 2026-10-10 09:47:35 +00:00
[diags] add minimal IEEE 802.15.4 frame size check (#6756)
Extending checks done by diag send command and diag repeat command to validate minimal size of frame.
This commit is contained in:
@@ -53,7 +53,7 @@ extern "C" {
|
||||
* @note This number versions both OpenThread platform and user APIs.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_API_VERSION (127)
|
||||
#define OPENTHREAD_API_VERSION (128)
|
||||
|
||||
/**
|
||||
* @addtogroup api-instance
|
||||
|
||||
@@ -68,6 +68,7 @@ extern "C" {
|
||||
enum
|
||||
{
|
||||
OT_RADIO_FRAME_MAX_SIZE = 127, ///< aMaxPHYPacketSize (IEEE 802.15.4-2006)
|
||||
OT_RADIO_FRAME_MIN_SIZE = 3, ///< Minimal size of frame FCS + CONTROL
|
||||
OT_RADIO_SYMBOLS_PER_OCTET = 2, ///< 2.4 GHz IEEE 802.15.4-2006
|
||||
OT_RADIO_BIT_RATE = 250000, ///< 2.4 GHz IEEE 802.15.4 (bits per second)
|
||||
OT_RADIO_BITS_PER_OCTET = 8, ///< Number of bits per octet
|
||||
|
||||
@@ -77,6 +77,8 @@ status 0x00
|
||||
|
||||
Transmit a fixed number of packets with fixed length.
|
||||
|
||||
Length parameter has to be in range [3, 127].
|
||||
|
||||
```bash
|
||||
> diag send 20 100
|
||||
sending 0x14 packet(s), length 0x64
|
||||
@@ -87,6 +89,8 @@ status 0x00
|
||||
|
||||
Transmit packets repeatedly with a fixed interval.
|
||||
|
||||
Length parameter has to be in range [3, 127].
|
||||
|
||||
```bash
|
||||
> diag repeat 100 100
|
||||
sending packets of length 0x64 at the delay of 0x64 ms
|
||||
|
||||
@@ -244,6 +244,7 @@ Error Diags::ProcessRepeat(uint8_t aArgsLength, char *aArgs[], char *aOutput, si
|
||||
|
||||
SuccessOrExit(error = ParseLong(aArgs[1], value));
|
||||
VerifyOrExit(value <= OT_RADIO_FRAME_MAX_SIZE, error = kErrorInvalidArgs);
|
||||
VerifyOrExit(value >= OT_RADIO_FRAME_MIN_SIZE, error = kErrorInvalidArgs);
|
||||
mTxLen = static_cast<uint8_t>(value);
|
||||
|
||||
mRepeatActive = true;
|
||||
@@ -271,6 +272,7 @@ Error Diags::ProcessSend(uint8_t aArgsLength, char *aArgs[], char *aOutput, size
|
||||
|
||||
SuccessOrExit(error = ParseLong(aArgs[1], value));
|
||||
VerifyOrExit(value <= OT_RADIO_FRAME_MAX_SIZE, error = kErrorInvalidArgs);
|
||||
VerifyOrExit(value >= OT_RADIO_FRAME_MIN_SIZE, error = kErrorInvalidArgs);
|
||||
mTxLen = static_cast<uint8_t>(value);
|
||||
|
||||
snprintf(aOutput, aOutputMaxLen, "sending %#x packet(s), length %#x\r\nstatus 0x%02x\r\n",
|
||||
|
||||
Reference in New Issue
Block a user