CoapPacket

- Added 2 byte option length decoding for 2 byte option delta mode
This commit is contained in:
Tristan B. Velloza Kildaire 2023-09-29 09:16:27 +02:00
parent 9b7859cd8f
commit 7b888d6b8f
1 changed files with 23 additions and 0 deletions

View File

@ -572,6 +572,29 @@ public class CoapPacket
else if(optLenType == OptionLenType._12_BIT_EXTENDED)
{
// TODO: THIS IS UNTESTED CODE!!!!
// Option length compute (it lacks 269 so add it back)
ushort optLen = order(*cast(ushort*)&data[idx], Order.BE);
optLen+=269;
writeln("Option len: ", optLen);
// Jump over the two option length bytes
idx+=2;
// Grab the data from [idx, idx+optLen)
ubyte[] optionValue = data[idx..idx+optLen];
writeln("Option value: ", optionValue);
writeln("Option value: ", cast(string)optionValue);
// Jump over the option value
idx+=optLen;
// Create the option and add it to the list of options
CoapOption option;
option.value = optionValue;
option.id = delta;
writeln("Built option: ", option);
createdOptions ~= option;
}
else
{