You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2018/12/19 14:40:19 UTC
[mynewt-nimble] branch master updated: blehr: Fix state
notifications Use conn_handle in ble_gattc_notify_custom() instead of
incorrect notify_state
This is an automated email from the ASF dual-hosted git repository.
andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
The following commit(s) were added to refs/heads/master by this push:
new d5dbea9 blehr: Fix state notifications Use conn_handle in ble_gattc_notify_custom() instead of incorrect notify_state
d5dbea9 is described below
commit d5dbea9d5113d6fb18c455d90e7be1e434b39228
Author: Prasad Alatkar <pr...@espressif.com>
AuthorDate: Thu Nov 29 17:15:08 2018 +0530
blehr: Fix state notifications
Use conn_handle in ble_gattc_notify_custom() instead of incorrect notify_state
---
apps/blehr/src/main.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/apps/blehr/src/main.c b/apps/blehr/src/main.c
index 217c2b1..bf0f3f3 100644
--- a/apps/blehr/src/main.c
+++ b/apps/blehr/src/main.c
@@ -32,6 +32,9 @@
static bool notify_state;
+/* Connection handle */
+static uint16_t conn_handle;
+
static const char *device_name = "blehr_sensor";
static int blehr_gap_event(struct ble_gap_event *event, void *arg);
@@ -143,7 +146,7 @@ blehr_tx_hrate(struct os_event *ev)
om = ble_hs_mbuf_from_flat(hrm, sizeof(hrm));
- rc = ble_gattc_notify_custom(notify_state, hrs_hrm_handle, om);
+ rc = ble_gattc_notify_custom(conn_handle, hrs_hrm_handle, om);
assert(rc == 0);
blehr_tx_hrate_reset();
@@ -162,11 +165,17 @@ blehr_gap_event(struct ble_gap_event *event, void *arg)
if (event->connect.status != 0) {
/* Connection failed; resume advertising */
blehr_advertise();
+ conn_handle = 0;
+ }
+ else {
+ conn_handle = event->connect.conn_handle;
}
+
break;
case BLE_GAP_EVENT_DISCONNECT:
MODLOG_DFLT(INFO, "disconnect; reason=%d\n", event->disconnect.reason);
+ conn_handle = BLE_HS_CONN_HANDLE_NONE; /* reset conn_handle */
/* Connection terminated; resume advertising */
blehr_advertise();