mirror of https://github.com/deavmi/doap
CoapPacket
- Now encodes the message ID in a platform independent manner. We will encode it into big endian seeing as it feels like it could be used in a number like fashion - Added `setMessageId(ushort)` to set the message id
This commit is contained in:
parent
8a11f3d405
commit
4e99ab50d8
|
@ -38,8 +38,23 @@ public class CoapPacket
|
|||
encoded ~= code;
|
||||
|
||||
// Set the message ID
|
||||
|
||||
version(LittleEndian)
|
||||
{
|
||||
ubyte* basePtr = cast(ubyte*)∣
|
||||
ubyte lowByte = *basePtr;
|
||||
ubyte hiByte = *(basePtr+1);
|
||||
|
||||
encoded ~= [hiByte, lowByte];
|
||||
|
||||
}
|
||||
else version(BigEndian)
|
||||
{
|
||||
ubyte* basePtr = cast(ubyte*)∣
|
||||
ubyte lowByte = *(basePtr+1);
|
||||
ubyte hiByte = *(basePtr);
|
||||
encoded ~= [hiByte, lowByte];
|
||||
}
|
||||
|
||||
return encoded;
|
||||
}
|
||||
|
||||
|
@ -78,6 +93,11 @@ public class CoapPacket
|
|||
this.code = code;
|
||||
}
|
||||
|
||||
public void setMessageId(ushort mid)
|
||||
{
|
||||
this.mid = mid;
|
||||
}
|
||||
|
||||
// public ubyte getVersion()
|
||||
// {
|
||||
|
||||
|
|
Loading…
Reference in New Issue