oic; use os_events to trigger oc_network_events handling.
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/9f291c69 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/9f291c69 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/9f291c69 Branch: refs/heads/develop Commit: 9f291c696f3dc3628bf0431379562d414684a809 Parents: 91419fd Author: Marko Kiiskila <ma...@runtime.io> Authored: Thu Nov 17 12:46:25 2016 -0800 Committer: Marko Kiiskila <ma...@runtime.io> Committed: Mon Nov 21 17:15:48 2016 -0800 ---------------------------------------------------------------------- net/oic/include/oic/oc_network_events.h | 2 -- net/oic/src/api/oc_buffer.c | 1 + net/oic/src/api/oc_network_events.c | 44 +++++++++++++--------------- net/oic/src/api/oc_ri.c | 2 -- 4 files changed, 22 insertions(+), 27 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9f291c69/net/oic/include/oic/oc_network_events.h ---------------------------------------------------------------------- diff --git a/net/oic/include/oic/oc_network_events.h b/net/oic/include/oic/oc_network_events.h index d0f5d41..fb557c0 100644 --- a/net/oic/include/oic/oc_network_events.h +++ b/net/oic/include/oic/oc_network_events.h @@ -24,8 +24,6 @@ extern "C" { #endif -OC_PROCESS_NAME(oc_network_events); - typedef struct oc_message_s oc_message_t; void oc_network_event(oc_message_t *message); http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9f291c69/net/oic/src/api/oc_buffer.c ---------------------------------------------------------------------- diff --git a/net/oic/src/api/oc_buffer.c b/net/oic/src/api/oc_buffer.c index 4661529..f5bc70d 100644 --- a/net/oic/src/api/oc_buffer.c +++ b/net/oic/src/api/oc_buffer.c @@ -71,6 +71,7 @@ oc_recv_message(oc_message_t *message) { oc_process_post(&message_buffer_handler, oc_events[INBOUND_NETWORK_EVENT], message); + oc_signal_main_loop(); } void http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9f291c69/net/oic/src/api/oc_network_events.c ---------------------------------------------------------------------- diff --git a/net/oic/src/api/oc_network_events.c b/net/oic/src/api/oc_network_events.c index 2149bd3..a472d54 100644 --- a/net/oic/src/api/oc_network_events.c +++ b/net/oic/src/api/oc_network_events.c @@ -14,44 +14,42 @@ // limitations under the License. */ +#include <os/os_eventq.h> + #include "oc_network_events.h" #include "oc_buffer.h" #include "port/oc_connectivity.h" #include "port/oc_signal_main_loop.h" +#include "port/mynewt/adaptor.h" #include "util/oc_list.h" OC_LIST(network_events); +static void oc_network_ev_process(struct os_event *ev); +static struct os_event oc_network_ev = { + .ev_cb = oc_network_ev_process +}; static void -oc_process_network_event(void) +oc_network_ev_process(struct os_event *ev) { - oc_network_event_handler_mutex_lock(); - oc_message_t *head = (oc_message_t *)oc_list_pop(network_events); - while (head != NULL) { - oc_recv_message(head); - head = oc_list_pop(network_events); - } - oc_network_event_handler_mutex_unlock(); -} + struct oc_message_s *head; -OC_PROCESS(oc_network_events, ""); -OC_PROCESS_THREAD(oc_network_events, ev, data) -{ - OC_PROCESS_POLLHANDLER(oc_process_network_event()); - OC_PROCESS_BEGIN(); - while (oc_process_is_running(&(oc_network_events))) { - OC_PROCESS_YIELD(); - } - OC_PROCESS_END(); + oc_network_event_handler_mutex_lock(); + head = (struct oc_message_s *)oc_list_pop(network_events); + while (head != NULL) { + oc_recv_message(head); + head = oc_list_pop(network_events); + } + oc_network_event_handler_mutex_unlock(); } void oc_network_event(oc_message_t *message) { - oc_network_event_handler_mutex_lock(); - oc_list_add(network_events, message); - oc_network_event_handler_mutex_unlock(); + oc_network_event_handler_mutex_lock(); + oc_list_add(network_events, message); + oc_network_event_handler_mutex_unlock(); - oc_process_poll(&(oc_network_events)); - oc_signal_main_loop(); + os_eventq_put(oc_evq_get(), &oc_network_ev); + oc_signal_main_loop(); } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9f291c69/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 c3c2772..09d49f7 100644 --- a/net/oic/src/api/oc_ri.c +++ b/net/oic/src/api/oc_ri.c @@ -198,8 +198,6 @@ start_processes(void) #ifdef OC_SECURITY oc_process_start(&oc_dtls_handler, NULL); #endif - - oc_process_start(&oc_network_events, NULL); } static void