You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/11/10 22:39:13 UTC
[06/50] [abbrv] incubator-mynewt-core git commit: bleprph_oic;
use new os_eventq mechanism.
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/master
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;