Commit 4ab74966 authored by Kishen Maloor's avatar Kishen Maloor

oc_cloud:do not return "at",check mandatory props

Change-Id: Ia8dbbf7ab8b5d4c5134fe199a2c742853d0b7f52
Signed-off-by: Kishen Maloor's avatarKishen Maloor <kishen.maloor@intel.com>
parent 3d7df830
......@@ -108,7 +108,7 @@ cloud_deregister_on_reset_internal(oc_cloud_context_t *ctx,
(void)status;
(void)data;
cloud_close_endpoint(ctx->cloud_ep);
cloud_store_deinit(&ctx->store);
cloud_store_initialize(&ctx->store);
cloud_manager_stop(ctx);
ctx->last_error = 0;
ctx->cps = 0;
......@@ -132,7 +132,7 @@ oc_cloud_reset_context(size_t device)
}
#endif /* OC_SECURITY */
cloud_store_deinit(&ctx->store);
cloud_store_initialize(&ctx->store);
cloud_manager_stop(ctx);
ctx->last_error = 0;
ctx->cps = 0;
......@@ -144,7 +144,7 @@ cloud_update_by_resource(oc_cloud_context_t *ctx,
const cloud_conf_update_t *data)
{
cloud_close_endpoint(ctx->cloud_ep);
cloud_store_deinit(&ctx->store);
cloud_store_initialize(&ctx->store);
cloud_manager_stop(ctx);
if (data->auth_provider && data->auth_provider_len) {
cloud_set_string(&ctx->store.auth_provider, data->auth_provider,
......@@ -269,7 +269,7 @@ oc_cloud_manager_stop(oc_cloud_context_t *ctx)
oc_remove_delayed_callback(ctx, start_manager);
cloud_rd_deinit(ctx);
cloud_manager_stop(ctx);
cloud_store_deinit(&ctx->store);
cloud_store_initialize(&ctx->store);
cloud_close_endpoint(ctx->cloud_ep);
ctx->cloud_manager = false;
return 0;
......@@ -311,7 +311,7 @@ oc_cloud_shutdown(void)
if (ctx) {
cloud_rd_deinit(ctx);
cloud_manager_stop(ctx);
cloud_store_initialize(&ctx->store);
cloud_store_deinit(&ctx->store);
cloud_close_endpoint(ctx->cloud_ep);
oc_free_endpoint(ctx->cloud_ep);
oc_memb_free(&cloud_context_pool, ctx);
......
......@@ -63,7 +63,6 @@ cloud_response(oc_cloud_context_t *ctx)
(oc_string(ctx->store.ci_server) ? oc_string(ctx->store.ci_server) : ""));
oc_rep_set_text_string(
root, sid, (oc_string(ctx->store.sid) ? oc_string(ctx->store.sid) : ""));
oc_rep_set_text_string(root, at, "");
oc_rep_set_int(root, clec, (int)ctx->last_error);
const char *cps = cps_to_str(ctx->cps);
......@@ -92,12 +91,14 @@ get_cloud(oc_request_t *request, oc_interface_mask_t interface, void *user_data)
static bool
cloud_update_from_request(oc_cloud_context_t *ctx, oc_request_t *request)
{
uint8_t required = 0;
bool changed = false;
cloud_conf_update_t data;
memset(&data, 0, sizeof(data));
if (oc_rep_get_string(request->request_payload, OC_RSRVD_ACCESSTOKEN,
&data.access_token, &data.access_token_len)) {
required |= 0x01;
changed = true;
}
......@@ -108,17 +109,23 @@ cloud_update_from_request(oc_cloud_context_t *ctx, oc_request_t *request)
if (oc_rep_get_string(request->request_payload, OC_RSRVD_CISERVER,
&data.ci_server, &data.ci_server_len)) {
required |= 0x02;
changed = true;
}
// OCF 2.0 spec version added sid property.
if (oc_rep_get_string(request->request_payload, OC_RSRVD_SERVERID, &data.sid,
&data.sid_len)) {
required |= 0x04;
changed = true;
}
if (changed) {
cloud_update_by_resource(ctx, &data);
if (required == 7) {
cloud_update_by_resource(ctx, &data);
} else {
changed = false;
}
}
return changed;
......@@ -158,7 +165,7 @@ post_cloud(oc_request_t *request, oc_interface_mask_t interface,
bool changed = cloud_update_from_request(ctx, request);
cloud_response(ctx);
oc_send_response(request,
changed ? OC_STATUS_CHANGED : OC_STATUS_NOT_MODIFIED);
changed ? OC_STATUS_CHANGED : OC_STATUS_BAD_REQUEST);
}
void
......
......@@ -206,7 +206,7 @@ cloud_store_decode(oc_rep_t *rep, oc_cloud_store_t *store)
}
void
cloud_store_initialize(oc_cloud_store_t *store)
cloud_store_deinit(oc_cloud_store_t *store)
{
cloud_set_string(&store->ci_server, NULL, 0);
cloud_set_string(&store->auth_provider, NULL, 0);
......@@ -266,7 +266,7 @@ cloud_store_load_internal(const char *store_name, oc_cloud_store_t *store)
}
void
cloud_store_deinit(oc_cloud_store_t *store)
cloud_store_initialize(oc_cloud_store_t *store)
{
cloud_set_string(&store->ci_server, "coaps+tcp://127.0.0.1", 21);
cloud_set_string(&store->auth_provider, NULL, 0);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment