You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2022/08/29 13:03:47 UTC
[mynewt-nimble] 03/03: nimble/ll/css: Add separate vs hci commands for css.
This is an automated email from the ASF dual-hosted git repository.
andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
commit 5098c2889e894521d2008c2a036c687335e4fd79
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Tue Aug 23 16:23:54 2022 +0200
nimble/ll/css: Add separate vs hci commands for css.
---
nimble/controller/src/ble_ll_hci_vs.c | 71 +++++++++++++----------------------
nimble/include/nimble/hci_common.h | 20 +++-------
2 files changed, 31 insertions(+), 60 deletions(-)
diff --git a/nimble/controller/src/ble_ll_hci_vs.c b/nimble/controller/src/ble_ll_hci_vs.c
index 7aa2e8d1..d0034650 100644
--- a/nimble/controller/src/ble_ll_hci_vs.c
+++ b/nimble/controller/src/ble_ll_hci_vs.c
@@ -138,7 +138,7 @@ ble_ll_hci_vs_set_tx_power(uint16_t ocf, const uint8_t *cmdbuf, uint8_t cmdlen,
#if MYNEWT_VAL(BLE_LL_HCI_VS_CONN_STRICT_SCHED)
#if !MYNEWT_VAL(BLE_LL_CONN_STRICT_SCHED_FIXED)
static int
-ble_ll_hci_vs_css_configure(const uint8_t *cmdbuf, uint8_t cmdlen,
+ble_ll_hci_vs_css_configure(uint16_t ocf, const uint8_t *cmdbuf, uint8_t cmdlen,
uint8_t *rspbuf, uint8_t *rsplen)
{
const struct ble_hci_vs_css_configure_cp *cmd = (const void *)cmdbuf;
@@ -149,9 +149,8 @@ ble_ll_hci_vs_css_configure(const uint8_t *cmdbuf, uint8_t cmdlen,
return BLE_ERR_INV_HCI_CMD_PARMS;
}
- if (ble_ll_sched_css_is_enabled() &&
- !SLIST_EMPTY(&g_ble_ll_conn_css_list)) {
- return BLE_ERR_CTLR_BUSY;
+ if (ble_ll_sched_css_is_enabled()) {
+ return BLE_ERR_CMD_DISALLOWED;
}
slot_us = le32toh(cmd->slot_us);
@@ -172,7 +171,7 @@ ble_ll_hci_vs_css_configure(const uint8_t *cmdbuf, uint8_t cmdlen,
#endif
static int
-ble_ll_hci_vs_css_enable(const uint8_t *cmdbuf, uint8_t cmdlen,
+ble_ll_hci_vs_css_enable(uint16_t ocf, const uint8_t *cmdbuf, uint8_t cmdlen,
uint8_t *rspbuf, uint8_t *rsplen)
{
const struct ble_hci_vs_css_enable_cp *cmd = (const void *)cmdbuf;
@@ -182,7 +181,7 @@ ble_ll_hci_vs_css_enable(const uint8_t *cmdbuf, uint8_t cmdlen,
}
if (!SLIST_EMPTY(&g_ble_ll_conn_active_list)) {
- return BLE_ERR_CTLR_BUSY;
+ return BLE_ERR_CMD_DISALLOWED;
}
if (cmd->enable & 0xfe) {
@@ -195,8 +194,9 @@ ble_ll_hci_vs_css_enable(const uint8_t *cmdbuf, uint8_t cmdlen,
}
static int
-ble_ll_hci_vs_css_set_next_slot(const uint8_t *cmdbuf, uint8_t cmdlen,
- uint8_t *rspbuf, uint8_t *rsplen)
+ble_ll_hci_vs_css_set_next_slot(uint16_t ocf, const uint8_t *cmdbuf,
+ uint8_t cmdlen, uint8_t *rspbuf,
+ uint8_t *rsplen)
{
const struct ble_hci_vs_css_set_next_slot_cp *cmd = (const void *)cmdbuf;
uint16_t slot_idx;
@@ -221,8 +221,9 @@ ble_ll_hci_vs_css_set_next_slot(const uint8_t *cmdbuf, uint8_t cmdlen,
}
static int
-ble_ll_hci_vs_css_set_conn_slot(const uint8_t *cmdbuf, uint8_t cmdlen,
- uint8_t *rspbuf, uint8_t *rsplen)
+ble_ll_hci_vs_css_set_conn_slot(uint16_t ocf, const uint8_t *cmdbuf,
+ uint8_t cmdlen, uint8_t *rspbuf,
+ uint8_t *rsplen)
{
const struct ble_hci_vs_css_set_conn_slot_cp *cmd = (const void *)cmdbuf;
struct ble_ll_conn_sm *connsm;
@@ -269,8 +270,9 @@ ble_ll_hci_vs_css_set_conn_slot(const uint8_t *cmdbuf, uint8_t cmdlen,
}
static int
-ble_ll_hci_vs_css_read_conn_slot(const uint8_t *cmdbuf, uint8_t cmdlen,
- uint8_t *rspbuf, uint8_t *rsplen)
+ble_ll_hci_vs_css_read_conn_slot(uint16_t ocf, const uint8_t *cmdbuf,
+ uint8_t cmdlen, uint8_t *rspbuf,
+ uint8_t *rsplen)
{
const struct ble_hci_vs_css_read_conn_slot_cp *cmd = (const void *)cmdbuf;
struct ble_hci_vs_css_read_conn_slot_rp *rsp = (void *)rspbuf;
@@ -292,42 +294,11 @@ ble_ll_hci_vs_css_read_conn_slot(const uint8_t *cmdbuf, uint8_t cmdlen,
}
*rsplen = sizeof(*rsp);
- rsp->opcode = cmd->opcode;
rsp->conn_handle = cmd->conn_handle;
rsp->slot_idx = htole16(connsm->css_slot_idx);
return BLE_ERR_SUCCESS;
}
-
-static int
-ble_ll_hci_vs_css(uint16_t ocf, const uint8_t *cmdbuf, uint8_t cmdlen,
- uint8_t *rspbuf, uint8_t *rsplen)
-{
- const struct ble_hci_vs_css_cp *cmd = (const void *)cmdbuf;
-
- if (cmdlen < sizeof(*cmd)) {
- return BLE_ERR_INV_HCI_CMD_PARMS;
- }
-
- *rsplen = 0;
-
- switch (cmd->opcode) {
-#if !MYNEWT_VAL(BLE_LL_CONN_STRICT_SCHED_FIXED)
- case BLE_HCI_VS_CSS_OP_CONFIGURE:
- return ble_ll_hci_vs_css_configure(cmdbuf, cmdlen, rspbuf, rsplen);
-#endif
- case BLE_HCI_VS_CSS_OP_ENABLE:
- return ble_ll_hci_vs_css_enable(cmdbuf, cmdlen, rspbuf, rsplen);
- case BLE_HCI_VS_CSS_OP_SET_NEXT_SLOT:
- return ble_ll_hci_vs_css_set_next_slot(cmdbuf, cmdlen, rspbuf, rsplen);
- case BLE_HCI_VS_CSS_OP_SET_CONN_SLOT:
- return ble_ll_hci_vs_css_set_conn_slot(cmdbuf, cmdlen, rspbuf, rsplen);
- case BLE_HCI_VS_CSS_OP_READ_CONN_SLOT:
- return ble_ll_hci_vs_css_read_conn_slot(cmdbuf, cmdlen, rspbuf, rsplen);
- }
-
- return BLE_ERR_INV_HCI_CMD_PARMS;
-}
#endif
static struct ble_ll_hci_vs_cmd g_ble_ll_hci_vs_cmds[] = {
@@ -336,8 +307,18 @@ static struct ble_ll_hci_vs_cmd g_ble_ll_hci_vs_cmds[] = {
BLE_LL_HCI_VS_CMD(BLE_HCI_OCF_VS_SET_TX_PWR,
ble_ll_hci_vs_set_tx_power),
#if MYNEWT_VAL(BLE_LL_HCI_VS_CONN_STRICT_SCHED)
- BLE_LL_HCI_VS_CMD(BLE_HCI_OCF_VS_CSS,
- ble_ll_hci_vs_css),
+#if !MYNEWT_VAL(BLE_LL_CONN_STRICT_SCHED_FIXED)
+ BLE_LL_HCI_VS_CMD(BLE_HCI_OCF_VS_CSS_CONFIGURE,
+ ble_ll_hci_vs_css_configure),
+#endif
+ BLE_LL_HCI_VS_CMD(BLE_HCI_OCF_VS_CSS_ENABLE,
+ ble_ll_hci_vs_css_enable),
+ BLE_LL_HCI_VS_CMD(BLE_HCI_OCF_VS_CSS_SET_NEXT_SLOT,
+ ble_ll_hci_vs_css_set_next_slot),
+ BLE_LL_HCI_VS_CMD(BLE_HCI_OCF_VS_CSS_SET_CONN_SLOT,
+ ble_ll_hci_vs_css_set_conn_slot),
+ BLE_LL_HCI_VS_CMD(BLE_HCI_OCF_VS_CSS_READ_CONN_SLOT,
+ ble_ll_hci_vs_css_read_conn_slot),
#endif
};
diff --git a/nimble/include/nimble/hci_common.h b/nimble/include/nimble/hci_common.h
index a4615843..b83c35aa 100644
--- a/nimble/include/nimble/hci_common.h
+++ b/nimble/include/nimble/hci_common.h
@@ -1142,39 +1142,29 @@ struct ble_hci_vs_set_tx_pwr_rp {
int8_t tx_power;
} __attribute__((packed));
-#define BLE_HCI_OCF_VS_CSS (MYNEWT_VAL(BLE_HCI_VS_OCF_OFFSET) + (0x0003))
-struct ble_hci_vs_css_cp {
- uint8_t opcode;
-} __attribute__((packed));
-#define BLE_HCI_VS_CSS_OP_CONFIGURE 0x01
+#define BLE_HCI_OCF_VS_CSS_CONFIGURE (MYNEWT_VAL(BLE_HCI_VS_OCF_OFFSET) + (0x0003))
struct ble_hci_vs_css_configure_cp {
- uint8_t opcode;
uint32_t slot_us;
uint32_t period_slots;
} __attribute__((packed));
-#define BLE_HCI_VS_CSS_OP_ENABLE 0x02
+#define BLE_HCI_OCF_VS_CSS_ENABLE (MYNEWT_VAL(BLE_HCI_VS_OCF_OFFSET) + (0x0004))
struct ble_hci_vs_css_enable_cp {
- uint8_t opcode;
uint8_t enable;
} __attribute__((packed));
-#define BLE_HCI_VS_CSS_OP_SET_NEXT_SLOT 0x03
+#define BLE_HCI_OCF_VS_CSS_SET_NEXT_SLOT (MYNEWT_VAL(BLE_HCI_VS_OCF_OFFSET) + (0x0005))
struct ble_hci_vs_css_set_next_slot_cp {
- uint8_t opcode;
uint16_t slot_idx;
} __attribute__((packed));
-#define BLE_HCI_VS_CSS_OP_SET_CONN_SLOT 0x04
+#define BLE_HCI_OCF_VS_CSS_SET_CONN_SLOT (MYNEWT_VAL(BLE_HCI_VS_OCF_OFFSET) + (0x0006))
struct ble_hci_vs_css_set_conn_slot_cp {
- uint8_t opcode;
uint16_t conn_handle;
uint16_t slot_idx;
} __attribute__((packed));
-#define BLE_HCI_VS_CSS_OP_READ_CONN_SLOT 0x05
+#define BLE_HCI_OCF_VS_CSS_READ_CONN_SLOT (MYNEWT_VAL(BLE_HCI_VS_OCF_OFFSET) + (0x0007))
struct ble_hci_vs_css_read_conn_slot_cp {
- uint8_t opcode;
uint16_t conn_handle;
} __attribute__((packed));
struct ble_hci_vs_css_read_conn_slot_rp {
- uint8_t opcode;
uint16_t conn_handle;
uint16_t slot_idx;
} __attribute__((packed));