Commit 886392f8 authored by Kishen Maloor's avatar Kishen Maloor

Merge branch 'origin/gaborone' into gaborone+

Signed-off-by: Kishen Maloor's avatarKishen Maloor <kishen.maloor@intel.com>
parents e5e7b242 608bba92
Pipeline #624 failed with stage
in 5 minutes and 19 seconds
This diff is collapsed.
{
"schemes":[
"http"
],
"swagger":"2.0",
"consumes":[
"application/json"
],
"paths":{
"/oic/p":{
"get":{
"responses":{
"200":{
"schema":{
"$ref":"#/definitions/Platform"
},
"description":""
}
},
"parameters":[
{
"$ref":"#/parameters/interface30"
}
],
"description":""
}
},
"/oic/mnt":{
"post":{
"responses":{
"200":{
"schema":{
"$ref":"#/definitions/mnt"
},
"description":""
}
},
"parameters":[
{
"$ref":"#/parameters/interface-rw"
},
{
"schema":{
"$ref":"#/definitions/mnt-update"
},
"in":"body",
"required":true,
"name":"body"
}
],
"description":""
},
"get":{
"responses":{
"200":{
"schema":{
"$ref":"#/definitions/mnt"
},
"description":""
}
},
"parameters":[
{
"$ref":"#/parameters/interface-all"
}
],
"description":""
}
}
},
"definitions":{
"Platform":{
"properties":{
"id":{
"type":"string",
"readOnly":true,
"maxLength":64,
"description":""
},
"if":{
"minItems":2,
"items":{
"enum":[
"oic.if.r",
"oic.if.baseline"
],
"type":"string",
"maxLength":64
},
"description":"",
"uniqueItems":true,
"readOnly":true,
"type":"array"
},
"n":{
"type":"string",
"readOnly":true,
"maxLength":64,
"description":""
},
"mnmn":{
"type":"string",
"readOnly":true,
"maxLength":64,
"description":""
},
"mnnct":{
"minItems":1,
"items":{
"minimum":1,
"type":"integer",
"description":""
},
"readOnly":true,
"type":"array",
"description":""
},
"mnml":{
"format":"uri",
"type":"string",
"readOnly":true,
"maxLength":256,
"description":""
},
"mnsel":{
"type":"string",
"readOnly":true,
"maxLength":64,
"description":""
},
"mnpv":{
"type":"string",
"readOnly":true,
"maxLength":64,
"description":""
},
"mnfv":{
"type":"string",
"readOnly":true,
"maxLength":64,
"description":""
},
"rt":{
"minItems":1,
"items":{
"enum":[
"oic.wk.p"
],
"type":"string",
"maxLength":64
},
"description":"",
"uniqueItems":true,
"readOnly":true,
"default":[
"oic.wk.p"
],
"type":"array"
},
"mnos":{
"type":"string",
"readOnly":true,
"maxLength":64,
"description":""
},
"mnhw":{
"type":"string",
"readOnly":true,
"maxLength":64,
"description":""
},
"vid":{
"type":"string",
"readOnly":true,
"maxLength":64,
"description":""
},
"mnmo":{
"type":"string",
"readOnly":true,
"maxLength":64,
"description":""
},
"mndt":{
"readOnly":true,
"type":"string",
"pattern":"^([0-9]{4})-(1[0-2]|0[1-9])-(3[0-1]|2[0-9]|1[0-9]|0[1-9])$",
"description":""
},
"pi":{
"readOnly":true,
"type":"string",
"pattern":"^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$",
"description":""
},
"st":{
"format":"date-time",
"readOnly":true,
"type":"string",
"description":""
},
"mnsl":{
"format":"uri",
"type":"string",
"readOnly":true,
"maxLength":256,
"description":""
}
},
"required":[
"pi",
"mnmn"
],
"type":"object"
},
"mnt":{
"anyOf":[
{
"required":[
"fr"
]
},
{
"required":[
"rb"
]
},
{
"required":[
"err"
]
}
],
"properties":{
"err":{
"type":"integer",
"minimum":399,
"readOnly":true,
"maximum":599,
"description":""
},
"rt":{
"minItems":1,
"items":{
"enum":[
"oic.wk.mnt"
],
"type":"string",
"maxLength":64
},
"description":"",
"uniqueItems":true,
"readOnly":true,
"default":[
"oic.wk.mnt"
],
"type":"array"
},
"id":{
"type":"string",
"readOnly":true,
"maxLength":64,
"description":""
},
"n":{
"type":"string",
"readOnly":true,
"maxLength":64,
"description":""
},
"rb":{
"type":"boolean",
"description":""
},
"fr":{
"type":"boolean",
"description":""
},
"if":{
"minItems":1,
"items":{
"enum":[
"oic.if.rw",
"oic.if.baseline"
],
"type":"string",
"maxLength":64
},
"description":"",
"uniqueItems":true,
"readOnly":true,
"type":"array"
}
},
"type":"object"
},
"mnt-update":{
"anyOf":[
{
"required":[
"fr"
]
},
{
"required":[
"rb"
]
}
],
"properties":{
"rb":{
"type":"boolean",
"description":""
},
"n":{
"type":"string",
"readOnly":true,
"maxLength":64,
"description":""
},
"fr":{
"type":"boolean",
"description":""
}
},
"type":"object"
}
},
"info":{
"version":"20190215",
"title":"serverlite24521",
"termsOfService":"https://openconnectivityfoundation.github.io/core/DISCLAIMER.md",
"license":{
"x-copyright":"copyright 2016-2017, 2019 Open Connectivity Foundation, Inc. All rights reserved.",
"url":"https://github.com/openconnectivityfoundation/core/blob/e28a9e0a92e17042ba3e83661e4c0fbce8bdc4ba/LICENSE.md",
"name":"OCF Data Model License"
}
},
"parameters":{
"interface30":{
"enum":[
"oic.if.r",
"oic.if.baseline"
],
"type":"string",
"in":"query",
"name":"if"
},
"interface-rw":{
"enum":[
"oic.if.rw",
"oic.if.baseline"
],
"type":"string",
"in":"query",
"name":"if"
},
"interface-all":{
"enum":[
"oic.if.rw",
"oic.if.baseline"
],
"type":"string",
"in":"query",
"name":"if"
},
"platforminterface-all":{
"enum":[
"oic.if.baseline"
],
"type":"string",
"in":"query",
"name":"if"
}
},
"produces":[
"application/json"
]
}
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include <stdio.h> #include <stdio.h>
// define application specific values. // define application specific values.
static const char *spec_version = "ocf.2.5.0"; static const char *spec_version = "ocf.2.1.1";
static const char *data_model_version = "ocf.res.1.3.0,ocf.sh.1.3.0"; static const char *data_model_version = "ocf.res.1.3.0,ocf.sh.1.3.0";
static const char *device_rt = "oic.d.switch"; static const char *device_rt = "oic.d.switch";
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
*/ */
#include "oc_api.h" #include "oc_api.h"
#include "oc_core_res.h"
#include "oc_pki.h" #include "oc_pki.h"
#include "port/oc_clock.h" #include "port/oc_clock.h"
#include <pthread.h> #include <pthread.h>
...@@ -69,7 +70,7 @@ app_init(void) ...@@ -69,7 +70,7 @@ app_init(void)
oc_activate_interrupt_handler(toggle_switch); oc_activate_interrupt_handler(toggle_switch);
int err = oc_init_platform("Intel", NULL, NULL); int err = oc_init_platform("Intel", NULL, NULL);
err |= oc_add_device("/oic/d", "oic.d.switch", "Temp_sensor", "ocf.2.5.0", err |= oc_add_device("/oic/d", "oic.d.switch", "Temp_sensor", "ocf.2.1.1",
"ocf.res.1.3.0,ocf.sh.1.3.0", NULL, NULL); "ocf.res.1.3.0,ocf.sh.1.3.0", NULL, NULL);
PRINT("\tSwitch device added.\n"); PRINT("\tSwitch device added.\n");
#if defined(OC_IDD_API) #if defined(OC_IDD_API)
...@@ -711,6 +712,15 @@ factory_presets_cb(size_t device, void *data) ...@@ -711,6 +712,15 @@ factory_presets_cb(size_t device, void *data)
#endif /* OC_SECURITY && OC_PKI */ #endif /* OC_SECURITY && OC_PKI */
} }
void
display_device_uuid(void)
{
char buffer[OC_UUID_LEN];
oc_uuid_to_str(oc_core_get_device_id(0), buffer, sizeof(buffer));
PRINT("Started device with ID: %s\n", buffer);
}
int int
main(void) main(void)
{ {
...@@ -749,6 +759,7 @@ main(void) ...@@ -749,6 +759,7 @@ main(void)
init = oc_main_init(&handler); init = oc_main_init(&handler);
if (init < 0) if (init < 0)
return init; return init;
display_device_uuid();
PRINT("Waiting for Client...\n"); PRINT("Waiting for Client...\n");
PRINT("Hit 'Enter' at any time to toggle switch resource\n"); PRINT("Hit 'Enter' at any time to toggle switch resource\n");
while (quit != 1) { while (quit != 1) {
......
...@@ -85,7 +85,7 @@ app_init(void) ...@@ -85,7 +85,7 @@ app_init(void)
{ {
int err = oc_init_platform("Intel", NULL, NULL); int err = oc_init_platform("Intel", NULL, NULL);
err |= oc_add_device("/oic/d", "oic.d.switch", "binary_switch", "ocf.2.5.0", err |= oc_add_device("/oic/d", "oic.d.switch", "binary_switch", "ocf.2.1.1",
"ocf.res.1.3.0,ocf.sh.1.3.0", NULL, NULL); "ocf.res.1.3.0,ocf.sh.1.3.0", NULL, NULL);
return err; return err;
} }
......
...@@ -130,7 +130,7 @@ static int ...@@ -130,7 +130,7 @@ static int
app_init(void) app_init(void)
{ {
int ret = oc_init_platform("OCF", NULL, NULL); int ret = oc_init_platform("OCF", NULL, NULL);
ret |= oc_add_device("/oic/d", "oic.d.dots", "OBT", "ocf.2.5.0", ret |= oc_add_device("/oic/d", "oic.d.dots", "OBT", "ocf.2.1.1",
"ocf.res.1.0.0,ocf.sh.1.0.0", NULL, NULL); "ocf.res.1.0.0,ocf.sh.1.0.0", NULL, NULL);
oc_device_bind_resource_type(0, "oic.d.ams"); oc_device_bind_resource_type(0, "oic.d.ams");
oc_device_bind_resource_type(0, "oic.d.cms"); oc_device_bind_resource_type(0, "oic.d.cms");
...@@ -1689,6 +1689,15 @@ discover_resources(void) ...@@ -1689,6 +1689,15 @@ discover_resources(void)
otb_mutex_unlock(app_sync_lock); otb_mutex_unlock(app_sync_lock);
} }
void
display_device_uuid()
{
char buffer[OC_UUID_LEN];
oc_uuid_to_str(oc_core_get_device_id(0), buffer, sizeof(buffer));
PRINT("Started device with ID: %s\n", buffer);
}
int int
main(void) main(void)
{ {
...@@ -1732,6 +1741,8 @@ main(void) ...@@ -1732,6 +1741,8 @@ main(void)
} }
#endif #endif
display_device_uuid();
int c; int c;
while (quit != 1) { while (quit != 1) {
display_menu(); display_menu();
......
...@@ -113,7 +113,7 @@ VPATH=../../messaging/coap/:../../util/:../../api/:../../deps/tinycbor/src/:../. ...@@ -113,7 +113,7 @@ VPATH=../../messaging/coap/:../../util/:../../api/:../../deps/tinycbor/src/:../.
LIBS?= -lm -pthread -lrt LIBS?= -lm -pthread -lrt
SAMPLES = server client temp_sensor simpleserver simpleserver_pki simpleclient client_collections_linux introspectionclient\ SAMPLES = server client temp_sensor simpleserver simpleserver_pki simpleclient client_collections_linux introspectionclient\
server_collections_linux server_block_linux client_block_linux smart_home_server_linux multi_device_server multi_device_client smart_lock server_multithread_linux client_multithread_linux server_collections_linux server_block_linux client_block_linux smart_home_server_linux multi_device_server multi_device_client smart_lock server_multithread_linux client_multithread_linux client_certification_tests
ifeq ($(CREATE),1) ifeq ($(CREATE),1)
EXTRA_CFLAGS += -DOC_COLLECTIONS_IF_CREATE EXTRA_CFLAGS += -DOC_COLLECTIONS_IF_CREATE
...@@ -262,6 +262,7 @@ copy_pki_certs: ...@@ -262,6 +262,7 @@ copy_pki_certs:
copy_idd_files: copy_idd_files:
@cp ../../apps/smart_home_server_linux_IDD.cbor . @cp ../../apps/smart_home_server_linux_IDD.cbor .
@cp ../../apps/client_certification_tests_IDD.cbor .
${SRC} ${SRC_COMMON}: $(MBEDTLS_PATCH_FILE) ${SRC} ${SRC_COMMON}: $(MBEDTLS_PATCH_FILE)
...@@ -319,6 +320,10 @@ smart_lock: libiotivity-lite-client.a $(ROOT_DIR)/apps/smart_lock_linux.c ...@@ -319,6 +320,10 @@ smart_lock: libiotivity-lite-client.a $(ROOT_DIR)/apps/smart_lock_linux.c
@mkdir -p $@_creds @mkdir -p $@_creds
${CC} -o $@ ../../apps/smart_lock_linux.c libiotivity-lite-client.a -DOC_CLIENT ${CFLAGS} ${LIBS} ${CC} -o $@ ../../apps/smart_lock_linux.c libiotivity-lite-client.a -DOC_CLIENT ${CFLAGS} ${LIBS}
client_certification_tests: libiotivity-lite-client.a $(ROOT_DIR)/apps/client_certification_tests.c copy_idd_files
@mkdir -p $@_creds
${CC} -o $@ ../../apps/client_certification_tests.c libiotivity-lite-client.a -DOC_CLIENT ${CFLAGS} ${LIBS}
temp_sensor: libiotivity-lite-client.a $(ROOT_DIR)/apps/temp_sensor_client_linux.c temp_sensor: libiotivity-lite-client.a $(ROOT_DIR)/apps/temp_sensor_client_linux.c
@mkdir -p $@_creds @mkdir -p $@_creds
${CC} -o $@ ../../apps/temp_sensor_client_linux.c libiotivity-lite-client.a -DOC_CLIENT ${CFLAGS} ${LIBS} ${CC} -o $@ ../../apps/temp_sensor_client_linux.c libiotivity-lite-client.a -DOC_CLIENT ${CFLAGS} ${LIBS}
...@@ -440,7 +445,7 @@ endif ...@@ -440,7 +445,7 @@ endif
clean: clean:
rm -rf obj $(PC) $(CONSTRAINED_LIBS) $(API_TEST_OBJ_FILES) $(SECURITY_TEST_OBJ_FILES) $(PLATFORM_TEST_OBJ_FILES) $(MESSAGING_TEST_OBJ_FILES) $(UNIT_TESTS) $(STORAGE_TEST_DIR) $(CLOUD_TEST_OBJ_FILES) $(RD_CLIENT_TEST_OBJ_FILES) rm -rf obj $(PC) $(CONSTRAINED_LIBS) $(API_TEST_OBJ_FILES) $(SECURITY_TEST_OBJ_FILES) $(PLATFORM_TEST_OBJ_FILES) $(MESSAGING_TEST_OBJ_FILES) $(UNIT_TESTS) $(STORAGE_TEST_DIR) $(CLOUD_TEST_OBJ_FILES) $(RD_CLIENT_TEST_OBJ_FILES)
rm -rf $(API_TEST_OBJ_DIR)/*.gcda $(SECURITY_TEST_OBJ_DIR)/*.gcda $(PLATFORM_TEST_OBJ_DIR)/*.gcda $(MESSAGING_TEST_OBJ_DIR)/*.gcda rm -rf $(API_TEST_OBJ_DIR)/*.gcda $(SECURITY_TEST_OBJ_DIR)/*.gcda $(PLATFORM_TEST_OBJ_DIR)/*.gcda $(MESSAGING_TEST_OBJ_DIR)/*.gcda
rm -rf pki_certs smart_home_server_linux_IDD.cbor rm -rf pki_certs smart_home_server_linux_IDD.cbor client_certification_tests_IDD.cbor
cleanall: clean cleanall: clean
rm -rf ${all} $(SAMPLES) $(TESTS) ${OBT} ${SAMPLES_CREDS} $(MBEDTLS_PATCH_FILE) *.o rm -rf ${all} $(SAMPLES) $(TESTS) ${OBT} ${SAMPLES_CREDS} $(MBEDTLS_PATCH_FILE) *.o
......
...@@ -389,7 +389,7 @@ oc_sec_add_new_cred(size_t device, bool roles_resource, oc_tls_peer_t *client, ...@@ -389,7 +389,7 @@ oc_sec_add_new_cred(size_t device, bool roles_resource, oc_tls_peer_t *client,
if (!subjectuuid) { if (!subjectuuid) {
if (credusage != OC_CREDUSAGE_ROLE_CERT) { if (credusage != OC_CREDUSAGE_ROLE_CERT) {
return -1; goto add_new_cred_error;
} else { } else {
subject.id[0] = '*'; subject.id[0] = '*';
} }
...@@ -439,6 +439,11 @@ oc_sec_add_new_cred(size_t device, bool roles_resource, oc_tls_peer_t *client, ...@@ -439,6 +439,11 @@ oc_sec_add_new_cred(size_t device, bool roles_resource, oc_tls_peer_t *client,
publicdata_size) == 0)) publicdata_size) == 0))
#endif /* OC_PKI */ #endif /* OC_PKI */
) { ) {
#ifdef OC_PKI
if (oc_string_len(public_key) > 0) {
oc_free_string(&public_key);
}
#endif /* OC_PKI */
return credid; return credid;
} else { } else {
oc_sec_remove_cred_by_credid(credid, device); oc_sec_remove_cred_by_credid(credid, device);
...@@ -470,6 +475,9 @@ oc_sec_add_new_cred(size_t device, bool roles_resource, oc_tls_peer_t *client, ...@@ -470,6 +475,9 @@ oc_sec_add_new_cred(size_t device, bool roles_resource, oc_tls_peer_t *client,
publicdata_size == oc_string_len(cred->publicdata.data) && publicdata_size == oc_string_len(cred->publicdata.data) &&
memcmp(publicdata, oc_string(cred->publicdata.data), memcmp(publicdata, oc_string(cred->publicdata.data),
publicdata_size) == 0) { publicdata_size) == 0) {
if (oc_string_len(public_key) > 0) {
oc_free_string(&public_key);
}
return cred->credid; return cred->credid;
} }
} }
...@@ -486,6 +494,9 @@ oc_sec_add_new_cred(size_t device, bool roles_resource, oc_tls_peer_t *client, ...@@ -486,6 +494,9 @@ oc_sec_add_new_cred(size_t device, bool roles_resource, oc_tls_peer_t *client,
if ((oc_string_len(roles->publicdata.data) == publicdata_size) && if ((oc_string_len(roles->publicdata.data) == publicdata_size) &&
memcmp(oc_string(roles->publicdata.data), publicdata, memcmp(oc_string(roles->publicdata.data), publicdata,
publicdata_size) == 0) { publicdata_size) == 0) {
if (oc_string_len(public_key) > 0) {
oc_free_string(&public_key);
}
return roles->credid; return roles->credid;
} }
roles = roles->next; roles = roles->next;
......
...@@ -365,8 +365,8 @@ public class OCRepresentationTest { ...@@ -365,8 +365,8 @@ public class OCRepresentationTest {
+ " }]\n" + " }]\n"
+ "}\n", OCRep.toJSON(rep, true)); + "}\n", OCRep.toJSON(rep, true));
System.out.println(rep.getType()); assertEquals(OCType.OC_REP_OBJECT_ARRAY, rep.getType());
System.out.println(rep.getName()); assertEquals("space_2001", rep.getName());