CoapPacket

- Added 2-byte option length decoding for 1byte option delta encoding
This commit is contained in:
Tristan B. Velloza Kildaire 2023-09-29 09:12:01 +02:00
parent 8c2a4b3812
commit ca89119c13
1 changed files with 22 additions and 1 deletions

View File

@ -460,7 +460,28 @@ public class CoapPacket
// Option length extended (16bit) (14)
else if(optLenType == OptionLenType._12_BIT_EXTENDED)
{
assert(false);
// 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;
}