From: Joseph Morrow Date: Mon, 14 Dec 2015 11:04:03 +0000 (-0800) Subject: Add /oic/d and /oic/p discovery response messaging to IoTivity. X-Git-Tag: 1.0.1~3 X-Git-Url: http://review.tizen.org/git/?p=contrib%2Fiotivity.git;a=commitdiff_plain;h=adac68d8f0a9887dde1fc5c7ca3b432b366a7509 Add /oic/d and /oic/p discovery response messaging to IoTivity. 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 Reviewed-on: https://gerrit.iotivity.org/gerrit/4567 Tested-by: jenkins-iotivity Reviewed-by: Markus Jung Reviewed-by: Jon A. Cruz (cherry picked from commit 30c25f5488fa19f686cdfe68d82d14842af1f7a3) Reviewed-on: https://gerrit.iotivity.org/gerrit/4585 --- diff --git a/resource/csdk/stack/include/octypes.h b/resource/csdk/stack/include/octypes.h index 2f9c0d6..8e75b48 100644 --- a/resource/csdk/stack/include/octypes.h +++ b/resource/csdk/stack/include/octypes.h @@ -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" diff --git a/resource/csdk/stack/src/ocstack.c b/resource/csdk/stack/src/ocstack.c index f530616..340657d 100755 --- a/resource/csdk/stack/src/ocstack.c +++ b/resource/csdk/stack/src/ocstack.c @@ -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; }