diff --git a/source/doap/packet.d b/source/doap/packet.d index 8f35d8c..b87c35a 100644 --- a/source/doap/packet.d +++ b/source/doap/packet.d @@ -54,6 +54,12 @@ public class CoapPacket ubyte hiByte = *(basePtr); encoded ~= [hiByte, lowByte]; } + + // Set the token (if any) + if(tokenLen) + { + encoded ~= token; + } return encoded; } @@ -169,4 +175,9 @@ unittest assert(thirdByte == 1); assert(fourthByte == 1); -} \ No newline at end of file + // Ensure the token is [0, 69] + ubyte fifthByte = encoded[4], sixthByte = encoded[5]; + assert(fifthByte == 0); + assert(sixthByte == 69); + +}