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:16 UTC
[1/7] incubator-mynewt-core git commit: bletiny: Add test commands to
manage PHY
Repository: incubator-mynewt-core
Updated Branches:
refs/heads/bluetooth5 566b5c691 -> 4c2a8d984
bletiny: Add test commands to manage PHY
With this patch we can read PHY on connection and set prefered
PHY (default and for connection)
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/c86c99ed
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/c86c99ed
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/c86c99ed
Branch: refs/heads/bluetooth5
Commit: c86c99ed0cad48b70e53cadc2a105bc201601ceb
Parents: c7aa21c
Author: \u0141ukasz Rymanowski <lu...@codecoup.pl>
Authored: Tue Apr 11 14:24:31 2017 +0200
Committer: \u0141ukasz Rymanowski <lu...@codecoup.pl>
Committed: Wed Apr 19 11:04:09 2017 +0200
----------------------------------------------------------------------
apps/bletiny/src/cmd.c | 175 +++++++++++++++++++++++++++++++++++++++++++
apps/bletiny/src/main.c | 9 ++-
2 files changed, 183 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c86c99ed/apps/bletiny/src/cmd.c
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/cmd.c b/apps/bletiny/src/cmd.c
index 19580c7..ea7f2ee 100644
--- a/apps/bletiny/src/cmd.c
+++ b/apps/bletiny/src/cmd.c
@@ -3551,6 +3551,180 @@ cmd_svcchg(int argc, char **argv)
return 0;
}
+static const struct cmd_entry cmd_phy_entries[];
+
+static int
+cmd_phy_help(int argc, char **argv)
+{
+ int i;
+
+ console_printf("Available PHY commands:\n");
+ for (i = 0; cmd_phy_entries[i].name != NULL; i++) {
+ console_printf("\t%s\n", cmd_phy_entries[i].name);
+ }
+ return 0;
+}
+
+static void
+bletiny_phy_set_help(void)
+{
+ console_printf("Available PHY set commands: \n");
+ console_printf("\thelp\n");
+ console_printf("Available PHY set params: \n");
+ help_cmd_uint16("conn");
+ help_cmd_uint8("tx_phys_mask");
+ help_cmd_uint8("rx_phys_mask");
+ help_cmd_uint16("phy_opts");
+}
+
+static int
+cmd_phy_set(int argc, char **argv)
+{
+ uint16_t conn;
+ uint8_t tx_phys_mask;
+ uint8_t rx_phys_mask;
+ uint16_t phy_opts;
+ int rc;
+
+ if (argc > 1 && strcmp(argv[1], "help") == 0) {
+ bletiny_phy_set_help();
+ return 0;
+ }
+
+ conn = parse_arg_uint16("conn", &rc);
+ if (rc != 0) {
+ console_printf("invalid 'conn' parameter\n");
+ help_cmd_uint16("conn");
+ return rc;
+ }
+
+ tx_phys_mask = parse_arg_uint8("tx_phys_mask", &rc);
+ if (rc != 0) {
+ console_printf("invalid 'tx_phys_mask' parameter\n");
+ help_cmd_uint8("tx_phys_mask");
+ return rc;
+ }
+
+ rx_phys_mask = parse_arg_uint8("rx_phys_mask", &rc);
+ if (rc != 0) {
+ console_printf("invalid 'rx_phys_mask' parameter\n");
+ help_cmd_uint8("rx_phys_mask");
+ return rc;
+ }
+
+ phy_opts = parse_arg_uint16("phy_opts", &rc);
+ if (rc != 0) {
+ console_printf("invalid 'phy_opts' parameter\n");
+ help_cmd_uint16("phy_opts");
+ return rc;
+ }
+
+ return ble_gap_set_prefered_le_phy(conn, tx_phys_mask, rx_phys_mask,
+ phy_opts);
+}
+
+static void
+bletiny_phy_set_def_help(void)
+{
+ console_printf("Available PHY set_def commands: \n");
+ console_printf("\thelp\n");
+ console_printf("Available PHY set_def params: \n");
+ help_cmd_uint8("tx_phys_mask");
+ help_cmd_uint8("rx_phys_mask");
+}
+
+static int
+cmd_phy_set_def(int argc, char **argv)
+{
+ uint8_t tx_phys_mask;
+ uint8_t rx_phys_mask;
+ int rc;
+
+ if (argc > 1 && strcmp(argv[1], "help") == 0) {
+ bletiny_phy_set_def_help();
+ return 0;
+ }
+
+ tx_phys_mask = parse_arg_uint8("tx_phys_mask", &rc);
+ if (rc != 0) {
+ console_printf("invalid 'tx_phys_mask' parameter\n");
+ help_cmd_uint8("tx_phys_mask");
+ return rc;
+ }
+
+ rx_phys_mask = parse_arg_uint8("rx_phys_mask", &rc);
+ if (rc != 0) {
+ console_printf("invalid 'rx_phys_mask' parameter\n");
+ help_cmd_uint8("rx_phys_mask");
+ return rc;
+ }
+
+ return ble_gap_set_prefered_default_le_phy(tx_phys_mask, rx_phys_mask);
+}
+
+static void
+bletiny_phy_read_help(void)
+{
+ console_printf("Available PHY read commands: \n");
+ console_printf("\thelp\n");
+ console_printf("Available PHY read params: \n");
+ help_cmd_uint16("conn");
+}
+
+static int
+cmd_phy_read(int argc, char **argv)
+{
+
+ uint16_t conn = 0;
+ uint8_t tx_phy;
+ uint8_t rx_phy;
+ int rc;
+
+ if (argc > 1 && strcmp(argv[1], "help") == 0) {
+ bletiny_phy_read_help();
+ return 0;
+ }
+
+ conn = parse_arg_uint16("conn", &rc);
+ if (rc != 0) {
+ console_printf("invalid 'conn' parameter\n");
+ help_cmd_uint16("conn");
+ return rc;
+ }
+
+ rc = ble_gap_read_le_phy(conn, &tx_phy, &rx_phy);
+ if (rc != 0) {
+ console_printf("Could not read PHY error: %d\n", rc);
+ return rc;
+ }
+
+ console_printf("TX_PHY: %d\n", tx_phy);
+ console_printf("RX_PHY: %d\n", tx_phy);
+
+ return 0;
+}
+
+static const struct cmd_entry cmd_phy_entries[] = {
+ { "read", cmd_phy_read },
+ { "set_def", cmd_phy_set_def },
+ { "set", cmd_phy_set },
+ { "help", cmd_phy_help },
+ { NULL, NULL }
+};
+
+static int
+cmd_phy(int argc, char **argv)
+{
+ int rc;
+
+ rc = cmd_exec(cmd_phy_entries, argc, argv);
+ if (rc != 0) {
+ return rc;
+ }
+
+ return 0;
+}
+
/*****************************************************************************
* $init *
*****************************************************************************/
@@ -3579,6 +3753,7 @@ static struct cmd_entry cmd_b_entries[] = {
{ "wl", cmd_wl },
{ "write", cmd_write },
{ "svcchg", cmd_svcchg },
+ { "phy", cmd_phy },
{ NULL, NULL }
};
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c86c99ed/apps/bletiny/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/main.c b/apps/bletiny/src/main.c
index 96ac90e..1203886 100755
--- a/apps/bletiny/src/main.c
+++ b/apps/bletiny/src/main.c
@@ -1035,7 +1035,14 @@ bletiny_gap_event(struct ble_gap_event *event, void *arg)
assert(rc == 0);
print_conn_desc(&desc);
return 0;
-
+ case BLE_GAP_EVENT_PHY_UPDATE_COMPLETE:
+ console_printf("PHY update complete; status=%d, conn_handle=%d "
+ " tx_phy=%d, rx_phy=%d\n",
+ event->phy_updated.status,
+ event->phy_updated.conn_handle,
+ event->phy_updated.tx_phy,
+ event->phy_updated.rx_phy);
+ return 0;
default:
return 0;
}
[7/7] incubator-mynewt-core git commit: This closes #229.
Posted by cc...@apache.org.
This closes #229.
Merge remote-tracking branch 'rymanluk/bluetooth5' into bluetooth5
* rymanluk/bluetooth5:
bletiny: Add test commands to manage PHY
nimble/gap: Add API to manage LE PHY
nimble/hci: Add LE set PHY command
nimble/hci: Add LE set default PHY command
nimble/hci: Add LE read PHY command
nimble/hci: Remove reduntant checks
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/4c2a8d98
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/4c2a8d98
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/4c2a8d98
Branch: refs/heads/bluetooth5
Commit: 4c2a8d984ea2c8ffebaab835b8f5056106397f4b
Parents: 566b5c6 c86c99e
Author: Christopher Collins <cc...@apache.org>
Authored: Tue Apr 25 10:40:13 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Apr 25 10:40:13 2017 -0700
----------------------------------------------------------------------
apps/bletiny/src/cmd.c | 175 +++++++++++++++
apps/bletiny/src/main.c | 9 +-
net/nimble/host/include/host/ble_gap.h | 35 +++
net/nimble/host/src/ble_gap.c | 94 ++++++++
net/nimble/host/src/ble_gap_priv.h | 1 +
net/nimble/host/src/ble_hs_hci_cmd.c | 326 ++++++++++++++--------------
net/nimble/host/src/ble_hs_hci_evt.c | 23 ++
net/nimble/host/src/ble_hs_hci_priv.h | 9 +
net/nimble/include/nimble/hci_common.h | 22 ++
9 files changed, 536 insertions(+), 158 deletions(-)
----------------------------------------------------------------------
[3/7] incubator-mynewt-core git commit: nimble/hci: Add LE read PHY
command
Posted by cc...@apache.org.
nimble/hci: Add LE read PHY command
With this command we can read used PHY on given connection
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/7744296b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/7744296b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/7744296b
Branch: refs/heads/bluetooth5
Commit: 7744296bc2b9783678c64f632ed7668c3f76ad6d
Parents: 1caef7a
Author: \u0141ukasz Rymanowski <lu...@codecoup.pl>
Authored: Tue Apr 11 09:16:39 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 | 17 +++++++++++++++++
net/nimble/host/src/ble_hs_hci_priv.h | 3 +++
2 files changed, 20 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7744296b/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 e4e0a02..a51df5d 100644
--- a/net/nimble/host/src/ble_hs_hci_cmd.c
+++ b/net/nimble/host/src/ble_hs_hci_cmd.c
@@ -1222,6 +1222,23 @@ ble_hs_hci_cmd_build_set_resolv_priv_addr_timeout(
timeout, dst + BLE_HCI_CMD_HDR_LEN);
}
+/*
+ * OGF=0x08 OCF=0x0030
+ */
+int
+ble_hs_hci_build_le_read_phy(uint16_t conn_handle, uint8_t *dst, int dst_len)
+{
+ BLE_HS_DBG_ASSERT(
+ dst_len >= BLE_HCI_CMD_HDR_LEN + BLE_HCI_LE_RD_PHY_LEN);
+
+ ble_hs_hci_cmd_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_RD_PHY,
+ BLE_HCI_LE_RD_PHY_LEN, dst);
+ dst += BLE_HCI_CMD_HDR_LEN;
+
+ put_le16(dst, conn_handle);
+
+ return 0;
+}
static int
ble_hs_hci_cmd_body_le_set_priv_mode(const uint8_t *addr, uint8_t addr_type,
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7744296b/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 b3be0bc..b536ccf 100644
--- a/net/nimble/host/src/ble_hs_hci_priv.h
+++ b/net/nimble/host/src/ble_hs_hci_priv.h
@@ -162,6 +162,9 @@ int ble_hs_hci_cmd_build_set_random_addr(const uint8_t *addr,
int ble_hs_hci_build_le_set_priv_mode(const uint8_t *addr, uint8_t addr_type,
uint8_t priv_mode, uint8_t *dst,
uint16_t dst_len);
+
+int ble_hs_hci_build_le_read_phy(uint16_t conn_handle, uint8_t *dst,
+ int dst_len);
#ifdef __cplusplus
}
#endif
[2/7] incubator-mynewt-core git commit: nimble/gap: Add API to manage
LE PHY
Posted by cc...@apache.org.
nimble/gap: Add API to manage LE PHY
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/c7aa21c3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/c7aa21c3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/c7aa21c3
Branch: refs/heads/bluetooth5
Commit: c7aa21c3f49e01393af9c94f67bcd62a5e45f447
Parents: 2210e7e
Author: \u0141ukasz Rymanowski <lu...@codecoup.pl>
Authored: Tue Apr 11 11:22:17 2017 +0200
Committer: \u0141ukasz Rymanowski <lu...@codecoup.pl>
Committed: Wed Apr 19 11:04:09 2017 +0200
----------------------------------------------------------------------
net/nimble/host/include/host/ble_gap.h | 35 +++++++++++
net/nimble/host/src/ble_gap.c | 94 +++++++++++++++++++++++++++++
net/nimble/host/src/ble_gap_priv.h | 1 +
net/nimble/host/src/ble_hs_hci_evt.c | 23 +++++++
net/nimble/include/nimble/hci_common.h | 13 ++++
5 files changed, 166 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c7aa21c3/net/nimble/host/include/host/ble_gap.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_gap.h b/net/nimble/host/include/host/ble_gap.h
index f40789a..b32071d 100644
--- a/net/nimble/host/include/host/ble_gap.h
+++ b/net/nimble/host/include/host/ble_gap.h
@@ -111,6 +111,7 @@ struct hci_conn_update;
#define BLE_GAP_EVENT_SUBSCRIBE 14
#define BLE_GAP_EVENT_MTU 15
#define BLE_GAP_EVENT_IDENTITY_RESOLVED 16
+#define BLE_GAP_EVENT_PHY_UPDATE_COMPLETE 17
/*** Reason codes for the subscribe GAP event. */
@@ -517,6 +518,24 @@ struct ble_gap_event {
/** The handle of the relevant connection. */
uint16_t conn_handle;
} identity_resolved;
+
+ /**
+ * Represents a change of PHY. This is issue after successful
+ * change on PHY.
+ */
+ struct {
+ int status;
+ uint16_t conn_handle;
+
+ /**
+ * Indicates enabled TX/RX PHY. Possible values:
+ * o BLE_GAP_LE_PHY_1M
+ * o BLE_GAP_LE_PHY_2M
+ * o BLE_GAP_LE_PHY_CODED
+ */
+ uint8_t tx_phy;
+ uint8_t rx_phy;
+ } phy_updated;
};
};
@@ -570,6 +589,22 @@ int ble_gap_conn_rssi(uint16_t conn_handle, int8_t *out_rssi);
#define BLE_GAP_PRIVATE_MODE_DEVICE 1
int ble_gap_set_priv_mode(const ble_addr_t *peer_addr, uint8_t priv_mode);
+#define BLE_GAP_LE_PHY_1M 1
+#define BLE_GAP_LE_PHY_2M 2
+#define BLE_GAP_LE_CODED 3
+int ble_gap_read_le_phy(uint16_t conn_handle, uint8_t *tx_phy, uint8_t *rx_phy);
+
+#define BLE_GAP_LE_PHY_1M_MASK 0x01
+#define BLE_GAP_LE_PHY_2M_MASK 0x02
+#define BLE_GAP_LE_PHY_CODED_MASK 0x04
+int ble_gap_set_prefered_default_le_phy(uint8_t tx_phys_mask,
+ uint8_t rx_phys_mask);
+
+#define BLE_GAP_LE_PHY_CODED_ANY 0
+#define BLE_GAP_LE_PHY_CODED_S2 1
+#define BLE_GAP_LE_PHY_CODED_S8 2
+int ble_gap_set_prefered_le_phy(uint16_t conn_handle, uint8_t tx_phys_mask,
+ uint8_t rx_phys_mask, uint16_t phy_opts);
#ifdef __cplusplus
}
#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c7aa21c3/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
index 6318a9e..99ab5cf 100644
--- a/net/nimble/host/src/ble_gap.c
+++ b/net/nimble/host/src/ble_gap.c
@@ -437,6 +437,85 @@ ble_gap_set_priv_mode(const ble_addr_t *peer_addr, uint8_t priv_mode)
return ble_hs_pvcy_set_mode(peer_addr, priv_mode);
}
+int
+ble_gap_read_le_phy(uint16_t conn_handle, uint8_t *tx_phy, uint8_t *rx_phy)
+{
+ struct ble_hs_conn *conn;
+ uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_LE_RD_PHY_LEN];
+ uint8_t rspbuf[4];
+ uint8_t rsplen;
+ int rc;
+
+ ble_hs_lock();
+ conn = ble_hs_conn_find(conn_handle);
+ ble_hs_unlock();
+
+ if (conn == NULL) {
+ return BLE_HS_ENOTCONN;
+ }
+
+ rc = ble_hs_hci_build_le_read_phy(conn_handle, buf, sizeof(buf));
+ if (rc != 0) {
+ return rc;
+ }
+
+ rc = ble_hs_hci_cmd_tx(buf, rspbuf, sizeof(rspbuf), &rsplen);
+ if (rc != 0) {
+ return rc;
+ }
+
+ if (rsplen != sizeof(rspbuf)) {
+ return BLE_HS_ECONTROLLER;
+ }
+
+ /* First two octets is conn_handle. We can ignore it */
+
+ *tx_phy = rspbuf[2];
+ *rx_phy = rspbuf[3];
+
+ return 0;
+}
+
+int
+ble_gap_set_prefered_default_le_phy(uint8_t tx_phys_mask, uint8_t rx_phys_mask)
+{
+ uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_LE_SET_DEFAULT_PHY_LEN];
+ int rc;
+
+ rc = ble_hs_hci_build_le_set_default_phy(tx_phys_mask, rx_phys_mask, buf,
+ sizeof(buf));
+ if (rc != 0) {
+ return rc;
+ }
+
+ return ble_hs_hci_cmd_tx(buf, NULL, 0, NULL);
+}
+
+int
+ble_gap_set_prefered_le_phy(uint16_t conn_handle, uint8_t tx_phys_mask,
+ uint8_t rx_phys_mask, uint16_t phy_opts)
+{
+ struct ble_hs_conn *conn;
+ uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_LE_SET_PHY_LEN];
+ int rc;
+
+ ble_hs_lock();
+ conn = ble_hs_conn_find(conn_handle);
+ ble_hs_unlock();
+
+ if (conn == NULL) {
+ return BLE_HS_ENOTCONN;
+ }
+
+ rc = ble_hs_hci_build_le_set_phy(conn_handle, tx_phys_mask, rx_phys_mask,
+ phy_opts, buf, sizeof(buf));
+ if (rc != 0) {
+ return rc;
+ }
+
+ return ble_hs_hci_cmd_tx(buf, NULL, 0, NULL);
+}
+
/*****************************************************************************
* $misc *
*****************************************************************************/
@@ -1217,6 +1296,21 @@ ble_gap_rx_l2cap_update_req(uint16_t conn_handle,
return rc;
}
+void
+ble_gap_rx_phy_update_complete(struct hci_le_phy_upd_complete *evt)
+{
+ struct ble_gap_event event;
+
+ memset(&event, 0, sizeof event);
+ event.type = BLE_GAP_EVENT_PHY_UPDATE_COMPLETE;
+ event.phy_updated.status = evt->status;
+ event.phy_updated.conn_handle = evt->connection_handle;
+ event.phy_updated.tx_phy = evt->tx_phy;
+ event.phy_updated.rx_phy = evt->rx_phy;
+
+ ble_gap_call_conn_event_cb(&event, evt->connection_handle);
+}
+
static int32_t
ble_gap_master_timer(void)
{
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c7aa21c3/net/nimble/host/src/ble_gap_priv.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gap_priv.h b/net/nimble/host/src/ble_gap_priv.h
index 2e2bc75..8c35223 100644
--- a/net/nimble/host/src/ble_gap_priv.h
+++ b/net/nimble/host/src/ble_gap_priv.h
@@ -81,6 +81,7 @@ void ble_gap_rx_update_complete(struct hci_le_conn_upd_complete *evt);
void ble_gap_rx_param_req(struct hci_le_conn_param_req *evt);
int ble_gap_rx_l2cap_update_req(uint16_t conn_handle,
struct ble_gap_upd_params *params);
+void ble_gap_rx_phy_update_complete(struct hci_le_phy_upd_complete *evt);
void ble_gap_enc_event(uint16_t conn_handle, int status,
int security_restored);
void ble_gap_passkey_event(uint16_t conn_handle,
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c7aa21c3/net/nimble/host/src/ble_hs_hci_evt.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_hci_evt.c b/net/nimble/host/src/ble_hs_hci_evt.c
index a9655e3..7af8db5 100644
--- a/net/nimble/host/src/ble_hs_hci_evt.c
+++ b/net/nimble/host/src/ble_hs_hci_evt.c
@@ -46,6 +46,7 @@ static ble_hs_hci_evt_le_fn ble_hs_hci_evt_le_conn_upd_complete;
static ble_hs_hci_evt_le_fn ble_hs_hci_evt_le_lt_key_req;
static ble_hs_hci_evt_le_fn ble_hs_hci_evt_le_conn_parm_req;
static ble_hs_hci_evt_le_fn ble_hs_hci_evt_le_dir_adv_rpt;
+static ble_hs_hci_evt_le_fn ble_hs_hci_evt_le_phy_update_complete;
/* Statistics */
struct host_hci_stats
@@ -92,6 +93,8 @@ static const struct ble_hs_hci_evt_le_dispatch_entry
{ BLE_HCI_LE_SUBEV_REM_CONN_PARM_REQ, ble_hs_hci_evt_le_conn_parm_req },
{ BLE_HCI_LE_SUBEV_ENH_CONN_COMPLETE, ble_hs_hci_evt_le_conn_complete },
{ BLE_HCI_LE_SUBEV_DIRECT_ADV_RPT, ble_hs_hci_evt_le_dir_adv_rpt },
+ { BLE_HCI_LE_SUBEV_PHY_UPDATE_COMPLETE,
+ ble_hs_hci_evt_le_phy_update_complete },
};
#define BLE_HS_HCI_EVT_LE_DISPATCH_SZ \
@@ -563,6 +566,26 @@ ble_hs_hci_evt_le_conn_parm_req(uint8_t subevent, uint8_t *data, int len)
return 0;
}
+static int
+ble_hs_hci_evt_le_phy_update_complete(uint8_t subevent, uint8_t *data, int len)
+{
+ struct hci_le_phy_upd_complete evt;
+
+ if (len < BLE_HCI_LE_PHY_UPD_LEN) {
+ return BLE_HS_ECONTROLLER;
+ }
+
+ evt.subevent_code = data[0];
+ evt.status = data[1];
+ evt.connection_handle = get_le16(data + 2);
+ evt.tx_phy = data[4];
+ evt.rx_phy = data[5];
+
+ ble_gap_rx_phy_update_complete(&evt);
+
+ return 0;
+}
+
int
ble_hs_hci_evt_process(uint8_t *data)
{
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c7aa21c3/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 689869e..8ae29dc 100644
--- a/net/nimble/include/nimble/hci_common.h
+++ b/net/nimble/include/nimble/hci_common.h
@@ -671,6 +671,9 @@ extern "C" {
/* LE data length change event (sub event 0x07) */
#define BLE_HCI_LE_DATA_LEN_CHG_LEN (11)
+/* LE PHY update complete event (sub event 0x0C) */
+#define BLE_HCI_LE_PHY_UPD_LEN (6)
+
/* LE Channel Selection Algorithm event (sub event 0x14) */
#define BLE_HCI_LE_SUBEV_CHAN_SEL_ALG_LEN (4)
@@ -874,6 +877,16 @@ struct hci_read_rssi_ack_params
int8_t rssi;
};
+/* PHY updated completed LE meta subevent */
+struct hci_le_phy_upd_complete
+{
+ uint8_t subevent_code;
+ uint8_t status;
+ uint16_t connection_handle;
+ uint8_t tx_phy;
+ uint8_t rx_phy;
+};
+
#define BLE_HCI_DATA_HDR_SZ 4
#define BLE_HCI_DATA_HANDLE(handle_pb_bc) (((handle_pb_bc) & 0x0fff) >> 0)
#define BLE_HCI_DATA_PB(handle_pb_bc) (((handle_pb_bc) & 0x3000) >> 12)
[5/7] incubator-mynewt-core git commit: nimble/hci: Add LE set
default PHY command
Posted by cc...@apache.org.
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)
[6/7] incubator-mynewt-core git commit: nimble/hci: Add LE set PHY
command
Posted by cc...@apache.org.
nimble/hci: Add LE set PHY command
With this command we can change prefered PHY for given connection
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/2210e7e1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/2210e7e1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/2210e7e1
Branch: refs/heads/bluetooth5
Commit: 2210e7e1de7a6c3c0e53380d290c763b9eacb6ab
Parents: 086c852
Author: \u0141ukasz Rymanowski <lu...@codecoup.pl>
Authored: Tue Apr 11 10:13:06 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 | 76 +++++++++++++++++++++++++++--
net/nimble/host/src/ble_hs_hci_priv.h | 3 ++
net/nimble/include/nimble/hci_common.h | 3 ++
3 files changed, 79 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2210e7e1/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 354adc1..30a7eac 100644
--- a/net/nimble/host/src/ble_hs_hci_cmd.c
+++ b/net/nimble/host/src/ble_hs_hci_cmd.c
@@ -1241,9 +1241,8 @@ 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)
+ble_hs_hci_verify_le_phy_params(uint8_t tx_phys_mask, uint8_t rx_phys_mask,
+ uint16_t phy_opts)
{
if (tx_phys_mask > (BLE_HCI_LE_PHY_1M_PREF_MASK |
BLE_HCI_LE_PHY_2M_PREF_MASK |
@@ -1257,6 +1256,24 @@ ble_hs_hci_cmd_body_le_set_default_phy(uint8_t tx_phys_mask,
return BLE_ERR_INV_HCI_CMD_PARMS;
}
+ if (phy_opts > BLE_HCI_LE_PHY_CODED_S8_PREF) {
+ return BLE_ERR_INV_HCI_CMD_PARMS;
+ }
+
+ return 0;
+}
+
+static int
+ble_hs_hci_cmd_body_le_set_default_phy(uint8_t tx_phys_mask,
+ uint8_t rx_phys_mask, uint8_t *dst)
+{
+ int rc;
+
+ rc = ble_hs_hci_verify_le_phy_params(tx_phys_mask, rx_phys_mask, 0);
+ if (rc !=0 ) {
+ return rc;
+ }
+
if (tx_phys_mask == 0) {
dst[0] |= BLE_HCI_LE_PHY_NO_TX_PREF_MASK;
} else {
@@ -1294,6 +1311,59 @@ ble_hs_hci_build_le_set_default_phy(uint8_t tx_phys_mask, uint8_t rx_phys_mask,
}
static int
+ble_hs_hci_cmd_body_le_set_phy(uint16_t conn_handle, uint8_t tx_phys_mask,
+ uint8_t rx_phys_mask, uint16_t phy_opts,
+ uint8_t *dst)
+{
+ int rc;
+
+ rc = ble_hs_hci_verify_le_phy_params(tx_phys_mask, rx_phys_mask, phy_opts);
+ if (rc != 0) {
+ return rc;
+ }
+
+ put_le16(dst, conn_handle);
+
+ if (tx_phys_mask == 0) {
+ dst[2] |= BLE_HCI_LE_PHY_NO_TX_PREF_MASK;
+ } else {
+ dst[3] = tx_phys_mask;
+ }
+
+ if (rx_phys_mask == 0){
+ dst[2] |= BLE_HCI_LE_PHY_NO_RX_PREF_MASK;
+ } else {
+ dst[4] = rx_phys_mask;
+ }
+
+ put_le16(dst + 5, phy_opts);
+
+ return 0;
+}
+
+/*
+ * OGF=0x08 OCF=0x0032
+ */
+int
+ble_hs_hci_build_le_set_phy(uint16_t conn_handle, uint8_t tx_phys_mask,
+ uint8_t rx_phys_mask, uint16_t phy_opts,
+ uint8_t *dst, int dst_len)
+{
+
+ BLE_HS_DBG_ASSERT(
+ dst_len >= BLE_HCI_CMD_HDR_LEN + BLE_HCI_LE_SET_PHY_LEN);
+
+ memset(dst, 0, dst_len);
+
+ ble_hs_hci_cmd_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_SET_PHY,
+ BLE_HCI_LE_SET_PHY_LEN, dst);
+ dst += BLE_HCI_CMD_HDR_LEN;
+
+ return ble_hs_hci_cmd_body_le_set_phy(conn_handle, tx_phys_mask,
+ rx_phys_mask, phy_opts, 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/2210e7e1/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 38270a5..aff3b10 100644
--- a/net/nimble/host/src/ble_hs_hci_priv.h
+++ b/net/nimble/host/src/ble_hs_hci_priv.h
@@ -168,6 +168,9 @@ int ble_hs_hci_build_le_read_phy(uint16_t conn_handle, uint8_t *dst,
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);
+int ble_hs_hci_build_le_set_phy(uint16_t conn_handle, uint8_t tx_phys_mask,
+ uint8_t rx_phys_mask, uint16_t phy_opts,
+ uint8_t *dst, int dst_len);
#ifdef __cplusplus
}
#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2210e7e1/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 5166946..689869e 100644
--- a/net/nimble/include/nimble/hci_common.h
+++ b/net/nimble/include/nimble/hci_common.h
@@ -431,6 +431,9 @@ extern "C" {
/* --- LE set PHY (OCF 0x0032) */
#define BLE_HCI_LE_SET_PHY_LEN (7)
+#define BLE_HCI_LE_PHY_CODED_ANY (0x0000)
+#define BLE_HCI_LE_PHY_CODED_S2_PREF (0x0001)
+#define BLE_HCI_LE_PHY_CODED_S8_PREF (0x0002)
/* --- LE enhanced receiver test (OCF 0x0033) */
#define BLE_HCI_LE_ENH_RCVR_TEST_LEN (3)
[4/7] incubator-mynewt-core git commit: nimble/hci: Remove reduntant
checks
Posted by cc...@apache.org.
nimble/hci: Remove reduntant checks
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/1caef7af
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/1caef7af
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/1caef7af
Branch: refs/heads/bluetooth5
Commit: 1caef7af29db648da90e5be0c33a485a9b9e3e3a
Parents: 566b5c6
Author: \u0141ukasz Rymanowski <lu...@codecoup.pl>
Authored: Tue Apr 11 08:39:38 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 | 186 +++++-------------------------
1 file changed, 29 insertions(+), 157 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1caef7af/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 6de599f..e4e0a02 100644
--- a/net/nimble/host/src/ble_hs_hci_cmd.c
+++ b/net/nimble/host/src/ble_hs_hci_cmd.c
@@ -95,7 +95,6 @@ ble_hs_hci_cmd_send_buf(void *buf)
uint16_t opcode;
uint8_t *u8ptr;
uint8_t len;
- int rc;
switch (ble_hs_sync_state) {
case BLE_HS_SYNC_STATE_BAD:
@@ -120,9 +119,8 @@ ble_hs_hci_cmd_send_buf(void *buf)
opcode = get_le16(u8ptr + 0);
len = u8ptr[2];
- rc = ble_hs_hci_cmd_send(BLE_HCI_OGF(opcode), BLE_HCI_OCF(opcode), len,
+ return ble_hs_hci_cmd_send(BLE_HCI_OGF(opcode), BLE_HCI_OCF(opcode), len,
u8ptr + BLE_HCI_CMD_HDR_LEN);
- return rc;
}
@@ -138,9 +136,7 @@ ble_hs_hci_cmd_send_buf(void *buf)
static int
ble_hs_hci_cmd_le_send(uint16_t ocf, uint8_t len, void *cmddata)
{
- int rc;
- rc = ble_hs_hci_cmd_send(BLE_HCI_OGF_LE, ocf, len, cmddata);
- return rc;
+ return ble_hs_hci_cmd_send(BLE_HCI_OGF_LE, ocf, len, cmddata);
}
/**
@@ -224,8 +220,6 @@ int
ble_hs_hci_cmd_build_le_set_adv_params(const struct hci_adv_params *adv,
uint8_t *dst, int dst_len)
{
- int rc;
-
BLE_HS_DBG_ASSERT(
dst_len >= BLE_HCI_CMD_HDR_LEN + BLE_HCI_SET_ADV_PARAM_LEN);
@@ -233,12 +227,7 @@ ble_hs_hci_cmd_build_le_set_adv_params(const struct hci_adv_params *adv,
BLE_HCI_SET_ADV_PARAM_LEN, dst);
dst += BLE_HCI_CMD_HDR_LEN;
- rc = ble_hs_hci_cmd_body_le_set_adv_params(adv, dst);
- if (rc != 0) {
- return rc;
- }
-
- return 0;
+ return ble_hs_hci_cmd_body_le_set_adv_params(adv, dst);
}
/**
@@ -285,8 +274,6 @@ int
ble_hs_hci_cmd_build_le_set_adv_data(const uint8_t *data, uint8_t len,
uint8_t *dst, int dst_len)
{
- int rc;
-
BLE_HS_DBG_ASSERT(
dst_len >= BLE_HCI_CMD_HDR_LEN + BLE_HCI_SET_ADV_DATA_LEN);
@@ -294,12 +281,7 @@ ble_hs_hci_cmd_build_le_set_adv_data(const uint8_t *data, uint8_t len,
BLE_HCI_SET_ADV_DATA_LEN, dst);
dst += BLE_HCI_CMD_HDR_LEN;
- rc = ble_hs_hci_cmd_body_le_set_adv_data(data, len, dst);
- if (rc != 0) {
- return rc;
- }
-
- return 0;
+ return ble_hs_hci_cmd_body_le_set_adv_data(data, len, dst);
}
static int
@@ -323,8 +305,6 @@ int
ble_hs_hci_cmd_build_le_set_scan_rsp_data(const uint8_t *data, uint8_t len,
uint8_t *dst, int dst_len)
{
- int rc;
-
BLE_HS_DBG_ASSERT(
dst_len >= BLE_HCI_CMD_HDR_LEN + BLE_HCI_SET_SCAN_RSP_DATA_LEN);
@@ -332,12 +312,7 @@ ble_hs_hci_cmd_build_le_set_scan_rsp_data(const uint8_t *data, uint8_t len,
BLE_HCI_SET_SCAN_RSP_DATA_LEN, dst);
dst += BLE_HCI_CMD_HDR_LEN;
- rc = ble_hs_hci_cmd_body_le_set_scan_rsp_data(data, len, dst);
- if (rc != 0) {
- return rc;
- }
-
- return 0;
+ return ble_hs_hci_cmd_body_le_set_scan_rsp_data(data, len, dst);
}
static void
@@ -401,14 +376,12 @@ int
ble_hs_hci_cmd_disconnect(uint16_t handle, uint8_t reason)
{
uint8_t cmd[BLE_HCI_DISCONNECT_CMD_LEN];
- int rc;
ble_hs_hci_cmd_body_disconnect(handle, reason, cmd);
- rc = ble_hs_hci_cmd_send(BLE_HCI_OGF_LINK_CTRL,
+ return ble_hs_hci_cmd_send(BLE_HCI_OGF_LINK_CTRL,
BLE_HCI_OCF_DISCONNECT_CMD,
BLE_HCI_DISCONNECT_CMD_LEN,
cmd);
- return rc;
}
static void
@@ -459,10 +432,7 @@ ble_hs_hci_cmd_build_le_read_buffer_size(uint8_t *dst, int dst_len)
int
ble_hs_hci_cmd_le_read_buffer_size(void)
{
- int rc;
-
- rc = ble_hs_hci_cmd_le_send(BLE_HCI_OCF_LE_RD_BUF_SIZE, 0, NULL);
- return rc;
+ return ble_hs_hci_cmd_le_send(BLE_HCI_OCF_LE_RD_BUF_SIZE, 0, NULL);
}
/**
@@ -543,8 +513,6 @@ ble_hs_hci_cmd_build_le_set_scan_params(uint8_t scan_type,
uint8_t filter_policy,
uint8_t *dst, int dst_len)
{
- int rc;
-
BLE_HS_DBG_ASSERT(
dst_len >= BLE_HCI_CMD_HDR_LEN + BLE_HCI_SET_SCAN_PARAM_LEN);
@@ -552,14 +520,9 @@ ble_hs_hci_cmd_build_le_set_scan_params(uint8_t scan_type,
BLE_HCI_SET_SCAN_PARAM_LEN, dst);
dst += BLE_HCI_CMD_HDR_LEN;
- rc = ble_hs_hci_cmd_body_le_set_scan_params(scan_type, scan_itvl,
+ return ble_hs_hci_cmd_body_le_set_scan_params(scan_type, scan_itvl,
scan_window, own_addr_type,
filter_policy, dst);
- if (rc != 0) {
- return rc;
- }
-
- return 0;
}
static void
@@ -662,21 +625,14 @@ int
ble_hs_hci_cmd_build_le_create_connection(const struct hci_create_conn *hcc,
uint8_t *cmd, int cmd_len)
{
- int rc;
-
BLE_HS_DBG_ASSERT(
cmd_len >= BLE_HCI_CMD_HDR_LEN + BLE_HCI_CREATE_CONN_LEN);
ble_hs_hci_cmd_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_CREATE_CONN,
BLE_HCI_CREATE_CONN_LEN, cmd);
- rc = ble_hs_hci_cmd_body_le_create_connection(hcc,
+ return ble_hs_hci_cmd_body_le_create_connection(hcc,
cmd + BLE_HCI_CMD_HDR_LEN);
- if (rc != 0) {
- return rc;
- }
-
- return 0;
}
void
@@ -692,8 +648,6 @@ ble_hs_hci_cmd_build_le_add_to_whitelist(const uint8_t *addr,
uint8_t addr_type,
uint8_t *dst, int dst_len)
{
- int rc;
-
BLE_HS_DBG_ASSERT(
dst_len >= BLE_HCI_CMD_HDR_LEN + BLE_HCI_CHG_WHITE_LIST_LEN);
@@ -701,12 +655,7 @@ ble_hs_hci_cmd_build_le_add_to_whitelist(const uint8_t *addr,
BLE_HCI_CHG_WHITE_LIST_LEN, dst);
dst += BLE_HCI_CMD_HDR_LEN;
- rc = ble_hs_hci_cmd_body_le_whitelist_chg(addr, addr_type, dst);
- if (rc != 0) {
- return rc;
- }
-
- return 0;
+ return ble_hs_hci_cmd_body_le_whitelist_chg(addr, addr_type, dst);
}
void
@@ -725,11 +674,8 @@ ble_hs_hci_cmd_build_reset(uint8_t *dst, int dst_len)
int
ble_hs_hci_cmd_reset(void)
{
- int rc;
-
- rc = ble_hs_hci_cmd_send(BLE_HCI_OGF_CTLR_BASEBAND, BLE_HCI_OCF_CB_RESET,
- 0, NULL);
- return rc;
+ return ble_hs_hci_cmd_send(BLE_HCI_OGF_CTLR_BASEBAND, BLE_HCI_OCF_CB_RESET,
+ 0, NULL);
}
void
@@ -748,11 +694,8 @@ ble_hs_hci_cmd_build_read_adv_pwr(uint8_t *dst, int dst_len)
int
ble_hs_hci_cmd_read_adv_pwr(void)
{
- int rc;
-
- rc = ble_hs_hci_cmd_send(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_RD_ADV_CHAN_TXPWR,
+ return ble_hs_hci_cmd_send(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_RD_ADV_CHAN_TXPWR,
0, NULL);
- return rc;
}
void
@@ -766,11 +709,8 @@ ble_hs_hci_cmd_build_le_create_conn_cancel(uint8_t *dst, int dst_len)
int
ble_hs_hci_cmd_le_create_conn_cancel(void)
{
- int rc;
-
- rc = ble_hs_hci_cmd_send(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_CREATE_CONN_CANCEL,
+ return ble_hs_hci_cmd_send(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_CREATE_CONN_CANCEL,
0, NULL);
- return rc;
}
static int
@@ -793,8 +733,6 @@ int
ble_hs_hci_cmd_build_le_conn_update(const struct hci_conn_update *hcu,
uint8_t *dst, int dst_len)
{
- int rc;
-
BLE_HS_DBG_ASSERT(
dst_len >= BLE_HCI_CMD_HDR_LEN + BLE_HCI_CONN_UPDATE_LEN);
@@ -802,12 +740,7 @@ ble_hs_hci_cmd_build_le_conn_update(const struct hci_conn_update *hcu,
BLE_HCI_CONN_UPDATE_LEN, dst);
dst += BLE_HCI_CMD_HDR_LEN;
- rc = ble_hs_hci_cmd_body_le_conn_update(hcu, dst);
- if (rc != 0) {
- return rc;
- }
-
- return 0;
+ return ble_hs_hci_cmd_body_le_conn_update(hcu, dst);
}
int
@@ -821,13 +754,8 @@ ble_hs_hci_cmd_le_conn_update(const struct hci_conn_update *hcu)
return rc;
}
- rc = ble_hs_hci_cmd_le_send(BLE_HCI_OCF_LE_CONN_UPDATE,
+ return ble_hs_hci_cmd_le_send(BLE_HCI_OCF_LE_CONN_UPDATE,
BLE_HCI_CONN_UPDATE_LEN, cmd);
- if (rc != 0) {
- return rc;
- }
-
- return 0;
}
static void
@@ -912,7 +840,6 @@ int
ble_hs_hci_cmd_le_conn_param_reply(const struct hci_conn_param_reply *hcr)
{
uint8_t cmd[BLE_HCI_CONN_PARAM_REPLY_LEN];
- int rc;
put_le16(cmd + 0, hcr->handle);
put_le16(cmd + 2, hcr->conn_itvl_min);
@@ -922,9 +849,8 @@ ble_hs_hci_cmd_le_conn_param_reply(const struct hci_conn_param_reply *hcr)
put_le16(cmd + 10, hcr->min_ce_len);
put_le16(cmd + 12, hcr->max_ce_len);
- rc = ble_hs_hci_cmd_le_send(BLE_HCI_OCF_LE_REM_CONN_PARAM_RR,
+ return ble_hs_hci_cmd_le_send(BLE_HCI_OCF_LE_REM_CONN_PARAM_RR,
BLE_HCI_CONN_PARAM_REPLY_LEN, cmd);
- return rc;
}
static void
@@ -955,13 +881,11 @@ ble_hs_hci_cmd_le_conn_param_neg_reply(
const struct hci_conn_param_neg_reply *hcn)
{
uint8_t cmd[BLE_HCI_CONN_PARAM_NEG_REPLY_LEN];
- int rc;
ble_hs_hci_cmd_body_le_conn_param_neg_reply(hcn, cmd);
- rc = ble_hs_hci_cmd_le_send(BLE_HCI_OCF_LE_REM_CONN_PARAM_NRR,
+ return ble_hs_hci_cmd_le_send(BLE_HCI_OCF_LE_REM_CONN_PARAM_NRR,
BLE_HCI_CONN_PARAM_NEG_REPLY_LEN, cmd);
- return rc;
}
/**
@@ -1067,8 +991,6 @@ ble_hs_hci_cmd_build_set_data_len(uint16_t connection_handle,
uint16_t tx_octets, uint16_t tx_time,
uint8_t *dst, int dst_len)
{
- int rc;
-
BLE_HS_DBG_ASSERT(
dst_len >= BLE_HCI_CMD_HDR_LEN + BLE_HCI_SET_DATALEN_LEN);
@@ -1076,13 +998,8 @@ ble_hs_hci_cmd_build_set_data_len(uint16_t connection_handle,
BLE_HCI_SET_DATALEN_LEN, dst);
dst += BLE_HCI_CMD_HDR_LEN;
- rc = ble_hs_hci_cmd_body_set_data_len(connection_handle, tx_octets,
+ return ble_hs_hci_cmd_body_set_data_len(connection_handle, tx_octets,
tx_time, dst);
- if (rc != 0) {
- return rc;
- }
-
- return 0;
}
/**
@@ -1117,22 +1034,15 @@ ble_hs_hci_cmd_build_add_to_resolv_list(
uint8_t *dst,
int dst_len)
{
- int rc;
-
BLE_HS_DBG_ASSERT(
dst_len >= BLE_HCI_CMD_HDR_LEN + BLE_HCI_ADD_TO_RESOLV_LIST_LEN);
ble_hs_hci_cmd_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_ADD_RESOLV_LIST,
BLE_HCI_ADD_TO_RESOLV_LIST_LEN, dst);
- rc = ble_hs_hci_cmd_body_add_to_resolv_list(
- padd->addr_type, padd->addr, padd->peer_irk, padd->local_irk,
- dst + BLE_HCI_CMD_HDR_LEN);
- if (rc != 0) {
- return rc;
- }
-
- return 0;
+ return ble_hs_hci_cmd_body_add_to_resolv_list(
+ padd->addr_type, padd->addr, padd->peer_irk, padd->local_irk,
+ dst + BLE_HCI_CMD_HDR_LEN);
}
static int
@@ -1155,20 +1065,14 @@ ble_hs_hci_cmd_build_remove_from_resolv_list(uint8_t addr_type,
const uint8_t *addr,
uint8_t *dst, int dst_len)
{
- int rc;
-
BLE_HS_DBG_ASSERT(
dst_len >= BLE_HCI_CMD_HDR_LEN + BLE_HCI_RMV_FROM_RESOLV_LIST_LEN);
ble_hs_hci_cmd_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_RMV_RESOLV_LIST,
BLE_HCI_RMV_FROM_RESOLV_LIST_LEN, dst);
- rc = ble_hs_hci_cmd_body_remove_from_resolv_list(addr_type, addr,
+ return ble_hs_hci_cmd_body_remove_from_resolv_list(addr_type, addr,
dst + BLE_HCI_CMD_HDR_LEN);
- if (rc != 0) {
- return rc;
- }
- return 0;
}
int
@@ -1214,8 +1118,6 @@ ble_hs_hci_cmd_build_read_peer_resolv_addr(uint8_t peer_identity_addr_type,
uint8_t *dst,
int dst_len)
{
- int rc;
-
BLE_HS_DBG_ASSERT(
dst_len >= BLE_HCI_CMD_HDR_LEN + BLE_HCI_RD_PEER_RESOLV_ADDR_LEN);
@@ -1223,13 +1125,9 @@ ble_hs_hci_cmd_build_read_peer_resolv_addr(uint8_t peer_identity_addr_type,
BLE_HCI_OCF_LE_RD_PEER_RESOLV_ADDR,
BLE_HCI_RD_PEER_RESOLV_ADDR_LEN, dst);
- rc = ble_hs_hci_cmd_body_read_peer_resolv_addr(peer_identity_addr_type,
+ return ble_hs_hci_cmd_body_read_peer_resolv_addr(peer_identity_addr_type,
peer_identity_addr,
dst + BLE_HCI_CMD_HDR_LEN);
- if (rc != 0) {
- return rc;
- }
- return 0;
}
static int
@@ -1256,8 +1154,6 @@ ble_hs_hci_cmd_build_read_lcl_resolv_addr(uint8_t local_identity_addr_type,
uint8_t *dst,
int dst_len)
{
- int rc;
-
BLE_HS_DBG_ASSERT(
dst_len >= BLE_HCI_CMD_HDR_LEN + BLE_HCI_RD_LOC_RESOLV_ADDR_LEN);
@@ -1265,13 +1161,9 @@ ble_hs_hci_cmd_build_read_lcl_resolv_addr(uint8_t local_identity_addr_type,
BLE_HCI_OCF_LE_RD_LOCAL_RESOLV_ADDR,
BLE_HCI_RD_LOC_RESOLV_ADDR_LEN, dst);
- rc = ble_hs_hci_cmd_body_read_lcl_resolv_addr(local_identity_addr_type,
+ return ble_hs_hci_cmd_body_read_lcl_resolv_addr(local_identity_addr_type,
local_identity_addr,
dst + BLE_HCI_CMD_HDR_LEN);
- if (rc != 0) {
- return rc;
- }
- return 0;
}
static int
@@ -1291,20 +1183,14 @@ ble_hs_hci_cmd_body_set_addr_res_en(uint8_t enable, uint8_t *dst)
int
ble_hs_hci_cmd_build_set_addr_res_en(uint8_t enable, uint8_t *dst, int dst_len)
{
- int rc;
-
BLE_HS_DBG_ASSERT(
dst_len >= BLE_HCI_CMD_HDR_LEN + BLE_HCI_SET_ADDR_RESOL_ENA_LEN);
ble_hs_hci_cmd_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_SET_ADDR_RES_EN,
BLE_HCI_SET_ADDR_RESOL_ENA_LEN, dst);
- rc = ble_hs_hci_cmd_body_set_addr_res_en(enable,
+ return ble_hs_hci_cmd_body_set_addr_res_en(enable,
dst + BLE_HCI_CMD_HDR_LEN);
- if (rc != 0) {
- return rc;
- }
- return 0;
}
static int
@@ -1364,8 +1250,6 @@ ble_hs_hci_build_le_set_priv_mode(const uint8_t *addr, uint8_t addr_type,
uint8_t priv_mode, uint8_t *dst,
uint16_t dst_len)
{
- int rc;
-
BLE_HS_DBG_ASSERT(
dst_len >= BLE_HCI_CMD_HDR_LEN + BLE_HCI_LE_SET_PRIVACY_MODE_LEN);
@@ -1373,15 +1257,9 @@ ble_hs_hci_build_le_set_priv_mode(const uint8_t *addr, uint8_t addr_type,
BLE_HCI_LE_SET_PRIVACY_MODE_LEN, dst);
dst += BLE_HCI_CMD_HDR_LEN;
- rc = ble_hs_hci_cmd_body_le_set_priv_mode(addr, addr_type, priv_mode, dst);
- if (rc != 0) {
- return rc;
- }
-
- return 0;
-
-
+ return ble_hs_hci_cmd_body_le_set_priv_mode(addr, addr_type, priv_mode, dst);
}
+
static int
ble_hs_hci_cmd_body_set_random_addr(const struct hci_rand_addr *paddr,
uint8_t *dst)
@@ -1395,7 +1273,6 @@ ble_hs_hci_cmd_build_set_random_addr(const uint8_t *addr,
uint8_t *dst, int dst_len)
{
struct hci_rand_addr r_addr;
- int rc;
memcpy(r_addr.addr, addr, sizeof(r_addr.addr));
@@ -1405,11 +1282,6 @@ ble_hs_hci_cmd_build_set_random_addr(const uint8_t *addr,
ble_hs_hci_cmd_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_SET_RAND_ADDR,
BLE_HCI_SET_RAND_ADDR_LEN, dst);
- rc = ble_hs_hci_cmd_body_set_random_addr(&r_addr,
+ return ble_hs_hci_cmd_body_set_random_addr(&r_addr,
dst + BLE_HCI_CMD_HDR_LEN);
- if (rc != 0) {
- return rc;
- }
-
- return 0;
}