CoapPacket

- Added 1 byte option length for 2 byte option delta decoding
This commit is contained in:
Tristan B. Velloza Kildaire 2023-09-29 09:14:14 +02:00
parent 1500e44153
commit 9b7859cd8f
1 changed files with 24 additions and 0 deletions

View File

@ -543,6 +543,30 @@ public class CoapPacket
else if(optLenType == OptionLenType._8BIT_EXTENDED)
{
// TODO: THIS IS UNTESTED CODE!!!!
// The total length is the extended value (which lacks 13 so we must add it)
writeln(data[idx..$]);
ubyte optLen8BitExt = data[idx];
ushort optLen = optLen8BitExt+13;
writeln("Option len: ", optLen);
// Jump over 8bit opt len ext
idx+=1;
// 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;
}
// Option length extended (16bit) (14)
else if(optLenType == OptionLenType._12_BIT_EXTENDED)