You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2016/11/07 22:23:09 UTC
[1/4] incubator-mynewt-core git commit: bleprph_oic;
use new os_eventq mechanism.
Repository: incubator-mynewt-core
Updated Branches:
refs/heads/develop acd26632d -> fcc53ee44
bleprph_oic; use new os_eventq mechanism.
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/c55ab97b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/c55ab97b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/c55ab97b
Branch: refs/heads/develop
Commit: c55ab97b6a0c3c64b13a58588626c711486cec8f
Parents: acd2663
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Mon Nov 7 14:16:58 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Mon Nov 7 14:16:58 2016 -0800
----------------------------------------------------------------------
apps/bleprph_oic/src/main.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c55ab97b/apps/bleprph_oic/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bleprph_oic/src/main.c b/apps/bleprph_oic/src/main.c
index 31e9009..72e2f5e 100755
--- a/apps/bleprph_oic/src/main.c
+++ b/apps/bleprph_oic/src/main.c
@@ -28,6 +28,7 @@
#include "hal/hal_gpio.h"
#include "console/console.h"
#include "imgmgr/imgmgr.h"
+#include "mgmt/mgmt.h"
/* BLE */
#include "nimble/ble.h"
@@ -46,6 +47,10 @@ struct log bleprph_log;
#define BLEPRPH_TASK_PRIO 1
#define BLEPRPH_STACK_SIZE (OS_STACK_ALIGN(336))
+static struct os_eventq bleprph_evq;
+static struct os_task bleprph_task;
+static os_stack_t bleprph_stack[BLEPRPH_STACK_SIZE];
+
static int bleprph_gap_event(struct ble_gap_event *event, void *arg);
/**
@@ -243,6 +248,17 @@ bleprph_on_sync(void)
bleprph_advertise();
}
+/*
+ * Event loop for the main bleprph task.
+ */
+static void
+bleprph_task_handler(void *unused)
+{
+ while (1) {
+ os_eventq_run(&bleprph_evq);
+ }
+}
+
/**
* main
*
@@ -269,6 +285,19 @@ main(void)
/* Initialize the NimBLE host configuration. */
log_register("ble_hs", &ble_hs_log, &log_console_handler, NULL, LOG_SYSLEVEL);
+ os_eventq_init(&bleprph_evq);
+ os_eventq_dflt_set(&bleprph_evq);
+
+ /*
+ * Create the bleprph task. All omgr and NimBLE host operations are
+ * performed in this task.
+ */
+ os_task_init(&bleprph_task, "bleprph", bleprph_task_handler,
+ NULL, BLEPRPH_TASK_PRIO, OS_WAIT_FOREVER,
+ bleprph_stack, BLEPRPH_STACK_SIZE);
+ mgmt_evq_set(&bleprph_evq);
+ ble_hs_evq_set(&bleprph_evq);
+
ble_coap_gatt_srv_init();
ble_hs_cfg.reset_cb = bleprph_on_reset;
ble_hs_cfg.sync_cb = bleprph_on_sync;
[4/4] incubator-mynewt-core git commit: slinky_oic;
queue the start event for oicmgr.
Posted by ma...@apache.org.
slinky_oic; queue the start event for oicmgr.
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/fcc53ee4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/fcc53ee4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/fcc53ee4
Branch: refs/heads/develop
Commit: fcc53ee4476c0c854281a0207e1136bb77c562be
Parents: 1b1a1e7
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Mon Nov 7 14:22:18 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Mon Nov 7 14:22:18 2016 -0800
----------------------------------------------------------------------
apps/slinky_oic/src/main.c | 2 ++
1 file changed, 2 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fcc53ee4/apps/slinky_oic/src/main.c
----------------------------------------------------------------------
diff --git a/apps/slinky_oic/src/main.c b/apps/slinky_oic/src/main.c
index 3f31f04..afadd33 100755
--- a/apps/slinky_oic/src/main.c
+++ b/apps/slinky_oic/src/main.c
@@ -33,6 +33,7 @@
#endif
#include <bootutil/image.h>
#include <imgmgr/imgmgr.h>
+#include <mgmt/mgmt.h>
#include <assert.h>
#include <string.h>
#include <json/json.h>
@@ -256,6 +257,7 @@ init_tasks(void)
*/
os_eventq_init(&slinky_oic_evq);
os_eventq_dflt_set(&slinky_oic_evq);
+ mgmt_evq_set(&slinky_oic_evq);
}
/**
[3/4] incubator-mynewt-core git commit: oicmgr;
update to use the new os_eventq() stuff
Posted by ma...@apache.org.
oicmgr; update to use the new os_eventq() stuff
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/1b1a1e75
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/1b1a1e75
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/1b1a1e75
Branch: refs/heads/develop
Commit: 1b1a1e7598e475d17564bd1444dd4e6a8ed68ed4
Parents: da398bd
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Mon Nov 7 14:21:38 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Mon Nov 7 14:21:38 2016 -0800
----------------------------------------------------------------------
mgmt/oicmgr/src/oicmgr.c | 62 ++++++++++++++-----------------------------
1 file changed, 20 insertions(+), 42 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1b1a1e75/mgmt/oicmgr/src/oicmgr.c
----------------------------------------------------------------------
diff --git a/mgmt/oicmgr/src/oicmgr.c b/mgmt/oicmgr/src/oicmgr.c
index eccec6b..32562d9 100644
--- a/mgmt/oicmgr/src/oicmgr.c
+++ b/mgmt/oicmgr/src/oicmgr.c
@@ -29,10 +29,6 @@
#include <mgmt/mgmt.h>
#include <nmgr_os/nmgr_os.h>
-#if (MYNEWT_VAL(OC_TRANSPORT_GATT) == 1)
-#include "host/ble_hs.h"
-#endif
-
#include <cborattr/cborattr.h>
#include <tinycbor/cbor.h>
#include <tinycbor/cbor_buf_writer.h>
@@ -45,22 +41,18 @@ struct omgr_cbuf {
};
struct omgr_state {
- struct os_eventq os_evq;
- struct os_event os_oc_event;
+ struct os_eventq *os_evq;
+ struct os_event os_event;
struct os_callout os_oc_timer;
struct os_task os_task;
struct omgr_cbuf os_cbuf; /* CBOR buffer for NMGR task */
};
static void omgr_event_start(struct os_event *ev);
-static void omgr_event_oc_ev(struct os_event *ev);
+static void omgr_process_oc_event(struct os_event *ev);
static struct omgr_state omgr_state = {
- .os_oc_event.ev_cb = omgr_event_oc_ev,
-};
-
-static struct os_event omgr_ev_start = {
- .ev_cb = omgr_event_start,
+ .os_event.ev_cb = omgr_event_start,
};
static void omgr_oic_get(oc_request_t *request, oc_interface_mask_t interface);
@@ -69,18 +61,17 @@ static void omgr_oic_put(oc_request_t *request, oc_interface_mask_t interface);
struct os_eventq *
mgmt_evq_get(void)
{
- os_eventq_ensure(&omgr_state.os_evq;, NULL);
- return &omgr_state.os_evq;
+ return omgr_state.os_evq;
}
void
-omgr_evq_set(struct os_eventq *evq)
+mgmt_evq_set(struct os_eventq *evq)
{
- os_eventq_designate(&omgr_state.os_evq, evq, NULL);
+ os_eventq_designate(&omgr_state.os_evq, evq, &omgr_state.os_event);
}
static const struct mgmt_handler *
-omgr_oic_find_handler(const char *q, int qlen)
+omgr_find_handler(const char *q, int qlen)
{
char id_str[8];
int grp = -1;
@@ -123,7 +114,7 @@ omgr_oic_op(oc_request_t *req, oc_interface_mask_t mask, int isset)
goto bad_req;
}
- handler = omgr_oic_find_handler(req->query, req->query_len);
+ handler = omgr_find_handler(req->query, req->query_len);
if (!handler) {
goto bad_req;
}
@@ -234,52 +225,39 @@ oc_signal_main_loop(void)
{
struct omgr_state *o = &omgr_state;
- os_childq_put(&o->os_cq, &o->os_oc_event);
+ assert(o->os_evq); /* Must call mgmt_evq_set() first. */
+ os_eventq_put(o->os_evq, &o->os_event);
}
static void
-omgr_oic_process_oc_event(struct os_event *ev)
+omgr_process_oc_event(struct os_event *ev)
{
struct omgr_state *o = &omgr_state;
os_time_t next_event;
-#if MYNEWT_VAL(OC_TRANSPORT_GATT)
- int rc;
-
- rc = ble_hs_start();
- assert(rc == 0);
-#endif
next_event = oc_main_poll();
if (next_event) {
- os_callout_reset(&o->os_oc_timer.cf_c, next_event - os_time_get());
+ os_callout_reset(&o->os_oc_timer, next_event - os_time_get());
} else {
- os_callout_stop(&o->os_oc_timer.cf_c);
+ os_callout_stop(&o->os_oc_timer);
}
}
static void
-omgr_oic_event_start(struct os_event *ev)
-{
- oc_main_init((oc_handler_t *)&omgr_oc_handler);
- os_callout_init(&omgr_state.os_oc_timer, mgmt_evq_get(),
- omgr_oic_process_oc_event, NULL);
-}
-
-static void
-omgr_oic_event_oc_ev(struct os_event *ev)
+omgr_event_start(struct os_event *ev)
{
- omgr_oic_process_oc_event(NULL);
+ struct omgr_state *o = &omgr_state;
+ os_eventq_ensure(&o->os_evq, NULL);
+ o->os_event.ev_cb = omgr_process_oc_event;
+ os_callout_init(&o->os_oc_timer, mgmt_evq_get(), omgr_process_oc_event,
+ NULL);
}
int
oicmgr_init(void)
{
- struct omgr_state *o = &omgr_state;
int rc;
- os_childq_init(&o->os_cq);
- o->os_cq.cq_ev_cb = omgr_oic_handle_event;
-
rc = nmgr_os_groups_register();
if (rc != 0) {
goto err;
[2/4] incubator-mynewt-core git commit: newtmgr/mgmt;
rename nmgr_evq_set() -> mgmt_evq_set()
Posted by ma...@apache.org.
newtmgr/mgmt; rename nmgr_evq_set() -> mgmt_evq_set()
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/da398bd2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/da398bd2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/da398bd2
Branch: refs/heads/develop
Commit: da398bd2246bcae923817857f430b39c31f5fe53
Parents: c55ab97
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Mon Nov 7 14:21:06 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Mon Nov 7 14:21:06 2016 -0800
----------------------------------------------------------------------
mgmt/mgmt/include/mgmt/mgmt.h | 1 +
mgmt/newtmgr/include/newtmgr/newtmgr.h | 1 -
mgmt/newtmgr/src/newtmgr.c | 2 +-
3 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/da398bd2/mgmt/mgmt/include/mgmt/mgmt.h
----------------------------------------------------------------------
diff --git a/mgmt/mgmt/include/mgmt/mgmt.h b/mgmt/mgmt/include/mgmt/mgmt.h
index bd3354b..9856405 100644
--- a/mgmt/mgmt/include/mgmt/mgmt.h
+++ b/mgmt/mgmt/include/mgmt/mgmt.h
@@ -89,6 +89,7 @@ const struct mgmt_handler *mgmt_find_handler(uint16_t group_id,
uint16_t handler_id);
struct os_eventq *mgmt_evq_get(void);
+void mgmt_evq_set(struct os_eventq *evq);
#ifdef __cplusplus
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/da398bd2/mgmt/newtmgr/include/newtmgr/newtmgr.h
----------------------------------------------------------------------
diff --git a/mgmt/newtmgr/include/newtmgr/newtmgr.h b/mgmt/newtmgr/include/newtmgr/newtmgr.h
index 9f87655..2349578 100644
--- a/mgmt/newtmgr/include/newtmgr/newtmgr.h
+++ b/mgmt/newtmgr/include/newtmgr/newtmgr.h
@@ -68,7 +68,6 @@ struct nmgr_transport {
nmgr_transport_get_mtu_func_t nt_get_mtu;
};
-void nmgr_evq_set(struct os_eventq *evq);
void nmgr_event_put(struct os_event *ev);
int nmgr_task_init(void);
int nmgr_transport_init(struct nmgr_transport *nt,
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/da398bd2/mgmt/newtmgr/src/newtmgr.c
----------------------------------------------------------------------
diff --git a/mgmt/newtmgr/src/newtmgr.c b/mgmt/newtmgr/src/newtmgr.c
index bd7474d..242b188 100644
--- a/mgmt/newtmgr/src/newtmgr.c
+++ b/mgmt/newtmgr/src/newtmgr.c
@@ -55,7 +55,7 @@ mgmt_evq_get(void)
}
void
-nmgr_evq_set(struct os_eventq *evq)
+mgmt_evq_set(struct os_eventq *evq)
{
os_eventq_designate(&nmgr_evq, evq, NULL);
}