andrzej-kaczmarek closed pull request #831: apps/ble: Fix GATT discovery in 
some apps
URL: https://github.com/apache/mynewt-core/pull/831
 
 
   

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/blecent/src/peer.c b/apps/blecent/src/peer.c
index 05ec8a005..f18dcbcc0 100644
--- a/apps/blecent/src/peer.c
+++ b/apps/blecent/src/peer.c
@@ -435,7 +435,7 @@ peer_disc_chrs(struct peer *peer)
 int
 peer_svc_is_empty(const struct peer_svc *svc)
 {
-    return svc->svc.end_handle < svc->svc.start_handle;
+    return svc->svc.end_handle <= svc->svc.start_handle;
 }
 
 static struct peer_svc *
diff --git a/apps/bletiny/src/bletiny.h b/apps/bletiny/src/bletiny.h
index 94000a7d2..e59779102 100644
--- a/apps/bletiny/src/bletiny.h
+++ b/apps/bletiny/src/bletiny.h
@@ -74,7 +74,6 @@ SLIST_HEAD(bletiny_chr_list, bletiny_chr);
 struct bletiny_svc {
     SLIST_ENTRY(bletiny_svc) next;
     struct ble_gatt_svc svc;
-    bool char_disc_sent;
     struct bletiny_chr_list chrs;
 };
 
diff --git a/apps/bletiny/src/main.c b/apps/bletiny/src/main.c
index f1f4717f1..25a346696 100755
--- a/apps/bletiny/src/main.c
+++ b/apps/bletiny/src/main.c
@@ -722,12 +722,7 @@ bletiny_disc_full_chrs(uint16_t conn_handle)
     }
 
     SLIST_FOREACH(svc, &conn->svcs, next) {
-        if (!svc_is_empty(svc) && !svc->char_disc_sent) {
-            /* Since it might happen that service does not have characteristics
-             * for some reason, lets keep track on services for which we send
-             * characteristic discovery
-             */
-            svc->char_disc_sent = true;
+        if (!svc_is_empty(svc) && SLIST_EMPTY(&svc->chrs)) {
             rc = bletiny_disc_all_chrs(conn_handle, svc->svc.start_handle,
                                        svc->svc.end_handle);
             if (rc != 0) {
diff --git a/apps/bletiny/src/misc.c b/apps/bletiny/src/misc.c
index 9914bfef7..11d72e825 100644
--- a/apps/bletiny/src/misc.c
+++ b/apps/bletiny/src/misc.c
@@ -76,7 +76,7 @@ print_uuid(const ble_uuid_t *uuid)
 int
 svc_is_empty(const struct bletiny_svc *svc)
 {
-    return svc->svc.end_handle < svc->svc.start_handle;
+    return svc->svc.end_handle <= svc->svc.start_handle;
 }
 
 uint16_t
diff --git a/apps/bsncent/src/peer.c b/apps/bsncent/src/peer.c
index 0e4f7f440..0993e050c 100644
--- a/apps/bsncent/src/peer.c
+++ b/apps/bsncent/src/peer.c
@@ -435,7 +435,7 @@ peer_disc_chrs(struct peer *peer)
 int
 peer_svc_is_empty(const struct peer_svc *svc)
 {
-    return svc->svc.end_handle < svc->svc.start_handle;
+    return svc->svc.end_handle <= svc->svc.start_handle;
 }
 
 static struct peer_svc *
diff --git a/apps/btshell/src/btshell.h b/apps/btshell/src/btshell.h
index ddbd5da53..fb8ca72cb 100644
--- a/apps/btshell/src/btshell.h
+++ b/apps/btshell/src/btshell.h
@@ -63,8 +63,6 @@ SLIST_HEAD(btshell_chr_list, btshell_chr);
 struct btshell_svc {
     SLIST_ENTRY(btshell_svc) next;
     struct ble_gatt_svc svc;
-
-    bool char_disc_sent;
     struct btshell_chr_list chrs;
 };
 
diff --git a/apps/btshell/src/main.c b/apps/btshell/src/main.c
index 17a66f607..06121620f 100755
--- a/apps/btshell/src/main.c
+++ b/apps/btshell/src/main.c
@@ -733,12 +733,7 @@ btshell_disc_full_chrs(uint16_t conn_handle)
     }
 
     SLIST_FOREACH(svc, &conn->svcs, next) {
-        if (!svc_is_empty(svc) && !svc->char_disc_sent) {
-            /* Since it might happen that service does not have characteristics
-             * for some reason, lets keep track on services for which we send
-             * characteristic discovery
-             */
-            svc->char_disc_sent = true;
+        if (!svc_is_empty(svc) && SLIST_EMPTY(&svc->chrs)) {
             rc = btshell_disc_all_chrs(conn_handle, svc->svc.start_handle,
                                        svc->svc.end_handle);
             if (rc != 0) {
diff --git a/apps/btshell/src/misc.c b/apps/btshell/src/misc.c
index 913fb403e..9a8e43352 100644
--- a/apps/btshell/src/misc.c
+++ b/apps/btshell/src/misc.c
@@ -76,7 +76,7 @@ print_uuid(const ble_uuid_t *uuid)
 int
 svc_is_empty(const struct btshell_svc *svc)
 {
-    return svc->svc.end_handle < svc->svc.start_handle;
+    return svc->svc.end_handle <= svc->svc.start_handle;
 }
 
 uint16_t


 

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to