mirror of https://github.com/deavmi/doap
CoapPacket
- Added optionlength-14 support for 0-12 option delta mode
This commit is contained in:
parent
a2fff5b389
commit
63b1313dbc
|
@ -341,6 +341,37 @@ public class CoapPacket
|
|||
// 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)
|
||||
{
|
||||
// TODO: THIS IS UNTESTED CODE!!!
|
||||
|
||||
// Jump to next byte of two bytes (which has length)
|
||||
idx+=1;
|
||||
|
||||
// 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;
|
||||
|
@ -375,6 +406,8 @@ public class CoapPacket
|
|||
writeln("8 bit option-id delta: ", optionId);
|
||||
|
||||
|
||||
|
||||
|
||||
assert(false);
|
||||
}
|
||||
// 14
|
||||
|
|
Loading…
Reference in New Issue