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/19 18:13:51 UTC
[2/2] incubator-mynewt-core git commit: blecent - Handle rx notify;
don't disconnect.
blecent - Handle rx notify; don't disconnect.
Prior to this change:
1. blecent disconnected immediately after subscribing to
notifications.
2. blecent did not do anything with incoming notifications /
indications.
Now:
1. blecent does not terminate the connection after subscription.
2. blecent logs a message for incoming notifications / indications.
The first change makes sense in light of the second change: if we
disconnect immediately after subscribing (and we don't bond), we will
never receive any notifications!
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/1f79ee28
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/1f79ee28
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/1f79ee28
Branch: refs/heads/develop
Commit: 1f79ee28288cdb4d585681c243728fc17a02a1ee
Parents: 245d516
Author: Christopher Collins <cc...@apache.org>
Authored: Tue Jul 19 11:10:14 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Jul 19 11:10:14 2016 -0700
----------------------------------------------------------------------
apps/blecent/src/main.c | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1f79ee28/apps/blecent/src/main.c
----------------------------------------------------------------------
diff --git a/apps/blecent/src/main.c b/apps/blecent/src/main.c
index f41a313..f4f11f4 100755
--- a/apps/blecent/src/main.c
+++ b/apps/blecent/src/main.c
@@ -127,13 +127,6 @@ blecent_on_subscribe(uint16_t conn_handle,
"attr_handle=%d\n",
error->status, conn_handle, attr->handle);
- /* Now that notifications have been enabled, we can terminate the
- * connection.
- */
- BLECENT_LOG(INFO, "Terminating the connection; conn_handle=%d\n",
- conn_handle);
- ble_gap_terminate(conn_handle, BLE_ERR_REM_USER_CONN_TERM);
-
return 0;
}
@@ -146,11 +139,8 @@ blecent_on_subscribe(uint16_t conn_handle,
*
* If the peer does not support a required service, characteristic, or
* descriptor, then the peer lied when it claimed support for the alert
- * notification service! When this happens, or if a GATT procedure fails, this
- * function immediately terminates the connection.
- *
- * When all three procedures have completed, the connection is terminated (this
- * happens in the subscribe callback, not in this function).
+ * notification service! When this happens, or if a GATT procedure fails,
+ * this function immediately terminates the connection.
*/
static void
blecent_read_write_subscribe(const struct peer *peer)
@@ -440,6 +430,20 @@ blecent_gap_event(struct ble_gap_event *event, void *arg)
print_conn_desc(&desc);
return 0;
+ case BLE_GAP_EVENT_NOTIFY_RX:
+ /* Peer sent us a notification or indication. */
+ BLECENT_LOG(INFO, "received %s; conn_handle=%d attr_handle=%d "
+ "attr_len=%d\n",
+ event->notify_rx.indication ?
+ "indication" :
+ "notification",
+ event->notify_rx.conn_handle,
+ event->notify_rx.attr_handle,
+ event->notify_rx.attr_len);
+
+ /* Attribute data is contained in event->notify_rx.attr_data. */
+ return 0;
+
default:
return 0;
}