Add /oic/d and /oic/p discovery response messaging to IoTivity.
authorJoseph Morrow <joseph.l.morrow@intel.com>
Mon, 14 Dec 2015 11:04:03 +0000 (03:04 -0800)
committerJon A. Cruz <jonc@osg.samsung.com>
Tue, 15 Dec 2015 03:04:15 +0000 (03:04 +0000)
Prior to this, Clients could only perform a GET request directly on
/oic/d and /oic/p. This commit also enables performing DISCOVERY
requests on /oic/d and /oic/p as well.

This aligns with OIC spec compliancy.

This fixes Jira Ticket IOT-874.

Change-Id: I29693a67bb245b3fae8d1ed54833eacd1397884e
Signed-off-by: Joseph Morrow <joseph.l.morrow@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/4567
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Markus Jung <markus.jung85@gmail.com>
Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com>
(cherry picked from commit 30c25f5488fa19f686cdfe68d82d14842af1f7a3)
Reviewed-on: https://gerrit.iotivity.org/gerrit/4585

resource/csdk/stack/include/octypes.h
resource/csdk/stack/src/ocstack.c

index 2f9c0d6..8e75b48 100644 (file)
@@ -137,6 +137,12 @@ extern "C" {
 /** To represent resource type with presence.*/
 #define OC_RSRVD_RESOURCE_TYPE_PRESENCE "oic.wk.ad"
 
+/** To represent resource type with device.*/
+#define OC_RSRVD_RESOURCE_TYPE_DEVICE   "oic.wk.d"
+
+/** To represent resource type with platform.*/
+#define OC_RSRVD_RESOURCE_TYPE_PLATFORM "oic.wk.p"
+
 /** To represent interface.*/
 #define OC_RSRVD_INTERFACE              "if"
 
@@ -155,6 +161,9 @@ extern "C" {
 /** To represent default interface.*/
 #define OC_RSRVD_INTERFACE_DEFAULT      "oic.if.baseline"
 
+/** To represent read-only interface.*/
+#define OC_RSRVD_INTERFACE_READ         "oic.if.r"
+
 /** To represent ll interface.*/
 #define OC_RSRVD_INTERFACE_LL           "oic.if.ll"
 
index f530616..340657d 100755 (executable)
@@ -99,6 +99,8 @@ static OCStackState stackState = OC_STACK_UNINITIALIZED;
 
 OCResource *headResource = NULL;
 static OCResource *tailResource = NULL;
+static OCResourceHandle platformResource = {0};
+static OCResourceHandle deviceResource = {0};
 #ifdef WITH_PRESENCE
 static OCPresenceState presenceState = OC_PRESENCE_UNINITIALIZED;
 static PresenceResource presenceResource;
@@ -115,7 +117,6 @@ OCDeviceEntityHandler defaultDeviceHandler;
 void* defaultDeviceHandlerCallbackParameter = NULL;
 static const char COAP_TCP[] = "coap+tcp:";
 
-
 //-----------------------------------------------------------------------------
 // Macros
 //-----------------------------------------------------------------------------
@@ -3732,6 +3733,29 @@ OCStackResult initResources()
         result = SRMInitSecureResources();
     }
 #endif
+
+    if(result == OC_STACK_OK)
+    {
+        result = OCCreateResource(&deviceResource,
+                                  OC_RSRVD_RESOURCE_TYPE_DEVICE,
+                                  OC_RSRVD_INTERFACE_DEFAULT,
+                                  OC_RSRVD_DEVICE_URI,
+                                  NULL,
+                                  NULL,
+                                  OC_DISCOVERABLE);
+    }
+
+    if(result == OC_STACK_OK)
+    {
+        result = OCCreateResource(&platformResource,
+                                  OC_RSRVD_RESOURCE_TYPE_PLATFORM,
+                                  OC_RSRVD_INTERFACE_DEFAULT,
+                                  OC_RSRVD_PLATFORM_URI,
+                                  NULL,
+                                  NULL,
+                                  OC_DISCOVERABLE);
+    }
+
     return result;
 }