Commit e5500cc5 authored by Kishen Maloor's avatar Kishen Maloor

Merge 'origin/master' into wes

Signed-off-by: Kishen Maloor's avatarKishen Maloor <kishen.maloor@intel.com>
parents 469d7364 bdb0410e
Pipeline #938 failed with stage
in 6 minutes and 26 seconds
--- ---
image: gcc image: gcc:9.3.0
Linux_Secured_Test: Linux_Secured_Test:
variables:
GIT_SUBMODULE_STRATEGY: normal
stage: build stage: build
before_script: before_script:
- apt update && apt -y install make autoconf - apt update && apt -y install make autoconf
...@@ -13,6 +15,8 @@ Linux_Secured_Test: ...@@ -13,6 +15,8 @@ Linux_Secured_Test:
- make DYNAMIC=1 IPV4=1 TCP=1 SECURE=1 test - make DYNAMIC=1 IPV4=1 TCP=1 SECURE=1 test
Linux_Unsecured_Test: Linux_Unsecured_Test:
variables:
GIT_SUBMODULE_STRATEGY: normal
stage: build stage: build
before_script: before_script:
- apt update && apt -y install make autoconf - apt update && apt -y install make autoconf
...@@ -24,37 +28,37 @@ Linux_Unsecured_Test: ...@@ -24,37 +28,37 @@ Linux_Unsecured_Test:
- make DYNAMIC=1 IPV4=1 TCP=1 SECURE=0 test - make DYNAMIC=1 IPV4=1 TCP=1 SECURE=0 test
Android_build: Android_build:
stage: build variables:
image: openjdk:8-jdk GIT_SUBMODULE_STRATEGY: normal
before_script: stage: build
- apt-get --quiet update --yes image: openjdk:8-jdk
- apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1 make autoconf swig patch before_script:
- wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip - apt-get --quiet update --yes
- unzip -d android-sdk-linux android-sdk.zip - apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1 make autoconf swig patch
- echo y | android-sdk-linux/tools/bin/sdkmanager "ndk-bundle" >/dev/null - wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
- echo y | android-sdk-linux/tools/bin/sdkmanager "platforms;android-28" >/dev/null - unzip -d android-sdk-linux android-sdk.zip
- echo y | android-sdk-linux/tools/bin/sdkmanager "platform-tools" >/dev/null - echo y | android-sdk-linux/tools/bin/sdkmanager "ndk-bundle" >/dev/null
- echo y | android-sdk-linux/tools/bin/sdkmanager "build-tools;28.0.2" >/dev/null - echo y | android-sdk-linux/tools/bin/sdkmanager "platforms;android-28" >/dev/null
- export ANDROID_HOME=$PWD/android-sdk-linux - echo y | android-sdk-linux/tools/bin/sdkmanager "platform-tools" >/dev/null
- export PATH=$PATH:$PWD/android-sdk-linux/platform-tools/ - echo y | android-sdk-linux/tools/bin/sdkmanager "build-tools;28.0.2" >/dev/null
# temporarily disable checking for EPIPE error and use yes to accept all licenses - export ANDROID_HOME=$PWD/android-sdk-linux
- set +o pipefail - export PATH=$PATH:$PWD/android-sdk-linux/platform-tools/
- yes | android-sdk-linux/tools/bin/sdkmanager --licenses # temporarily disable checking for EPIPE error and use yes to accept all licenses
- set -o pipefail - set +o pipefail
- ./android-sdk-linux/ndk-bundle/build/tools/make_standalone_toolchain.py --arch arm --api 23 --install-dir ~/android-arm-23 - yes | android-sdk-linux/tools/bin/sdkmanager --licenses
script: - set -o pipefail
- cd port/android - ./android-sdk-linux/ndk-bundle/build/tools/make_standalone_toolchain.py --arch arm --api 23 --install-dir ~/android-arm-23
- make DYNAMIC=1 TCP=1 IPV4=1 SECURE=1 PKI=1 CLOUD=1 JAVA=1 DEBUG=0 script:
- cd port/android
- make DYNAMIC=1 TCP=1 IPV4=1 SECURE=1 PKI=1 CLOUD=1 JAVA=1 DEBUG=0
whitespace_and_doxygen: doxygen:
variables:
GIT_SUBMODULE_STRATEGY: none
stage: build stage: build
before_script: before_script:
- apt update && apt -y install make autoconf doxygen clang-format - apt update && apt -y install doxygen
script: script:
- clang-format --version
- doxygen --version - doxygen --version
- cp tools/_clang-format _clang-format
- cp tools/whitespace_commit_checker.sh whitespace_commit_checker.sh
- ./whitespace_commit_checker.sh
- cd tools - cd tools
- ./build_doc.sh - ./build_doc.sh
...@@ -113,7 +113,7 @@ cloud_deregister_on_reset_internal(oc_cloud_context_t *ctx, ...@@ -113,7 +113,7 @@ cloud_deregister_on_reset_internal(oc_cloud_context_t *ctx,
cloud_store_initialize(&ctx->store); cloud_store_initialize(&ctx->store);
cloud_manager_stop(ctx); cloud_manager_stop(ctx);
ctx->last_error = 0; ctx->last_error = 0;
ctx->cps = 0; ctx->store.cps = 0;
} }
#endif /* OC_SECURITY */ #endif /* OC_SECURITY */
...@@ -137,7 +137,7 @@ oc_cloud_reset_context(size_t device) ...@@ -137,7 +137,7 @@ oc_cloud_reset_context(size_t device)
cloud_store_initialize(&ctx->store); cloud_store_initialize(&ctx->store);
cloud_manager_stop(ctx); cloud_manager_stop(ctx);
ctx->last_error = 0; ctx->last_error = 0;
ctx->cps = 0; ctx->store.cps = 0;
return 0; return 0;
} }
...@@ -168,7 +168,7 @@ oc_cloud_provision_conf_resource(oc_cloud_context_t *ctx, const char *server, ...@@ -168,7 +168,7 @@ oc_cloud_provision_conf_resource(oc_cloud_context_t *ctx, const char *server,
} }
ctx->store.status = OC_CLOUD_INITIALIZED; ctx->store.status = OC_CLOUD_INITIALIZED;
ctx->cps = OC_CPS_READYTOREGISTER; ctx->store.cps = OC_CPS_READYTOREGISTER;
cloud_store_dump_async(&ctx->store); cloud_store_dump_async(&ctx->store);
...@@ -204,7 +204,7 @@ cloud_update_by_resource(oc_cloud_context_t *ctx, ...@@ -204,7 +204,7 @@ cloud_update_by_resource(oc_cloud_context_t *ctx,
cloud_set_string(&ctx->store.sid, data->sid, data->sid_len); cloud_set_string(&ctx->store.sid, data->sid, data->sid_len);
} }
ctx->store.status = OC_CLOUD_INITIALIZED; ctx->store.status = OC_CLOUD_INITIALIZED;
ctx->cps = OC_CPS_READYTOREGISTER; ctx->store.cps = OC_CPS_READYTOREGISTER;
if (ctx->cloud_manager) { if (ctx->cloud_manager) {
cloud_reconnect(ctx); cloud_reconnect(ctx);
} }
......
...@@ -70,12 +70,16 @@ free_api_param(cloud_api_param_t *p) ...@@ -70,12 +70,16 @@ free_api_param(cloud_api_param_t *p)
int int
conv_cloud_endpoint(oc_cloud_context_t *ctx) conv_cloud_endpoint(oc_cloud_context_t *ctx)
{ {
int ret = 0;
oc_endpoint_t ep; oc_endpoint_t ep;
memset(&ep, 0, sizeof(oc_endpoint_t)); memset(&ep, 0, sizeof(oc_endpoint_t));
if (memcmp(&ep, ctx->cloud_ep, sizeof(oc_endpoint_t)) == 0) { if (memcmp(&ep, ctx->cloud_ep, sizeof(oc_endpoint_t)) == 0) {
return oc_string_to_endpoint(&ctx->store.ci_server, ctx->cloud_ep, NULL); ret = oc_string_to_endpoint(&ctx->store.ci_server, ctx->cloud_ep, NULL);
#ifdef OC_DNS_CACHE
oc_dns_clear_cache();
#endif /* OC_DNS_CACHE */
} }
return 0; return ret;
} }
int int
...@@ -105,7 +109,7 @@ oc_cloud_register(oc_cloud_context_t *ctx, oc_cloud_cb_t cb, void *data) ...@@ -105,7 +109,7 @@ oc_cloud_register(oc_cloud_context_t *ctx, oc_cloud_cb_t cb, void *data)
oc_string(ctx->store.uid), oc_string(ctx->store.access_token), oc_string(ctx->store.uid), oc_string(ctx->store.access_token),
ctx->device, oc_cloud_register_handler, p)) { ctx->device, oc_cloud_register_handler, p)) {
cannotConnect = false; cannotConnect = false;
ctx->cps = OC_CPS_REGISTERING; ctx->store.cps = OC_CPS_REGISTERING;
} }
if (cannotConnect) { if (cannotConnect) {
cloud_set_last_error(ctx, CLOUD_ERROR_CONNECT); cloud_set_last_error(ctx, CLOUD_ERROR_CONNECT);
...@@ -227,17 +231,15 @@ cloud_deregistered_internal(oc_client_response_t *data) ...@@ -227,17 +231,15 @@ cloud_deregistered_internal(oc_client_response_t *data)
{ {
cloud_api_param_t *p = (cloud_api_param_t *)data->user_data; cloud_api_param_t *p = (cloud_api_param_t *)data->user_data;
oc_cloud_context_t *ctx = p->ctx; oc_cloud_context_t *ctx = p->ctx;
if (data->code >= OC_STATUS_SERVICE_UNAVAILABLE) { if (data->code < OC_STATUS_BAD_REQUEST ||
cloud_set_last_error(ctx, CLOUD_ERROR_CONNECT); data->code >= OC_STATUS_SERVICE_UNAVAILABLE) {
ctx->store.status |= OC_CLOUD_FAILURE; ctx->store.status = OC_CLOUD_DEREGISTERED;
} else if (data->code >= OC_STATUS_BAD_REQUEST) { } else if (data->code >= OC_STATUS_BAD_REQUEST) {
cloud_set_last_error(ctx, CLOUD_ERROR_RESPONSE); cloud_set_last_error(ctx, CLOUD_ERROR_RESPONSE);
ctx->store.status |= OC_CLOUD_FAILURE; ctx->store.status |= OC_CLOUD_FAILURE;
} else {
ctx->store.status = OC_CLOUD_DEREGISTERED;
} }
ctx->cps = OC_CPS_READYTOREGISTER; ctx->store.cps = OC_CPS_READYTOREGISTER;
if (p->cb) { if (p->cb) {
p->cb(ctx, ctx->store.status, p->data); p->cb(ctx, ctx->store.status, p->data);
...@@ -245,6 +247,8 @@ cloud_deregistered_internal(oc_client_response_t *data) ...@@ -245,6 +247,8 @@ cloud_deregistered_internal(oc_client_response_t *data)
free_api_param(p); free_api_param(p);
ctx->store.status &= ~(OC_CLOUD_FAILURE | OC_CLOUD_DEREGISTERED); ctx->store.status &= ~(OC_CLOUD_FAILURE | OC_CLOUD_DEREGISTERED);
cloud_store_dump_async(&ctx->store);
} }
int int
...@@ -318,6 +322,25 @@ oc_cloud_refresh_token(oc_cloud_context_t *ctx, oc_cloud_cb_t cb, void *data) ...@@ -318,6 +322,25 @@ oc_cloud_refresh_token(oc_cloud_context_t *ctx, oc_cloud_cb_t cb, void *data)
return -1; return -1;
} }
int
oc_cloud_discover_resources(oc_cloud_context_t *ctx,
oc_discovery_all_handler_t handler, void *user_data)
{
if (!ctx) {
return -1;
}
if (!(ctx->store.status & OC_CLOUD_LOGGED_IN)) {
return -1;
}
if (oc_do_ip_discovery_all_at_endpoint(handler, ctx->cloud_ep, user_data)) {
return 0;
}
return -1;
}
/* Internal APIs for accessing the OCF Cloud */ /* Internal APIs for accessing the OCF Cloud */
bool bool
cloud_access_register(oc_endpoint_t *endpoint, const char *auth_provider, cloud_access_register(oc_endpoint_t *endpoint, const char *auth_provider,
...@@ -339,7 +362,9 @@ cloud_access_register(oc_endpoint_t *endpoint, const char *auth_provider, ...@@ -339,7 +362,9 @@ cloud_access_register(oc_endpoint_t *endpoint, const char *auth_provider,
} }
#ifdef OC_SECURITY #ifdef OC_SECURITY
oc_tls_select_cloud_ciphersuite(); if (!oc_tls_connected(endpoint)) {
oc_tls_select_cloud_ciphersuite();
}
#endif /* OC_SECURITY */ #endif /* OC_SECURITY */
if (oc_init_post(OC_RSRVD_ACCOUNT_URI, endpoint, NULL, handler, LOW_QOS, if (oc_init_post(OC_RSRVD_ACCOUNT_URI, endpoint, NULL, handler, LOW_QOS,
...@@ -384,23 +409,32 @@ cloud_access_deregister(oc_endpoint_t *endpoint, const char *uid, ...@@ -384,23 +409,32 @@ cloud_access_deregister(oc_endpoint_t *endpoint, const char *uid,
OC_ERR("Error of input parameters"); OC_ERR("Error of input parameters");
return false; return false;
} }
oc_string_t d; oc_string_t at_uid;
(void)device;
oc_string_t at; oc_string_t at;
oc_concat_strings(&at, "accesstoken=", access_token); oc_concat_strings(&at, "accesstoken=", access_token);
oc_string_t u_id; oc_string_t u_id;
oc_concat_strings(&u_id, "&uid=", uid); oc_concat_strings(&u_id, "&uid=", uid);
oc_concat_strings(&d, oc_string(at), oc_string(u_id)); oc_concat_strings(&at_uid, oc_string(at), oc_string(u_id));
char uuid[OC_UUID_LEN] = { 0 };
oc_uuid_to_str(oc_core_get_device_id(device), uuid, OC_UUID_LEN);
oc_string_t di;
oc_concat_strings(&di, "&di=", uuid);
oc_string_t at_uid_di;
oc_concat_strings(&at_uid_di, oc_string(at_uid), oc_string(di));
#ifdef OC_SECURITY #ifdef OC_SECURITY
oc_tls_select_cloud_ciphersuite(); if (!oc_tls_connected(endpoint)) {
oc_tls_select_cloud_ciphersuite();
}
#endif /* OC_SECURITY */ #endif /* OC_SECURITY */
bool s = oc_do_delete(OC_RSRVD_ACCOUNT_URI, endpoint, oc_string(d), handler, bool s = oc_do_delete(OC_RSRVD_ACCOUNT_URI, endpoint, oc_string(at_uid_di),
HIGH_QOS, user_data); handler, HIGH_QOS, user_data);
oc_free_string(&d); oc_free_string(&at_uid);
oc_free_string(&at); oc_free_string(&at);
oc_free_string(&u_id); oc_free_string(&u_id);
oc_free_string(&di);
oc_free_string(&at_uid_di);
return s; return s;
} }
...@@ -422,7 +456,9 @@ cloud_access_login_out(oc_endpoint_t *endpoint, const char *uid, ...@@ -422,7 +456,9 @@ cloud_access_login_out(oc_endpoint_t *endpoint, const char *uid,
} }
#ifdef OC_SECURITY #ifdef OC_SECURITY
oc_tls_select_cloud_ciphersuite(); if (!oc_tls_connected(endpoint)) {
oc_tls_select_cloud_ciphersuite();
}
#endif /* OC_SECURITY */ #endif /* OC_SECURITY */
if (oc_init_post(OC_RSRVD_ACCOUNT_SESSION_URI, endpoint, NULL, handler, if (oc_init_post(OC_RSRVD_ACCOUNT_SESSION_URI, endpoint, NULL, handler,
...@@ -481,7 +517,9 @@ cloud_access_refresh_access_token(oc_endpoint_t *endpoint, const char *uid, ...@@ -481,7 +517,9 @@ cloud_access_refresh_access_token(oc_endpoint_t *endpoint, const char *uid,
} }
#ifdef OC_SECURITY #ifdef OC_SECURITY
oc_tls_select_cloud_ciphersuite(); if (!oc_tls_connected(endpoint)) {
oc_tls_select_cloud_ciphersuite();
}
#endif /* OC_SECURITY */ #endif /* OC_SECURITY */
if (oc_init_post(OC_RSRVD_ACCOUNT_TOKEN_REFRESH_URI, endpoint, NULL, handler, if (oc_init_post(OC_RSRVD_ACCOUNT_TOKEN_REFRESH_URI, endpoint, NULL, handler,
......
...@@ -146,8 +146,6 @@ _register_handler(oc_cloud_context_t *ctx, oc_client_response_t *data) ...@@ -146,8 +146,6 @@ _register_handler(oc_cloud_context_t *ctx, oc_client_response_t *data)
oc_rep_t *payload = data->payload; oc_rep_t *payload = data->payload;
ctx->store.status = 0;
char *value = NULL; char *value = NULL;
size_t size = 0; size_t size = 0;
...@@ -195,12 +193,14 @@ _register_handler(oc_cloud_context_t *ctx, oc_client_response_t *data) ...@@ -195,12 +193,14 @@ _register_handler(oc_cloud_context_t *ctx, oc_client_response_t *data)
cloud_set_last_error(ctx, CLOUD_OK); cloud_set_last_error(ctx, CLOUD_OK);
ctx->store.status |= OC_CLOUD_REGISTERED; ctx->store.status |= OC_CLOUD_REGISTERED;
ctx->cps = OC_CPS_REGISTERED; ctx->store.cps = OC_CPS_REGISTERED;
oc_notify_observers(ctx->cloud_conf);
return 0; return 0;
error: error:
ctx->cps = OC_CPS_FAILED; ctx->store.cps = OC_CPS_FAILED;
ctx->store.status |= OC_CLOUD_FAILURE; ctx->store.status |= OC_CLOUD_FAILURE;
if (ctx->last_error == 0) { if (ctx->last_error == 0) {
cloud_set_last_error(ctx, CLOUD_ERROR_RESPONSE); cloud_set_last_error(ctx, CLOUD_ERROR_RESPONSE);
...@@ -259,7 +259,7 @@ cloud_register(void *data) ...@@ -259,7 +259,7 @@ cloud_register(void *data)
oc_string(ctx->store.uid), oc_string(ctx->store.access_token), oc_string(ctx->store.uid), oc_string(ctx->store.access_token),
ctx->device, cloud_register_handler, data)) { ctx->device, cloud_register_handler, data)) {
cannotConnect = false; cannotConnect = false;
ctx->cps = OC_CPS_REGISTERING; ctx->store.cps = OC_CPS_REGISTERING;
} }
if (cannotConnect) { if (cannotConnect) {
cloud_set_last_error(ctx, CLOUD_ERROR_CONNECT); cloud_set_last_error(ctx, CLOUD_ERROR_CONNECT);
...@@ -297,7 +297,7 @@ _login_handler(oc_cloud_context_t *ctx, oc_client_response_t *data) ...@@ -297,7 +297,7 @@ _login_handler(oc_cloud_context_t *ctx, oc_client_response_t *data)
return 0; return 0;
error: error:
ctx->cps = OC_CPS_FAILED; ctx->store.cps = OC_CPS_FAILED;
ctx->store.status |= OC_CLOUD_FAILURE; ctx->store.status |= OC_CLOUD_FAILURE;
if (ctx->last_error == 0) { if (ctx->last_error == 0) {
cloud_set_last_error(ctx, CLOUD_ERROR_RESPONSE); cloud_set_last_error(ctx, CLOUD_ERROR_RESPONSE);
...@@ -430,7 +430,7 @@ error: ...@@ -430,7 +430,7 @@ error:
if (ctx->last_error == 0) { if (ctx->last_error == 0) {
cloud_set_last_error(ctx, CLOUD_ERROR_REFRESH_ACCESS_TOKEN); cloud_set_last_error(ctx, CLOUD_ERROR_REFRESH_ACCESS_TOKEN);
} }
ctx->cps = OC_CPS_FAILED; ctx->store.cps = OC_CPS_FAILED;
ctx->store.status |= OC_CLOUD_FAILURE; ctx->store.status |= OC_CLOUD_FAILURE;
return -1; return -1;
} }
......
...@@ -129,7 +129,7 @@ publish_resources_handler(oc_client_response_t *data) ...@@ -129,7 +129,7 @@ publish_resources_handler(oc_client_response_t *data)
if (l) { if (l) {
l->ins = instance_id; l->ins = instance_id;
rd_link_remove(&ctx->rd_publish_resources, l); rd_link_remove(&ctx->rd_publish_resources, l);
rd_link_add(&ctx->rd_publish_resources, l); rd_link_add(&ctx->rd_published_resources, l);
} }
} }
link = link->next; link = link->next;
......
...@@ -66,7 +66,7 @@ cloud_response(oc_cloud_context_t *ctx) ...@@ -66,7 +66,7 @@ cloud_response(oc_cloud_context_t *ctx)
root, sid, (oc_string(ctx->store.sid) ? oc_string(ctx->store.sid) : "")); root, sid, (oc_string(ctx->store.sid) ? oc_string(ctx->store.sid) : ""));
oc_rep_set_int(root, clec, (int)ctx->last_error); oc_rep_set_int(root, clec, (int)ctx->last_error);
const char *cps = cps_to_str(ctx->cps); const char *cps = cps_to_str(ctx->store.cps);
if (cps) { if (cps) {
oc_rep_set_text_string(root, cps, cps); oc_rep_set_text_string(root, cps, cps);
} }
...@@ -145,7 +145,7 @@ post_cloud(oc_request_t *request, oc_interface_mask_t interface, ...@@ -145,7 +145,7 @@ post_cloud(oc_request_t *request, oc_interface_mask_t interface,
OC_DBG("POST request received"); OC_DBG("POST request received");
(void)interface; (void)interface;
switch (ctx->cps) { switch (ctx->store.cps) {
case OC_CPS_UNINITIALIZED: case OC_CPS_UNINITIALIZED:
case OC_CPS_READYTOREGISTER: case OC_CPS_READYTOREGISTER:
case OC_CPS_FAILED: case OC_CPS_FAILED:
......
...@@ -64,10 +64,12 @@ encode_cloud_with_map(CborEncoder *object_map, const oc_cloud_store_t *store) ...@@ -64,10 +64,12 @@ encode_cloud_with_map(CborEncoder *object_map, const oc_cloud_store_t *store)
oc_rep_set_text_string(*object, auth_provider, oc_rep_set_text_string(*object, auth_provider,
oc_string(store->auth_provider)); oc_string(store->auth_provider));
oc_rep_set_text_string(*object, uid, oc_string(store->uid)); oc_rep_set_text_string(*object, uid, oc_string(store->uid));
oc_rep_set_text_string(*object, sid, oc_string(store->sid));
oc_rep_set_text_string(*object, access_token, oc_string(store->access_token)); oc_rep_set_text_string(*object, access_token, oc_string(store->access_token));
oc_rep_set_text_string(*object, refresh_token, oc_rep_set_text_string(*object, refresh_token,
oc_string(store->refresh_token)); oc_string(store->refresh_token));
oc_rep_set_int(*object, status, store->status); oc_rep_set_int(*object, status, store->status);
oc_rep_set_int(*object, cps, store->cps);
} }
static void static void
...@@ -145,6 +147,9 @@ cloud_store_decode(oc_rep_t *rep, oc_cloud_store_t *store) ...@@ -145,6 +147,9 @@ cloud_store_decode(oc_rep_t *rep, oc_cloud_store_t *store)
if (len == 9 && memcmp(oc_string(t->name), "ci_server", 9) == 0) { if (len == 9 && memcmp(oc_string(t->name), "ci_server", 9) == 0) {
cloud_set_string(&store->ci_server, oc_string(t->value.string), cloud_set_string(&store->ci_server, oc_string(t->value.string),
oc_string_len(t->value.string)); oc_string_len(t->value.string));
} else if (len == 3 && memcmp(oc_string(t->name), "sid", 3) == 0) {
cloud_set_string(&store->sid, oc_string(t->value.string),
oc_string_len(t->value.string));
} else if (len == 13 && } else if (len == 13 &&
memcmp(oc_string(t->name), "auth_provider", 13) == 0) { memcmp(oc_string(t->name), "auth_provider", 13) == 0) {
cloud_set_string(&store->auth_provider, oc_string(t->value.string), cloud_set_string(&store->auth_provider, oc_string(t->value.string),
...@@ -168,6 +173,8 @@ cloud_store_decode(oc_rep_t *rep, oc_cloud_store_t *store) ...@@ -168,6 +173,8 @@ cloud_store_decode(oc_rep_t *rep, oc_cloud_store_t *store)
case OC_REP_INT: case OC_REP_INT:
if (len == 6 && memcmp(oc_string(t->name), "status", 6) == 0) { if (len == 6 && memcmp(oc_string(t->name), "status", 6) == 0) {
store->status = (uint8_t)t->value.integer; store->status = (uint8_t)t->value.integer;
} else if (len == 3 && memcmp(oc_string(t->name), "cps", 3) == 0) {
store->cps = (uint8_t)t->value.integer;
} else { } else {
OC_ERR("[CLOUD_STORE] Unknown property %s", oc_string(t->name)); OC_ERR("[CLOUD_STORE] Unknown property %s", oc_string(t->name));
return -1; return -1;
......
...@@ -197,6 +197,37 @@ oc_free_server_endpoints(oc_endpoint_t *endpoint) ...@@ -197,6 +197,37 @@ oc_free_server_endpoints(oc_endpoint_t *endpoint)
} }
} }
bool
oc_get_response_payload_raw(oc_client_response_t *response,
const uint8_t **payload, size_t *size,
oc_content_format_t *content_format)
{
if (!response || !payload || !size || !content_format) {
return false;
}
if (response->_payload && response->_payload_len > 0) {
*content_format = response->content_format;
*payload = response->_payload;
*size = response->_payload_len;
return true;
}
return false;
}
bool
oc_get_diagnostic_message(oc_client_response_t *response, const char **msg,