mirror of https://github.com/deavmi/doap
CoapPacket
- Added decoding of 1-byte option length for 1-byte delta option encoding
This commit is contained in:
parent
dd69be55ff
commit
8c2a4b3812
|
@ -433,8 +433,29 @@ public class CoapPacket
|
|||
// Option length extended (8bit) (13)
|
||||
else if(optLenType == OptionLenType._8BIT_EXTENDED)
|
||||
{
|
||||
// TODO: Implement me
|
||||
assert(false);
|
||||
// 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)
|
||||
|
|
Loading…
Reference in New Issue