Merge pull request #360 from sjanc/bt5_ext_adv

MYNEWT-715 Extended Advertising - Advertiser support for controller

X-Original-Commit: 0d96596be5e2473b7f27f097ae845dc6d90fa76b
This commit is contained in:
Łukasz Rymanowski
2017-06-30 08:04:25 +02:00
committed by GitHub
18 changed files with 1640 additions and 500 deletions
@@ -203,6 +203,7 @@ extern STATS_SECT_DECL(ble_ll_stats) ble_ll_stats;
/* LL timing */
#define BLE_LL_IFS (150) /* usecs */
#define BLE_LL_MAFS (300) /* usecs */
/*
* BLE LL device address. Note that element 0 of the array is the LSB and
@@ -270,6 +271,34 @@ struct ble_dev_addr
#define BLE_ADV_PDU_TYPE_AUX_SCAN_REQ BLE_ADV_PDU_TYPE_SCAN_REQ
#define BLE_ADV_PDU_TYPE_AUX_CONNECT_RSP (8)
#define BLE_ADV_PDU_TYPE_AUX_SCAN_REQ BLE_ADV_PDU_TYPE_SCAN_REQ
#define BLE_ADV_PDU_TYPE_AUX_CONNECT_REQ BLE_ADV_PDU_TYPE_CONNECT_REQ
#define BLE_ADV_PDU_TYPE_ADV_EXT_IND (7)
#define BLE_ADV_PDU_TYPE_AUX_ADV_IND BLE_ADV_PDU_TYPE_ADV_EXT_IND
#define BLE_ADV_PDU_TYPE_AUX_SCAN_RSP BLE_ADV_PDU_TYPE_ADV_EXT_IND
#define BLE_ADV_PDU_TYPE_AUX_SYNC_IND BLE_ADV_PDU_TYPE_ADV_EXT_IND
#define BLE_ADV_PDU_TYPE_AUX_CHAIN_IND BLE_ADV_PDU_TYPE_ADV_EXT_IND
#define BLE_ADV_PDU_TYPE_AUX_CONNECT_RSP (8)
#define BLE_LL_EXT_ADV_ADVA_BIT (0)
#define BLE_LL_EXT_ADV_TARGETA_BIT (1)
#define BLE_LL_EXT_ADV_RFU_BIT (2)
#define BLE_LL_EXT_ADV_DATA_INFO_BIT (3)
#define BLE_LL_EXT_ADV_AUX_PTR_BIT (4)
#define BLE_LL_EXT_ADV_SYNC_INFO_BIT (5)
#define BLE_LL_EXT_ADV_TX_POWER_BIT (6)
#define BLE_LL_EXT_ADV_ADVA_SIZE (6)
#define BLE_LL_EXT_ADV_TARGETA_SIZE (6)
#define BLE_LL_EXT_ADV_DATA_INFO_SIZE (2)
#define BLE_LL_EXT_ADV_AUX_PTR_SIZE (3)
#define BLE_LL_EXT_ADV_SYNC_INFO_SIZE (18)
#define BLE_LL_EXT_ADV_TX_POWER_SIZE (1)
#define BLE_LL_EXT_ADV_MODE_NON_CONN (0x00)
#define BLE_LL_EXT_ADV_MODE_CONN (0x01)
#define BLE_LL_EXT_ADV_MODE_SCAN (0x02)
/* If Channel Selection Algorithm #2 is supported */
#define BLE_ADV_PDU_HDR_CHSEL (0x20)
@@ -113,25 +113,22 @@ int ble_ll_adv_start_req(uint8_t adv_chanmask, uint8_t adv_type,
uint8_t *init_addr, uint16_t adv_itvl, void *handle);
/* Start or stop advertising */
int ble_ll_adv_set_enable(uint8_t *cmd, uint8_t instance);
int ble_ll_adv_set_enable(uint8_t instance, uint8_t enable, uint16_t duration,
uint8_t event);
/* Set advertising data */
int ble_ll_adv_set_adv_data(uint8_t *cmd, uint8_t instance);
int ble_ll_adv_set_adv_data(uint8_t *cmd, uint8_t instance, uint8_t operation);
/* Set scan response data */
int ble_ll_adv_set_scan_rsp_data(uint8_t *cmd, uint8_t instance);
int ble_ll_adv_set_scan_rsp_data(uint8_t *cmd, uint8_t instance,
uint8_t operation);
/* Set advertising parameters */
int ble_ll_adv_set_adv_params(uint8_t *cmd, uint8_t instance, int is_multi);
int ble_ll_adv_set_adv_params(uint8_t *cmd);
/* Read advertising channel power */
int ble_ll_adv_read_txpwr(uint8_t *rspbuf, uint8_t *rsplen);
#if MYNEWT_VAL(BLE_MULTI_ADV_SUPPORT)
int ble_ll_adv_multi_adv_cmd(uint8_t *cmd, uint8_t cmdlen, uint8_t *rspbuf,
uint8_t *rsplen);
#endif
/*---- API used by BLE LL ----*/
/* Send the connection complete event */
void ble_ll_adv_send_conn_comp_ev(struct ble_ll_conn_sm *connsm,
@@ -165,9 +162,6 @@ void ble_ll_adv_rx_pkt_in(uint8_t ptype, uint8_t *rxbuf,
/* Boolean function denoting whether or not the whitelist can be changed */
int ble_ll_adv_can_chg_whitelist(void);
/* Called when an advertising event has been scheduled */
void ble_ll_adv_scheduled(struct ble_ll_adv_sm *, uint32_t sch_start);
/*
* Called when an advertising event has been removed from the scheduler
* without being run.
@@ -180,6 +174,14 @@ void ble_ll_adv_halt(struct ble_ll_adv_sm *advsm);
/* Called to determine if advertising is enabled */
uint8_t ble_ll_adv_enabled(void);
int ble_ll_adv_set_random_addr(uint8_t *addr, uint8_t instance);
int ble_ll_adv_remove(uint8_t instance);
int ble_ll_adv_clear_all(void);
int ble_ll_adv_ext_set_param(uint8_t *cmdbuf, uint8_t *rspbuf, uint8_t *rsplen);
int ble_ll_adv_ext_set_adv_data(uint8_t *cmdbuf, uint8_t cmdlen);
int ble_ll_adv_ext_set_scan_rsp(uint8_t *cmdbuf, uint8_t cmdlen);
int ble_ll_adv_ext_set_enable(uint8_t *cmdbuf, uint8_t len);
#ifdef __cplusplus
}
#endif
@@ -270,6 +270,10 @@ int ble_ll_hci_ev_ltk_req(struct ble_ll_conn_sm *connsm);
int ble_ll_hci_ev_hw_err(uint8_t hw_err);
void ble_ll_hci_ev_databuf_overflow(void);
void ble_ll_hci_ev_le_csa(struct ble_ll_conn_sm *connsm);
void ble_ll_hci_ev_send_scan_req_recv(uint8_t adv_handle, const uint8_t *peer,
uint8_t peer_addr_type);
void ble_ll_hci_ev_send_adv_set_terminated(uint8_t status, uint8_t adv_handle,
uint16_t conn_handle, uint8_t events);
int ble_ll_hci_ev_phy_update(struct ble_ll_conn_sm *connsm, uint8_t status);
void ble_ll_calc_session_key(struct ble_ll_conn_sm *connsm);
void ble_ll_ctrl_phy_update_proc_complete(struct ble_ll_conn_sm *connsm);
@@ -111,8 +111,11 @@ int ble_ll_sched_master_new(struct ble_ll_conn_sm *connsm,
/* Schedule a new slave connection */
int ble_ll_sched_slave_new(struct ble_ll_conn_sm *connsm);
struct ble_ll_adv_sm;
typedef void ble_ll_sched_adv_new_cb(struct ble_ll_adv_sm *advsm, uint32_t sch_start);
/* Schedule a new advertising event */
int ble_ll_sched_adv_new(struct ble_ll_sched_item *sch);
int ble_ll_sched_adv_new(struct ble_ll_sched_item *sch, ble_ll_sched_adv_new_cb cb);
/* Reschedule an advertising event */
int ble_ll_sched_adv_reschedule(struct ble_ll_sched_item *sch, uint32_t *start,
@@ -121,6 +121,9 @@ int ble_phy_rssi_get(void);
/* Set the transmit power */
int ble_phy_txpwr_set(int dbm);
/* Get highest allowed power from range */
int ble_phy_txpower_round(int dbm);
/* Get the transmit power */
int ble_phy_txpwr_get(void);
File diff suppressed because it is too large Load Diff
+23 -5
View File
@@ -2291,9 +2291,24 @@ ble_ll_conn_created(struct ble_ll_conn_sm *connsm, struct ble_mbuf_hdr *rxhdr)
connsm->last_anchor_point = rxhdr->beg_cputime;
usecs = rxhdr->rem_usecs + 1250 +
(connsm->tx_win_off * BLE_LL_CONN_TX_WIN_USECS) +
ble_ll_pdu_tx_time_get(BLE_CONNECT_REQ_LEN,
connsm->phy_data.tx_phy_mode);
(connsm->tx_win_off * BLE_LL_CONN_TX_WIN_USECS) +
ble_ll_pdu_tx_time_get(BLE_CONNECT_REQ_LEN,
connsm->phy_data.rx_phy_mode);
if (rxhdr->rxinfo.channel < BLE_PHY_NUM_DATA_CHANS) {
switch (rxhdr->rxinfo.phy) {
case BLE_PHY_1M:
usecs += 1250;
break;
case BLE_PHY_CODED:
usecs += 2500;
break;
case BLE_PHY_2M:
default:
assert(0);
break;
}
}
/* Anchor point is cputime. */
endtime = os_cputime_usecs_to_ticks(usecs);
@@ -3714,7 +3729,8 @@ ble_ll_conn_set_global_chanmap(uint8_t num_used_chans, uint8_t *chanmap)
* @return 0: connection not started; 1 connecton started
*/
int
ble_ll_conn_slave_start(uint8_t *rxbuf, uint8_t pat, struct ble_mbuf_hdr *rxhdr)
ble_ll_conn_slave_start(uint8_t *rxbuf, uint8_t pat, struct ble_mbuf_hdr *rxhdr,
bool force_csa2)
{
int rc;
uint32_t temp;
@@ -3804,7 +3820,9 @@ ble_ll_conn_slave_start(uint8_t *rxbuf, uint8_t pat, struct ble_mbuf_hdr *rxhdr)
/* Start the connection state machine */
connsm->conn_role = BLE_LL_CONN_ROLE_SLAVE;
ble_ll_conn_sm_new(connsm);
ble_ll_conn_set_csa(connsm, rxbuf[0] & BLE_ADV_PDU_HDR_CHSEL_MASK);
ble_ll_conn_set_csa(connsm,
force_csa2 || (rxbuf[0] & BLE_ADV_PDU_HDR_CHSEL_MASK));
/* Set initial schedule callback */
connsm->conn_sch.sched_cb = ble_ll_conn_event_start_cb;
+1 -1
View File
@@ -112,7 +112,7 @@ void ble_ll_conn_datalen_update(struct ble_ll_conn_sm *connsm,
/* Advertising interface */
int ble_ll_conn_slave_start(uint8_t *rxbuf, uint8_t pat,
struct ble_mbuf_hdr *rxhdr);
struct ble_mbuf_hdr *rxhdr, bool force_csa2);
/* Link Layer interface */
void ble_ll_conn_module_init(void);
+59 -72
View File
@@ -24,7 +24,6 @@
#include "nimble/ble.h"
#include "nimble/nimble_opt.h"
#include "nimble/hci_common.h"
#include "nimble/hci_vendor.h"
#include "nimble/ble_hci_trans.h"
#include "controller/ble_hw.h"
#include "controller/ble_ll_adv.h"
@@ -582,8 +581,25 @@ ble_ll_hci_le_cmd_send_cmd_status(uint16_t ocf)
return rc;
}
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
/** HCI LE read maximum advertising data length command. Returns the controllers
* max supported advertising data length;
*
* @param rspbuf Pointer to response buffer
* @param rsplen Length of response buffer
*
* @return int BLE error code
*/
static int
ble_ll_adv_rd_max_adv_data_len(uint8_t *rspbuf, uint8_t *rsplen)
{
put_le16(rspbuf, BLE_ADV_DATA_MAX_LEN);
*rsplen = BLE_HCI_RD_MAX_ADV_DATA_LEN;
return BLE_ERR_SUCCESS;
}
/**
* Returns the vendor specific capabilities
* HCI LE read number of supported advertising sets
*
* @param rspbuf Pointer to response buffer
* @param rsplen Length of response buffer
@@ -591,78 +607,21 @@ ble_ll_hci_le_cmd_send_cmd_status(uint16_t ocf)
* @return int BLE error code
*/
static int
ble_ll_hci_vendor_caps(uint8_t *rspbuf, uint8_t *rsplen)
ble_ll_adv_rd_sup_adv_sets(uint8_t *rspbuf, uint8_t *rsplen)
{
/* Clear all bytes */
memset(rspbuf, 0, 14);
/* Fill out the ones we support */
rspbuf[0] = BLE_LL_ADV_INSTANCES;
rspbuf[9] = 0x60;
*rsplen = 14;
*rsplen = BLE_HCI_RD_NR_SUP_ADV_SETS;
return BLE_ERR_SUCCESS;
}
/**
* Process a vendor 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)
* -> Length of parameters (1 byte; does include command header bytes).
*
* @param cmdbuf Pointer to command buffer. Points to start of command header.
* @param ocf Opcode command field.
* @param *rsplen Pointer to length of response
*
* @return int This function returns a BLE error code. If a command status
* event should be returned as opposed to command complete,
* 256 gets added to the return value.
*/
static int
ble_ll_hci_vendor_cmd_proc(uint8_t *cmdbuf, uint16_t ocf, uint8_t *rsplen)
ble_ll_ext_adv_set_remove(uint8_t *cmd)
{
int rc;
uint8_t cmdlen;
uint8_t *rspbuf;
/* Assume error; if all pass rc gets set to 0 */
rc = BLE_ERR_INV_HCI_CMD_PARMS;
/* Get length from command */
cmdlen = cmdbuf[sizeof(uint16_t)];
/*
* The command response pointer points into the same buffer as the
* command data itself. That is fine, as each command reads all the data
* before crafting a response.
*/
rspbuf = cmdbuf + BLE_HCI_EVENT_CMD_COMPLETE_MIN_LEN;
/* Move past HCI command header */
cmdbuf += BLE_HCI_CMD_HDR_LEN;
switch (ocf) {
case BLE_HCI_OCF_VENDOR_CAPS:
if (cmdlen == 0) {
ble_ll_hci_vendor_caps(rspbuf, rsplen);
rc = BLE_ERR_SUCCESS;
}
break;
#if MYNEWT_VAL(BLE_MULTI_ADV_SUPPORT)
case BLE_HCI_OCF_MULTI_ADV:
if (cmdlen > 0) {
rc = ble_ll_adv_multi_adv_cmd(cmdbuf, cmdlen, rspbuf, rsplen);
}
break;
#endif
default:
rc = BLE_ERR_UNKNOWN_HCI_CMD;
break;
}
/* XXX: for now, all vendor commands return a command complete */
return rc;
return ble_ll_adv_remove(cmd[0]);
}
#endif
/**
* 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:
@@ -721,19 +680,21 @@ ble_ll_hci_le_cmd_proc(uint8_t *cmdbuf, uint16_t ocf, uint8_t *rsplen)
rc = ble_ll_set_random_addr(cmdbuf);
break;
case BLE_HCI_OCF_LE_SET_ADV_PARAMS:
rc = ble_ll_adv_set_adv_params(cmdbuf, 0, 0);
rc = ble_ll_adv_set_adv_params(cmdbuf);
break;
case BLE_HCI_OCF_LE_RD_ADV_CHAN_TXPWR:
rc = ble_ll_adv_read_txpwr(rspbuf, rsplen);
break;
case BLE_HCI_OCF_LE_SET_ADV_DATA:
rc = ble_ll_adv_set_adv_data(cmdbuf, 0);
rc = ble_ll_adv_set_adv_data(cmdbuf, 0,
BLE_HCI_LE_SET_EXT_ADV_DATA_OPER_COMPLETE);
break;
case BLE_HCI_OCF_LE_SET_SCAN_RSP_DATA:
rc = ble_ll_adv_set_scan_rsp_data(cmdbuf, 0);
rc = ble_ll_adv_set_scan_rsp_data(cmdbuf, 0,
BLE_HCI_LE_SET_EXT_SCAN_RSP_DATA_OPER_COMPLETE);
break;
case BLE_HCI_OCF_LE_SET_ADV_ENABLE:
rc = ble_ll_adv_set_enable(cmdbuf, 0);
rc = ble_ll_adv_set_enable(cmdbuf[0], 0, 0, 0);
break;
case BLE_HCI_OCF_LE_SET_SCAN_ENABLE:
rc = ble_ll_scan_set_enable(cmdbuf, 0);
@@ -852,6 +813,35 @@ ble_ll_hci_le_cmd_proc(uint8_t *cmdbuf, uint16_t ocf, uint8_t *rsplen)
case BLE_HCI_OCF_LE_RD_MAX_DATA_LEN:
rc = ble_ll_hci_le_rd_max_data_len(rspbuf, rsplen);
break;
#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV) == 1)
case BLE_HCI_OCF_LE_SET_ADV_SET_RND_ADDR:
rc = ble_ll_adv_set_random_addr(cmdbuf + 1, cmdbuf[0]);
break;
case BLE_HCI_OCF_LE_SET_EXT_ADV_PARAM:
rc = ble_ll_adv_ext_set_param(cmdbuf, rspbuf, rsplen);
break;
case BLE_HCI_OCF_LE_SET_EXT_ADV_DATA:
rc = ble_ll_adv_ext_set_adv_data(cmdbuf, cmdlen);
break;
case BLE_HCI_OCF_LE_SET_EXT_SCAN_RSP_DATA:
rc = ble_ll_adv_ext_set_scan_rsp(cmdbuf, cmdlen);
break;
case BLE_HCI_OCF_LE_SET_EXT_ADV_ENABLE:
rc = ble_ll_adv_ext_set_enable(cmdbuf, len);
break;
case BLE_HCI_OCF_LE_RD_MAX_ADV_DATA_LEN:
rc = ble_ll_adv_rd_max_adv_data_len(rspbuf, rsplen);
break;
case BLE_HCI_OCF_LE_RD_NUM_OF_ADV_SETS:
rc = ble_ll_adv_rd_sup_adv_sets(rspbuf, rsplen);
break;
case BLE_HCI_OCF_LE_REMOVE_ADV_SET:
rc = ble_ll_ext_adv_set_remove(cmdbuf);
break;
case BLE_HCI_OCF_LE_CLEAR_ADV_SETS:
rc = ble_ll_adv_clear_all();
break;
#endif
#if (BLE_LL_BT5_PHY_SUPPORTED == 1)
case BLE_HCI_OCF_LE_RD_PHY:
rc = ble_ll_conn_hci_le_rd_phy(cmdbuf, rspbuf, rsplen);
@@ -1122,9 +1112,6 @@ ble_ll_hci_cmd_proc(struct os_event *ev)
case BLE_HCI_OGF_LE:
rc = ble_ll_hci_le_cmd_proc(cmdbuf, ocf, &rsplen);
break;
case BLE_HCI_OGF_VENDOR:
rc = ble_ll_hci_vendor_cmd_proc(cmdbuf, ocf, &rsplen);
break;
default:
/* XXX: Need to support other OGF. For now, return unsupported */
rc = BLE_ERR_UNKNOWN_HCI_CMD;
+53
View File
@@ -293,6 +293,59 @@ ble_ll_hci_ev_le_csa(struct ble_ll_conn_sm *connsm)
}
#endif
/**
* Sends the LE Scan Request Received event
*
*/
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
void
ble_ll_hci_ev_send_scan_req_recv(uint8_t adv_handle, const uint8_t *peer,
uint8_t peer_addr_type)
{
uint8_t *evbuf;
if (ble_ll_hci_is_le_event_enabled(BLE_HCI_LE_SUBEV_SCAN_REQ_RCVD)) {
evbuf = ble_hci_trans_buf_alloc(BLE_HCI_TRANS_BUF_EVT_HI);
if (evbuf) {
evbuf[0] = BLE_HCI_EVCODE_LE_META;
evbuf[1] = BLE_HCI_LE_SUBEV_SCAN_REQ_RCVD_LEN;
evbuf[2] = BLE_HCI_LE_SUBEV_SCAN_REQ_RCVD;
evbuf[3] = adv_handle;
evbuf[4] = peer_addr_type;
memcpy(&evbuf[5], peer, BLE_DEV_ADDR_LEN);
ble_ll_hci_event_send(evbuf);
}
}
}
#endif
/**
* Sends the LE Advertising Set Terminated event
*
*/
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
void
ble_ll_hci_ev_send_adv_set_terminated(uint8_t status, uint8_t adv_handle,
uint16_t conn_handle, uint8_t events)
{
uint8_t *evbuf;
if (ble_ll_hci_is_le_event_enabled(BLE_HCI_LE_SUBEV_ADV_SET_TERMINATED)) {
evbuf = ble_hci_trans_buf_alloc(BLE_HCI_TRANS_BUF_EVT_HI);
if (evbuf) {
evbuf[0] = BLE_HCI_EVCODE_LE_META;
evbuf[1] = BLE_HCI_LE_SUBEV_ADV_SET_TERMINATED_LEN;
evbuf[2] = BLE_HCI_LE_SUBEV_ADV_SET_TERMINATED;
evbuf[3] = status;
evbuf[4] = adv_handle;
put_le16(evbuf + 5, conn_handle);
evbuf[7] = events;
ble_ll_hci_event_send(evbuf);
}
}
}
#endif
/**
* Send a PHY update complete event
*
+4 -2
View File
@@ -595,7 +595,7 @@ ble_ll_sched_slave_new(struct ble_ll_conn_sm *connsm)
}
int
ble_ll_sched_adv_new(struct ble_ll_sched_item *sch)
ble_ll_sched_adv_new(struct ble_ll_sched_item *sch, ble_ll_sched_adv_new_cb cb)
{
int rc;
os_sr_t sr;
@@ -646,7 +646,9 @@ ble_ll_sched_adv_new(struct ble_ll_sched_item *sch)
sch = TAILQ_FIRST(&g_ble_ll_sched_q);
}
ble_ll_adv_scheduled((struct ble_ll_adv_sm *)orig->cb_arg, adv_start);
if (cb) {
cb((struct ble_ll_adv_sm *)orig->cb_arg, adv_start);
}
#ifdef BLE_XCVR_RFCLK
if (orig == sch) {
+23
View File
@@ -497,6 +497,29 @@ ble_phy_txpwr_set(int dbm)
return 0;
}
/**
* ble phy txpwr round
*
* Get the rounded transmit output power (in dBm).
*
* @param dbm Power output in dBm.
*
* @return int Rounded power in dBm
*/
int ble_phy_txpower_round(int dbm)
{
/* "Rail" power level if outside supported range */
if (dbm > BLE_XCVR_TX_PWR_MAX_DBM) {
dbm = BLE_XCVR_TX_PWR_MAX_DBM;
} else {
if (dbm < BLE_XCVR_TX_PWR_MIN_DBM) {
dbm = BLE_XCVR_TX_PWR_MIN_DBM;
}
}
return dbm;
}
/**
* ble phy txpwr get
*
+23
View File
@@ -1212,6 +1212,29 @@ ble_phy_txpwr_set(int dbm)
return 0;
}
/**
* ble phy txpwr round
*
* Get the rounded transmit output power (in dBm).
*
* @param dbm Power output in dBm.
*
* @return int Rounded power in dBm
*/
int ble_phy_txpower_round(int dbm)
{
/* "Rail" power level if outside supported range */
if (dbm > NRF_TX_PWR_MAX_DBM) {
dbm = NRF_TX_PWR_MAX_DBM;
} else {
if (dbm < NRF_TX_PWR_MIN_DBM) {
dbm = NRF_TX_PWR_MIN_DBM;
}
}
return dbm;
}
/**
* ble phy txpwr get
*
+23
View File
@@ -1294,6 +1294,29 @@ ble_phy_txpwr_set(int dbm)
return 0;
}
/**
* ble phy txpwr round
*
* Get the rounded transmit output power (in dBm).
*
* @param dbm Power output in dBm.
*
* @return int Rounded power in dBm
*/
int ble_phy_txpower_round(int dbm)
{
/* "Rail" power level if outside supported range */
if (dbm > NRF_TX_PWR_MAX_DBM) {
dbm = NRF_TX_PWR_MAX_DBM;
} else {
if (dbm < NRF_TX_PWR_MIN_DBM) {
dbm = NRF_TX_PWR_MIN_DBM;
}
}
return dbm;
}
/**
* ble phy set access addr
*
+5 -3
View File
@@ -67,10 +67,9 @@ struct ble_mbuf_hdr_rxinfo
uint8_t handle;
int8_t rssi;
int8_t phy;
#if MYNEWT_VAL(BLE_MULTI_ADV_SUPPORT)
void *advsm; /* advertising state machine */
#endif
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
/* TODO this could be just one user-data pointer */
void *advsm; /* advertising state machine */
void *aux_data;
#endif
};
@@ -208,6 +207,9 @@ enum ble_error_codes
BLE_ERR_CONN_ESTABLISHMENT = 62,
BLE_ERR_MAC_CONN_FAIL = 63,
BLE_ERR_COARSE_CLK_ADJ = 64,
BLE_ERR_TYPE0_SUBMAP_NDEF = 65,
BLE_ERR_UNK_ADV_INDENT = 66,
BLE_RR_LIMIT_REACHED = 67,
BLE_ERR_MAX = 255
};
+35
View File
@@ -467,12 +467,35 @@ extern "C" {
/* --- LE set extended advertising parameters (OCF 0x0036) */
#define BLE_HCI_LE_SET_EXT_ADV_PARAM_LEN (25)
#define BLE_HCI_LE_SET_EXT_ADV_PROP_CONNECTABLE (0x0001)
#define BLE_HCI_LE_SET_EXT_ADV_PROP_SCANNABLE (0x0002)
#define BLE_HCI_LE_SET_EXT_ADV_PROP_DIRECTED (0x0004)
#define BLE_HCI_LE_SET_EXT_ADV_PROP_HD_DIRECTED (0x0008)
#define BLE_HCI_LE_SET_EXT_ADV_PROP_LEGACY (0x0010)
#define BLE_HCI_LE_SET_EXT_ADV_PROP_ANON_ADV (0x0020)
#define BLE_HCI_LE_SET_EXT_ADV_PROP_INC_TX_PWR (0x0040)
#define BLE_HCI_LE_SET_EXT_ADV_PROP_MASK (0x7F)
#define BLE_HCI_LE_SET_EXT_ADV_PROP_LEGACY_IND (0x0013)
#define BLE_HCI_LE_SET_EXT_ADV_PROP_LEGACY_LD_DIR (0x0015)
#define BLE_HCI_LE_SET_EXT_ADV_PROP_LEGACY_HD_DIR (0x001d)
#define BLE_HCI_LE_SET_EXT_ADV_PROP_LEGACY_SCAN (0x0012)
#define BLE_HCI_LE_SET_EXT_ADV_PROP_LEGACY_NONCONN (0x0010)
/* --- LE set extended advertising data (OCF 0x0037) */
#define BLE_HCI_LE_SET_EXT_ADV_DATA_LEN BLE_HCI_VARIABLE_LEN
#define BLE_HCI_LE_SET_EXT_ADV_DATA_OPER_INT (0)
#define BLE_HCI_LE_SET_EXT_ADV_DATA_OPER_FIRST (1)
#define BLE_HCI_LE_SET_EXT_ADV_DATA_OPER_LAST (2)
#define BLE_HCI_LE_SET_EXT_ADV_DATA_OPER_COMPLETE (3)
#define BLE_HCI_LE_SET_EXT_ADV_DATA_OPER_UNCHANGED (4)
/* --- LE set extended scan response data (OCF 0x0038) */
#define BLE_HCI_LE_SET_EXT_SCAN_RSP_DATA_LEN BLE_HCI_VARIABLE_LEN
#define BLE_HCI_LE_SET_EXT_SCAN_RSP_DATA_OPER_INT (0)
#define BLE_HCI_LE_SET_EXT_SCAN_RSP_DATA_OPER_FIRST (1)
#define BLE_HCI_LE_SET_EXT_SCAN_RSP_DATA_OPER_LAST (2)
#define BLE_HCI_LE_SET_EXT_SCAN_RSP_DATA_OPER_COMPLETE (3)
/* --- LE set extended advertising enable (OCF 0x0039) */
#define BLE_HCI_LE_SET_EXT_ADV_ENABLE_LEN BLE_HCI_VARIABLE_LEN
@@ -480,6 +503,12 @@ extern "C" {
/* --- LE remove advertising set (OCF 0x003C) */
#define BLE_HCI_LE_REMOVE_ADV_SET_LEN (1)
/* --- LE read maximum advertising data length (OCF 0x003A) */
#define BLE_HCI_RD_MAX_ADV_DATA_LEN (2)
/* --- LE read number of supported advertising sets (OCF 0x003B) */
#define BLE_HCI_RD_NR_SUP_ADV_SETS (1)
/* --- LE set periodic advertising parameters (OCF 0x003E) */
#define BLE_HCI_LE_SET_PER_ADV_PARAMS_LEN (7)
@@ -706,6 +735,12 @@ extern "C" {
/* LE PHY update complete event (sub event 0x0C) */
#define BLE_HCI_LE_PHY_UPD_LEN (6)
/* LE Advertising Set Terminated Event (sub event 0x12) */
#define BLE_HCI_LE_SUBEV_ADV_SET_TERMINATED_LEN (6)
/* LE Scan Request Received event (sub event 0x13) */
#define BLE_HCI_LE_SUBEV_SCAN_REQ_RCVD_LEN (9)
/* LE Channel Selection Algorithm event (sub event 0x14) */
#define BLE_HCI_LE_SUBEV_CHAN_SEL_ALG_LEN (4)
-112
View File
@@ -1,112 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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_HCI_VENDOR_
#define H_BLE_HCI_VENDOR_
#ifdef __cplusplus
extern "C" {
#endif
/* Here is a list of the vendor specific OCFs */
#define BLE_HCI_OCF_VENDOR_CAPS (0x153)
#define BLE_HCI_OCF_MULTI_ADV (0x154)
/* Multi-advertiser sub-commands */
#define BLE_HCI_MULTI_ADV_PARAMS (0x01)
#define BLE_HCI_MULTI_ADV_DATA (0x02)
#define BLE_HCI_MULTI_ADV_SCAN_RSP_DATA (0x03)
#define BLE_HCI_MULTI_ADV_SET_RAND_ADDR (0x04)
#define BLE_HCI_MULTI_ADV_ENABLE (0x05)
/* Command lengths. Includes sub-command opcode */
#define BLE_HCI_MULTI_ADV_PARAMS_LEN (24)
#define BLE_HCI_MULTI_ADV_DATA_LEN (34)
#define BLE_HCI_MULTI_ADV_SCAN_RSP_DATA_LEN (34)
#define BLE_HCI_MULTI_ADV_SET_RAND_ADDR_LEN (8)
#define BLE_HCI_MULTI_ADV_ENABLE_LEN (3)
/* Vendor specific events (LE meta events) */
#define BLE_HCI_LE_SUBEV_ADV_STATE_CHG (0x55)
/* Data structures associated with vendor specific commands */
struct hci_vendor_capabilities
{
uint8_t max_advt_instances;
uint8_t offloaded_resolution_of_priv_addr;
uint16_t total_scan_results_bytes;
uint8_t max_irk_list_sz;
uint8_t filtering_support;
uint8_t max_filters;
uint8_t activity_energy_info_support;
uint16_t version_supported;
uint16_t total_adv_tracked;
uint8_t extended_scan_support;
uint8_t debug_logging_supported;
};
/* NOTE: these are not in command order */
struct hci_multi_adv_params
{
uint8_t adv_type;
uint8_t adv_channel_map;
uint8_t own_addr_type;
uint8_t peer_addr_type;
uint8_t adv_filter_policy;
int8_t adv_tx_pwr; /* -70 to +20 */
uint8_t adv_instance;
uint16_t adv_itvl_min;
uint16_t adv_itvl_max;
uint8_t peer_addr[BLE_DEV_ADDR_LEN];
uint8_t own_addr[BLE_DEV_ADDR_LEN];
};
/*
* NOTE: structures are not defined for the following sub commands.
* The format of these commands is:
*
* Multi-adv Set Advertising Data:
* - Advertising data length (1)
* - Advertising data (31)
* - Advertising Instance (1)
*
* Multi-adv Set Scan Response Data:
* - Scan response data length (1)
* - Scan response data (31)
* - Advertising Instance (1)
*
* Multi-adv Set Random Address:
* - Random Address (6)
* - Advertising Instance (1)
*
* Multi-adv Set Advertising Enable:
* - Random Address (6)
* - Advertising Instance (1)
*
* All of these commands generate a Command Complete with this format:
* - Status (1)
* - Multi-adv opcode (1)
*/
#ifdef __cplusplus
}
#endif
#endif /* H_BLE_HCI_VENDOR_ */
-3
View File
@@ -41,9 +41,6 @@ syscfg.defs:
Enables the BLE whitelist for controlling who to connect to or
accept a connection from. (0/1)
value: 1
BLE_MULTI_ADV_SUPPORT:
description: 'Support for multi-advertisers'
value: 0
BLE_MULTI_ADV_INSTANCES:
description: >
This is the number of multi-advertising instances. This is NOT the