CoapPacket

- `getBytes()` now encodes the token

Packet (unit tests)

- Check the encoding of the token
This commit is contained in:
Tristan B. Velloza Kildaire 2023-09-12 19:23:20 +02:00
parent 0e450556be
commit 8c30637c1f

View File

@ -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);
}
// Ensure the token is [0, 69]
ubyte fifthByte = encoded[4], sixthByte = encoded[5];
assert(fifthByte == 0);
assert(sixthByte == 69);
}