You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/12/19 14:40:16 UTC

[GitHub] andrzej-kaczmarek closed pull request #250: blehr: Fix state notifications

andrzej-kaczmarek closed pull request #250: blehr: Fix state notifications
URL: https://github.com/apache/mynewt-nimble/pull/250
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/apps/blehr/src/main.c b/apps/blehr/src/main.c
index 217c2b12..bf0f3f30 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();


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services