Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
WS4D
jCoAP
Commits
fb29fea6
Commit
fb29fea6
authored
Nov 23, 2017
by
Björn Butzin
Browse files
added some logging; added interface description
parent
673fa682
Changes
9
Hide whitespace changes
Inline
Side-by-side
ws4d-jcoap/pom.xml
View file @
fb29fea6
...
...
@@ -89,7 +89,7 @@
<dependency>
<groupId>
org.apache.logging.log4j
</groupId>
<artifactId>
log4j-core
</artifactId>
<version>
2.
6.2
</version>
<version>
2.
10.0
</version>
</dependency>
</dependencies>
<organization>
...
...
ws4d-jcoap/release/jcoap-core-1.1.5-sources.jar
0 → 100644
View file @
fb29fea6
File added
ws4d-jcoap/release/jcoap-core-1.1.5.jar
0 → 100644
View file @
fb29fea6
File added
ws4d-jcoap/src/org/ws4d/coap/core/connection/BasicCoapChannelManager.java
View file @
fb29fea6
...
...
@@ -99,6 +99,7 @@ public class BasicCoapChannelManager implements CoapChannelManager {
SocketInformation
socketInfo
=
new
SocketInformation
(
new
BasicCoapSocketHandler
(
this
,
localPort
),
listener
);
this
.
socketMap
.
put
(
localPort
,
socketInfo
);
logger
.
info
(
"Server is listening on port "
+
localPort
);
}
catch
(
IOException
e
)
{
logger
.
warn
(
e
.
getLocalizedMessage
());
}
...
...
ws4d-jcoap/src/org/ws4d/coap/core/connection/BasicCoapSocketHandler.java
View file @
fb29fea6
...
...
@@ -116,18 +116,21 @@ public class BasicCoapSocketHandler implements CoapSocketHandler {
try
{
this
.
dgramSocket
.
joinGroup
(
InetAddress
.
getByName
(
CoapConstants
.
COAP_ALL_NODES_IPV6_LL_MC_ADDR
));
logger
.
info
(
"joined IPv6 link local multicast group"
);
}
catch
(
Exception
e1
){
logger
.
warn
(
"IPv6 link local multicast not available. Continuing without."
);
logger
.
debug
(
e1
.
getLocalizedMessage
());
}
try
{
this
.
dgramSocket
.
joinGroup
(
InetAddress
.
getByName
(
CoapConstants
.
COAP_ALL_NODES_IPV6_SL_MC_ADDR
));
logger
.
info
(
"joined IPv6 site local multicast group"
);
}
catch
(
Exception
e1
){
logger
.
warn
(
"IPv6 site local multicast not available. Continuing without."
);
logger
.
debug
(
e1
.
getLocalizedMessage
());
}
try
{
this
.
dgramSocket
.
joinGroup
(
InetAddress
.
getByName
(
CoapConstants
.
COAP_ALL_NODES_IPV4_MC_ADDR
));
logger
.
info
(
"joined IPv4 multicast group"
);
}
catch
(
Exception
e1
){
logger
.
warn
(
"IPv4 multicast not available. Continuing without."
);
logger
.
debug
(
e1
.
getLocalizedMessage
());
...
...
ws4d-jcoap/src/org/ws4d/coap/core/rest/BasicCoapResource.java
View file @
fb29fea6
...
...
@@ -82,6 +82,7 @@ public class BasicCoapResource implements CoapResource {
this
.
path
=
initPath
;
this
.
content
=
initValue
;
this
.
mediaType
=
initMediaType
;
this
.
compileIf
();
}
public
synchronized
CoapResource
setCoapMediaType
(
CoapMediaType
mediaType
)
{
...
...
@@ -204,11 +205,13 @@ public class BasicCoapResource implements CoapResource {
public
synchronized
BasicCoapResource
setPostable
(
boolean
postable
)
{
this
.
postable
=
postable
;
this
.
compileIf
();
return
this
;
}
public
synchronized
BasicCoapResource
setPutable
(
boolean
putable
)
{
this
.
putable
=
putable
;
this
.
compileIf
();
return
this
;
}
...
...
@@ -228,6 +231,7 @@ public class BasicCoapResource implements CoapResource {
public
synchronized
BasicCoapResource
setDeletable
(
boolean
deletable
)
{
this
.
deletable
=
deletable
;
this
.
compileIf
();
return
this
;
}
...
...
@@ -307,6 +311,7 @@ public class BasicCoapResource implements CoapResource {
public
BasicCoapResource
setGetable
(
boolean
getable
)
{
this
.
getable
=
getable
;
this
.
compileIf
();
return
this
;
}
...
...
@@ -325,4 +330,22 @@ public class BasicCoapResource implements CoapResource {
public
void
removeTag
(
String
tag
)
{
this
.
tags
.
remove
(
tag
);
}
private
void
compileIf
()
{
String
ifTag
=
""
;
if
(
this
.
isGetable
())
ifTag
+=
"GET"
;
if
(
this
.
isPutable
())
{
if
(!
ifTag
.
isEmpty
())
{
ifTag
+=
" "
;}
ifTag
+=
"PUT"
;
}
if
(
this
.
isPostable
())
{
if
(!
ifTag
.
isEmpty
())
{
ifTag
+=
" "
;}
ifTag
+=
"POST"
;
}
if
(
this
.
isDeletable
())
{
if
(!
ifTag
.
isEmpty
())
{
ifTag
+=
" "
;}
ifTag
+=
"DELETE"
;
}
this
.
setInterfaceDescription
(
ifTag
);
}
}
\ No newline at end of file
ws4d-jcoap/src/org/ws4d/coap/core/rest/CoreResource.java
View file @
fb29fea6
...
...
@@ -122,7 +122,7 @@ public class CoreResource extends BasicCoapResource {
// add ',' if this is not the first entry
if
(!
first
)
{
returnString
.
append
(
","
);
returnString
.
append
(
",
"
);
}
else
{
first
=
false
;
}
...
...
@@ -136,7 +136,7 @@ public class CoreResource extends BasicCoapResource {
while
(
it
.
hasNext
()){
String
key
=
it
.
next
();
String
value
=
resource
.
getTags
().
get
(
key
);
returnString
.
append
(
";"
);
returnString
.
append
(
";
"
);
returnString
.
append
(
key
);
if
(
null
!=
value
){
returnString
.
append
(
"=\""
);
...
...
@@ -147,7 +147,7 @@ public class CoreResource extends BasicCoapResource {
// size estimate to be displayed?
// only display sz when larger than MTU
if
(
resource
.
getSizeEstimate
()
>
CoapConstants
.
COAP_PAYLOAD_SIZE_MAX
)
{
returnString
.
append
(
";sz=\""
);
returnString
.
append
(
";
sz=\""
);
returnString
.
append
(
resource
.
getSizeEstimate
());
returnString
.
append
(
"\""
);
}
...
...
ws4d-jcoap/src/org/ws4d/coap/core/rest/MultiTypeResource.java
View file @
fb29fea6
...
...
@@ -86,8 +86,12 @@ public class MultiTypeResource extends BasicCoapResource {
}
@Override
public
synchronized
boolean
post
(
byte
[]
data
,
CoapMediaType
type
)
{
return
this
.
resourceHandler
.
get
(
type
).
handlePost
(
data
);
public
synchronized
boolean
post
(
byte
[]
data
,
CoapMediaType
mediaType
)
{
ResourceHandler
rh
=
this
.
resourceHandler
.
get
(
mediaType
);
if
(
rh
!=
null
)
{
return
rh
.
handlePost
(
data
);
}
return
false
;
}
@Override
...
...
@@ -97,7 +101,11 @@ public class MultiTypeResource extends BasicCoapResource {
@Override
public
synchronized
boolean
put
(
byte
[]
data
,
CoapMediaType
mediaType
)
{
return
this
.
resourceHandler
.
get
(
mediaType
).
handlePut
(
data
);
ResourceHandler
rh
=
this
.
resourceHandler
.
get
(
mediaType
);
if
(
rh
!=
null
)
{
return
rh
.
handlePut
(
data
);
}
return
false
;
}
@Override
...
...
ws4d-jcoap/test/org/ws4d/coap/core/test/PlugTest.java
View file @
fb29fea6
...
...
@@ -295,7 +295,7 @@ public class PlugTest {
clientChannel
.
sendMessage
(
request
);
while
(
null
==
receivedResponse
)
Thread
.
sleep
(
10
);
Assert
.
assertEquals
(
"</.well-known/core>;obs
,
</resource1>;rt=\"resource1Type\";if=\"resource1Description\""
,
Assert
.
assertEquals
(
"</.well-known/core>;
obs
; if=\"GET\",
</resource1>;
rt=\"resource1Type\";
if=\"resource1Description\""
,
Encoder
.
ByteToString
(
receivedResponse
.
getPayload
()));
}
...
...
@@ -315,7 +315,7 @@ public class PlugTest {
while
(
null
==
receivedResponse
)
Thread
.
sleep
(
10
);
Assert
.
assertEquals
(
"</resource1>;rt=\"resource1Type\";if=\"resource1Description\""
,
Assert
.
assertEquals
(
"</resource1>;
rt=\"resource1Type\";
if=\"resource1Description\""
,
Encoder
.
ByteToString
(
receivedResponse
.
getPayload
()));
}
...
...
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