IOT-3213 Handle reset code properly 35/27235/1
authorOndrej <ondrej.tomcik@kistler.com>
Wed, 5 Sep 2018 08:39:53 +0000 (10:39 +0200)
committerPeter Rafaj <peter.rafaj@kistler.com>
Mon, 15 Oct 2018 12:57:39 +0000 (14:57 +0200)
Change-Id: I728588ab5852da4cefa7a8a5b565875522d6ccc4
Signed-off-by: Peter Rafaj <peter.rafaj@kistler.com>
cloud/stack/src/main/java/org/iotivity/cloud/base/protocols/coap/CoapDecoder.java
cloud/stack/src/main/java/org/iotivity/cloud/base/protocols/coap/CoapResponse.java
cloud/stack/src/main/java/org/iotivity/cloud/base/protocols/enums/ResponseStatus.java

index f476ec5..35d9ebb 100644 (file)
@@ -110,7 +110,9 @@ public class CoapDecoder extends ByteToMessageDecoder {
 
                     case CODE_TOKEN_OPTION:
                         int code = in.readByte() & 0xFF;
-                        if (code <= 31) {
+                        if (code == 0) {
+                            partialMsg = new CoapResponse(code);
+                        } else if (code <= 31) {
                             partialMsg = new CoapRequest(code);
                         } else if (code > 224) {
                             partialMsg = new CoapSignaling(code);
index 8f6e3d1..f018c87 100644 (file)
@@ -34,6 +34,9 @@ public class CoapResponse extends CoapMessage {
 
     public CoapResponse(int code) {
         switch (code) {
+            case 0:
+                mResponseStatus = ResponseStatus.EMPTY;
+                break;
             case 65:
                 mResponseStatus = ResponseStatus.CREATED;
                 break;
@@ -108,6 +111,8 @@ public class CoapResponse extends CoapMessage {
     public int getCode() {
         // TODO Auto-generated method stub
         switch (mResponseStatus) {
+            case EMPTY:
+                return 0;
             case BAD_GATEWAY:
                 return 162;
             case BAD_OPTION:
index 38e354f..e9c7e13 100644 (file)
@@ -25,6 +25,8 @@ import java.util.Arrays;
 import java.util.List;
 
 public enum ResponseStatus {
+    // Empty response
+    EMPTY,
     // Success 2.xx
     CREATED, DELETED, VALID, CHANGED, CONTENT,
     // Client Error 4.xx