mirror of
https://github.com/espressif/openthread.git
synced 2026-08-19 08:59:52 +00:00
DIAG: Add CLI support for Diagnostic DIAG_GET.rsp message. (#1062)
* DIAG: Add CLI support for Diagnostic DIAG_GET.rsp message.
This commit is contained in:
committed by
Jonathan Hui
parent
df6da01f68
commit
dbc1384db2
@@ -143,6 +143,7 @@ Interpreter::Interpreter(otInstance *aInstance):
|
||||
memset(mSlaacAddresses, 0, sizeof(mSlaacAddresses));
|
||||
mInstance->mIp6.mIcmp.SetEchoReplyHandler(&s_HandleEchoResponse, this);
|
||||
otSetStateChangedCallback(mInstance, &Interpreter::s_HandleNetifStateChanged, this);
|
||||
otSetReceiveDiagnosticGetCallback(mInstance, &Interpreter::s_HandleDiagnosticGetResponse, this);
|
||||
}
|
||||
|
||||
int Interpreter::Hex2Bin(const char *aHex, uint8_t *aBin, uint16_t aBinLength)
|
||||
@@ -2652,6 +2653,7 @@ void Interpreter::ProcessNetworkDiagnostic(int argc, char *argv[])
|
||||
if (strcmp(argv[0], "get") == 0)
|
||||
{
|
||||
otSendDiagnosticGet(mInstance, &address, payload, payloadIndex);
|
||||
return;
|
||||
}
|
||||
else if (strcmp(argv[0], "reset") == 0)
|
||||
{
|
||||
@@ -2662,5 +2664,35 @@ exit:
|
||||
AppendResult(error);
|
||||
}
|
||||
|
||||
void Interpreter::s_HandleDiagnosticGetResponse(otMessage aMessage, const otMessageInfo *aMessageInfo,
|
||||
void *aContext)
|
||||
{
|
||||
static_cast<Interpreter *>(aContext)->HandleDiagnosticGetResponse(*static_cast<Message *>(aMessage),
|
||||
*static_cast<const Ip6::MessageInfo *>(aMessageInfo));
|
||||
}
|
||||
|
||||
void Interpreter::HandleDiagnosticGetResponse(Message &aMessage, const Ip6::MessageInfo &)
|
||||
{
|
||||
uint8_t buf[16];
|
||||
uint16_t bytesToPrint;
|
||||
uint16_t bytesPrinted = 0;
|
||||
uint16_t length = aMessage.GetLength() - aMessage.GetOffset();
|
||||
|
||||
sServer->OutputFormat("DIAG_GET.rsp: ");
|
||||
|
||||
while (length > 0)
|
||||
{
|
||||
bytesToPrint = (length < sizeof(buf)) ? length : sizeof(buf);
|
||||
aMessage.Read(aMessage.GetOffset() + bytesPrinted, bytesToPrint, buf);
|
||||
|
||||
OutputBytes(buf, static_cast<uint8_t>(bytesToPrint));
|
||||
|
||||
length -= bytesToPrint;
|
||||
bytesPrinted += bytesToPrint;
|
||||
}
|
||||
|
||||
sServer->OutputFormat("\r\n");
|
||||
}
|
||||
|
||||
} // namespace Cli
|
||||
} // namespace Thread
|
||||
|
||||
@@ -224,6 +224,7 @@ private:
|
||||
static void s_HandleEnergyReport(uint32_t aChannelMask, const uint8_t *aEnergyList, uint8_t aEnergyListLength,
|
||||
void *aContext);
|
||||
static void s_HandlePanIdConflict(uint16_t aPanId, uint32_t aChannelMask, void *aContext);
|
||||
static void s_HandleDiagnosticGetResponse(otMessage aMessage, const otMessageInfo *aMessageInfo, void *aContext);
|
||||
|
||||
void HandleEchoResponse(Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
|
||||
void HandlePingTimer();
|
||||
@@ -232,6 +233,7 @@ private:
|
||||
void HandleLinkPcapReceive(const RadioPacket *aFrame);
|
||||
void HandleEnergyReport(uint32_t aChannelMask, const uint8_t *aEnergyList, uint8_t aEnergyListLength);
|
||||
void HandlePanIdConflict(uint16_t aPanId, uint32_t aChannelMask);
|
||||
void HandleDiagnosticGetResponse(Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
|
||||
|
||||
static const struct Command sCommands[];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user