Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
WS4D
jCoAP
Commits
1f96e5bf
Commit
1f96e5bf
authored
May 20, 2014
by
Bjoern Konieczek
Browse files
updated option structure
parent
19d73671
Changes
3
Hide whitespace changes
Inline
Side-by-side
ws4d-jcoap/bin/org/ws4d/coap/messages/AbstractCoapMessage$CoapHeaderOption.class
View file @
1f96e5bf
No preview for this file type
ws4d-jcoap/bin/org/ws4d/coap/messages/AbstractCoapMessage$CoapHeaderOptions.class
View file @
1f96e5bf
No preview for this file type
ws4d-jcoap/src/org/ws4d/coap/messages/AbstractCoapMessage.java
View file @
1f96e5bf
...
...
@@ -565,10 +565,28 @@ public abstract class AbstractCoapMessage implements CoapMessage {
}
public
CoapHeaderOption
(
byte
[]
bytes
,
int
offset
,
int
lastOptionNumber
){
int
headerLength
;
int
headerLength
=
1
;
int
internalOffset
=
offset
;
/* parse option type */
optionTypeValue
=
((
bytes
[
offset
]
&
0xF0
)
>>
4
)
+
lastOptionNumber
;
optionTypeValue
=
((
bytes
[
offset
]
&
0xF0
)
>>
4
);
if
(
optionTypeValue
==
13
)
{
optionTypeValue
+=
bytes
[
offset
+
1
]
+
lastOptionNumber
;
internalOffset
++;
headerLength
++;
System
.
out
.
println
(
"Option: "
+
optionTypeValue
);
}
else
if
(
optionTypeValue
==
14
)
{
int
part1
=
((
bytes
[
offset
+
1
]
&
0xFF
)
<<
8
);
int
part2
=
bytes
[
offset
+
2
];
optionTypeValue
+=
part1
+
part2
+
lastOptionNumber
;
internalOffset
+=
2
;
headerLength
+=
2
;
}
else
{
optionTypeValue
+=
lastOptionNumber
;
}
optionType
=
CoapHeaderOptionType
.
parse
(
optionTypeValue
);
System
.
out
.
println
(
"Option: "
+
optionTypeValue
);
if
(
optionType
==
CoapHeaderOptionType
.
UNKNOWN
){
if
(
optionTypeValue
%
14
==
0
){
/* no-op: no operation for deltas > 14 */
...
...
@@ -578,14 +596,15 @@ public abstract class AbstractCoapMessage implements CoapMessage {
}
}
/* parse length */
if
((
bytes
[
offset
]
&
0x0F
)
<
15
)
{
shortLength
=
(
bytes
[
offset
]
&
0x0F
);
if
((
bytes
[
offset
]
&
0x0F
)
==
13
)
{
headerLength
++;
}
else
if
(
shortLength
==
14
)
{
shortLength
=
bytes
[
offset
]
&
0x0F
;
longLength
=
0
;
headerLength
=
1
;
headerLength
+
=
2
;
}
else
{
shortLength
=
15
;
longLength
=
bytes
[
offset
+
1
];
headerLength
=
2
;
/* additional length byte */
longLength
=
0
;
}
/* copy value */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment