[meshcop] simplify processing of Commissioner ID TLV (#9543)

This commit updates CommissionerIdTlv to be defined as `StringTlvInfo`
(a TLV with a UTF-8 string value with a specified maximum length). This
allows us to use `Tlv` helper methods to `Find` and `Append` this
TLV, simplifying the code.

This commit also adds a helper `StringCopy()` method that copies a
C string into a given target string buffer array if it fits in the array.
This method can also optionally perform an encoding check on the string,
such as a UTF-8 encoding check. This helper method is used to simplify
setting different strings, such as Commissioner ID, Provisioning URL,
Vendor Name, etc.
This commit is contained in:
Abtin Keshavarzian
2023-10-18 16:11:49 -07:00
committed by GitHub
parent 2457ba7c18
commit a69c2db333
11 changed files with 139 additions and 142 deletions
+2 -2
View File
@@ -52,9 +52,9 @@ expect_line "Done"
send "commissioner id\n"
expect "OpenThread Commissioner"
expect_line "Done"
send "commissioner id reallyAndUnnecessaryLongOpenthreadComisionerCustomIdShouldNotFit\n"
send "commissioner id 12345678901234567890123456789012345678901234567890123456789012345\n"
expect "Error 7: InvalidArgs"
send "commissioner id reallyAndUnnecessaryLongOpenthreadCommissionerCustomIdShouldFit\n"
send "commissioner id 1234567890123456789012345678901234567890123456789012345678901234\n"
expect "Done"
send "commissioner id customId\n"
expect "Done"