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 2017/04/25 17:54:20 UTC
[5/7] incubator-mynewt-core git commit: nimble/hci: Add LE set
default PHY command
nimble/hci: Add LE set default PHY command
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/086c852f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/086c852f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/086c852f
Branch: refs/heads/bluetooth5
Commit: 086c852fa67375b5a5ce3875456875330051c56c
Parents: 7744296
Author: \u0141ukasz Rymanowski <lu...@codecoup.pl>
Authored: Tue Apr 11 09:17:33 2017 +0200
Committer: \u0141ukasz Rymanowski <lu...@codecoup.pl>
Committed: Wed Apr 19 11:04:09 2017 +0200
----------------------------------------------------------------------
net/nimble/host/src/ble_hs_hci_cmd.c | 53 +++++++++++++++++++++++++++++
net/nimble/host/src/ble_hs_hci_priv.h | 3 ++
net/nimble/include/nimble/hci_common.h | 6 ++++
3 files changed, 62 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/086c852f/net/nimble/host/src/ble_hs_hci_cmd.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_hci_cmd.c b/net/nimble/host/src/ble_hs_hci_cmd.c
index a51df5d..354adc1 100644
--- a/net/nimble/host/src/ble_hs_hci_cmd.c
+++ b/net/nimble/host/src/ble_hs_hci_cmd.c
@@ -1241,6 +1241,59 @@ ble_hs_hci_build_le_read_phy(uint16_t conn_handle, uint8_t *dst, int dst_len)
}
static int
+ble_hs_hci_cmd_body_le_set_default_phy(uint8_t tx_phys_mask,
+ uint8_t rx_phys_mask,
+ uint8_t *dst)
+{
+ if (tx_phys_mask > (BLE_HCI_LE_PHY_1M_PREF_MASK |
+ BLE_HCI_LE_PHY_2M_PREF_MASK |
+ BLE_HCI_LE_PHY_CODED_PREF_MASK)) {
+ return BLE_ERR_INV_HCI_CMD_PARMS;
+ }
+
+ if (rx_phys_mask > (BLE_HCI_LE_PHY_1M_PREF_MASK |
+ BLE_HCI_LE_PHY_2M_PREF_MASK |
+ BLE_HCI_LE_PHY_CODED_PREF_MASK)) {
+ return BLE_ERR_INV_HCI_CMD_PARMS;
+ }
+
+ if (tx_phys_mask == 0) {
+ dst[0] |= BLE_HCI_LE_PHY_NO_TX_PREF_MASK;
+ } else {
+ dst[1] = tx_phys_mask;
+ }
+
+ if (rx_phys_mask == 0){
+ dst[0] |= BLE_HCI_LE_PHY_NO_RX_PREF_MASK;
+ } else {
+ dst[2] = rx_phys_mask;
+ }
+
+ return 0;
+}
+
+/*
+ * OGF=0x08 OCF=0x0031
+ */
+int
+ble_hs_hci_build_le_set_default_phy(uint8_t tx_phys_mask, uint8_t rx_phys_mask,
+ uint8_t *dst, int dst_len)
+{
+
+ BLE_HS_DBG_ASSERT(
+ dst_len >= BLE_HCI_CMD_HDR_LEN + BLE_HCI_LE_SET_DEFAULT_PHY_LEN);
+
+ memset(dst, 0, dst_len);
+
+ ble_hs_hci_cmd_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_SET_DEFAULT_PHY,
+ BLE_HCI_LE_SET_DEFAULT_PHY_LEN, dst);
+ dst += BLE_HCI_CMD_HDR_LEN;
+
+ return ble_hs_hci_cmd_body_le_set_default_phy(tx_phys_mask, rx_phys_mask,
+ dst);
+}
+
+static int
ble_hs_hci_cmd_body_le_set_priv_mode(const uint8_t *addr, uint8_t addr_type,
uint8_t priv_mode, uint8_t *dst)
{
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/086c852f/net/nimble/host/src/ble_hs_hci_priv.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_hci_priv.h b/net/nimble/host/src/ble_hs_hci_priv.h
index b536ccf..38270a5 100644
--- a/net/nimble/host/src/ble_hs_hci_priv.h
+++ b/net/nimble/host/src/ble_hs_hci_priv.h
@@ -165,6 +165,9 @@ int ble_hs_hci_build_le_set_priv_mode(const uint8_t *addr, uint8_t addr_type,
int ble_hs_hci_build_le_read_phy(uint16_t conn_handle, uint8_t *dst,
int dst_len);
+int ble_hs_hci_build_le_set_default_phy(uint8_t tx_phys_mask,
+ uint8_t rx_phys_mask,
+ uint8_t *dst, int dst_len);
#ifdef __cplusplus
}
#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/086c852f/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 7404627..5166946 100644
--- a/net/nimble/include/nimble/hci_common.h
+++ b/net/nimble/include/nimble/hci_common.h
@@ -422,6 +422,12 @@ extern "C" {
/* --- LE set default PHY (OCF 0x0031) */
#define BLE_HCI_LE_SET_DEFAULT_PHY_LEN (3)
+#define BLE_HCI_LE_PHY_NO_TX_PREF_MASK (0x01)
+#define BLE_HCI_LE_PHY_NO_RX_PREF_MASK (0x02)
+
+#define BLE_HCI_LE_PHY_1M_PREF_MASK (0x01)
+#define BLE_HCI_LE_PHY_2M_PREF_MASK (0x02)
+#define BLE_HCI_LE_PHY_CODED_PREF_MASK (0x04)
/* --- LE set PHY (OCF 0x0032) */
#define BLE_HCI_LE_SET_PHY_LEN (7)