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/27 23:35:27 UTC
[3/6] incubator-mynewt-core git commit: BLEuart app changes and host
fix
BLEuart app changes and host fix
- Fix newtmgr initialization
- Ensure data packets are in a single mbuf in the nimBLE host
- Prevent double free on the last fragment
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/ac78fde5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/ac78fde5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/ac78fde5
Branch: refs/heads/develop
Commit: ac78fde543700fc2ab7ec55b67bb98e15ee4f4b8
Parents: 72dd7d9
Author: Vipul Rahane <vi...@runtime.io>
Authored: Wed Jul 27 15:55:26 2016 -0700
Committer: Vipul Rahane <vi...@runtime.io>
Committed: Wed Jul 27 15:55:26 2016 -0700
----------------------------------------------------------------------
apps/bleuart/src/main.c | 19 +++++++++++++++----
net/nimble/host/src/host_hci.c | 9 ++++++++-
2 files changed, 23 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ac78fde5/apps/bleuart/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bleuart/src/main.c b/apps/bleuart/src/main.c
index e27ad13..24f1a3b 100755
--- a/apps/bleuart/src/main.c
+++ b/apps/bleuart/src/main.c
@@ -129,6 +129,16 @@ bleuart_advertise(void)
return;
}
+ memset(&fields, 0, sizeof fields);
+ fields.name = (uint8_t *)ble_svc_gap_device_name();
+ fields.name_len = strlen((char *)fields.name);
+ fields.name_is_complete = 1;
+
+ rc = ble_gap_adv_rsp_set_fields(&fields);
+ if (rc != 0) {
+ return;
+ }
+
/* Begin advertising. */
memset(&adv_params, 0, sizeof adv_params);
adv_params.conn_mode = BLE_GAP_CONN_MODE_UND;
@@ -303,16 +313,17 @@ main(void)
rc = ble_svc_gatt_init(&cfg);
assert(rc == 0);
- /* Nmgr ble GATT server initialization */
- rc = nmgr_ble_gatt_svr_init(&bleuart_evq, &cfg);
- assert(rc == 0);
-
rc = bleuart_gatt_svr_init(&cfg);
assert(rc == 0);
/* Initialize eventq */
os_eventq_init(&bleuart_evq);
+ /* Nmgr ble GATT server initialization */
+ rc = nmgr_ble_gatt_svr_init(&bleuart_evq, &cfg);
+ assert(rc == 0);
+
+
rc = ble_hs_init(&bleuart_evq, &cfg);
assert(rc == 0);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ac78fde5/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 887c6fa..44d83b3 100644
--- a/net/nimble/host/src/host_hci.c
+++ b/net/nimble/host/src/host_hci.c
@@ -767,8 +767,8 @@ host_hci_data_hdr_prepend(struct os_mbuf *om, uint16_t handle, uint8_t pb_flag)
if (om2 == NULL) {
return NULL;
}
- BLE_HS_DBG_ASSERT(om2 == om);
+ om = om2;
om = os_mbuf_pullup(om, sizeof hci_hdr);
if (om == NULL) {
return NULL;
@@ -869,6 +869,7 @@ host_hci_data_tx(struct ble_hs_conn *connection, struct os_mbuf **txom)
case BLE_HS_EDONE:
/* This is the final fragment. */
done = 1;
+ om = NULL;
break;
case BLE_HS_EAGAIN:
@@ -890,6 +891,12 @@ host_hci_data_tx(struct ble_hs_conn *connection, struct os_mbuf **txom)
ble_hs_log_mbuf(frag);
BLE_HS_LOG(DEBUG, "\n");
+ /* Next fragment */
+ frag = os_mbuf_pullup(frag, OS_MBUF_PKTLEN(frag));
+ if (frag == NULL) {
+ rc = BLE_HS_ENOMEM;
+ goto err;
+ }
rc = ble_hs_tx_data(frag);
if (rc != 0) {
goto err;