This change set is based on OIC core framework standard specification draft A.
Modified reserved namespace to ‘/oc/core’ to ‘/oic/res’ and '/oc to /oic' for
discovery, including core framework, unit tests and samples.
Change-Id: I9721a2a70fd1e3245088b8a2f6366853db849b21
Signed-off-by: Moumita Ray <moumita.ray@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/953
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Erich Keane <erich.keane@intel.com>
/**\r
* Default interface\r
*/\r
- public static final String DEFAULT_INTERFACE = "oc.mi.def";\r
+ public static final String DEFAULT_INTERFACE = "oic.mi.def";\r
\r
/**\r
* Used in discovering (GET) links to other resources of a collection\r
*/\r
- public static final String LINK_INTERFACE = "oc.mi.ll";\r
+ public static final String LINK_INTERFACE = "oic.mi.ll";\r
\r
/**\r
* Used in GET, PUT, POST, DELETE methods on links to other resources of a collection\r
*/\r
- public static final String BATCH_INTERFACE = "oc.mi.b";\r
+ public static final String BATCH_INTERFACE = "oic.mi.b";\r
\r
/**\r
* Used in GET, PUT, POST methods on links to other remote resources of a group\r
*/\r
- public static final String GROUP_INTERFACE = "oc.mi.grp";\r
+ public static final String GROUP_INTERFACE = "oic.mi.grp";\r
\r
- public static final String WELL_KNOWN_QUERY = "224.0.1.187:5683/oc/core";\r
+ public static final String WELL_KNOWN_QUERY = "224.0.1.187:5683/oic/res";\r
public static final String MULTICAST_PREFIX = "224.0.1.187:5683";\r
public static final String MULTICAST_IP = "224.0.1.187";\r
public static final int MULTICAST_PORT = 5683;\r
public static final int DEFAULT_PRESENCE_TTL = 60;\r
- public static final String PRESENCE_URI = "/oc/presence";\r
+ public static final String PRESENCE_URI = "/oic/ad";\r
\r
private static volatile boolean sIsPlatformInitialized = false;\r
\r
TEST(CAProtocolMessage, CAParseURIBase)
{
- char sampleURI[] = "coap://[::]/oc/core?rt=core.sensor&if=core.mi.ll";
+ char sampleURI[] = "coap://[::]/oic/res?rt=core.sensor&if=core.mi.ll";
CoAPOptionCase cases[] = {
- {COAP_OPTION_URI_PATH, 2, "oc"},
- {COAP_OPTION_URI_PATH, 4, "core"},
+ {COAP_OPTION_URI_PATH, 3, "oic"},
+ {COAP_OPTION_URI_PATH, 3, "res"},
{COAP_OPTION_URI_QUERY, 14, "rt=core.sensor"},
{COAP_OPTION_URI_QUERY, 13, "if=core.mi.ll"},
};
// Try for multiple URI parameters that still total less than 128
TEST(CAProtocolMessage, CAParseURIManyParams)
{
- char sampleURI[] = "coap://[::]/oc/core/"
+ char sampleURI[] = "coap://[::]/oic/res/"
"?rt=core.sensor&a=0&b=1&c=2&d=3&e=4&f=5&g=6&h=7&i=8&j=9";
CoAPOptionCase cases[] = {
- {COAP_OPTION_URI_PATH, 2, "oc"},
- {COAP_OPTION_URI_PATH, 4, "core"},
+ {COAP_OPTION_URI_PATH, 3, "oic"},
+ {COAP_OPTION_URI_PATH, 3, "res"},
{COAP_OPTION_URI_QUERY, 14, "rt=core.sensor"},
{COAP_OPTION_URI_QUERY, 3, "a=0"},
{COAP_OPTION_URI_QUERY, 3, "b=1"},
// Test that an initial long path component won't hide latter ones.
TEST(CAProtocolMessage, CAParseURILongPath)
{
- char sampleURI[] = "coap://[::]/oc"
+ char sampleURI[] = "coap://[::]/oic"
"123456789012345678901234567890123456789012345678901234567890"
"12345678901234567890123456789012345678901234567890"
- "/core?rt=core.sensor&if=core.mi.ll";
+ "/res?rt=core.sensor&if=core.mi.ll";
CoAPOptionCase cases[] = {
- {COAP_OPTION_URI_PATH, 112, "oc"
+ {COAP_OPTION_URI_PATH, 113, "oic"
"123456789012345678901234567890123456789012345678901234567890"
"12345678901234567890123456789012345678901234567890"},
- {COAP_OPTION_URI_PATH, 4, "core"},
+ {COAP_OPTION_URI_PATH, 3, "res"},
{COAP_OPTION_URI_QUERY, 14, "rt=core.sensor"},
{COAP_OPTION_URI_QUERY, 13, "if=core.mi.ll"},
};
* These details are exposed in ocstackconfig.h file in the form of documentation.
* Remember to update the documentation there if these are changed.
*/
-#define OC_JSON_PREFIX "{\"oc\":["
+#define OC_JSON_PREFIX "{\"oic\":["
#define OC_JSON_PREFIX_LEN (sizeof(OC_JSON_PREFIX) - 1)
#define OC_JSON_SUFFIX "]}"
#define OC_JSON_SUFFIX_LEN (sizeof(OC_JSON_SUFFIX) - 1)
* Maximum length of the response supported by Server for any REST request.
* The actual repsonse length is 256 for Arduino and 1024 for other platforms.
* Note that the stack will add a prefix and suffix to the payload.
- * Prefix : {"oc":[
+ * Prefix : {"oic":[
* Suffix : ]}
- * They have a combined size of 9 bytes.
+ * They have a combined size of 10 bytes.
*/
#ifdef WITH_ARDUINO
-#define MAX_RESPONSE_LENGTH (247)
+#define MAX_RESPONSE_LENGTH (246)
#else
-#define MAX_RESPONSE_LENGTH (1015)
+#define MAX_RESPONSE_LENGTH (1014)
#endif
/**
//Don't want to expose to application layer that lower level stack is using CoAP.
/// Authority + URI string to prefix well known queries
-#define OC_WELL_KNOWN_QUERY "224.0.1.187:5683/oc/core"
-#define OC_MULTICAST_DISCOVERY_URI "/oc/core"
-#define OC_EXPLICIT_DEVICE_DISCOVERY_URI "224.0.1.187:5683/oc/core/d?rt=core.led"
+#define OC_WELL_KNOWN_QUERY "224.0.1.187:5683/oic/res"
+#define OC_MULTICAST_DISCOVERY_URI "/oic/res"
+#define OC_EXPLICIT_DEVICE_DISCOVERY_URI "224.0.1.187:5683/oic/res/d?rt=core.led"
/// Multicast address and port string to prefix multicast queries
#define OC_MULTICAST_PREFIX "224.0.1.187:5683"
/// IP Multicast address to use for multicast requests
#define OC_RSRVD_INTERFACE_DEFAULT "oic.if.baseline"
#define OC_RSRVD_INTERFACE_LL "oic.if.ll"
#define OC_RSRVD_INTERFACE_BATCH "oic.if.b"
-#define OC_RSRVD_INTERFACE_GROUP "oc.mi.grp"
+#define OC_RSRVD_INTERFACE_GROUP "oic.mi.grp"
+#define OC_RSRVD_MFG_DATE "mndt"
#define OC_RSRVD_FW_VERSION "mnfv"
#define OC_RSRVD_HOST_NAME "hn"
#define OC_RSRVD_VERSION "icv"
*/
typedef enum
{
- OC_WELL_KNOWN_URI= 0, ///< "/oc/core"
- OC_DEVICE_URI, ///< "/oc/core/d"
+ OC_WELL_KNOWN_URI= 0, ///< "/oic/res"
+ OC_DEVICE_URI, ///< "/oic/res/d"
OC_PLATFORM_URI, ///< "/oic/p"
- OC_RESOURCE_TYPES_URI, ///< "/oc/core/d/type"
+ OC_RESOURCE_TYPES_URI, ///< "/oic/res/d/type"
#ifdef WITH_PRESENCE
OC_PRESENCE, ///< "/oic/ad"
#endif
static int UNICAST_DISCOVERY = 0;
static int TEST_CASE = 0;
-static const char * UNICAST_DISCOVERY_QUERY = "coap://%s:6298/oc/core";
-static const char * UNICAST_DEVICE_DISCOVERY_QUERY = "coap://%s:6298/oc/core/d";
+
+static const char * UNICAST_DISCOVERY_QUERY = "coap://%s:6298/oic/res";
+static const char * UNICAST_DEVICE_DISCOVERY_QUERY = "coap://%s:6298/oic/res/d";
static const char * UNICAST_PLATFORM_DISCOVERY_QUERY = "coap://%s:6298/oic/p";
-static const char * MULTICAST_DEVICE_DISCOVERY_QUERY = "/oc/core/d";
+static const char * MULTICAST_DEVICE_DISCOVERY_QUERY = "/oic/res/d";
static const char * MULTICAST_PLATFORM_DISCOVERY_QUERY = "/oic/p";
-static const char * MULTICAST_RESOURCE_DISCOVERY_QUERY = "/oc/core";
+static const char * MULTICAST_RESOURCE_DISCOVERY_QUERY = "/oic/res";
//The following variable determines the interface protocol (IPv4, IPv6, etc)
//to be used for sending unicast messages. Default set to IPv4.
static OCConnectivityType OC_CONNTYPE = OC_IPV4;
-static std::string putPayload = "{\"oc\":[{\"rep\":{\"power\":15,\"state\":true}}]}";
+
+static std::string putPayload = "{\"oic\":[{\"rep\":{\"power\":15,\"state\":true}}]}";
static std::string coapServerIP = "255.255.255.255";
static std::string coapServerPort = "5683";
static std::string coapServerResource = "/a/light";
static int UNICAST_DISCOVERY = 0;
static int TEST_CASE = 0;
-static const char UNICAST_DISCOVERY_QUERY[] = "coap://%s:6298/oc/core";
+static const char UNICAST_DISCOVERY_QUERY[] = "coap://%s:6298/oic/res";
static std::string putPayload = "{\"state\":\"off\",\"power\":10}";
//The following variable determines the interface protocol (IPv4, IPv6, etc)
//to be used for sending unicast messages. Default set to IPv4.
static OCConnectivityType OC_CONNTYPE = OC_IPV4;
-static const char * MULTICAST_RESOURCE_DISCOVERY_QUERY = "/oc/core";
+static const char * MULTICAST_RESOURCE_DISCOVERY_QUERY = "/oic/res";
int gQuitFlag = 0;
return OC_STACK_INVALID_JSON;
}
- oc = cJSON_GetObjectItem(root,"oc");
+ oc = cJSON_GetObjectItem(root,"oic");
if (!oc)
{
OC_LOG(ERROR, TAG, "Invalid JSON : Missing oc object");
//The following variable determines the interface protocol (IPv4, IPv6, etc)
//to be used for sending unicast messages. Default set to IPv4.
static OCConnectivityType OC_CONNTYPE = OC_IPV4;
-static const char * MULTICAST_RESOURCE_DISCOVERY_QUERY = "/oc/core";
+static const char * MULTICAST_RESOURCE_DISCOVERY_QUERY = "/oic/res";
// The handle for the observe registration
OCDoHandle gObserveDoHandle;
static int UNICAST_DISCOVERY = 0;
static int TEST_CASE = 0;
-static const char * UNICAST_DISCOVERY_QUERY = "coap://%s:6298/oc/core";
+static const char * UNICAST_DISCOVERY_QUERY = "coap://%s:6298/oic/res";
static std::string putPayload = "{\"state\":\"off\",\"power\":10}";
static std::string coapServerIP = "255.255.255.255";
static std::string coapServerPort = "5683";
//The following variable determines the interface protocol (IPv4, IPv6, etc)
//to be used for sending unicast messages. Default set to IPv4.
static OCConnectivityType OC_CONNTYPE = OC_IPV4;
-static const char * MULTICAST_RESOURCE_DISCOVERY_QUERY = "/oc/core";
+static const char * MULTICAST_RESOURCE_DISCOVERY_QUERY = "/oic/res";
+
static int IPV4_ADDR_SIZE = 16;
void StripNewLineChar(char* str);
}
// Get root of JSON payload, then the 1st resource.
- cJSON* carrier = cJSON_GetObjectItem(putJson, "oc");
+ cJSON* carrier = cJSON_GetObjectItem(putJson, "oic");
carrier = cJSON_GetArrayItem(carrier, 0);
carrier = cJSON_GetObjectItem(carrier, "rep");
}
return 0;
-}
\ No newline at end of file
+}
static int TEST_CASE = 0;
static int IPV4_ADDR_SIZE = 16;
-static char UNICAST_DISCOVERY_QUERY[] = "coap://%s:6298/oc/core";
-static char MULTICAST_DISCOVERY_QUERY[] = "/oc/core";
+static char UNICAST_DISCOVERY_QUERY[] = "coap://%s:6298/oic/res";
+static char MULTICAST_DISCOVERY_QUERY[] = "/oic/res";
-static std::string putPayload = "{\"state\":\"off\",\"power\":10}";
+static std::string putPayload = "{\"oic\":[{\"rep\":{\"state\":\"off\",\"power\":10}}]}";
static std::string coapServerIP;
static std::string coapServerPort;
static std::string coapServerResource;
return -1;
}
- oc = cJSON_GetObjectItem(root,"oc");
+ oc = cJSON_GetObjectItem(root,"oic");
if (!oc)
{
return -1;
static cJSON *savedDeviceInfo = NULL;
static const char * VIRTUAL_RSRCS[] =
{
- "/oc/core",
- "/oc/core/d",
"/oic/p",
- "/oc/core/types/d",
+ "/oic/res",
+ "/oic/res/d",
+ "/oic/res/types/d",
#ifdef WITH_PRESENCE
"/oic/ad"
#endif
{
char * tok = NULL;
char * savePtr = NULL;
- // The format of the payload is {"oc":[%u:%u:%s]}
+ // The format of the payload is {"oic":[%u:%u:%s]}
// %u : sequence number,
// %u : max age
// %s : Resource Type (Optional)
*
* @param host - Host IP Address. If null or empty, Multicast is performed.
* @param deviceURI - Uri containing address to the virtual device in C Stack
- ("/oc/core/d")
+ ("/oic/res/d")
* @param connectivityType - @ref OCConnectivityType type of connectivity indicating the
* interface. Example: OC_WIFI, OC_ETHERNET, OC_ALL
* @param deviceInfoHandler - device discovery callback
* Above relative URI will be prepended (by core) with a host IP + namespace "oc"
* Therefore, fully qualified URI format would be //HostIP-Address/namespace/relativeURI"
* Example, a relative URI: 'a/light' will result in a fully qualified URI:
- * //192.168.1.1/oc/a/light"
+ * //192.168.1.1/oic/a/light"
* First parameter can take a relative URI and core will take care of preparing the fully
* qualified URI OR
* first parameter can take fully qualified URI and core will take that as is for further
*
* @param host - Host IP Address. If null or empty, Multicast is performed.
* @param resourceURI - Uri containing address to the virtual device in C Stack
- * ("/oc/core/d")
+ * ("/oic/res/d")
*
* @param QualityOfService the quality of communication
*
* Above relative URI will be prepended (by core) with a host IP + namespace "oc"
* Therefore, fully qualified URI format would be //HostIP-Address/namespace/relativeURI"
* Example, a relative URI: 'a/light' will result in a fully qualified URI:
- * //192.168.1.1/oc/a/light"
+ * //192.168.1.1/oic/a/light"
* First parameter can take a relative URI and core will take care of preparing the fully
* qualified URI OR
* first parameter can take fully qualified URI and core will take that as is for further
namespace Key
{
- static const std::string OCKEY = "oc";
+ static const std::string OCKEY = "oic";
static const std::string URIKEY = "href";
static const std::string OBSERVABLEKEY = "obs";
static const std::string RESOURCETYPESKEY = "rt";
//GetDeviceInfo Test
TEST(GetDeviceInfoTest, DISABLED_GetDeviceInfoWithValidParameters)
{
- std::string deviceDiscoveryURI = "/oc/core/d";
+ std::string deviceDiscoveryURI = "/oic/res/d";
PlatformConfig cfg;
OCPlatform::Configure(cfg);
std::ostringstream requestURI;
TEST(GetDeviceInfoTest, GetDeviceInfoWithNullDeviceInfoHandler)
{
- std::string deviceDiscoveryURI = "/oc/core/d";
+ std::string deviceDiscoveryURI = "/oic/res/d";
PlatformConfig cfg;
OCPlatform::Configure(cfg);
std::ostringstream requestURI;
TEST(GetDeviceInfoTest, DISABLED_GetDeviceInfoWithLowQos)
{
- std::string deviceDiscoveryURI = "/oc/core/d";
+ std::string deviceDiscoveryURI = "/oic/res/d";
PlatformConfig cfg;
OCPlatform::Configure(cfg);
std::ostringstream requestURI;
TEST(GetDeviceInfoTest, DISABLED_GetDeviceInfoWithMidQos)
{
- std::string deviceDiscoveryURI = "/oc/core/d";
+ std::string deviceDiscoveryURI = "/oic/res/d";
PlatformConfig cfg;
OCPlatform::Configure(cfg);
std::ostringstream requestURI;
TEST(GetDeviceInfoTest, DISABLED_GetDeviceInfoWithHighQos)
{
- std::string deviceDiscoveryURI = "/oc/core/d";
+ std::string deviceDiscoveryURI = "/oic/res/d";
PlatformConfig cfg;
OCPlatform::Configure(cfg);
std::ostringstream requestURI;
TEST(GetDeviceInfoTest, DISABLED_GetDeviceInfoWithNaQos)
{
- std::string deviceDiscoveryURI = "/oc/core/d";
+ std::string deviceDiscoveryURI = "/oic/res/d";
PlatformConfig cfg;
OCPlatform::Configure(cfg);
std::ostringstream requestURI;