This is an automated email from the ASF dual-hosted git repository. janc pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
commit f639326653bad3be44eeeaddf2b0fe77d2022419 Author: Magdalena Kasenberg <[email protected]> AuthorDate: Thu Feb 29 10:41:06 2024 +0100 nimble: controller: Add initial support for CS HCI Add stubs for Channel Sounding. --- nimble/controller/include/controller/ble_ll.h | 83 ++++++++-------- nimble/controller/include/controller/ble_ll_cs.h | 51 ++++++++++ nimble/controller/src/ble_ll.c | 5 + nimble/controller/src/ble_ll_cs.c | 119 +++++++++++++++++++++++ nimble/controller/src/ble_ll_hci.c | 47 +++++++++ nimble/controller/syscfg.yml | 8 ++ 6 files changed, 273 insertions(+), 40 deletions(-) diff --git a/nimble/controller/include/controller/ble_ll.h b/nimble/controller/include/controller/ble_ll.h index 0b5e1d52c..752ca43e9 100644 --- a/nimble/controller/include/controller/ble_ll.h +++ b/nimble/controller/include/controller/ble_ll.h @@ -245,46 +245,49 @@ extern STATS_SECT_DECL(ble_ll_stats) ble_ll_stats; #endif /* LL Features */ -#define BLE_LL_FEAT_LE_ENCRYPTION (0x0000000001) -#define BLE_LL_FEAT_CONN_PARM_REQ (0x0000000002) -#define BLE_LL_FEAT_EXTENDED_REJ (0x0000000004) -#define BLE_LL_FEAT_PERIPH_INIT (0x0000000008) -#define BLE_LL_FEAT_LE_PING (0x0000000010) -#define BLE_LL_FEAT_DATA_LEN_EXT (0x0000000020) -#define BLE_LL_FEAT_LL_PRIVACY (0x0000000040) -#define BLE_LL_FEAT_EXT_SCAN_FILT (0x0000000080) -#define BLE_LL_FEAT_LE_2M_PHY (0x0000000100) -#define BLE_LL_FEAT_STABLE_MOD_ID_TX (0x0000000200) -#define BLE_LL_FEAT_STABLE_MOD_ID_RX (0x0000000400) -#define BLE_LL_FEAT_LE_CODED_PHY (0x0000000800) -#define BLE_LL_FEAT_EXT_ADV (0x0000001000) -#define BLE_LL_FEAT_PERIODIC_ADV (0x0000002000) -#define BLE_LL_FEAT_CSA2 (0x0000004000) -#define BLE_LL_FEAT_LE_POWER_CLASS_1 (0x0000008000) -#define BLE_LL_FEAT_MIN_USED_CHAN (0x0000010000) -#define BLE_LL_FEAT_CTE_REQ (0x0000020000) -#define BLE_LL_FEAT_CTE_RSP (0x0000040000) -#define BLE_LL_FEAT_CTE_TX (0x0000080000) -#define BLE_LL_FEAT_CTE_RX (0x0000100000) -#define BLE_LL_FEAT_CTE_AOD (0x0000200000) -#define BLE_LL_FEAT_CTE_AOA (0x0000400000) -#define BLE_LL_FEAT_CTE_RECV (0x0000800000) -#define BLE_LL_FEAT_SYNC_TRANS_SEND (0x0001000000) -#define BLE_LL_FEAT_SYNC_TRANS_RECV (0x0002000000) -#define BLE_LL_FEAT_SCA_UPDATE (0x0004000000) -#define BLE_LL_FEAT_REM_PKEY (0x0008000000) -#define BLE_LL_FEAT_CIS_CENTRAL (0x0010000000) -#define BLE_LL_FEAT_CIS_PERIPH (0x0020000000) -#define BLE_LL_FEAT_ISO_BROADCASTER (0x0040000000) -#define BLE_LL_FEAT_SYNC_RECV (0x0080000000) -#define BLE_LL_FEAT_CIS_HOST (0x0100000000) -#define BLE_LL_FEAT_POWER_CTRL_REQ (0x0200000000) -#define BLE_LL_FEAT_POWER_CHANGE_IND (0x0400000000) -#define BLE_LL_FEAT_PATH_LOSS_MON (0x0800000000) -#define BLE_LL_FEAT_PERIODIC_ADV_ADI (0x1000000000) -#define BLE_LL_FEAT_CONN_SUBRATING (0x2000000000) -#define BLE_LL_FEAT_CONN_SUBRATING_HOST (0x4000000000) -#define BLE_LL_FEAT_CHANNEL_CLASS (0x8000000000) +#define BLE_LL_FEAT_LE_ENCRYPTION (0x0000000000001) +#define BLE_LL_FEAT_CONN_PARM_REQ (0x0000000000002) +#define BLE_LL_FEAT_EXTENDED_REJ (0x0000000000004) +#define BLE_LL_FEAT_PERIPH_INIT (0x0000000000008) +#define BLE_LL_FEAT_LE_PING (0x0000000000010) +#define BLE_LL_FEAT_DATA_LEN_EXT (0x0000000000020) +#define BLE_LL_FEAT_LL_PRIVACY (0x0000000000040) +#define BLE_LL_FEAT_EXT_SCAN_FILT (0x0000000000080) +#define BLE_LL_FEAT_LE_2M_PHY (0x0000000000100) +#define BLE_LL_FEAT_STABLE_MOD_ID_TX (0x0000000000200) +#define BLE_LL_FEAT_STABLE_MOD_ID_RX (0x0000000000400) +#define BLE_LL_FEAT_LE_CODED_PHY (0x0000000000800) +#define BLE_LL_FEAT_EXT_ADV (0x0000000001000) +#define BLE_LL_FEAT_PERIODIC_ADV (0x0000000002000) +#define BLE_LL_FEAT_CSA2 (0x0000000004000) +#define BLE_LL_FEAT_LE_POWER_CLASS_1 (0x0000000008000) +#define BLE_LL_FEAT_MIN_USED_CHAN (0x0000000010000) +#define BLE_LL_FEAT_CTE_REQ (0x0000000020000) +#define BLE_LL_FEAT_CTE_RSP (0x0000000040000) +#define BLE_LL_FEAT_CTE_TX (0x0000000080000) +#define BLE_LL_FEAT_CTE_RX (0x0000000100000) +#define BLE_LL_FEAT_CTE_AOD (0x0000000200000) +#define BLE_LL_FEAT_CTE_AOA (0x0000000400000) +#define BLE_LL_FEAT_CTE_RECV (0x0000000800000) +#define BLE_LL_FEAT_SYNC_TRANS_SEND (0x0000001000000) +#define BLE_LL_FEAT_SYNC_TRANS_RECV (0x0000002000000) +#define BLE_LL_FEAT_SCA_UPDATE (0x0000004000000) +#define BLE_LL_FEAT_REM_PKEY (0x0000008000000) +#define BLE_LL_FEAT_CIS_CENTRAL (0x0000010000000) +#define BLE_LL_FEAT_CIS_PERIPH (0x0000020000000) +#define BLE_LL_FEAT_ISO_BROADCASTER (0x0000040000000) +#define BLE_LL_FEAT_SYNC_RECV (0x0000080000000) +#define BLE_LL_FEAT_CIS_HOST (0x0000100000000) +#define BLE_LL_FEAT_POWER_CTRL_REQ (0x0000200000000) +#define BLE_LL_FEAT_POWER_CHANGE_IND (0x0000400000000) +#define BLE_LL_FEAT_PATH_LOSS_MON (0x0000800000000) +#define BLE_LL_FEAT_PERIODIC_ADV_ADI (0x0001000000000) +#define BLE_LL_FEAT_CONN_SUBRATING (0x0002000000000) +#define BLE_LL_FEAT_CONN_SUBRATING_HOST (0x0004000000000) +#define BLE_LL_FEAT_CHANNEL_CLASS (0x0008000000000) +#define BLE_LL_FEAT_CS (0x0400000000000) +#define BLE_LL_FEAT_CS_HOST_SUPPORT (0x0800000000000) +#define BLE_LL_FEAT_CS_PCT_QUALITY_IND (0x1000000000000) /* This is initial mask, so if feature exchange will not happen, * but host will want to use this procedure, we will try. If not diff --git a/nimble/controller/include/controller/ble_ll_cs.h b/nimble/controller/include/controller/ble_ll_cs.h new file mode 100644 index 000000000..fb7cb4a59 --- /dev/null +++ b/nimble/controller/include/controller/ble_ll_cs.h @@ -0,0 +1,51 @@ +/* + * 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. + */ + +/* All Channel Sounding APIs are experimental and subject to change at any time */ + +#ifndef H_BLE_LL_CS +#define H_BLE_LL_CS + +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* HCI handlers */ +int ble_ll_cs_hci_rd_loc_supp_cap(uint8_t *rspbuf, uint8_t *rsplen); +int ble_ll_cs_hci_rd_rem_supp_cap(const uint8_t *cmdbuf, uint8_t cmdlen); +int ble_ll_cs_hci_wr_cached_rem_supp_cap(const uint8_t *cmdbuf, uint8_t cmdlen, uint8_t *rspbuf, uint8_t *rsplen); +int ble_ll_cs_hci_sec_enable(const uint8_t *cmdbuf, uint8_t cmdlen); +int ble_ll_cs_hci_set_def_settings(const uint8_t *cmdbuf, uint8_t cmdlen, uint8_t *rspbuf, uint8_t *rsplen); +int ble_ll_cs_hci_rd_rem_fae(const uint8_t *cmdbuf, uint8_t cmdlen); +int ble_ll_cs_hci_wr_cached_rem_fae(const uint8_t *cmdbuf, uint8_t cmdlen, uint8_t *rspbuf, uint8_t *rsplen); +int ble_ll_cs_hci_create_config(const uint8_t *cmdbuf, uint8_t cmdlen); +int ble_ll_cs_hci_remove_config(const uint8_t *cmdbuf, uint8_t cmdlen); +int ble_ll_cs_hci_set_chan_class(const uint8_t *cmdbuf, uint8_t cmdlen); +int ble_ll_cs_hci_set_proc_params(const uint8_t *cmdbuf, uint8_t cmdlen, uint8_t *rspbuf, uint8_t *rsplen); +int ble_ll_cs_hci_proc_enable(const uint8_t *cmdbuf, uint8_t cmdlen); +int ble_ll_cs_hci_test(const uint8_t *cmdbuf, uint8_t cmdlen, uint8_t *rspbuf, uint8_t *rsplen); +int ble_ll_cs_hci_test_end(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/nimble/controller/src/ble_ll.c b/nimble/controller/src/ble_ll.c index 998f8d4f0..7e87891ab 100644 --- a/nimble/controller/src/ble_ll.c +++ b/nimble/controller/src/ble_ll.c @@ -1930,6 +1930,11 @@ ble_ll_init(void) features |= BLE_LL_FEAT_CONN_SUBRATING; #endif +#if MYNEWT_VAL(BLE_LL_CHANNEL_SOUNDING) + features |= BLE_LL_FEAT_CS; + features |= BLE_LL_FEAT_CS_PCT_QUALITY_IND; +#endif + lldata->ll_supp_features = features; /* Initialize random number generation */ diff --git a/nimble/controller/src/ble_ll_cs.c b/nimble/controller/src/ble_ll_cs.c new file mode 100644 index 000000000..a9a181a84 --- /dev/null +++ b/nimble/controller/src/ble_ll_cs.c @@ -0,0 +1,119 @@ +/* + * 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. + */ + +#include <syscfg/syscfg.h> +#if MYNEWT_VAL(BLE_LL_CHANNEL_SOUNDING) +#include <stdint.h> +#include "nimble/hci_common.h" +#include "controller/ble_ll_utils.h" +#include "controller/ble_ll.h" +#include "controller/ble_ll_conn.h" +#include "controller/ble_ll_hci.h" +#include "controller/ble_ll_cs.h" + +int +ble_ll_cs_hci_rd_loc_supp_cap(uint8_t *rspbuf, uint8_t *rsplen) +{ + return BLE_ERR_UNSUPPORTED; +} + +int +ble_ll_cs_hci_rd_rem_supp_cap(const uint8_t *cmdbuf, uint8_t cmdlen) +{ + return BLE_ERR_UNSUPPORTED; +} + +int +ble_ll_cs_hci_wr_cached_rem_supp_cap(const uint8_t *cmdbuf, uint8_t cmdlen, + uint8_t *rspbuf, uint8_t *rsplen) +{ + return BLE_ERR_UNSUPPORTED; +} + +int +ble_ll_cs_hci_sec_enable(const uint8_t *cmdbuf, uint8_t cmdlen) +{ + return BLE_ERR_UNSUPPORTED; +} + +int +ble_ll_cs_hci_set_def_settings(const uint8_t *cmdbuf, uint8_t cmdlen, + uint8_t *rspbuf, uint8_t *rsplen) +{ + return BLE_ERR_UNSUPPORTED; +} + +int +ble_ll_cs_hci_rd_rem_fae(const uint8_t *cmdbuf, uint8_t cmdlen) +{ + return BLE_ERR_UNSUPPORTED; +} + +int +ble_ll_cs_hci_wr_cached_rem_fae(const uint8_t *cmdbuf, uint8_t cmdlen, + uint8_t *rspbuf, uint8_t *rsplen) +{ + return BLE_ERR_UNSUPPORTED; +} + +int +ble_ll_cs_hci_create_config(const uint8_t *cmdbuf, uint8_t cmdlen) +{ + return BLE_ERR_UNSUPPORTED; +} + +int +ble_ll_cs_hci_remove_config(const uint8_t *cmdbuf, uint8_t cmdlen) +{ + return BLE_ERR_UNSUPPORTED; +} + +int +ble_ll_cs_hci_set_chan_class(const uint8_t *cmdbuf, uint8_t cmdlen) +{ + return BLE_ERR_UNSUPPORTED; +} + +int +ble_ll_cs_hci_set_proc_params(const uint8_t *cmdbuf, uint8_t cmdlen, + uint8_t *rspbuf, uint8_t *rsplen) +{ + return BLE_ERR_UNSUPPORTED; +} + +int +ble_ll_cs_hci_proc_enable(const uint8_t *cmdbuf, uint8_t cmdlen) +{ + return BLE_ERR_UNSUPPORTED; +} + +int +ble_ll_cs_hci_test(const uint8_t *cmdbuf, uint8_t cmdlen, + uint8_t *rspbuf, uint8_t *rsplen) +{ + return BLE_ERR_UNSUPPORTED; +} + +int +ble_ll_cs_hci_test_end(void) +{ + return BLE_ERR_UNSUPPORTED; +} + +#endif /* BLE_LL_CHANNEL_SOUNDING */ diff --git a/nimble/controller/src/ble_ll_hci.c b/nimble/controller/src/ble_ll_hci.c index 6e5f46891..f75e4ddba 100644 --- a/nimble/controller/src/ble_ll_hci.c +++ b/nimble/controller/src/ble_ll_hci.c @@ -37,6 +37,7 @@ #include "controller/ble_ll_isoal.h" #include "controller/ble_ll_iso.h" #include "controller/ble_ll_iso_big.h" +#include "controller/ble_ll_cs.h" #include "ble_ll_priv.h" #include "ble_ll_conn_priv.h" #include "ble_ll_hci_priv.h" @@ -1315,6 +1316,52 @@ ble_ll_hci_le_cmd_proc(const uint8_t *cmdbuf, uint8_t len, uint16_t ocf, case BLE_HCI_OCF_LE_SUBRATE_REQ: rc = ble_ll_conn_hci_subrate_req(cmdbuf, len, rspbuf, rsplen); break; +#endif +#if MYNEWT_VAL(BLE_LL_CHANNEL_SOUNDING) + case BLE_HCI_OCF_LE_CS_RD_LOC_SUPP_CAP: + rc = ble_ll_cs_hci_rd_loc_supp_cap(rspbuf, rsplen); + break; + case BLE_HCI_OCF_LE_CS_RD_REM_SUPP_CAP: + rc = ble_ll_cs_hci_rd_rem_supp_cap(cmdbuf, len); + break; + case BLE_HCI_OCF_LE_CS_WR_CACHED_REM_SUPP_CAP: + rc = ble_ll_cs_hci_wr_cached_rem_supp_cap(cmdbuf, len, rspbuf, rsplen); + break; +#if MYNEWT_VAL(BLE_LL_ROLE_CENTRAL) + case BLE_HCI_OCF_LE_CS_SEC_ENABLE: + rc = ble_ll_cs_hci_sec_enable(cmdbuf, len); + break; +#endif + case BLE_HCI_OCF_LE_CS_SET_DEF_SETTINGS: + rc = ble_ll_cs_hci_set_def_settings(cmdbuf, len, rspbuf, rsplen); + break; + case BLE_HCI_OCF_LE_CS_RD_REM_FAE: + rc = ble_ll_cs_hci_rd_rem_fae(cmdbuf, len); + break; + case BLE_HCI_OCF_LE_CS_WR_CACHED_REM_FAE: + rc = ble_ll_cs_hci_wr_cached_rem_fae(cmdbuf, len, rspbuf, rsplen); + break; + case BLE_HCI_OCF_LE_CS_CREATE_CONFIG: + rc = ble_ll_cs_hci_create_config(cmdbuf, len); + break; + case BLE_HCI_OCF_LE_CS_REMOVE_CONFIG: + rc = ble_ll_cs_hci_remove_config(cmdbuf, len); + break; + case BLE_HCI_OCF_LE_CS_SET_CHAN_CLASS: + rc = ble_ll_cs_hci_set_chan_class(cmdbuf, len); + break; + case BLE_HCI_OCF_LE_CS_SET_PROC_PARAMS: + rc = ble_ll_cs_hci_set_proc_params(cmdbuf, len, rspbuf, rsplen); + break; + case BLE_HCI_OCF_LE_CS_PROC_ENABLE: + rc = ble_ll_cs_hci_proc_enable(cmdbuf, len); + break; + case BLE_HCI_OCF_LE_CS_TEST: + rc = ble_ll_cs_hci_test(cmdbuf, len, rspbuf, rsplen); + break; + case BLE_HCI_OCF_LE_CS_TEST_END: + rc = ble_ll_cs_hci_test_end(); + break; #endif default: rc = BLE_ERR_UNKNOWN_HCI_CMD; diff --git a/nimble/controller/syscfg.yml b/nimble/controller/syscfg.yml index 8a32e2e02..ce8fad1e9 100644 --- a/nimble/controller/syscfg.yml +++ b/nimble/controller/syscfg.yml @@ -516,6 +516,14 @@ syscfg.defs: value: 0 experimental: 1 + BLE_LL_CHANNEL_SOUNDING: + description: > + Enable support for Channel Sounding feature. + restrictions: + - (BLE_VERSION >= 54) if 1 + value: MYNEWT_VAL(BLE_CHANNEL_SOUNDING) + state: experimental + BLE_LL_SYSINIT_STAGE: description: > Sysinit stage for the NimBLE controller.
