mirror of
https://github.com/espressif/openthread.git
synced 2026-07-08 05:10:25 +00:00
[cli] support joiner discerner (#5298)
This commit adds support joiner discerner in CLI. The format of joiner discerner is `number/length`. For example `0xabc/12` means the discerner value is `0xabc` and the length is `12`.
This commit is contained in:
@@ -399,6 +399,30 @@ otError Interpreter::ParseUnsignedLong(char *aString, unsigned long &aUnsignedLo
|
||||
return (*endptr == '\0') ? OT_ERROR_NONE : OT_ERROR_INVALID_ARGS;
|
||||
}
|
||||
|
||||
otError Interpreter::ParseJoinerDiscerner(char *aString, otJoinerDiscerner &aDiscerner)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
char * separator = strstr(aString, "/");
|
||||
unsigned long length;
|
||||
|
||||
VerifyOrExit(separator != nullptr, error = OT_ERROR_NOT_FOUND);
|
||||
|
||||
SuccessOrExit(error = ParseUnsignedLong(separator + 1, length));
|
||||
VerifyOrExit(length > 0 && length <= 64, error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
{
|
||||
char * end;
|
||||
unsigned long long value = strtoull(aString, &end, 0);
|
||||
aDiscerner.mValue = value;
|
||||
VerifyOrExit(end == separator, error = OT_ERROR_INVALID_ARGS);
|
||||
}
|
||||
|
||||
aDiscerner.mLength = static_cast<uint8_t>(length);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError Interpreter::ParsePingInterval(const char *aString, uint32_t &aInterval)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
Reference in New Issue
Block a user