You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by we...@apache.org on 2015/11/05 02:30:37 UTC
incubator-mynewt-larva git commit: Move bletest references out of
host code and put it bletest project directory where they belong. If we are
building for sim, dont include transport references
Repository: incubator-mynewt-larva
Updated Branches:
refs/heads/master 93fc8e306 -> 7c50b189e
Move bletest references out of host code and put it bletest project directory where they belong. If we are building for sim, dont include transport references
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/7c50b189
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/7c50b189
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/7c50b189
Branch: refs/heads/master
Commit: 7c50b189ec34453dd60e9537ab34b52964311169
Parents: 93fc8e3
Author: Willam San Filippo <wi...@micosa.io>
Authored: Wed Nov 4 17:28:04 2015 -0800
Committer: Willam San Filippo <wi...@micosa.io>
Committed: Wed Nov 4 17:28:09 2015 -0800
----------------------------------------------------------------------
net/nimble/host/src/host_hci.c | 29 ++++-----------------
project/bletest/src/main.c | 51 +++++++++++++++++++++++++++++++++++++
2 files changed, 56 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/7c50b189/net/nimble/host/src/host_hci.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/host_hci.c b/net/nimble/host/src/host_hci.c
index 2148163..a52ffbd 100644
--- a/net/nimble/host/src/host_hci.c
+++ b/net/nimble/host/src/host_hci.c
@@ -52,18 +52,15 @@ struct host_hci_stats
struct host_hci_stats g_host_hci_stats;
-
-/* Callout for timer */
-extern void bletest_execute(void);
-struct os_callout_func g_ble_host_hci_timer;
-
-#if 0
static int
host_hci_cmd_send(uint8_t *cmdbuf)
{
+#ifdef ARCH_sim
+ return 0;
+#else
return ble_hci_transport_host_cmd_send(cmdbuf);
-}
#endif
+}
static int
host_hci_le_cmd_send(uint16_t ocf, uint8_t len, void *cmddata)
@@ -81,7 +78,7 @@ host_hci_le_cmd_send(uint16_t ocf, uint8_t len, void *cmddata)
if (len) {
memcpy(cmd + BLE_HCI_CMD_HDR_LEN, cmddata, len);
}
- //rc = host_hci_cmd_send(cmd);
+ rc = host_hci_cmd_send(cmd);
}
return rc;
@@ -416,23 +413,11 @@ ble_hci_transport_ctlr_event_send(uint8_t *hci_ev)
}
void
-host_hci_timer_cb(void *arg)
-{
- /* Call the bletest code */
- //bletest_execute();
-
- /* Re-start the timer */
- //os_callout_reset(&g_ble_host_hci_timer.cf_c, OS_TICKS_PER_SEC);
-}
-
-void
host_hci_task(void *arg)
{
struct os_event *ev;
struct os_callout_func *cf;
- host_hci_timer_cb(NULL);
-
while (1) {
ev = os_eventq_get(&g_ble_host_hci_evq);
switch (ev->ev_type) {
@@ -524,10 +509,6 @@ host_hci_init(void)
"HCIOsEventPool");
assert(rc == 0);
- /* Initialize the host timer */
- os_callout_func_init(&g_ble_host_hci_timer, &g_ble_host_hci_evq,
- host_hci_timer_cb, NULL);
-
/* Initialize eventq */
os_eventq_init(&g_ble_host_hci_evq);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/7c50b189/project/bletest/src/main.c
----------------------------------------------------------------------
diff --git a/project/bletest/src/main.c b/project/bletest/src/main.c
index a47c263..748e7ee 100755
--- a/project/bletest/src/main.c
+++ b/project/bletest/src/main.c
@@ -75,8 +75,15 @@ os_membuf_t g_mbuf_buffer[MBUF_MEMPOOL_SIZE];
#define BLETEST_CFG_SCAN_TYPE (BLE_HCI_SCAN_TYPE_PASSIVE)
#define BLETEST_CFG_SCAN_FILT_POLICY (BLE_HCI_SCAN_FILT_USE_WL)
+/* BLETEST variables */
+#define BLETEST_STACK_SIZE (64)
+#define BLETEST_TASK_PRIO (HOST_TASK_PRIO + 1)
uint32_t g_next_os_time;
int g_bletest_state;
+struct os_eventq g_bletest_evq;
+struct os_callout_func g_bletest_timer;
+struct os_task bletest_task;
+os_stack_t bletest_stack[BLETEST_STACK_SIZE];
void
bletest_inc_adv_pkt_num(void)
@@ -290,6 +297,46 @@ bletest_execute(void)
#endif
}
+void
+bletest_timer_cb(void *arg)
+{
+ /* Call the bletest code */
+ bletest_execute();
+
+ /* Re-start the timer */
+ os_callout_reset(&g_bletest_timer.cf_c, OS_TICKS_PER_SEC);
+}
+
+void
+bletest_task_handler(void *arg)
+{
+ struct os_event *ev;
+ struct os_callout_func *cf;
+
+ /* Initialize the host timer */
+ os_callout_func_init(&g_bletest_timer, &g_bletest_evq, bletest_timer_cb,
+ NULL);
+
+ /* Initialize eventq */
+ os_eventq_init(&g_bletest_evq);
+
+ bletest_timer_cb(NULL);
+
+ while (1) {
+ ev = os_eventq_get(&g_bletest_evq);
+ switch (ev->ev_type) {
+ case OS_EVENT_T_TIMER:
+ cf = (struct os_callout_func *)ev;
+ assert(cf->cf_func);
+ cf->cf_func(cf->cf_arg);
+ break;
+ default:
+ assert(0);
+ break;
+ }
+ }
+}
+
/**
* init_tasks
*
@@ -304,6 +351,10 @@ init_tasks(void)
os_task_init(&host_task, "host", host_task_handler, NULL, HOST_TASK_PRIO,
OS_WAIT_FOREVER, host_stack, HOST_STACK_SIZE);
+ os_task_init(&bletest_task, "bletest", bletest_task_handler, NULL,
+ BLETEST_TASK_PRIO, OS_WAIT_FOREVER, bletest_stack,
+ BLETEST_STACK_SIZE);
+
tasks_initialized = 1;
return 0;