-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathCoAP.cs
More file actions
98 lines (88 loc) · 2.79 KB
/
CoAP.cs
File metadata and controls
98 lines (88 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using System;
namespace Networking.Model.Application
{
/// <summary>
/// CoAP : Constrained Application Protocol
/// <see href="https://coap.technology/"/>
/// </summary>
public partial class CoAP : Octets
{
/// <summary>
/// 服务端端口号=5683
/// </summary>
public const UInt16 ServerPort = 5683;
/// <summary>
/// Version
/// </summary>
public Byte Version
{
get { return base.GetByte(Layout.VersionBegin, Layout.VersionBitsIndex, Layout.VersionBitsLength); }
set { base.SetByte(Layout.VersionBegin, Layout.VersionBitsIndex, Layout.VersionBitsLength, value); }
}
/// <summary>
/// Type
/// </summary>
public CoAPType Type
{
get { return (CoAPType)base.GetByte(Layout.TypeBegin, Layout.TypeBitsIndex, Layout.TypeBitsLength); }
set { base.SetByte(Layout.TypeBegin, Layout.TypeBitsIndex, Layout.TypeBitsLength, (Byte)value); }
}
/// <summary>
/// Token Length
/// </summary>
public Byte TokenLength
{
get { return base.GetByte(Layout.TokenLengthBegin, Layout.TokenLengthBitsIndex, Layout.TokenLengthBitsLength); }
set { base.SetByte(Layout.TokenLengthBegin, Layout.TokenLengthBitsIndex, Layout.TokenLengthBitsLength, value); }
}
/// <summary>
/// Code
/// </summary>
public CoAPCode Code
{
get { return (CoAPCode)base.GetByte(Layout.CodeBegin); }
set { base.SetByte(Layout.CodeBegin, (Byte)value); }
}
/// <summary>
/// Code c
/// </summary>
public Byte CodeC
{
get { return base.GetByte(Layout.CodeBegin, Layout.CodeCBitsIndex, Layout.CodeCBitsLength); }
}
/// <summary>
/// Code dd
/// </summary>
public Byte CodeDD
{
get { return base.GetByte(Layout.CodeBegin, Layout.CodeDDBitsIndex, Layout.CodeDDBitsLength); }
}
/// <summary>
/// MessageId
/// </summary>
public UInt16 MessageId
{
get { return base.GetUInt16(Layout.MessageIdBegin); }
set { base.SetUInt16(Layout.MessageIdBegin, value); }
}
/// <summary>
/// Token
/// </summary>
public Octets Token
{
get
{
var tokenLength = TokenLength;
if (tokenLength <= 0)
{
return null;
}
var tokenBytes = GetBytes(Layout.FixedHeaderLength, tokenLength);
return new Octets
{
Bytes = tokenBytes
};
}
}
}
}