[IOT-2444] Add constant for MAX_SEQUENCE_NUMBER 75/22175/3
authorLarry Sachs <larry.j.sachs@intel.com>
Mon, 28 Aug 2017 20:25:50 +0000 (13:25 -0700)
committerRick Bell <richard.s.bell@intel.com>
Tue, 5 Sep 2017 06:27:56 +0000 (06:27 +0000)
Added a constant for MAX_SEQUENCE_NUMBER and updated
sample client apps to use the value when checking for
deregister completion.

Change-Id: Ie24c6ce33f10291fe45e2ca8eda27c997dd332a6
Signed-off-by: Larry Sachs <larry.j.sachs@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/22175
Reviewed-by: George Nash <george.nash@intel.com>
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Ondrej Tomcik <ondrej.tomcik@kistler.com>
Reviewed-by: Rick Bell <richard.s.bell@intel.com>
java/common/src/main/java/org/iotivity/base/OcResource.java
java/examples-android/simpleclient/src/main/java/org/iotivity/base/examples/SimpleClient.java
java/examples-java/simpleclient/src/main/java/org/iotivity/base/examples/SimpleClient.java
java/examples-java/simpleclientserver/src/main/java/org/iotivity/base/examples/SimpleClient.java

index 8a765ba..6224c7c 100644 (file)
@@ -660,6 +660,13 @@ public class OcResource {
          */
         public static final int NO_OPTION = 2;
 
+        /**
+         * Maximum sequence number.
+         * A successful deregister will have a sequence number
+         * of MAX_SEQUENCE_NUMBER + 1.
+         */
+        public static final int MAX_SEQUENCE_NUMBER = 0xffffff;
+
         public void onObserveCompleted(List<OcHeaderOption> headerOptionList,
                                        OcRepresentation ocRepresentation,
                                        int sequenceNumber);
index 849cdc1..fa77326 100644 (file)
@@ -70,8 +70,7 @@ public class SimpleClient extends Activity implements
     private OcResource mFoundLightResource = null;
     //local representation of a server's light resource
     private Light mLight = new Light();
-    //variables related observer
-    private int maxSequenceNumber = 0xFFFFFF;
+
     private OcConnectivityType adapterFlag = OcConnectivityType.CT_ADAPTER_IP;
     //flags related TCP transport test
     private boolean isRequestFlag = false;
@@ -511,7 +510,7 @@ public class SimpleClient extends Activity implements
                                                 OcRepresentation ocRepresentation,
                                                 int sequenceNumber) {
 
-        if (sequenceNumber != maxSequenceNumber + 1)
+        if (sequenceNumber != OcResource.OnObserveListener.MAX_SEQUENCE_NUMBER + 1)
         {
             msg("OBSERVE Result:");
             msg("\tSequenceNumber:" + sequenceNumber);
index ef94e9b..ece2984 100644 (file)
@@ -466,10 +466,8 @@ public class SimpleClient implements
                                                 int sequenceNumber) {
         if (OcResource.OnObserveListener.REGISTER == sequenceNumber) {
             msg("Observe registration action is successful:");
-        } else if (OcResource.OnObserveListener.DEREGISTER == sequenceNumber) {
+        } else if (OcResource.OnObserveListener.MAX_SEQUENCE_NUMBER + 1 == sequenceNumber) {
             msg("Observe De-registration action is successful");
-        } else if (OcResource.OnObserveListener.NO_OPTION == sequenceNumber) {
-            msg("Observe registration or de-registration action is failed");
         }
 
         msg("OBSERVE Result:");
index 6ab4517..dbf333d 100644 (file)
@@ -465,10 +465,8 @@ public class SimpleClient implements OcPlatform.OnResourceFoundListener, OcResou
             int sequenceNumber) {
         if (OcResource.OnObserveListener.REGISTER == sequenceNumber) {
             msg("Observe registration action is successful:");
-        } else if (OcResource.OnObserveListener.DEREGISTER == sequenceNumber) {
+        } else if (OcResource.OnObserveListener.MAX_SEQUENCE_NUMBER + 1 == sequenceNumber) {
             msg("Observe De-registration action is successful");
-        } else if (OcResource.OnObserveListener.NO_OPTION == sequenceNumber) {
-            msg("Observe registration or de-registration action is failed");
         }
 
         msg("OBSERVE Result:");