You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by we...@apache.org on 2015/10/28 21:11:31 UTC
[2/4] incubator-mynewt-larva git commit: Add console to ble stack.
Add sending of advertising report to host
Add console to ble stack. Add sending of advertising report to host
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/d49b73ce
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/d49b73ce
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/d49b73ce
Branch: refs/heads/master
Commit: d49b73ce2854f3f6eff8417f009f5042577f96bf
Parents: 2ec7592
Author: Willam San Filippo <wi...@micosa.io>
Authored: Wed Oct 28 10:37:56 2015 -0700
Committer: Willam San Filippo <wi...@micosa.io>
Committed: Wed Oct 28 10:37:56 2015 -0700
----------------------------------------------------------------------
.../controller/include/controller/ll_hci.h | 11 +-
.../controller/include/controller/ll_scan.h | 2 +-
net/nimble/controller/src/ble_ll_scan.c | 149 ++++++++++++++++---
net/nimble/controller/src/ll.c | 7 +-
net/nimble/controller/src/ll_hci.c | 86 +++++++----
net/nimble/host/src/host_hci.c | 4 +-
net/nimble/include/nimble/hci_common.h | 20 +++
net/nimble/include/nimble/hci_transport.h | 4 +-
project/bletest/bletest.yml | 1 +
project/bletest/src/main.c | 14 +-
10 files changed, 237 insertions(+), 61 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/d49b73ce/net/nimble/controller/include/controller/ll_hci.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/include/controller/ll_hci.h b/net/nimble/controller/include/controller/ll_hci.h
index c2eb0f6..3d2fcd4 100644
--- a/net/nimble/controller/include/controller/ll_hci.h
+++ b/net/nimble/controller/include/controller/ll_hci.h
@@ -27,7 +27,16 @@
*/
#define BLE_LL_CFG_NUM_HCI_CMD_PKTS (1)
+/* Initialize LL HCI */
+void ble_ll_hci_init(void);
+
/* HCI command processing function */
-void ll_hci_cmd_proc(struct os_event *ev);
+void ble_ll_hci_cmd_proc(struct os_event *ev);
+
+/* Used to determine if the LE event is enabled or disabled */
+uint8_t ble_ll_hci_is_le_event_enabled(int bitpos);
+
+/* Send event from controller to host */
+int ble_ll_hci_event_send(uint8_t *evbuf);
#endif /* H_LL_ADV_ */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/d49b73ce/net/nimble/controller/include/controller/ll_scan.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/include/controller/ll_scan.h b/net/nimble/controller/include/controller/ll_scan.h
index e54d538..42f1be7 100644
--- a/net/nimble/controller/include/controller/ll_scan.h
+++ b/net/nimble/controller/include/controller/ll_scan.h
@@ -80,6 +80,6 @@ int ble_ll_scan_rx_pdu_start(uint8_t pdu_type, struct os_mbuf *rxpdu);
int ble_ll_scan_rx_pdu_end(uint8_t *rxbuf);
/* Process a scan response PDU */
-void ble_ll_scan_rx_pdu_process(uint8_t pdu_type, uint8_t *rxbuf);
+void ble_ll_scan_rx_pdu_proc(uint8_t pdu_type, uint8_t *rxbuf, int8_t rssi);
#endif /* H_LL_SCAN_ */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/d49b73ce/net/nimble/controller/src/ble_ll_scan.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_scan.c b/net/nimble/controller/src/ble_ll_scan.c
index 5ddf941..28013e8 100644
--- a/net/nimble/controller/src/ble_ll_scan.c
+++ b/net/nimble/controller/src/ble_ll_scan.c
@@ -25,6 +25,7 @@
#include "controller/ll_sched.h"
#include "controller/ll_adv.h"
#include "controller/ll_scan.h"
+#include "controller/ll_hci.h"
#include "hal/hal_cputime.h"
#include "hal/hal_gpio.h"
@@ -37,6 +38,7 @@
* 5) Interleave sending scan requests to different advertisers? I guess I need
* a list of advertisers to which I sent a scan request and have yet to
* receive a scan response from? Implement this.
+ * 6) Make sure we send an advertising report if we hear a scan response too!
*/
/*
@@ -45,6 +47,10 @@
* is there no chance that a public address will match a random
* address? This applies to checking for advertisers that we have heard a scan
* response from or sent an advertising report for.
+ *
+ * 2) I think I can guarantee that we dont process things out of order if
+ * I send an event when a scan request is sent. The scan_rsp_pending flag
+ * code might be made simpler.
*/
/*
@@ -245,6 +251,41 @@ ble_ll_scan_is_dup_adv(uint8_t pdu_type, uint8_t addr_type, uint8_t *addr)
}
/**
+ * Add an advertiser the list of duplicate advertisers. An address gets added to
+ * the list of duplicate addresses when the controller sends an advertising
+ * report to the host.
+ *
+ * @param addr
+ * @param addr_type
+ */
+void
+ble_ll_scan_add_dup_adv(uint8_t *addr, uint8_t addr_type)
+{
+ uint8_t num_advs;
+ struct ble_ll_scan_advertisers *adv;
+
+ /* XXX: for now, if we dont have room, just leave */
+ num_advs = g_ble_ll_num_scan_dup_advs;
+ if (num_advs == BLE_LL_SCAN_CFG_NUM_DUP_ADVS) {
+ return;
+ }
+
+ /* Add the advertiser to the array */
+ adv = &g_ble_ll_scan_dup_advs[num_advs];
+ memcpy(&adv->adv_addr, addr, BLE_DEV_ADDR_LEN);
+
+ /*
+ * XXX: need to set correct flag based on type of report being sent
+ * for now, we dont send direct advertising reports
+ */
+ adv->sc_adv_flags = BLE_LL_SC_ADV_F_ADV_RPT_SENT;
+ if (addr_type) {
+ adv->sc_adv_flags |= BLE_LL_SC_ADV_F_RANDOM_ADDR;
+ }
+ ++g_ble_ll_num_scan_dup_advs;
+}
+
+/**
* Checks to see if we have received a scan response from this advertiser.
*
* @param adv_addr Address of advertiser
@@ -293,28 +334,12 @@ ble_ll_scan_add_scan_rsp_adv(uint8_t *addr, uint8_t addr_type)
return;
}
- /* XXX: might make a function out of this */
- /* Make sure this address is not here */
- adv = &g_ble_ll_scan_rsp_advs[0];
- while (num_advs) {
- if (!memcmp(&adv->adv_addr, addr, BLE_DEV_ADDR_LEN)) {
- /* Address type must match */
- if (addr_type) {
- if (adv->sc_adv_flags & BLE_LL_SC_ADV_F_RANDOM_ADDR) {
- return;
- }
- } else {
- if ((adv->sc_adv_flags & BLE_LL_SC_ADV_F_RANDOM_ADDR) == 0) {
- return;
- }
- }
- }
- ++adv;
- --num_advs;
+ /* Check if address is already on the list */
+ if (ble_ll_scan_have_rxd_scan_rsp(addr, addr_type)) {
+ return;
}
/* Add the advertiser to the array */
- num_advs = g_ble_ll_num_scan_rsp_advs;
adv = &g_ble_ll_scan_rsp_advs[num_advs];
memcpy(&adv->adv_addr, addr, BLE_DEV_ADDR_LEN);
adv->sc_adv_flags = BLE_LL_SC_ADV_F_SCAN_RSP_RXD;
@@ -327,6 +352,85 @@ ble_ll_scan_add_scan_rsp_adv(uint8_t *addr, uint8_t addr_type)
}
/**
+ * Send an advertising report to the host.
+ *
+ * NOTE: while we are allowed to send multiple devices in one report, we
+ * will just send for one for now.
+ *
+ * @param pdu_type
+ * @param rxadv
+ *
+ * @return int
+ */
+static int
+ble_ll_hci_send_adv_report(uint8_t pdu_type, uint8_t addr_type, uint8_t *rxbuf,
+ int8_t rssi)
+{
+ int rc;
+ uint8_t evtype;
+ uint8_t subev;
+ uint8_t *evbuf;
+ uint8_t adv_data_len;
+
+ subev = BLE_HCI_LE_SUBEV_ADV_RPT;
+ if (pdu_type == BLE_ADV_PDU_TYPE_ADV_DIRECT_IND) {
+ /* XXX: NOTE: the direct advertising report is only used when InitA
+ is a resolvable private address. We dont support that yet! */
+ //subev = BLE_HCI_LE_SUBEV_DIRECT_ADV_RPT;
+ evtype = BLE_HCI_ADV_RPT_EVTYPE_DIR_IND;
+ adv_data_len = 0;
+ } else {
+ if (pdu_type == BLE_ADV_PDU_TYPE_ADV_IND) {
+ evtype = BLE_HCI_ADV_RPT_EVTYPE_ADV_IND;
+ } else if (pdu_type == BLE_ADV_PDU_TYPE_ADV_SCAN_IND) {
+ evtype = BLE_HCI_ADV_RPT_EVTYPE_SCAN_IND;
+ } else if (pdu_type == BLE_ADV_PDU_TYPE_ADV_NONCONN_IND) {
+ evtype = BLE_HCI_ADV_RPT_EVTYPE_NONCONN_IND;
+ } else {
+ evtype = BLE_HCI_ADV_RPT_EVTYPE_SCAN_RSP;
+ }
+ subev = BLE_HCI_LE_SUBEV_ADV_RPT;
+
+ adv_data_len = rxbuf[1] & BLE_ADV_PDU_HDR_LEN_MASK;
+ adv_data_len -= (BLE_LL_PDU_HDR_LEN + BLE_DEV_ADDR_LEN);
+ }
+
+ rc = BLE_ERR_MEM_CAPACITY;
+ if (ble_ll_hci_is_le_event_enabled(subev - 1)) {
+ evbuf = os_memblock_get(&g_hci_cmd_pool);
+ if (evbuf) {
+ evbuf[0] = BLE_HCI_EVCODE_LE_META;
+ evbuf[1] = 12 + adv_data_len;
+ evbuf[2] = subev;
+ evbuf[3] = 1; /* number of reports */
+ evbuf[4] = evtype;
+
+ /* XXX: need to deal with resolvable addresses here! */
+ if (addr_type) {
+ evbuf[5] = BLE_HCI_ADV_OWN_ADDR_RANDOM;
+ } else {
+ evbuf[5] = BLE_HCI_ADV_OWN_ADDR_PUBLIC;
+ }
+ memcpy(evbuf + 6, rxbuf + BLE_LL_PDU_HDR_LEN, BLE_DEV_ADDR_LEN);
+ evbuf[12] = adv_data_len;
+ memcpy(evbuf + 13, rxbuf + BLE_LL_PDU_HDR_LEN + BLE_DEV_ADDR_LEN,
+ adv_data_len);
+ evbuf[13 + adv_data_len] = rssi;
+ }
+
+ rc = ble_ll_hci_event_send(evbuf);
+ if (!rc) {
+ /* If we are filtering, add it to list of duplicate addresses */
+ if (g_ble_ll_scan_sm.scan_filt_dups) {
+ ble_ll_scan_add_dup_adv(rxbuf + BLE_LL_PDU_HDR_LEN, addr_type);
+ }
+ }
+ }
+
+ return rc;
+}
+
+/**
* ble ll scan chk filter policy
*
* @param pdu_type
@@ -730,7 +834,7 @@ ble_ll_scan_rx_pdu_end(uint8_t *rxbuf)
* @param rxbuf
*/
void
-ble_ll_scan_rx_pdu_process(uint8_t pdu_type, uint8_t *rxbuf)
+ble_ll_scan_rx_pdu_proc(uint8_t pdu_type, uint8_t *rxbuf, int8_t rssi)
{
uint8_t *adv_addr;
uint8_t *adva;
@@ -798,9 +902,8 @@ ble_ll_scan_rx_pdu_process(uint8_t pdu_type, uint8_t *rxbuf)
}
}
- /* XXX: send the host an advertising report. Add that address to the dup
- adv array */
- //ble_ll_hci_send_adv_report();
+ /* Send the advertising report */
+ ble_ll_hci_send_adv_report(pdu_type, addr_type, rxbuf, rssi);
}
int
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/d49b73ce/net/nimble/controller/src/ll.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ll.c b/net/nimble/controller/src/ll.c
index e49ac06..baa895d 100644
--- a/net/nimble/controller/src/ll.c
+++ b/net/nimble/controller/src/ll.c
@@ -328,7 +328,7 @@ ll_rx_pkt_in_proc(void)
break;
case BLE_LL_STATE_SCANNING:
if (ble_hdr->crcok) {
- ble_ll_scan_rx_pdu_process(pdu_type, rxbuf);
+ ble_ll_scan_rx_pdu_proc(pdu_type, rxbuf, ble_hdr->rssi);
}
/* We need to re-enable the PHY if we are in idle state */
@@ -550,7 +550,7 @@ ll_task(void *arg)
break;
case BLE_LL_EVENT_HCI_CMD:
/* Process HCI command */
- ll_hci_cmd_proc(ev);
+ ble_ll_hci_cmd_proc(ev);
break;
case BLE_LL_EVENT_ADV_TXDONE:
ll_adv_tx_done_proc(ev->ev_arg);
@@ -616,6 +616,9 @@ ll_init(void)
/* Initialize receive packet (from phy) event */
g_ll_data.ll_rx_pkt_ev.ev_type = BLE_LL_EVENT_RX_PKT_IN;
+ /* Initialize LL HCI */
+ ble_ll_hci_init();
+
/* Init the scheduler */
ll_sched_init();
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/d49b73ce/net/nimble/controller/src/ll_hci.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ll_hci.c b/net/nimble/controller/src/ll_hci.c
index 841e3ef..e717f75 100644
--- a/net/nimble/controller/src/ll_hci.c
+++ b/net/nimble/controller/src/ll_hci.c
@@ -26,8 +26,8 @@
#include "controller/ll_hci.h"
/* LE event mask */
-uint8_t g_ll_hci_le_event_mask[BLE_HCI_SET_LE_EVENT_MASK_LEN];
-uint8_t g_ll_hci_event_mask[BLE_HCI_SET_EVENT_MASK_LEN];
+uint8_t g_ble_ll_hci_le_event_mask[BLE_HCI_SET_LE_EVENT_MASK_LEN];
+uint8_t g_ble_ll_hci_event_mask[BLE_HCI_SET_EVENT_MASK_LEN];
/**
* ll hci get num cmd pkts
@@ -38,13 +38,20 @@ uint8_t g_ll_hci_event_mask[BLE_HCI_SET_EVENT_MASK_LEN];
* @return uint8_t
*/
static uint8_t
-ll_hci_get_num_cmd_pkts(void)
+ble_ll_hci_get_num_cmd_pkts(void)
{
return BLE_LL_CFG_NUM_HCI_CMD_PKTS;
}
-static int
-ll_hci_event_send(uint8_t *evbuf)
+/**
+ * Send an event to the host.
+ *
+ * @param evbuf Pointer to event buffer to send
+ *
+ * @return int 0: success; -1 otherwise.
+ */
+int
+ble_ll_hci_event_send(uint8_t *evbuf)
{
int rc;
@@ -52,7 +59,7 @@ ll_hci_event_send(uint8_t *evbuf)
++g_ll_stats.hci_events_sent;
/* Send the event to the host */
- rc = hci_transport_ctlr_event_send(evbuf);
+ rc = ble_hci_transport_ctlr_event_send(evbuf);
return rc;
}
@@ -69,10 +76,10 @@ ll_hci_event_send(uint8_t *evbuf)
* @return int BLE_ERR_SUCCESS. Does not return any errors.
*/
static int
-ll_hci_set_le_event_mask(uint8_t *cmdbuf)
+ble_ll_hci_set_le_event_mask(uint8_t *cmdbuf)
{
/* Copy the data into the event mask */
- memcpy(g_ll_hci_le_event_mask, cmdbuf, BLE_HCI_SET_LE_EVENT_MASK_LEN);
+ memcpy(g_ble_ll_hci_le_event_mask, cmdbuf, BLE_HCI_SET_LE_EVENT_MASK_LEN);
return BLE_ERR_SUCCESS;
}
@@ -88,7 +95,7 @@ ll_hci_set_le_event_mask(uint8_t *cmdbuf)
* @return int
*/
static int
-ll_hci_le_read_bufsize(uint8_t *rspbuf)
+ble_ll_hci_le_read_bufsize(uint8_t *rspbuf)
{
/* Place the data packet length and number of packets in the buffer */
htole16(rspbuf, BLE_LL_CFG_ACL_DATA_PKT_LEN);
@@ -97,8 +104,28 @@ ll_hci_le_read_bufsize(uint8_t *rspbuf)
}
/**
- * ll hci le cmd proc
- *
+ * Checks to see if a LE event has been disabled by the host.
+ *
+ * @param bitpos This is the bit position of the LE event. Note that this can
+ * be a value from 0 to 63, inclusive.
+ *
+ * @return uint8_t 0: event is not enabled; otherwise event is enabled.
+ */
+uint8_t
+ble_ll_hci_is_le_event_enabled(int bitpos)
+{
+ uint8_t enabled;
+ uint8_t bytenum;
+ uint8_t bitmask;
+
+ bytenum = bitpos / 8;
+ bitmask = 1 << (bitpos & 0x7);
+ enabled = g_ble_ll_hci_le_event_mask[bytenum] & bitmask;
+
+ return enabled;
+}
+
+/**
* Process a LE command sent from the host to the controller. The HCI command
* has a 3 byte command header followed by data. The header is:
* -> opcode (2 bytes)
@@ -110,8 +137,8 @@ ll_hci_le_read_bufsize(uint8_t *rspbuf)
*
* @return int
*/
-int
-ll_hci_le_cmd_proc(uint8_t *cmdbuf, uint16_t ocf, uint8_t *rsplen)
+static int
+ble_ll_hci_le_cmd_proc(uint8_t *cmdbuf, uint16_t ocf, uint8_t *rsplen)
{
int rc;
uint8_t len;
@@ -136,12 +163,12 @@ ll_hci_le_cmd_proc(uint8_t *cmdbuf, uint16_t ocf, uint8_t *rsplen)
switch (ocf) {
case BLE_HCI_OCF_LE_SET_EVENT_MASK:
if (len == BLE_HCI_SET_LE_EVENT_MASK_LEN) {
- rc = ll_hci_set_le_event_mask(cmdbuf);
+ rc = ble_ll_hci_set_le_event_mask(cmdbuf);
}
break;
case BLE_HCI_OCF_LE_RD_BUF_SIZE:
if (len == BLE_HCI_RD_BUF_SIZE_LEN) {
- rc = ll_hci_le_read_bufsize(rspbuf);
+ rc = ble_ll_hci_le_read_bufsize(rspbuf);
*rsplen = 3;
}
break;
@@ -201,7 +228,7 @@ ll_hci_le_cmd_proc(uint8_t *cmdbuf, uint16_t ocf, uint8_t *rsplen)
}
void
-ll_hci_cmd_proc(struct os_event *ev)
+ble_ll_hci_cmd_proc(struct os_event *ev)
{
int rc;
uint8_t ogf;
@@ -229,7 +256,7 @@ ll_hci_cmd_proc(struct os_event *ev)
switch (ogf) {
case BLE_HCI_OGF_LE:
- rc = ll_hci_le_cmd_proc(cmdbuf, ocf, &rsplen);
+ rc = ble_ll_hci_le_cmd_proc(cmdbuf, ocf, &rsplen);
break;
case BLE_HCI_OGF_CTLR_BASEBAND:
/* XXX: Implement */
@@ -254,12 +281,12 @@ ll_hci_cmd_proc(struct os_event *ev)
/* Create a command complete event with status from command */
cmdbuf[0] = BLE_HCI_EVCODE_COMMAND_COMPLETE;
cmdbuf[1] = 4 + rsplen; /* Length of the data */
- cmdbuf[2] = ll_hci_get_num_cmd_pkts();
+ cmdbuf[2] = ble_ll_hci_get_num_cmd_pkts();
htole16(cmdbuf + 3, opcode);
cmdbuf[5] = (uint8_t)rc;
/* Send the event. This event cannot be masked */
- ll_hci_event_send(cmdbuf);
+ ble_ll_hci_event_send(cmdbuf);
} else {
/* XXX: placeholder for sending command status or other events */
assert(0);
@@ -268,7 +295,7 @@ ll_hci_cmd_proc(struct os_event *ev)
/* XXX: For now, put this here */
int
-hci_transport_host_cmd_send(uint8_t *cmd)
+ble_hci_transport_host_cmd_send(uint8_t *cmd)
{
os_error_t err;
struct os_event *ev;
@@ -290,17 +317,20 @@ hci_transport_host_cmd_send(uint8_t *cmd)
return 0;
}
+/**
+ * Initalize the LL HCI.
+ */
void
-ll_hci_init()
+ble_ll_hci_init(void)
{
/* Set defaults for LE events: Vol 2 Part E 7.8.1 */
- g_ll_hci_le_event_mask[0] = 0x1f;
+ g_ble_ll_hci_le_event_mask[0] = 0x1f;
/* Set defaults for controller/baseband events: Vol 2 Part E 7.3.1 */
- g_ll_hci_event_mask[0] = 0xff;
- g_ll_hci_event_mask[1] = 0xff;
- g_ll_hci_event_mask[2] = 0xff;
- g_ll_hci_event_mask[3] = 0xff;
- g_ll_hci_event_mask[4] = 0xff;
- g_ll_hci_event_mask[5] = 0x1f;
+ g_ble_ll_hci_event_mask[0] = 0xff;
+ g_ble_ll_hci_event_mask[1] = 0xff;
+ g_ble_ll_hci_event_mask[2] = 0xff;
+ g_ble_ll_hci_event_mask[3] = 0xff;
+ g_ble_ll_hci_event_mask[4] = 0xff;
+ g_ble_ll_hci_event_mask[5] = 0x1f;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/d49b73ce/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 cc4477e..aa13cbc 100644
--- a/net/nimble/host/src/host_hci.c
+++ b/net/nimble/host/src/host_hci.c
@@ -53,7 +53,7 @@ struct os_callout_func g_ble_host_hci_timer;
static int
host_hci_cmd_send(uint8_t *cmdbuf)
{
- return hci_transport_host_cmd_send(cmdbuf);
+ return ble_hci_transport_host_cmd_send(cmdbuf);
}
static int
@@ -297,7 +297,7 @@ host_hci_event_proc(struct os_event *ev)
/* XXX: For now, put this here */
int
-hci_transport_ctlr_event_send(uint8_t *hci_ev)
+ble_hci_transport_ctlr_event_send(uint8_t *hci_ev)
{
os_error_t err;
struct os_event *ev;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/d49b73ce/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 138d014..cff82bd 100644
--- a/net/nimble/include/nimble/hci_common.h
+++ b/net/nimble/include/nimble/hci_common.h
@@ -226,10 +226,30 @@
#define BLE_HCI_EVCODE_LE_META (0x3E)
/* XXX: Define them all... */
+/* LE sub-event codes */
+#define BLE_HCI_LE_SUBEV_CONN_COMPLETE (0x01)
+#define BLE_HCI_LE_SUBEV_ADV_RPT (0x02)
+#define BLE_HCI_LE_SUBEV_CONN_UPD_COMPLETE (0x03)
+#define BLE_HCI_LE_SUBEV_RD_REM_USED_FEAT (0x04)
+#define BLE_HCI_LE_SUBEV_LT_KEY_REQ (0x05)
+#define BLE_HCI_LE_SUBEV_REM_CONN_PARM_REQ (0x06)
+#define BLE_HCI_LE_SUBEV_DATA_LEN_CHG (0x07)
+#define BLE_HCI_LE_SUBEV_RD_LOC_P256_PUBKEY (0x08)
+#define BLE_HCI_LE_SUBEV_GEN_DHKEY_COMPLETE (0x09)
+#define BLE_HCI_LE_SUBEV_ENH_CONN_COMPLETE (0x0A)
+#define BLE_HCI_LE_SUBEV_DIRECT_ADV_RPT (0x0B)
+
/* Event specific definitions */
/* Event command complete */
#define BLE_HCI_EVENT_CMD_COMPLETE_HDR_LEN (6)
+/* Advertising report */
+#define BLE_HCI_ADV_RPT_EVTYPE_ADV_IND (0)
+#define BLE_HCI_ADV_RPT_EVTYPE_DIR_IND (1)
+#define BLE_HCI_ADV_RPT_EVTYPE_SCAN_IND (2)
+#define BLE_HCI_ADV_RPT_EVTYPE_NONCONN_IND (3)
+#define BLE_HCI_ADV_RPT_EVTYPE_SCAN_RSP (5)
+
/*--- Shared data structures ---*/
/* set advertising parameters command (ocf = 0x0006) */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/d49b73ce/net/nimble/include/nimble/hci_transport.h
----------------------------------------------------------------------
diff --git a/net/nimble/include/nimble/hci_transport.h b/net/nimble/include/nimble/hci_transport.h
index 6e8b951..3787c43 100644
--- a/net/nimble/include/nimble/hci_transport.h
+++ b/net/nimble/include/nimble/hci_transport.h
@@ -17,9 +17,9 @@
#define H_HCI_TRANSPORT_
/* Send a HCI command from the host to the controller */
-int hci_transport_host_cmd_send(uint8_t *cmd);
+int ble_hci_transport_host_cmd_send(uint8_t *cmd);
/* Send a HCI event from the controller to the host */
-int hci_transport_ctlr_event_send(uint8_t *hci_ev);
+int ble_hci_transport_ctlr_event_send(uint8_t *hci_ev);
#endif /* H_HCI_COMMON_ */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/d49b73ce/project/bletest/bletest.yml
----------------------------------------------------------------------
diff --git a/project/bletest/bletest.yml b/project/bletest/bletest.yml
index 5c5e4ed..c45dc08 100644
--- a/project/bletest/bletest.yml
+++ b/project/bletest/bletest.yml
@@ -3,3 +3,4 @@ project.eggs:
- libs/os
- net/nimble/controller
- net/nimble/host
+ - libs/console/full
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/d49b73ce/project/bletest/src/main.c
----------------------------------------------------------------------
diff --git a/project/bletest/src/main.c b/project/bletest/src/main.c
index 153a976..34bc283 100755
--- a/project/bletest/src/main.c
+++ b/project/bletest/src/main.c
@@ -13,12 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include <assert.h>
+#include <string.h>
#include "os/os.h"
#include "bsp/bsp.h"
#include "hal/hal_gpio.h"
#include "hal/hal_cputime.h"
-#include <assert.h>
-#include <string.h>
+#include "console/console.h"
/* BLE */
#include "nimble/ble.h"
@@ -158,6 +159,12 @@ bletest_init_scanner(void)
void
host_task_handler(void *arg)
{
+ int rc;
+
+ /* Init the console */
+ rc = console_init(NULL);
+ assert(rc == 0);
+
/* Initialize host HCI */
host_hci_init();
@@ -178,6 +185,9 @@ host_task_handler(void *arg)
bletest_state = 0;
g_next_os_time = os_time_get();
+ /* We are initialized */
+ console_printf("Nimble stack initialized");
+
/* Call the host hci task */
host_hci_task(arg);
}