Repository: incubator-mynewt-core Updated Branches: refs/heads/develop 4b17e1692 -> f85603717
oic; coap separate response support is now optional. Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/9d5dc272 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/9d5dc272 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/9d5dc272 Branch: refs/heads/develop Commit: 9d5dc2727589456f80de5a54a6fd7b47cec126e0 Parents: 0ae187a Author: Marko Kiiskila <[email protected]> Authored: Fri Jan 13 13:36:46 2017 -0800 Committer: Marko Kiiskila <[email protected]> Committed: Fri Jan 13 13:45:54 2017 -0800 ---------------------------------------------------------------------- net/oic/include/oic/oc_api.h | 2 ++ net/oic/src/api/oc_ri.c | 4 ++-- net/oic/src/api/oc_server_api.c | 9 +++++---- net/oic/src/messaging/coap/engine.c | 2 ++ net/oic/src/messaging/coap/observe.c | 4 ++++ net/oic/src/messaging/coap/oc_coap.h | 2 +- net/oic/src/messaging/coap/separate.c | 4 ++-- net/oic/src/messaging/coap/separate.h | 3 +++ net/oic/syscfg.yml | 4 ++++ 9 files changed, 25 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9d5dc272/net/oic/include/oic/oc_api.h ---------------------------------------------------------------------- diff --git a/net/oic/include/oic/oc_api.h b/net/oic/include/oic/oc_api.h index e62b1cb..78c8eb6 100644 --- a/net/oic/include/oic/oc_api.h +++ b/net/oic/include/oic/oc_api.h @@ -101,11 +101,13 @@ int oc_get_query_value(oc_request_t *request, const char *key, char **value); void oc_send_response(oc_request_t *request, oc_status_t response_code); void oc_ignore_request(oc_request_t *request); +#if MYNEWT_VAL(OC_SEPARATE_RESPONSES) void oc_indicate_separate_response(oc_request_t *request, oc_separate_response_t *response); void oc_set_separate_response_buffer(oc_separate_response_t *handle); void oc_send_separate_response(oc_separate_response_t *handle, oc_status_t response_code); +#endif int oc_notify_observers(oc_resource_t *resource); http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9d5dc272/net/oic/src/api/oc_ri.c ---------------------------------------------------------------------- diff --git a/net/oic/src/api/oc_ri.c b/net/oic/src/api/oc_ri.c index f1bce07..d6180a6 100644 --- a/net/oic/src/api/oc_ri.c +++ b/net/oic/src/api/oc_ri.c @@ -594,7 +594,7 @@ oc_ri_invoke_coap_entity_handler(struct coap_packet_rx *request, } #endif -#ifdef OC_SERVER +#if defined(OC_SERVER) && MYNEWT_VAL(OC_SEPARATE_RESPONSES) /* The presence of a separate response handle here indicates a * successful handling of the request by a slow resource. */ @@ -613,7 +613,7 @@ oc_ri_invoke_coap_entity_handler(struct coap_packet_rx *request, observe) == 1) response_obj.separate_response->active = 1; } else -#endif +#endif /* OC_SERVER && OC_SEPARATE_RESPONSES */ if (response_buffer.code == OC_IGNORE) { /* If the server-side logic chooses to reject a request, it sends * below a response code of IGNORE, which results in the messaging http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9d5dc272/net/oic/src/api/oc_server_api.c ---------------------------------------------------------------------- diff --git a/net/oic/src/api/oc_server_api.c b/net/oic/src/api/oc_server_api.c index f697f5c..61acdcd 100644 --- a/net/oic/src/api/oc_server_api.c +++ b/net/oic/src/api/oc_server_api.c @@ -216,19 +216,20 @@ oc_interate_query(oc_request_t *request, char **key, int *key_len, char **value, return 1; } -#if 0 /* XXXX fix this */ +#if MYNEWT_VAL(OC_SEPARATE_RESPONSES) void oc_indicate_separate_response(oc_request_t *request, oc_separate_response_t *response) { - request->response->separate_response = response; - oc_send_response(request, OC_STATUS_OK); + request->response->separate_response = response; + oc_send_response(request, OC_STATUS_OK); } void oc_set_separate_response_buffer(oc_separate_response_t *handle) { - oc_rep_new(handle->buffer, COAP_MAX_BLOCK_SIZE); // check + assert(handle->buffer); + oc_rep_new(handle->buffer); // check } void http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9d5dc272/net/oic/src/messaging/coap/engine.c ---------------------------------------------------------------------- diff --git a/net/oic/src/messaging/coap/engine.c b/net/oic/src/messaging/coap/engine.c index 456e292..b1cb8f0 100644 --- a/net/oic/src/messaging/coap/engine.c +++ b/net/oic/src/messaging/coap/engine.c @@ -311,7 +311,9 @@ coap_engine_init(void) coap_init_connection(); coap_transaction_init(); #ifdef OC_SERVER +#if MYNEWT_VAL(OC_SEPARATE_RESPONSES) coap_separate_init(); +#endif coap_observe_init(); #endif } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9d5dc272/net/oic/src/messaging/coap/observe.c ---------------------------------------------------------------------- diff --git a/net/oic/src/messaging/coap/observe.c b/net/oic/src/messaging/coap/observe.c index df79262..234b2da 100644 --- a/net/oic/src/messaging/coap/observe.c +++ b/net/oic/src/messaging/coap/observe.c @@ -236,6 +236,7 @@ coap_notify_observers(oc_resource_t *resource, memcmp(&obs->endpoint, endpoint, sizeof(oc_endpoint_t)) == 0)); obs = SLIST_NEXT(obs, next)) { num_observers = obs->resource->num_observers; +#if MYNEWT_VAL(OC_SEPARATE_RESPONSES) if (response.separate_response != NULL && response_buf->code == oc_status_code(OC_STATUS_OK)) { struct coap_packet_rx req[1]; @@ -256,6 +257,7 @@ coap_notify_observers(oc_resource_t *resource, response.separate_response->active = 1; } } else { +#endif /* OC_SEPARATE_RESPONSES */ OC_LOG_DEBUG("coap_notify_observers: notifying observer\n"); coap_transaction_t *transaction = NULL; if (response_buf && (transaction = coap_new_transaction( @@ -295,7 +297,9 @@ coap_notify_observers(oc_resource_t *resource, coap_clear_transaction(transaction); } } +#if MYNEWT_VAL(OC_SEPARATE_RESPONSES) } +#endif } if (m) { os_mbuf_free_chain(m); http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9d5dc272/net/oic/src/messaging/coap/oc_coap.h ---------------------------------------------------------------------- diff --git a/net/oic/src/messaging/coap/oc_coap.h b/net/oic/src/messaging/coap/oc_coap.h index 2654d98..e2ee243 100644 --- a/net/oic/src/messaging/coap/oc_coap.h +++ b/net/oic/src/messaging/coap/oc_coap.h @@ -26,7 +26,7 @@ extern "C" { typedef struct oc_separate_response { SLIST_HEAD(, coap_separate) requests; int active; - uint8_t buffer[COAP_MAX_BLOCK_SIZE]; + struct os_mbuf *buffer; } oc_separate_response_t; typedef struct oc_response_buffer { http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9d5dc272/net/oic/src/messaging/coap/separate.c ---------------------------------------------------------------------- diff --git a/net/oic/src/messaging/coap/separate.c b/net/oic/src/messaging/coap/separate.c index fe77106..f47b3a3 100644 --- a/net/oic/src/messaging/coap/separate.c +++ b/net/oic/src/messaging/coap/separate.c @@ -33,7 +33,7 @@ #include "config.h" -#ifdef OC_SERVER +#if defined(OC_SERVER) && MYNEWT_VAL(OC_SEPARATE_RESPONSES) #include <stdio.h> #include <string.h> @@ -160,4 +160,4 @@ coap_separate_init(void) os_mempool_init(&coap_separate_pool, MAX_NUM_CONCURRENT_REQUESTS, sizeof(coap_separate_t), coap_separate_area, "coap_sep"); } -#endif /* OC_SERVER */ +#endif /* OC_SERVER && OC_SEPARATE_RESPONSES */ http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9d5dc272/net/oic/src/messaging/coap/separate.h ---------------------------------------------------------------------- diff --git a/net/oic/src/messaging/coap/separate.h b/net/oic/src/messaging/coap/separate.h index 190e4ec..987ead9 100644 --- a/net/oic/src/messaging/coap/separate.h +++ b/net/oic/src/messaging/coap/separate.h @@ -41,6 +41,7 @@ extern "C" { #endif +#if MYNEWT_VAL(OC_SEPARATE_RESPONSES) /* OIC stack headers */ #include "oc_coap.h" #include "oic/oc_ri.h" @@ -75,6 +76,8 @@ void coap_separate_clear(oc_separate_response_t *separate_response, void coap_separate_init(void); +#endif + #ifdef __cplusplus } #endif http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9d5dc272/net/oic/syscfg.yml ---------------------------------------------------------------------- diff --git a/net/oic/syscfg.yml b/net/oic/syscfg.yml index c5dbfa2..3b7460a 100644 --- a/net/oic/syscfg.yml +++ b/net/oic/syscfg.yml @@ -62,6 +62,10 @@ syscfg.defs: description: 'Platform payload size' value: 256 + OC_SEPARATE_RESPONSES: + description: 'Support COAP delayed responses for slow resousrces.' + value: 1 + OC_LOGGING: description: 'Logging enabled' value: 0
