Merge branch 'master' into feature/options_full

This commit is contained in:
Tristan B. Velloza Kildaire 2023-09-29 10:13:00 +02:00
commit 6adf185073
1 changed files with 27 additions and 15 deletions

View File

@ -31,6 +31,24 @@ public struct CoapOption
// TODO: remove this
import std.stdio : writeln;
private enum OptionLenType
{
ZERO_TO_TWELVE,
_8BIT_EXTENDED,
_12_BIT_EXTENDED,
UPPER_PAYLOAD_MARKER
}
private enum OptionDeltaType
{
ZERO_TO_TWELVE,
_8BIT_EXTENDED,
_12_BIT_EXTENDED,
UPPER_PAYLOAD_MARKER
}
/**
* Represents a CoAP packet
*/
@ -669,14 +687,14 @@ public class CoapPacket
return packet;
}
private enum OptionLenType
{
ZERO_TO_TWELVE,
_8BIT_EXTENDED,
_12_BIT_EXTENDED,
UPPER_PAYLOAD_MARKER
}
/**
* Extracts the option length encoding
* type from the header
*
* Params:
* hdr = the header
* Returns: the `OptionLenType`
*/
private static OptionLenType getOptionLenType(ubyte hdr)
{
ubyte type = (hdr&15);
@ -692,16 +710,10 @@ public class CoapPacket
{
return OptionLenType._12_BIT_EXTENDED;
}
else if(type == 15)
else
{
return OptionLenType.UPPER_PAYLOAD_MARKER;
}
else
{
writeln("GetOptionLenType(): Major error if this happens");
assert(false);
}
}