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/07/18 20:54:08 UTC

[5/5] incubator-mynewt-core git commit: MYNEWT 266 - newtmgr over BLE(API Changes)

MYNEWT 266 - newtmgr over BLE(API Changes)

- Decreasing number of mbufs and reducing stack size
- Adapting newtmgr BLE to API changes


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/ab33b2be
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/ab33b2be
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/ab33b2be

Branch: refs/heads/develop
Commit: ab33b2bed53fd5948241b80be48ca10e8bbe32e2
Parents: 2350723
Author: Vipul Rahane <vi...@runtime.io>
Authored: Mon Jul 18 13:27:01 2016 -0700
Committer: Vipul Rahane <vi...@runtime.io>
Committed: Mon Jul 18 13:27:01 2016 -0700

----------------------------------------------------------------------
 apps/bleprph/src/main.c                         | 15 ++++---
 .../transport/ble/include/nmgrble/newtmgr_ble.h |  6 ++-
 libs/newtmgr/transport/ble/src/newtmgr_ble.c    | 41 +++++++++++++++++---
 3 files changed, 50 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ab33b2be/apps/bleprph/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bleprph/src/main.c b/apps/bleprph/src/main.c
index f7ccf82..946e227 100755
--- a/apps/bleprph/src/main.c
+++ b/apps/bleprph/src/main.c
@@ -56,7 +56,7 @@
 #include "bleprph.h"
 
 /** Mbuf settings. */
-#define MBUF_NUM_MBUFS      (24)
+#define MBUF_NUM_MBUFS      (12)
 #define MBUF_BUF_SIZE       OS_ALIGN(BLE_MBUF_PAYLOAD_SIZE, 4)
 #define MBUF_MEMBLOCK_SIZE  (MBUF_BUF_SIZE + BLE_MBUF_MEMBLOCK_OVERHEAD)
 #define MBUF_MEMPOOL_SIZE   OS_MEMPOOL_SIZE(MBUF_NUM_MBUFS, MBUF_MEMBLOCK_SIZE)
@@ -74,10 +74,10 @@ struct log bleprph_log;
 
 /** bleprph task settings. */
 #define BLEPRPH_TASK_PRIO           1
-#define BLEPRPH_STACK_SIZE          (OS_STACK_ALIGN(512))
+#define BLEPRPH_STACK_SIZE          (OS_STACK_ALIGN(336))
 
 #define NEWTMGR_TASK_PRIO (4)
-#define NEWTMGR_TASK_STACK_SIZE (OS_STACK_ALIGN(1024))
+#define NEWTMGR_TASK_STACK_SIZE (OS_STACK_ALIGN(512))
 os_stack_t newtmgr_stack[NEWTMGR_TASK_STACK_SIZE];
 
 struct os_eventq bleprph_evq;
@@ -392,6 +392,10 @@ main(void)
     rc = gatt_svr_init(&cfg);
     assert(rc == 0);
 
+    /* Nmgr ble GATT server initialization */
+    rc = nmgr_ble_gatt_svr_init(&bleprph_evq, &cfg);
+    assert(rc == 0);
+
     /* Initialize eventq */
     os_eventq_init(&bleprph_evq);
 
@@ -421,8 +425,9 @@ main(void)
     rc = ble_svc_gap_device_name_set("nimble-bleprph");
     assert(rc == 0);
 
-    /* Register nmgr ble GATT service and characteristic */
-    nmgr_ble_gatt_svr_init(&bleprph_evq);
+    /* Nmgr ble GATT server initialization */
+    rc = nmgr_ble_svc_register();
+    assert(rc == 0);
 
     /* Start the OS */
     os_start();

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ab33b2be/libs/newtmgr/transport/ble/include/nmgrble/newtmgr_ble.h
----------------------------------------------------------------------
diff --git a/libs/newtmgr/transport/ble/include/nmgrble/newtmgr_ble.h b/libs/newtmgr/transport/ble/include/nmgrble/newtmgr_ble.h
index 5bbd677..937b21d 100644
--- a/libs/newtmgr/transport/ble/include/nmgrble/newtmgr_ble.h
+++ b/libs/newtmgr/transport/ble/include/nmgrble/newtmgr_ble.h
@@ -22,7 +22,9 @@
 
 int
 nmgr_ble_proc_mq_evt(struct os_event *ev);
-void
-nmgr_ble_gatt_svr_init(struct os_eventq *evq);
+int
+nmgr_ble_gatt_svr_init(struct os_eventq *evq, struct ble_hs_cfg *cfg);
+int
+nmgr_ble_svc_register(void);
 
 #endif /* _NETMGR_H */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ab33b2be/libs/newtmgr/transport/ble/src/newtmgr_ble.c
----------------------------------------------------------------------
diff --git a/libs/newtmgr/transport/ble/src/newtmgr_ble.c b/libs/newtmgr/transport/ble/src/newtmgr_ble.c
index 6185aca..e618593 100644
--- a/libs/newtmgr/transport/ble/src/newtmgr_ble.c
+++ b/libs/newtmgr/transport/ble/src/newtmgr_ble.c
@@ -117,6 +117,14 @@ err:
     return BLE_ATT_ERR_UNLIKELY;
 }
 
+/**
+ * Nmgr ble process mqueue event
+ * Gets an event from the nmgr mqueue and does a notify with the response
+ *
+ * @param eventq
+ * @return 0 on success; non-zero on failure
+ */
+
 int
 nmgr_ble_proc_mq_evt(struct os_event *ev)
 {
@@ -174,21 +182,44 @@ err:
     return (rc);
 }
 
-void
-nmgr_ble_gatt_svr_init(struct os_eventq *evq)
+/**
+ * Nmgr ble GATT server initialization
+ *
+ * @param eventq
+ * @return 0 on success; non-zero on failure
+ */
+int
+nmgr_ble_gatt_svr_init(struct os_eventq *evq, struct ble_hs_cfg *cfg)
 {
     int rc;
 
     assert(evq != NULL);
 
-    rc = ble_gatts_register_svcs(gatt_svr_svcs, NULL, NULL);
-    assert(rc == 0);
+    rc = ble_gatts_count_cfg(gatt_svr_svcs, cfg);
+    if (rc != 0) {
+        goto err;
+    }
 
     app_evq = evq;
 
     os_mqueue_init(&ble_nmgr_mq, &ble_nmgr_mq);
 
-    nmgr_transport_init(&ble_nt, &nmgr_ble_out);
+    rc = nmgr_transport_init(&ble_nt, &nmgr_ble_out);
 
+err:
+    return rc;
 }
 
+/**
+ * Register nmgr service
+ *
+ * @return 0 on success; non-zero on failure
+ */
+int
+nmgr_ble_svc_register(void) {
+
+    int rc;
+    rc = ble_gatts_register_svcs(gatt_svr_svcs, NULL, NULL);
+    return rc;
+
+}