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 2015/11/13 03:00:38 UTC
incubator-mynewt-larva git commit: Make HCI acks OGF-aware;
work queue for GAP.
Repository: incubator-mynewt-larva
Updated Branches:
refs/heads/master 9f8e83276 -> 629247cb1
Make HCI acks OGF-aware; work queue for GAP.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/629247cb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/629247cb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/629247cb
Branch: refs/heads/master
Commit: 629247cb1cedd7b98184fd3635c5888c5c64a370
Parents: 9f8e832
Author: Christopher Collins <cc...@gmail.com>
Authored: Thu Nov 12 17:59:45 2015 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Thu Nov 12 17:59:45 2015 -0800
----------------------------------------------------------------------
net/nimble/host/include/host/ble_hs.h | 1 +
net/nimble/host/src/ble_gap.c | 54 +++++++++++
net/nimble/host/src/ble_gap.h | 24 +++++
net/nimble/host/src/ble_gap_conn.c | 22 ++++-
net/nimble/host/src/ble_gap_conn.h | 2 +
net/nimble/host/src/ble_hs.c | 37 +++++++-
net/nimble/host/src/ble_hs_ack.h | 2 +-
net/nimble/host/src/ble_hs_conn.c | 33 ++-----
net/nimble/host/src/ble_hs_conn.h | 3 +-
net/nimble/host/src/ble_hs_work.c | 110 +++++++++++++++++++++++
net/nimble/host/src/ble_hs_work.h | 48 ++++++++++
net/nimble/host/src/host_hci.c | 4 +-
net/nimble/host/src/host_hci_cmd.c | 2 +-
net/nimble/host/src/test/ble_hs_conn_test.c | 8 +-
net/nimble/host/src/test/ble_hs_test_util.c | 13 ++-
net/nimble/host/src/test/ble_hs_test_util.h | 3 +-
net/nimble/include/nimble/hci_common.h | 15 +++-
17 files changed, 330 insertions(+), 51 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/629247cb/net/nimble/host/include/host/ble_hs.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_hs.h b/net/nimble/host/include/host/ble_hs.h
index 1b7a38d..885ecb7 100644
--- a/net/nimble/host/include/host/ble_hs.h
+++ b/net/nimble/host/include/host/ble_hs.h
@@ -20,6 +20,7 @@
#include <inttypes.h>
void ble_hs_task_handler(void *arg);
+void ble_hs_kick(void);
int ble_hs_init(void);
#endif /* _BLE_HOST_H */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/629247cb/net/nimble/host/src/ble_gap.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gap.c b/net/nimble/host/src/ble_gap.c
new file mode 100644
index 0000000..8989b13
--- /dev/null
+++ b/net/nimble/host/src/ble_gap.c
@@ -0,0 +1,54 @@
+/**
+ * Copyright (c) 2015 Runtime Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stddef.h>
+#include <errno.h>
+#include <string.h>
+#include "ble_hs_work.h"
+#include "ble_gap.h"
+
+/**
+ * Performs the Direct Connection Establishment Procedure, as described in
+ * vol. 3, part C, section 9.3.8.
+ *
+ * @param addr_type The peer's address type; one of:
+ * o BLE_HCI_ADV_PEER_ADDR_PUBLIC
+ * o BLE_HCI_ADV_PEER_ADDR_RANDOM
+ * o BLE_HCI_ADV_PEER_ADDR_PUBLIC_IDENT
+ * o BLE_HCI_ADV_PEER_ADDR_RANDOM_IDENT
+ * @param addr The address of the peer to connect to.
+ *
+ * @return 0 on success; nonzero on failure.
+ */
+int
+ble_gap_direct_connection_establishment(uint8_t addr_type, uint8_t *addr)
+{
+ struct ble_hs_work_entry *entry;
+
+ entry = ble_hs_work_entry_alloc();
+ if (entry == NULL) {
+ return ENOMEM;
+ }
+
+ entry->bwe_type = BLE_HS_WORK_TYPE_DIRECT_CONNECT;
+ entry->bwe_direct_connect.bwdc_peer_addr_type = addr_type;
+ memcpy(entry->bwe_direct_connect.bwdc_peer_addr, addr,
+ sizeof entry->bwe_direct_connect.bwdc_peer_addr);
+
+ ble_hs_work_enqueue(entry);
+
+ return 0;
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/629247cb/net/nimble/host/src/ble_gap.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gap.h b/net/nimble/host/src/ble_gap.h
new file mode 100644
index 0000000..7637996
--- /dev/null
+++ b/net/nimble/host/src/ble_gap.h
@@ -0,0 +1,24 @@
+/**
+ * Copyright (c) 2015 Runtime Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef H_BLE_GAP_
+#define H_BLE_GAP_
+
+#include <inttypes.h>
+
+int ble_gap_direct_connection_establishment(uint8_t addr_type, uint8_t *addr);
+
+#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/629247cb/net/nimble/host/src/ble_gap_conn.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gap_conn.c b/net/nimble/host/src/ble_gap_conn.c
index 12af411..44318a7 100644
--- a/net/nimble/host/src/ble_gap_conn.c
+++ b/net/nimble/host/src/ble_gap_conn.c
@@ -22,6 +22,7 @@
#include "ble_hs_ack.h"
#include "ble_hs_conn.h"
#include "ble_hs_ack.h"
+#include "ble_hs_work.h"
#include "ble_gap_conn.h"
#define BLE_GAP_CONN_STATE_IDLE 0
@@ -49,6 +50,9 @@ ble_gap_conn_master_ack(struct ble_hs_ack *ack, void *arg)
} else {
ble_gap_conn_master_state = BLE_GAP_CONN_STATE_MASTER_DIRECT_ACKED;
}
+
+ /* The host is done sending commands to the controller. */
+ ble_hs_work_done();
}
static void
@@ -88,7 +92,6 @@ ble_gap_conn_slave_ack(struct ble_hs_ack *ack, void *arg)
/**
* Initiates a connection using the GAP Direct Connection Establishment
* Procedure.
- * XXX: Add timeout parameter.
*
* @return 0 on success; nonzero on failure.
*/
@@ -128,7 +131,6 @@ ble_gap_conn_initiate_direct(int addr_type, uint8_t *addr)
return 0;
}
-/* XXX: Add timeout parameter. */
int
ble_gap_conn_advertise_direct(int addr_type, uint8_t *addr)
{
@@ -184,12 +186,28 @@ ble_gap_conn_accept_conn(uint8_t *addr)
return ENOENT;
}
+/**
+ * Processes an incoming connection-complete HCI event.
+ */
int
ble_gap_conn_rx_conn_complete(struct hci_le_conn_complete *evt)
{
struct ble_hs_conn *conn;
int rc;
+ /* Determine if this event refers to a completed connection or a connection
+ * in progress.
+ */
+ conn = ble_hs_conn_find(evt->connection_handle);
+ if (conn != NULL) {
+ if (evt->status != 0) {
+ ble_hs_conn_remove(conn);
+ ble_hs_conn_free(conn);
+ }
+
+ return 0;
+ }
+
rc = ble_gap_conn_accept_conn(evt->peer_addr);
if (rc != 0) {
return ENOENT;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/629247cb/net/nimble/host/src/ble_gap_conn.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gap_conn.h b/net/nimble/host/src/ble_gap_conn.h
index e0f1fd6..23b0698 100644
--- a/net/nimble/host/src/ble_gap_conn.h
+++ b/net/nimble/host/src/ble_gap_conn.h
@@ -17,6 +17,8 @@
#ifndef H_BLE_GAP_CONN_
#define H_BLE_GAP_CONN_
+#include <inttypes.h>
+struct hci_le_conn_complete;
struct ble_hs_ack;
int ble_gap_conn_initiate_direct(int addr_type, uint8_t *addr);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/629247cb/net/nimble/host/src/ble_hs.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs.c b/net/nimble/host/src/ble_hs.c
index ed99968..d50ef0c 100644
--- a/net/nimble/host/src/ble_hs.c
+++ b/net/nimble/host/src/ble_hs.c
@@ -21,6 +21,7 @@
#include "ble_hs_att.h"
#include "ble_hs_conn.h"
#include "ble_hs_ack.h"
+#include "ble_hs_work.h"
#include "ble_gap_conn.h"
#define HCI_CMD_BUFS (8)
@@ -38,7 +39,9 @@ os_membuf_t g_hci_os_event_buf[OS_MEMPOOL_SIZE(HCI_NUM_OS_EVENTS,
/* Host HCI Task Events */
struct os_eventq g_ble_host_hci_evq;
-#define BLE_HOST_HCI_EVENT_CTLR_EVENT (OS_EVENT_T_PERUSER)
+static struct os_event ble_hs_kick_ev;
+#define BLE_HOST_HCI_EVENT_CTLR_EVENT (OS_EVENT_T_PERUSER + 0)
+#define BLE_HS_KICK_EVENT (OS_EVENT_T_PERUSER + 1)
void
ble_hs_task_handler(void *arg)
@@ -54,19 +57,40 @@ ble_hs_task_handler(void *arg)
assert(cf->cf_func);
cf->cf_func(cf->cf_arg);
break;
+
case BLE_HOST_HCI_EVENT_CTLR_EVENT:
/* Process HCI event from controller */
host_hci_os_event_proc(ev);
break;
+
+ case BLE_HS_KICK_EVENT:
+ break;
+
default:
assert(0);
break;
}
+
+ /* If a work event is not already in progress, and there is another
+ * event pending, begin processing it.
+ */
+ if (!ble_hs_work_busy) {
+ ble_hs_work_process_next();
+ }
}
}
/**
- * Initialize the host portion of the BLE stack.
+ * Wakes the BLE host task so that it can process work events.
+ */
+void
+ble_hs_kick(void)
+{
+ os_eventq_put(&g_ble_host_hci_evq, &ble_hs_kick_ev);
+}
+
+/**
+ * Initializes the host portion of the BLE stack.
*/
int
ble_hs_init(void)
@@ -112,5 +136,14 @@ ble_hs_init(void)
ble_hs_ack_init();
+ rc = ble_hs_work_init();
+ if (rc != 0) {
+ return rc;
+ }
+
+ ble_hs_kick_ev.ev_queued = 0;
+ ble_hs_kick_ev.ev_type = BLE_HS_KICK_EVENT;
+ ble_hs_kick_ev.ev_arg = NULL;
+
return 0;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/629247cb/net/nimble/host/src/ble_hs_ack.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_ack.h b/net/nimble/host/src/ble_hs_ack.h
index af90d8f..096d446 100644
--- a/net/nimble/host/src/ble_hs_ack.h
+++ b/net/nimble/host/src/ble_hs_ack.h
@@ -20,7 +20,7 @@
#include <inttypes.h>
struct ble_hs_ack {
- uint16_t bha_ocf;
+ uint16_t bha_opcode;
uint8_t bha_status;
uint8_t *bha_params;
int bha_params_len;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/629247cb/net/nimble/host/src/ble_hs_conn.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_conn.c b/net/nimble/host/src/ble_hs_conn.c
index b08bad1..23f218d 100644
--- a/net/nimble/host/src/ble_hs_conn.c
+++ b/net/nimble/host/src/ble_hs_conn.c
@@ -27,25 +27,6 @@
static SLIST_HEAD(, ble_hs_conn) ble_hs_conns;
static struct os_mempool ble_hs_conn_pool;
-static struct os_mutex ble_hs_conn_mutex;
-
-void
-ble_hs_conn_lock(void)
-{
- int rc;
-
- rc = os_mutex_pend(&ble_hs_conn_mutex, 0xffffffff);
- assert(rc == 0 || rc == OS_NOT_STARTED);
-}
-
-void
-ble_hs_conn_unlock(void)
-{
- int rc;
-
- rc = os_mutex_release(&ble_hs_conn_mutex);
- assert(rc == 0 || rc == OS_NOT_STARTED);
-}
struct ble_hs_conn *
ble_hs_conn_alloc(void)
@@ -99,12 +80,14 @@ ble_hs_conn_free(struct ble_hs_conn *conn)
void
ble_hs_conn_insert(struct ble_hs_conn *conn)
{
- ble_hs_conn_lock();
-
assert(ble_hs_conn_find(conn->bhc_handle) == NULL);
SLIST_INSERT_HEAD(&ble_hs_conns, conn, bhc_next);
+}
- ble_hs_conn_unlock();
+void
+ble_hs_conn_remove(struct ble_hs_conn *conn)
+{
+ SLIST_REMOVE(&ble_hs_conns, conn, ble_hs_conn, bhc_next);
}
struct ble_hs_conn *
@@ -131,7 +114,6 @@ ble_hs_conn_first(void)
return SLIST_FIRST(&ble_hs_conns);
}
-
int
ble_hs_conn_init(void)
{
@@ -154,10 +136,5 @@ ble_hs_conn_init(void)
SLIST_INIT(&ble_hs_conns);
- rc = os_mutex_init(&ble_hs_conn_mutex);
- if (rc != 0) {
- return EINVAL; // XXX
- }
-
return 0;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/629247cb/net/nimble/host/src/ble_hs_conn.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_conn.h b/net/nimble/host/src/ble_hs_conn.h
index 636a30d..deb5879 100644
--- a/net/nimble/host/src/ble_hs_conn.h
+++ b/net/nimble/host/src/ble_hs_conn.h
@@ -34,11 +34,10 @@ struct ble_hs_conn {
struct ble_l2cap_chan_list bhc_channels;
};
-void ble_hs_conn_lock(void);
-void ble_hs_conn_unlock(void);
struct ble_hs_conn *ble_hs_conn_alloc(void);
void ble_hs_conn_free(struct ble_hs_conn *conn);
void ble_hs_conn_insert(struct ble_hs_conn *conn);
+void ble_hs_conn_remove(struct ble_hs_conn *conn);
struct ble_hs_conn *ble_hs_conn_find(uint16_t con_handle);
struct ble_hs_conn *ble_hs_conn_first(void);
int ble_hs_conn_init(void);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/629247cb/net/nimble/host/src/ble_hs_work.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_work.c b/net/nimble/host/src/ble_hs_work.c
new file mode 100644
index 0000000..b56985f
--- /dev/null
+++ b/net/nimble/host/src/ble_hs_work.c
@@ -0,0 +1,110 @@
+/**
+ * Copyright (c) 2015 Runtime Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stddef.h>
+#include <assert.h>
+#include <errno.h>
+#include "os/os.h"
+#include "ble_gap_conn.h"
+#include "ble_hs_work.h"
+
+#define BLE_HS_WORK_NUM_ENTRIES 16
+
+uint8_t ble_hs_work_busy;
+
+static void *ble_hs_work_entry_mem;
+static struct os_mempool ble_hs_work_entry_pool;
+static STAILQ_HEAD(, ble_hs_work_entry) ble_hs_work_queue;
+
+struct ble_hs_work_entry *
+ble_hs_work_entry_alloc(void)
+{
+ struct ble_hs_work_entry *entry;
+
+ entry = os_memblock_get(&ble_hs_work_entry_pool);
+ return entry;
+}
+
+void
+ble_hs_work_enqueue(struct ble_hs_work_entry *entry)
+{
+ STAILQ_INSERT_TAIL(&ble_hs_work_queue, entry, bwe_next);
+}
+
+void
+ble_hs_work_process_next(void)
+{
+ struct ble_hs_work_entry *entry;
+ int rc;
+
+ assert(!ble_hs_work_busy);
+
+ entry = STAILQ_FIRST(&ble_hs_work_queue);
+ if (entry == NULL) {
+ return;
+ }
+
+ switch (entry->bwe_type) {
+ case BLE_HS_WORK_TYPE_DIRECT_CONNECT:
+ rc = ble_gap_conn_initiate_direct(
+ entry->bwe_direct_connect.bwdc_peer_addr_type,
+ entry->bwe_direct_connect.bwdc_peer_addr);
+ break;
+
+ default:
+ rc = -1;
+ assert(0);
+ break;
+ }
+
+ if (rc == 0) {
+ ble_hs_work_busy = 1;
+ }
+
+ os_memblock_put(&ble_hs_work_entry_pool, entry);
+}
+
+void
+ble_hs_work_done(void)
+{
+ assert(ble_hs_work_busy || !g_os_started);
+ ble_hs_work_busy = 0;
+}
+
+int
+ble_hs_work_init(void)
+{
+ int rc;
+
+ free(ble_hs_work_entry_mem);
+ ble_hs_work_entry_mem = malloc(
+ OS_MEMPOOL_BYTES(BLE_HS_WORK_NUM_ENTRIES,
+ sizeof (struct ble_hs_work_entry)));
+ if (ble_hs_work_entry_mem == NULL) {
+ return ENOMEM;
+ }
+
+ rc = os_mempool_init(&ble_hs_work_entry_pool, BLE_HS_WORK_NUM_ENTRIES,
+ sizeof (struct ble_hs_work_entry),
+ ble_hs_work_entry_mem, "ble_hs_work_entry_pool");
+ if (rc != 0) {
+ return EINVAL; // XXX
+ }
+
+ STAILQ_INIT(&ble_hs_work_queue);
+
+ return 0;
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/629247cb/net/nimble/host/src/ble_hs_work.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_work.h b/net/nimble/host/src/ble_hs_work.h
new file mode 100644
index 0000000..df36485
--- /dev/null
+++ b/net/nimble/host/src/ble_hs_work.h
@@ -0,0 +1,48 @@
+/**
+ * Copyright (c) 2015 Runtime Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef H_BLE_WORK_
+#define H_BLE_WORK_
+
+#include <inttypes.h>
+#include "os/queue.h"
+
+#define BLE_HS_WORK_TYPE_DIRECT_CONNECT 0
+#define BLE_HS_WORK_TYPE_MAX 1
+
+struct ble_hs_work_direct_connect {
+ uint8_t bwdc_peer_addr[8];
+ uint8_t bwdc_peer_addr_type;
+};
+
+struct ble_hs_work_entry {
+ int bwe_type;
+ STAILQ_ENTRY(ble_hs_work_entry) bwe_next;
+
+ union {
+ struct ble_hs_work_direct_connect bwe_direct_connect;
+ };
+};
+
+struct ble_hs_work_entry *ble_hs_work_entry_alloc(void);
+void ble_hs_work_enqueue(struct ble_hs_work_entry *entry);
+void ble_hs_work_process_next(void);
+void ble_hs_work_done(void);
+int ble_hs_work_init(void);
+
+extern uint8_t ble_hs_work_busy;
+
+#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/629247cb/net/nimble/host/src/host_hci.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/host_hci.c b/net/nimble/host/src/host_hci.c
index 74f0baf..ada2616 100644
--- a/net/nimble/host/src/host_hci.c
+++ b/net/nimble/host/src/host_hci.c
@@ -163,7 +163,7 @@ host_hci_rx_cmd_complete(uint8_t event_code, uint8_t *data, int len)
/* XXX: Stop timer. */
}
- ack.bha_ocf = BLE_HCI_OCF(opcode);
+ ack.bha_opcode = opcode;
ack.bha_params = params;
ack.bha_params_len = len - BLE_HCI_EVENT_CMD_COMPLETE_HDR_LEN;
if (ack.bha_params_len > 0) {
@@ -211,7 +211,7 @@ host_hci_rx_cmd_status(uint8_t event_code, uint8_t *data, int len)
/* XXX: Stop timer. */
}
- ack.bha_ocf = BLE_HCI_OCF(opcode);
+ ack.bha_opcode = opcode;
ack.bha_params = NULL;
ack.bha_params_len = 0;
ack.bha_status = status;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/629247cb/net/nimble/host/src/host_hci_cmd.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/host_hci_cmd.c b/net/nimble/host/src/host_hci_cmd.c
index b918a94..2b4fd36 100644
--- a/net/nimble/host/src/host_hci_cmd.c
+++ b/net/nimble/host/src/host_hci_cmd.c
@@ -302,7 +302,7 @@ host_hci_cmd_le_create_connection(struct hci_create_conn *hcc)
}
/* Check peer addr type */
- if (hcc->peer_addr_type > BLE_HCI_ADV_OWN_ADDR_MAX) {
+ if (hcc->peer_addr_type > BLE_HCI_CONN_PEER_ADDR_MAX) {
return BLE_ERR_INV_HCI_CMD_PARMS;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/629247cb/net/nimble/host/src/test/ble_hs_conn_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_hs_conn_test.c b/net/nimble/host/src/test/ble_hs_conn_test.c
index 5373a9b..86283b4 100644
--- a/net/nimble/host/src/test/ble_hs_conn_test.c
+++ b/net/nimble/host/src/test/ble_hs_conn_test.c
@@ -49,7 +49,7 @@ TEST_CASE(ble_hs_conn_test_master_direct_success)
TEST_ASSERT(ble_gap_conn_master_in_progress());
/* Receive command status event. */
- ble_hs_test_util_rx_ack(BLE_HCI_OCF_LE_CREATE_CONN, BLE_ERR_SUCCESS);
+ ble_hs_test_util_rx_le_ack(BLE_HCI_OCF_LE_CREATE_CONN, BLE_ERR_SUCCESS);
TEST_ASSERT(ble_gap_conn_master_in_progress());
/* Receive successful connection complete event. */
@@ -98,7 +98,7 @@ TEST_CASE(ble_hs_conn_test_master_direct_hci_errors)
TEST_ASSERT(ble_gap_conn_master_in_progress());
/* Receive success command status event. */
- ble_hs_test_util_rx_ack(BLE_HCI_OCF_LE_CREATE_CONN, BLE_ERR_SUCCESS);
+ ble_hs_test_util_rx_le_ack(BLE_HCI_OCF_LE_CREATE_CONN, BLE_ERR_SUCCESS);
TEST_ASSERT(ble_gap_conn_master_in_progress());
/* Receive failure connection complete event. */
@@ -131,12 +131,12 @@ TEST_CASE(ble_hs_conn_test_slave_direct_success)
TEST_ASSERT(ble_gap_conn_slave_in_progress());
/* Receive set-adv-params ack. */
- ble_hs_test_util_rx_ack(BLE_HCI_OCF_LE_SET_ADV_PARAMS, BLE_ERR_SUCCESS);
+ ble_hs_test_util_rx_le_ack(BLE_HCI_OCF_LE_SET_ADV_PARAMS, BLE_ERR_SUCCESS);
TEST_ASSERT(!ble_gap_conn_master_in_progress());
TEST_ASSERT(ble_gap_conn_slave_in_progress());
/* Receive set-adv-enable ack. */
- ble_hs_test_util_rx_ack(BLE_HCI_OCF_LE_SET_ADV_ENABLE, BLE_ERR_SUCCESS);
+ ble_hs_test_util_rx_le_ack(BLE_HCI_OCF_LE_SET_ADV_ENABLE, BLE_ERR_SUCCESS);
TEST_ASSERT(!ble_gap_conn_master_in_progress());
TEST_ASSERT(ble_gap_conn_slave_in_progress());
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/629247cb/net/nimble/host/src/test/ble_hs_test_util.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_hs_test_util.c b/net/nimble/host/src/test/ble_hs_test_util.c
index 555b22c..3689cc3 100644
--- a/net/nimble/host/src/test/ble_hs_test_util.c
+++ b/net/nimble/host/src/test/ble_hs_test_util.c
@@ -59,7 +59,7 @@ ble_hs_test_util_create_conn(uint16_t handle, uint8_t *addr)
rc = ble_gap_conn_initiate_direct(0, addr);
TEST_ASSERT(rc == 0);
- ble_hs_test_util_rx_ack(BLE_HCI_OCF_LE_CREATE_CONN, BLE_ERR_SUCCESS);
+ ble_hs_test_util_rx_le_ack(BLE_HCI_OCF_LE_CREATE_CONN, BLE_ERR_SUCCESS);
memset(&evt, 0, sizeof evt);
evt.subevent_code = BLE_HCI_LE_SUBEV_CONN_COMPLETE;
@@ -70,13 +70,18 @@ ble_hs_test_util_create_conn(uint16_t handle, uint8_t *addr)
}
void
-ble_hs_test_util_rx_ack(uint16_t ocf, uint8_t status)
+ble_hs_test_util_rx_ack(uint16_t opcode, uint8_t status)
{
uint8_t buf[BLE_HCI_EVENT_CMD_STATUS_LEN];
int rc;
- ble_hs_test_util_build_cmd_status(buf, sizeof buf, status, 1,
- (BLE_HCI_OGF_LE << 10) | ocf);
+ ble_hs_test_util_build_cmd_status(buf, sizeof buf, status, 1, opcode);
rc = host_hci_event_rx(buf);
TEST_ASSERT(rc == 0);
}
+
+void
+ble_hs_test_util_rx_le_ack(uint16_t ocf, uint8_t status)
+{
+ ble_hs_test_util_rx_ack((BLE_HCI_OGF_LE << 10) | ocf, status);
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/629247cb/net/nimble/host/src/test/ble_hs_test_util.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_hs_test_util.h b/net/nimble/host/src/test/ble_hs_test_util.h
index a2d5c19..6461f3b 100644
--- a/net/nimble/host/src/test/ble_hs_test_util.h
+++ b/net/nimble/host/src/test/ble_hs_test_util.h
@@ -26,6 +26,7 @@ void ble_hs_test_util_build_cmd_status(uint8_t *dst, int len,
uint8_t status, uint8_t num_pkts,
uint16_t opcode);
void ble_hs_test_util_create_conn(uint16_t handle, uint8_t *addr);
-void ble_hs_test_util_rx_ack(uint16_t ocf, uint8_t status);
+void ble_hs_test_util_rx_ack(uint16_t opcode, uint8_t status);
+void ble_hs_test_util_rx_le_ack(uint16_t ocf, uint8_t status);
#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/629247cb/net/nimble/include/nimble/hci_common.h
----------------------------------------------------------------------
diff --git a/net/nimble/include/nimble/hci_common.h b/net/nimble/include/nimble/hci_common.h
index 3a3413e..7a31197 100644
--- a/net/nimble/include/nimble/hci_common.h
+++ b/net/nimble/include/nimble/hci_common.h
@@ -145,10 +145,17 @@
#define BLE_HCI_ADV_OWN_ADDR_PRIV_RAND (3)
#define BLE_HCI_ADV_OWN_ADDR_MAX (3)
-/* Peer Address Type */
-#define BLE_HCI_ADV_PEER_ADDR_PUBLIC (0)
-#define BLE_HCI_ADV_PEER_ADDR_RANDOM (1)
-#define BLE_HCI_ADV_PEER_ADDR_MAX (1)
+/* Advertisement peer address Type */
+#define BLE_HCI_ADV_PEER_ADDR_PUBLIC (0)
+#define BLE_HCI_ADV_PEER_ADDR_RANDOM (1)
+#define BLE_HCI_ADV_PEER_ADDR_MAX (1)
+
+/* Connect peer address type */
+#define BLE_HCI_CONN_PEER_ADDR_PUBLIC (0)
+#define BLE_HCI_CONN_PEER_ADDR_RANDOM (1)
+#define BLE_HCI_CONN_PEER_ADDR_PUBLIC_IDENT (2)
+#define BLE_HCI_CONN_PEER_ADDR_RANDOM_IDENT (3)
+#define BLE_HCI_CONN_PEER_ADDR_MAX (3)
/*
* Advertising filter policy