Skip to content

Commit

Permalink
fixup! Incremental query
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielius1922 committed Sep 22, 2023
1 parent 47e8901 commit 80acd1f
Show file tree
Hide file tree
Showing 8 changed files with 505 additions and 137 deletions.
86 changes: 35 additions & 51 deletions api/oc_client_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,15 +394,13 @@ oc_do_request(oc_method_t method, const char *uri,
return NULL;
}

bool status =
prepare_coap_request(cb, configure_request, configure_request_data);
if (status) {
status = dispatch_coap_request();
}
if (!status) {
if (!prepare_coap_request(cb, configure_request, configure_request_data)) {
oc_client_cb_free(cb);
return NULL;
}
if (!dispatch_coap_request()) {
return NULL;
}
if (timeout_seconds > 0) {
oc_set_delayed_callback(cb, oc_client_cb_remove_with_notify_timeout_async,
timeout_seconds);
Expand Down Expand Up @@ -484,8 +482,7 @@ oc_do_async_request_with_timeout(uint16_t timeout_seconds, oc_method_t method)
return false;
}

bool dispatch = dispatch_coap_request();
if (!dispatch) {
if (!dispatch_coap_request()) {
return false;
}

Expand Down Expand Up @@ -639,9 +636,13 @@ oc_do_ipv4_discovery(const char *query, oc_client_handler_t handler,
if (cb == NULL) {
return NULL;
}
if (!prepare_coap_request(cb, NULL, NULL)) {
oc_client_cb_free(cb);
return NULL;
}
cb->discovery = true;
if (prepare_coap_request(cb, NULL, NULL)) {
dispatch_coap_request();
if (!dispatch_coap_request()) {
return NULL;
}
return cb;
}
Expand All @@ -665,19 +666,15 @@ oc_do_ipv4_multicast(const char *uri, const char *query,
return NULL;
}

cb->multicast = true;

bool status = prepare_coap_request(cb, NULL, NULL);

if (status) {
status = dispatch_coap_request();
if (!prepare_coap_request(cb, NULL, NULL)) {
oc_client_cb_free(cb);
return NULL;
}

if (status) {
return cb;
cb->multicast = true;
if (!dispatch_coap_request()) {
return NULL;
}

return NULL;
return cb;
}
#endif /* OC_IPV4 */

Expand Down Expand Up @@ -709,25 +706,20 @@ multi_scope_ipv6_multicast(const oc_client_cb_t *cb4, uint8_t scope,

oc_client_cb_t *cb = oc_ri_alloc_client_cb(
uri, &mcast, OC_GET, query, client_handler, LOW_QOS, user_data);
if (cb == NULL) {
return false;
}
if (cb4 != NULL) {
cb->mid = cb4->mid;
memcpy(cb->token, cb4->token, cb4->token_len);
}

if (cb) {
if (cb4) {
cb->mid = cb4->mid;
memcpy(cb->token, cb4->token, cb4->token_len);
}
cb->multicast = true;
if (prepare_coap_request(cb, NULL, NULL) && dispatch_coap_request()) {
return true;
}

if (g_dispatch.transaction) {
coap_clear_transaction(g_dispatch.transaction);
g_dispatch.transaction = NULL;
}
if (!prepare_coap_request(cb, NULL, NULL)) {
oc_client_cb_free(cb);
g_dispatch.client_cb = NULL;
return false;
}
return false;
cb->multicast = true;
return dispatch_coap_request();
}

bool
Expand Down Expand Up @@ -775,28 +767,20 @@ dispatch_ip_discovery(const oc_client_cb_t *cb4, const char *query,

oc_client_cb_t *cb = oc_ri_alloc_client_cb(OCF_RES_URI, endpoint, OC_GET,
query, handler, qos, user_data);

if (cb == NULL) {
return false;
}
cb->discovery = true;
if (cb4) {
if (cb4 != NULL) {
cb->mid = cb4->mid;
memcpy(cb->token, cb4->token, cb4->token_len);
}

if (prepare_coap_request(cb, NULL, NULL) && dispatch_coap_request()) {
return true;
}

if (g_dispatch.transaction) {
coap_clear_transaction(g_dispatch.transaction);
g_dispatch.transaction = NULL;
if (!prepare_coap_request(cb, NULL, NULL)) {
oc_client_cb_free(cb);
return false;
}

oc_client_cb_free(cb);
g_dispatch.client_cb = NULL;
return false;
cb->discovery = true;
return dispatch_coap_request();
}

static bool
Expand Down
Loading

0 comments on commit 80acd1f

Please sign in to comment.