CoapPacket

- Implemented 0-12 option length decoding for 1-byte option delta mode
This commit is contained in:
Tristan B. Velloza Kildaire 2023-09-29 09:08:08 +02:00
parent 16261dff24
commit dd69be55ff
1 changed files with 17 additions and 2 deletions

View File

@ -412,8 +412,23 @@ public class CoapPacket
// Simple case (12)
if(optLenType == OptionLenType.ZERO_TO_TWELVE)
{
// TODO: Implement me
assert(false);
// Compute the length
ubyte optLen = (curValue&15);
writeln("Option len: ", optLen);
// Grab the data from [idx, idx+length)
ubyte[] optionValue = data[idx..idx+optLen];
writeln("Option value: ", 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 (8bit) (13)
else if(optLenType == OptionLenType._8BIT_EXTENDED)