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/10/11 19:17:05 UTC

[GitHub] michal-narajowski closed pull request #215: host/gap: Add connection find by address API

michal-narajowski closed pull request #215: host/gap: Add connection find by address API
URL: https://github.com/apache/mynewt-nimble/pull/215
 
 
   

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/nimble/host/include/host/ble_gap.h b/nimble/host/include/host/ble_gap.h
index 97a40939..20c6facc 100644
--- a/nimble/host/include/host/ble_gap.h
+++ b/nimble/host/include/host/ble_gap.h
@@ -736,6 +736,22 @@ typedef int ble_gap_event_fn(struct ble_gap_event *event, void *arg);
  */
 int ble_gap_conn_find(uint16_t handle, struct ble_gap_conn_desc *out_desc);
 
+/**
+ * Searches for a connection with a peer with the specified address.
+ * If a matching connection is found, the supplied connection descriptor
+ * is filled correspondingly.
+ *
+ * @param addr      The ble address of a connected peer device to search for.
+ * @param out_desc  On success, this is populated with information relating to
+ *                  the matching connection.  Pass NULL if you don't need this
+ *                  information.
+ *
+ * @return          0 on success, BLE_HS_ENOTCONN if no matching connection was
+ *                  found.
+ */
+int ble_gap_conn_find_by_addr(const ble_addr_t *addr,
+                              struct ble_gap_conn_desc *out_desc);
+
 /**
  * Configures a connection to use the specified GAP event callback.  A
  * connection's GAP event callback is first specified when the connection is
diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c
index bc82ef03..1650960e 100644
--- a/nimble/host/src/ble_gap.c
+++ b/nimble/host/src/ble_gap.c
@@ -436,6 +436,28 @@ ble_gap_conn_find(uint16_t handle, struct ble_gap_conn_desc *out_desc)
     }
 }
 
+int
+ble_gap_conn_find_by_addr(const ble_addr_t *addr,
+                          struct ble_gap_conn_desc *out_desc)
+{
+	struct ble_hs_conn *conn;
+
+	ble_hs_lock();
+
+	conn = ble_hs_conn_find_by_addr(addr);
+	if (conn != NULL && out_desc != NULL) {
+		ble_gap_fill_conn_desc(conn, out_desc);
+	}
+
+	ble_hs_unlock();
+
+	if (conn == NULL) {
+		return BLE_HS_ENOTCONN;
+	}
+
+	return 0;
+}
+
 static int
 ble_gap_extract_conn_cb(uint16_t conn_handle,
                         ble_gap_event_fn **out_cb, void **out_cb_arg)


 

----------------------------------------------------------------
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