diff --git a/include/zephyr/bluetooth/bluetooth.h b/include/zephyr/bluetooth/bluetooth.h index 7f287f1c344..750155d211e 100644 --- a/include/zephyr/bluetooth/bluetooth.h +++ b/include/zephyr/bluetooth/bluetooth.h @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -71,11 +72,17 @@ extern "C" { #define BT_ID_DEFAULT 0 /** - * @brief Number of octets for local supported + * @brief Number of octets for local supported features * - * The value of 8 correspond to page 0 in the LE Controller supported features + * The value of 8 correspond to page 0 in the LE Controller supported features. + * 24 bytes are required for all subsequent supported feature pages. */ -#define BT_LE_LOCAL_SUPPORTED_FEATURES_SIZE 8 +#define BT_LE_LOCAL_SUPPORTED_FEATURES_SIZE \ + (BT_HCI_LE_BYTES_PAGE_0_FEATURE_PAGE + \ + COND_CODE_1(CONFIG_BT_LE_MAX_LOCAL_SUPPORTED_FEATURE_PAGE, \ + (CONFIG_BT_LE_MAX_LOCAL_SUPPORTED_FEATURE_PAGE \ + * BT_HCI_LE_BYTES_PER_FEATURE_PAGE), \ + (0U))) /** Opaque type representing an advertiser. */ struct bt_le_ext_adv; diff --git a/include/zephyr/bluetooth/conn.h b/include/zephyr/bluetooth/conn.h index 8bc060bb05b..c6d8ce2015f 100644 --- a/include/zephyr/bluetooth/conn.h +++ b/include/zephyr/bluetooth/conn.h @@ -252,6 +252,107 @@ struct bt_conn_le_subrate_changed { uint16_t supervision_timeout; }; +/** Read all remote features complete callback params */ +struct bt_conn_le_read_all_remote_feat_complete { + /** @brief HCI Status from LE Read All Remote Features Complete event. + * + * The remaining parameters will be unchanged if status is not @ref BT_HCI_ERR_SUCCESS. + */ + uint8_t status; + /** Number of pages supported by remote device. */ + uint8_t max_remote_page; + /** Number of pages fetched from remote device. */ + uint8_t max_valid_page; + /** @brief Pointer to array of size 248, with feature bits of remote supported features. + * + * Page 0 being 8 bytes, with the following 10 pages of 24 bytes. + * Refer to BT_LE_FEAT_BIT_* for values. + * Refer to the BT_FEAT_LE_* macros for value comparison. + * See Bluetooth Core Specification, Vol 6, Part B, Section 4.6. + */ + const uint8_t *features; +}; + +#define BT_CONN_LE_FRAME_SPACE_TYPES_MASK_ACL_IFS \ + (BT_HCI_LE_FRAME_SPACE_UPDATE_SPACING_TYPE_IFS_ACL_CP_MASK | \ + BT_HCI_LE_FRAME_SPACE_UPDATE_SPACING_TYPE_IFS_ACL_PC_MASK) + +#define BT_CONN_LE_FRAME_SPACE_TYPES_MASK_ACL \ + (BT_HCI_LE_FRAME_SPACE_UPDATE_SPACING_TYPE_IFS_ACL_CP_MASK | \ + BT_HCI_LE_FRAME_SPACE_UPDATE_SPACING_TYPE_IFS_ACL_PC_MASK | \ + BT_HCI_LE_FRAME_SPACE_UPDATE_SPACING_TYPE_MCES_MASK) + +#define BT_CONN_LE_FRAME_SPACE_TYPES_MASK_CIS \ + (BT_HCI_LE_FRAME_SPACE_UPDATE_SPACING_TYPE_IFS_CIS_MASK | \ + BT_HCI_LE_FRAME_SPACE_UPDATE_SPACING_TYPE_MSS_CIS_MASK) + +/** Maximum frame space in microseconds. + * As defined in Bluetooth Core Specification, Vol 4, Part E, Section 7.8.151. + */ +#define BT_CONN_LE_FRAME_SPACE_MAX (10000U) + +/** Frame space update initiator. */ +enum bt_conn_le_frame_space_update_initiator { + /** Initiated by local host */ + BT_CONN_LE_FRAME_SPACE_UPDATE_INITIATOR_LOCAL_HOST = + BT_HCI_LE_FRAME_SPACE_UPDATE_INITIATOR_LOCAL_HOST, + /** Initiated by local controller */ + BT_CONN_LE_FRAME_SPACE_UPDATE_INITIATOR_LOCAL_CONTROLLER = + BT_HCI_LE_FRAME_SPACE_UPDATE_INITIATOR_LOCAL_CONTROLLER, + /** Initiated by peer */ + BT_CONN_LE_FRAME_SPACE_UPDATE_INITIATOR_PEER = + BT_HCI_LE_FRAME_SPACE_UPDATE_INITIATOR_PEER +}; + +/** Frame space update params */ +struct bt_conn_le_frame_space_update_param { + /** Phy mask of the PHYs to be updated. + * Refer to BT_HCI_LE_FRAME_SPACE_UPDATE_PHY_* for values. + */ + uint8_t phys; + /** Spacing types mask of the spacing types to be updated. + * Refer to BT_HCI_LE_FRAME_SPACE_UPDATE_SPACING_TYPE_* and + * BT_CONN_LE_FRAME_SPACE_TYPES_MASK_* for values. + */ + uint16_t spacing_types; + /** Minimum frame space in microseconds. + * Bluetooth Core Specification, Vol 4, Part E, Section 7.8.151 + * allows for a range of frame space from 0 to 10000 microseconds. + * The actual supported frame space values will be dependent on + * the controller's capabilities. + */ + uint16_t frame_space_min; + /** Maximum frame space in microseconds. + * Bluetooth Core Specification, Vol 4, Part E, Section 7.8.151 + * allows for a range of frame space from 0 to 10000 microseconds. + * The actual supported frame space values will be dependent on + * the controller's capabilities. + */ + uint16_t frame_space_max; +}; + +/** Frame space updated callback params */ +struct bt_conn_le_frame_space_updated { + /** HCI Status from LE Frame Space Update Complete event. + * The remaining parameters will be invalid if status is not + * @ref BT_HCI_ERR_SUCCESS. + */ + uint8_t status; + /** Initiator of the frame space update. */ + enum bt_conn_le_frame_space_update_initiator initiator; + /** Updated frame space in microseconds. */ + uint16_t frame_space; + /** Phy mask of the PHYs updated. + * Refer to BT_HCI_LE_FRAME_SPACE_UPDATE_PHY_* for values. + */ + uint8_t phys; + /** Spacing types mask of the spacing types updated. + * Refer to BT_HCI_LE_FRAME_SPACE_UPDATE_SPACING_TYPE_* and + * BT_CONN_LE_FRAME_SPACE_TYPES_MASK_* for values. + */ + uint16_t spacing_types; +}; + /** Connection Type */ enum __packed bt_conn_type { /** LE Connection Type */ @@ -1186,6 +1287,41 @@ int bt_conn_le_subrate_set_defaults(const struct bt_conn_le_subrate_param *param int bt_conn_le_subrate_request(struct bt_conn *conn, const struct bt_conn_le_subrate_param *params); +/** @brief Read remote feature pages. + * + * Request remote feature pages, from 0 up to pages_requested or the number + * of pages supported by the peer. There is a maximum of 10 pages. + * This function will trigger the read_all_remote_feat_complete callback + * when the procedure is completed. + * + * @kconfig_dep{CONFIG_BT_LE_EXTENDED_FEAT_SET} + * + * @param conn @ref BT_CONN_TYPE_LE connection object. + * @param pages_requested Number of feature pages to be requested from peer. + * There is a maximum of 10 pages. + * + * @return Zero on success or (negative) error code on failure. + * @return -EINVAL @p conn is not a valid @ref BT_CONN_TYPE_LE connection. + */ +int bt_conn_le_read_all_remote_features(struct bt_conn *conn, uint8_t pages_requested); + +/** @brief Update frame space. + * + * Request a change to the frame space parameters of a connection. + * This function will trigger the frame_space_updated callback when the + * procedure is completed. + * + * @kconfig_dep{CONFIG_BT_FRAME_SPACE_UPDATE}. + * + * @param conn @ref BT_CONN_TYPE_LE connection object. + * @param params Frame Space Update parameters. + * + * @return Zero on success or (negative) error code on failure. + * @return -EINVAL @p conn is not a valid @ref BT_CONN_TYPE_LE connection. + */ +int bt_conn_le_frame_space_update(struct bt_conn *conn, + const struct bt_conn_le_frame_space_update_param *params); + /** @brief Update the connection parameters. * * If the local device is in the peripheral role then updating the connection @@ -1877,6 +2013,45 @@ struct bt_conn_cb { const struct bt_conn_le_subrate_changed *params); #endif /* CONFIG_BT_SUBRATING */ +#if defined(CONFIG_BT_LE_EXTENDED_FEAT_SET) + /** @brief Read all remote features complete event. + * + * This callback notifies the application that a 'read all remote + * features' procedure of the connection is completed. The other params + * will not be populated if status is not @ref BT_HCI_ERR_SUCCESS. + * + * This callback can be triggered by calling @ref + * bt_conn_le_read_all_remote_features or by the procedure running + * autonomously in the controller. + * + * @param conn Connection object. + * @param params Remote features. + */ + void (*read_all_remote_feat_complete)( + struct bt_conn *conn, + const struct bt_conn_le_read_all_remote_feat_complete *params); +#endif /* CONFIG_BT_LE_EXTENDED_FEAT_SET */ + +#if defined(CONFIG_BT_FRAME_SPACE_UPDATE) + /** @brief Frame Space Update Complete event. + * + * This callback notifies the application that the frame space of + * the connection may have changed. + * The frame space update parameters will be invalid + * if status is not @ref BT_HCI_ERR_SUCCESS. + * + * This callback can be triggered by calling @ref + * bt_conn_le_frame_space_update, by the procedure running + * autonomously in the controller or by the peer. + * + * @param conn Connection object. + * @param params New frame space update parameters. + */ + void (*frame_space_updated)( + struct bt_conn *conn, + const struct bt_conn_le_frame_space_updated *params); +#endif /* CONFIG_BT_FRAME_SPACE_UPDATE */ + #if defined(CONFIG_BT_CHANNEL_SOUNDING) /** @brief LE CS Read Remote Supported Capabilities Complete event. * @@ -1975,6 +2150,17 @@ struct bt_conn_cb { #endif +#if defined(CONFIG_BT_CLASSIC) + /** @brief The role of the connection has changed. + * + * This callback notifies the application that the role switch procedure has completed. + * + * @param conn Connection object. + * @param status HCI status of role change event. + */ + void (*role_changed)(struct bt_conn *conn, uint8_t status); +#endif + /** @internal Internally used field for list handling */ sys_snode_t _node; }; @@ -2677,6 +2863,29 @@ struct bt_conn *bt_conn_lookup_addr_br(const bt_addr_t *peer); */ const bt_addr_t *bt_conn_get_dst_br(const struct bt_conn *conn); +/** @brief Change the role of the conn. + * + * @param conn Connection object. + * @param role The role that want to switch as, the value is @ref BT_HCI_ROLE_CENTRAL and + * @ref BT_HCI_ROLE_PERIPHERAL from hci_types.h. + * + * @return Zero on success or (negative) error code on failure. + * @return -ENOBUFS HCI command buffer is not available. + * @return -EINVAL @p conn is not a valid @ref BT_CONN_TYPE_BR connection + */ +int bt_conn_br_switch_role(const struct bt_conn *conn, uint8_t role); + +/** @brief Enable/disable role switch of the connection by setting the connection's link policy. + * + * @param conn Connection object. + * @param enable Value enable/disable role switch of controller. + * + * @return Zero on success or (negative) error code on failure. + * @return -ENOBUFS HCI command buffer is not available. + * @return -EINVAL @p conn is not a valid @ref BT_CONN_TYPE_BR connection. + */ +int bt_conn_br_set_role_switch_enable(const struct bt_conn *conn, bool enable); + #ifdef __cplusplus } #endif diff --git a/include/zephyr/bluetooth/hci_types.h b/include/zephyr/bluetooth/hci_types.h index 0b2c1b1a397..cc4cdad9364 100644 --- a/include/zephyr/bluetooth/hci_types.h +++ b/include/zephyr/bluetooth/hci_types.h @@ -207,7 +207,8 @@ struct bt_hci_cmd_hdr { #define BT_LE_FEAT_BIT_CHANNEL_SOUNDING 46 #define BT_LE_FEAT_BIT_CHANNEL_SOUNDING_HOST 47 #define BT_LE_FEAT_BIT_CHANNEL_SOUNDING_TONE_QUAL_IND 48 -#define BT_LE_FEAT_BIT_LL_EXTENDED_FEAT_SET 63 +#define BT_LE_FEAT_BIT_EXTENDED_FEAT_SET 63 +#define BT_LE_FEAT_BIT_FRAME_SPACE_UPDATE 65 #define BT_LE_FEAT_TEST(feat, n) (feat[(n) >> 3] & \ BIT((n) & 7)) @@ -284,6 +285,10 @@ struct bt_hci_cmd_hdr { BT_LE_FEAT_BIT_CHANNEL_SOUNDING) #define BT_FEAT_LE_CHANNEL_SOUNDING_HOST(feat) BT_LE_FEAT_TEST(feat, \ BT_LE_FEAT_BIT_CHANNEL_SOUNDING_HOST) +#define BT_FEAT_LE_EXTENDED_FEAT_SET(feat) BT_LE_FEAT_TEST(feat, \ + BT_LE_FEAT_BIT_EXTENDED_FEAT_SET) +#define BT_FEAT_LE_FRAME_SPACE_UPDATE_SET(feat) BT_LE_FEAT_TEST(feat, \ + BT_LE_FEAT_BIT_FRAME_SPACE_UPDATE) #define BT_FEAT_LE_CIS(feat) (BT_FEAT_LE_CIS_CENTRAL(feat) | \ BT_FEAT_LE_CIS_PERIPHERAL(feat)) @@ -363,6 +368,7 @@ struct bt_hci_cmd_hdr { /* OpCode Group Fields */ #define BT_OGF_LINK_CTRL 0x01 +#define BT_OGF_LINK_POLICY 0x02 #define BT_OGF_BASEBAND 0x03 #define BT_OGF_INFO 0x04 #define BT_OGF_STATUS 0x05 @@ -558,6 +564,43 @@ struct bt_hci_cp_io_capability_neg_reply { uint8_t reason; } __packed; +#define BT_HCI_OP_SWITCH_ROLE BT_OP(BT_OGF_LINK_POLICY, 0x000b) +struct bt_hci_cp_switch_role { + bt_addr_t bdaddr; + uint8_t role; +} __packed; + +#define BT_HCI_LINK_POLICY_SETTINGS_ENABLE_ROLE_SWITCH BIT(0) +#define BT_HCI_LINK_POLICY_SETTINGS_ENABLE_HOLD_MODE BIT(1) +#define BT_HCI_LINK_POLICY_SETTINGS_ENABLE_SNIFF_SWITCH BIT(2) + +#define BT_HCI_OP_READ_LINK_POLICY_SETTINGS BT_OP(BT_OGF_LINK_POLICY, 0x000c) +struct bt_hci_cp_read_link_policy_settings { + uint16_t handle; +} __packed; +struct bt_hci_rp_read_link_policy_settings { + uint8_t status; + uint16_t handle; + uint16_t link_policy_settings; +} __packed; + +#define BT_HCI_OP_WRITE_LINK_POLICY_SETTINGS BT_OP(BT_OGF_LINK_POLICY, 0x000d) +struct bt_hci_cp_write_link_policy_settings { + uint16_t handle; + uint16_t link_policy_settings; +} __packed; + +#define BT_HCI_OP_READ_DEFAULT_LINK_POLICY_SETTINGS BT_OP(BT_OGF_LINK_POLICY, 0x000e) +struct bt_hci_rp_read_default_link_policy_settings { + uint8_t status; + uint16_t default_link_policy_settings; +} __packed; + +#define BT_HCI_OP_WRITE_DEFAULT_LINK_POLICY_SETTINGS BT_OP(BT_OGF_LINK_POLICY, 0x000f) +struct bt_hci_cp_write_default_link_policy_settings { + uint16_t default_link_policy_settings; +} __packed; + #define BT_HCI_OP_SET_EVENT_MASK BT_OP(BT_OGF_BASEBAND, 0x0001) /* 0x0c01 */ struct bt_hci_cp_set_event_mask { uint8_t events[8]; @@ -2438,6 +2481,22 @@ struct bt_hci_cp_le_tx_test_v4 { uint8_t ant_ids[0]; } __packed; +#define BT_HCI_OP_LE_READ_ALL_LOCAL_SUPPORTED_FEATURES BT_OP(BT_OGF_LE, 0x0087) /* 0x2087 */ +struct bt_hci_rp_le_read_all_local_supported_features { + uint8_t status; + uint8_t max_page; + uint8_t features[248]; +} __packed; + +#define BT_READ_ALL_LOCAL_FEATURES_SUPPORTED(supported_commands) \ + BT_CMD_TEST(supported_commands, 47, 2) + +#define BT_HCI_OP_LE_READ_ALL_REMOTE_FEATURES BT_OP(BT_OGF_LE, 0x0088) /* 0x2088 */ +struct bt_hci_cp_le_read_all_remote_features { + uint16_t handle; + uint8_t pages_requested; +} __packed; + #define BT_HCI_TX_TEST_POWER_MIN -0x7F #define BT_HCI_TX_TEST_POWER_MAX 0x14 @@ -2759,6 +2818,30 @@ struct bt_hci_cp_le_cs_remove_config { #define BT_HCI_OP_LE_CS_TEST_END BT_OP(BT_OGF_LE, 0x0096) /* 0x2096 */ +#define BT_HCI_LE_FRAME_SPACE_UPDATE_PHY_1M_MASK BIT(0) +#define BT_HCI_LE_FRAME_SPACE_UPDATE_PHY_2M_MASK BIT(1) +#define BT_HCI_LE_FRAME_SPACE_UPDATE_PHY_CODED_MASK BIT(2) + +#define BT_HCI_LE_FRAME_SPACE_UPDATE_SPACING_TYPE_IFS_ACL_CP_MASK BIT(0) +#define BT_HCI_LE_FRAME_SPACE_UPDATE_SPACING_TYPE_IFS_ACL_PC_MASK BIT(1) +#define BT_HCI_LE_FRAME_SPACE_UPDATE_SPACING_TYPE_MCES_MASK BIT(2) +#define BT_HCI_LE_FRAME_SPACE_UPDATE_SPACING_TYPE_IFS_CIS_MASK BIT(3) +#define BT_HCI_LE_FRAME_SPACE_UPDATE_SPACING_TYPE_MSS_CIS_MASK BIT(4) + +#define BT_HCI_LE_FRAME_SPACE_UPDATE_INITIATOR_LOCAL_HOST (0) +#define BT_HCI_LE_FRAME_SPACE_UPDATE_INITIATOR_LOCAL_CONTROLLER (1) +#define BT_HCI_LE_FRAME_SPACE_UPDATE_INITIATOR_PEER (2) + +struct bt_hci_cp_le_frame_space_update { + uint16_t handle; + uint16_t frame_space_min; + uint16_t frame_space_max; + uint8_t phys; + uint16_t spacing_types; +} __packed; + +#define BT_HCI_OP_LE_FRAME_SPACE_UPDATE BT_OP(BT_OGF_LE, 0x009D) /* 0x209D */ + /* Event definitions */ #define BT_HCI_EVT_UNKNOWN 0x00 @@ -3552,6 +3635,20 @@ struct bt_hci_evt_le_cis_established_v2 { uint8_t framing; } __packed; +#define BT_HCI_EVT_LE_READ_ALL_REMOTE_FEAT_COMPLETE 0x2b + +#define BT_HCI_LE_FEATURE_PAGE_MAX 10 +#define BT_HCI_LE_BYTES_PER_FEATURE_PAGE 24 +#define BT_HCI_LE_BYTES_PAGE_0_FEATURE_PAGE 8 + +struct bt_hci_evt_le_read_all_remote_feat_complete { + uint8_t status; + uint16_t handle; + uint8_t max_remote_page; + uint8_t max_valid_page; + uint8_t features[248]; +} __packed; + #define BT_HCI_LE_CS_INITIATOR_ROLE_MASK BIT(0) #define BT_HCI_LE_CS_REFLECTOR_ROLE_MASK BIT(1) @@ -3934,6 +4031,16 @@ struct bt_hci_evt_le_cs_procedure_enable_complete { uint16_t max_procedure_len; } __packed; +#define BT_HCI_EVT_LE_FRAME_SPACE_UPDATE_COMPLETE 0x35 +struct bt_hci_evt_le_frame_space_update_complete { + uint8_t status; + uint16_t handle; + uint8_t initiator; + uint16_t frame_space; + uint8_t phys; + uint16_t spacing_types; +} __packed; + /* Event mask bits */ #define BT_EVT_BIT(n) (1ULL << (n)) @@ -4024,6 +4131,8 @@ struct bt_hci_evt_le_cs_procedure_enable_complete { #define BT_EVT_MASK_LE_ENH_CONN_COMPLETE_V2 BT_EVT_BIT(40) #define BT_EVT_MASK_LE_CIS_ESTABLISHED_V2 BT_EVT_BIT(41) +#define BT_EVT_MASK_LE_READ_ALL_REMOTE_FEAT_COMPLETE BT_EVT_BIT(42) + #define BT_EVT_MASK_LE_CS_READ_REMOTE_SUPPORTED_CAPABILITIES_COMPLETE BT_EVT_BIT(43) #define BT_EVT_MASK_LE_CS_READ_REMOTE_FAE_TABLE_COMPLETE BT_EVT_BIT(44) #define BT_EVT_MASK_LE_CS_SECURITY_ENABLE_COMPLETE BT_EVT_BIT(45) @@ -4033,6 +4142,8 @@ struct bt_hci_evt_le_cs_procedure_enable_complete { #define BT_EVT_MASK_LE_CS_SUBEVENT_RESULT_CONTINUE BT_EVT_BIT(49) #define BT_EVT_MASK_LE_CS_TEST_END_COMPLETE BT_EVT_BIT(50) +#define BT_EVT_MASK_LE_FRAME_SPACE_UPDATE_COMPLETE BT_EVT_BIT(52) + /** HCI Error Codes, BT Core Spec v5.4 [Vol 1, Part F]. */ #define BT_HCI_ERR_SUCCESS 0x00 #define BT_HCI_ERR_UNKNOWN_CMD 0x01 diff --git a/samples/bluetooth/central_hr/overlay-static_callbacks.conf b/samples/bluetooth/central_hr/overlay-static_callbacks.conf new file mode 100644 index 00000000000..528958ad3a9 --- /dev/null +++ b/samples/bluetooth/central_hr/overlay-static_callbacks.conf @@ -0,0 +1,2 @@ +# Disable connection dynamic callbacks +CONFIG_BT_CONN_DYNAMIC_CALLBACKS=n diff --git a/samples/bluetooth/central_hr/prj_minimal.conf b/samples/bluetooth/central_hr/prj_minimal.conf index 3ea96d693c7..983b5a934d7 100644 --- a/samples/bluetooth/central_hr/prj_minimal.conf +++ b/samples/bluetooth/central_hr/prj_minimal.conf @@ -87,6 +87,7 @@ CONFIG_BT_GATT_SERVICE_CHANGED=n CONFIG_BT_GAP_PERIPHERAL_PREF_PARAMS=n CONFIG_BT_SETTINGS_CCC_LAZY_LOADING=y CONFIG_BT_HCI_VS=n +CONFIG_BT_CONN_DYNAMIC_CALLBACKS=n # Disable Bluetooth controller features not needed CONFIG_BT_CTLR_PRIVACY=n diff --git a/samples/bluetooth/peripheral_hr/overlay-static_callbacks.conf b/samples/bluetooth/peripheral_hr/overlay-static_callbacks.conf new file mode 100644 index 00000000000..528958ad3a9 --- /dev/null +++ b/samples/bluetooth/peripheral_hr/overlay-static_callbacks.conf @@ -0,0 +1,2 @@ +# Disable connection dynamic callbacks +CONFIG_BT_CONN_DYNAMIC_CALLBACKS=n diff --git a/samples/bluetooth/peripheral_hr/prj_minimal.conf b/samples/bluetooth/peripheral_hr/prj_minimal.conf index 8f9c2b85cb1..76cac20ec5e 100644 --- a/samples/bluetooth/peripheral_hr/prj_minimal.conf +++ b/samples/bluetooth/peripheral_hr/prj_minimal.conf @@ -93,6 +93,7 @@ CONFIG_BT_GATT_SERVICE_CHANGED=n CONFIG_BT_GAP_PERIPHERAL_PREF_PARAMS=n CONFIG_BT_SETTINGS_CCC_LAZY_LOADING=y CONFIG_BT_HCI_VS=n +CONFIG_BT_CONN_DYNAMIC_CALLBACKS=n # Disable Bluetooth controller features not needed CONFIG_BT_CTLR_PRIVACY=n diff --git a/soc/atmel/sam0/common/Kconfig.samd2x b/soc/atmel/sam0/common/Kconfig.samd2x index 11f76f608a1..c9de00e3249 100644 --- a/soc/atmel/sam0/common/Kconfig.samd2x +++ b/soc/atmel/sam0/common/Kconfig.samd2x @@ -8,7 +8,7 @@ config SOC_ATMEL_SAMD_NVM_WAIT_STATES default 1 help Wait states to set for NVM. Consult the datasheet as these are highly - dependent on the device operationg conditions. + dependent on the device operating conditions. config SOC_ATMEL_SAMD_OSC32K bool "Internal 32.768 kHz RC oscillator" diff --git a/soc/espressif/esp32s3/Kconfig b/soc/espressif/esp32s3/Kconfig index 99ebadeb440..5fa2d4607e8 100644 --- a/soc/espressif/esp32s3/Kconfig +++ b/soc/espressif/esp32s3/Kconfig @@ -152,7 +152,8 @@ config MAC_BB_PD help If enabled, the MAC and baseband of Wi-Fi and Bluetooth will be powered down when PHY is disabled. Enabling this setting reduces power consumption - by a small amount but increases RAM use by approximat + by a small amount but increases RAM use by approximately 4KB (Wi-Fi only), + 2KB (Bluetooth only) or 5.3KB (Wi-Fi + Bluetooth). endmenu # Cache config diff --git a/soc/intel/intel_adsp/Kconfig b/soc/intel/intel_adsp/Kconfig index 096c4336876..2d87adb0306 100644 --- a/soc/intel/intel_adsp/Kconfig +++ b/soc/intel/intel_adsp/Kconfig @@ -141,8 +141,8 @@ config XTENSA_WAITI_BUG config ADSP_IDLE_CLOCK_GATING bool "DSP clock gating in Idle" help - When true, FW will run with enabled clock gating. This options change - HW configuration of a DSP. Evry time core goes to the WAITI state + When true, FW will run with enabled clock gating. This option changes + HW configuration of a DSP. Every time core goes to the WAITI state (wait for interrupt) during idle, the clock can be gated (however, this does not mean that this will happen). diff --git a/soc/intel/intel_adsp/Kconfig.defconfig b/soc/intel/intel_adsp/Kconfig.defconfig index 5a2ff345e25..1d8312e7fb6 100644 --- a/soc/intel/intel_adsp/Kconfig.defconfig +++ b/soc/intel/intel_adsp/Kconfig.defconfig @@ -18,7 +18,7 @@ config XTENSA_RPO_CACHE def_bool y # console can't handle the amount of data coming from many tests, so introduce -# a delay beween testcases. +# a delay between testcases. if ZTEST config ZTEST_TEST_DELAY_MS default 100 diff --git a/soc/nxp/imxrt/imxrt118x/Kconfig b/soc/nxp/imxrt/imxrt118x/Kconfig index d62af3d1b51..1ec08a04311 100644 --- a/soc/nxp/imxrt/imxrt118x/Kconfig +++ b/soc/nxp/imxrt/imxrt118x/Kconfig @@ -40,11 +40,11 @@ config IMAGE_CONTAINER_OFFSET default 0x1000 help Image container is a boot image format that is used by ROM. Container - format consists container header, image arrary entry, signature block + format consists of container header, image array entry, signature block and user program images and data. The boot ROM expects container data to be saved in external memory. -# Note- This config present the offest between container header and user +# Note- This config presents the offset between container header and user # image. If ROM_START_OFFSET changed, you also need to change CONTAINER_USER_IMAGE_OFFSET # value. CONTAINER_USER_IMAGE_OFFSET = ROM_START_OFFSET - IMAGE_CONTAINER_OFFSET. config CONTAINER_USER_IMAGE_OFFSET diff --git a/soc/nxp/rw/Kconfig b/soc/nxp/rw/Kconfig index a32483ad0c1..63a2e28b732 100644 --- a/soc/nxp/rw/Kconfig +++ b/soc/nxp/rw/Kconfig @@ -39,7 +39,7 @@ config FLASH_CONFIG_OFFSET default 0x400 help The flash config offset provides the boot ROM with the on-board - flash type and parameters. The boot ROM requires a fixed flash conifg + flash type and parameters. The boot ROM requires a fixed flash config offset for FlexSPI device. config IMAGE_VECTOR_TABLE_OFFSET diff --git a/soc/renesas/rx/Kconfig b/soc/renesas/rx/Kconfig index f0670b850e3..2f5253bf541 100644 --- a/soc/renesas/rx/Kconfig +++ b/soc/renesas/rx/Kconfig @@ -10,7 +10,7 @@ config RENESAS_NONE_USED_PORT_INIT bool "Initialize unused ports" default y help - Initialize the unsed pins of RX MCU followed by in the "Handling of + Initialize the unused pins of RX MCU followed by in the "Handling of Unused Pins" section of PORT chapter of RX MCU of User's manual. Note: please MUST set "BSP_PACKAGE_PINS" definition to your device of pin type in r_bsp_config.h. diff --git a/soc/silabs/Kconfig b/soc/silabs/Kconfig index dcf8de541c6..1fb5535ac67 100644 --- a/soc/silabs/Kconfig +++ b/soc/silabs/Kconfig @@ -9,7 +9,7 @@ if SOC_FAMILY_SILABS_S0 || SOC_FAMILY_SILABS_S1 || SOC_FAMILY_SILABS_S2 config SOC_GECKO_SDID int help - Gecko SDK sometime refere to the chipset using the internal ID. This + Sometimes, Gecko SDK refers to the chipset using the internal ID. This entry reflects this ID. config SOC_GECKO_BURTC diff --git a/soc/st/stm32/Kconfig b/soc/st/stm32/Kconfig index 59a245fb17a..a14d9ea8182 100644 --- a/soc/st/stm32/Kconfig +++ b/soc/st/stm32/Kconfig @@ -36,7 +36,7 @@ config STM32_ENABLE_DEBUG_SLEEP_STOP Some STM32 parts disable the DBGMCU in sleep/stop modes because of power consumption. As a side-effects this prevents debuggers from attaching w/o resetting the target. This - effectivly destroys the use-case of `west attach`. Also + effectively destroys the use-case of `west attach`. Also SEGGER RTT and similar technologies need this. config SWJ_ANALOG_PRIORITY diff --git a/soc/st/stm32/Kconfig.defconfig b/soc/st/stm32/Kconfig.defconfig index 18f343b9324..26055f9eb60 100644 --- a/soc/st/stm32/Kconfig.defconfig +++ b/soc/st/stm32/Kconfig.defconfig @@ -3,7 +3,7 @@ # Copyright (c) 2017, I-SENSE group of ICCS # SPDX-License-Identifier: Apache-2.0 -# Default configurations appplied tp the whole STM32 family +# Default configurations applied to the whole STM32 family if SOC_FAMILY_STM32 diff --git a/subsys/bluetooth/Kconfig b/subsys/bluetooth/Kconfig index 68d08819e1c..7e8fa5dca6e 100644 --- a/subsys/bluetooth/Kconfig +++ b/subsys/bluetooth/Kconfig @@ -115,7 +115,39 @@ config BT_CONN_TX help Hidden configuration that is true if ACL or broadcast ISO is enabled +config BT_LE_LOCAL_MINIMUM_REQUIRED_FEATURE_PAGE + int + default 1 if BT_FRAME_SPACE_UPDATE + default 0 + depends on BT_LE_EXTENDED_FEAT_SET + help + Minimum required feature page that must be supported. + +config BT_LE_MAX_LOCAL_SUPPORTED_FEATURE_PAGE + int "Maximum supported feature page" + default BT_LE_LOCAL_MINIMUM_REQUIRED_FEATURE_PAGE + range BT_LE_LOCAL_MINIMUM_REQUIRED_FEATURE_PAGE 10 + depends on BT_LE_EXTENDED_FEAT_SET + help + Maximum feature page that can be stored for local supported features. + +config BT_LE_EXTENDED_FEAT_SET + bool "LL Extended Feature Set" + depends on !HAS_BT_CTLR || BT_CTLR_EXTENDED_FEAT_SET_SUPPORT + help + Enable support for the LL Extended Feature Set feature. + if BT_CONN +config BT_CONN_DYNAMIC_CALLBACKS + bool "Dynamic connection callbacks" + default y + help + Enable support for dynamic connection callbacks. This links in + bt_conn_cb_register(). Disabling this config is safe. It will make + uses of this and associated APIs fail to link. Note: Static registration + through BT_CONN_CB_DEFINE() is always available and does not depend on + this config. + config BT_HCI_ACL_FLOW_CONTROL bool "Controller to Host ACL flow control support" # Enable if building a Host-only build @@ -188,6 +220,12 @@ config BT_SUBRATING Enable support for LE Connection Subrating feature that is defined in the Bluetooth Core specification, Version 5.4 | Vol 6, Part B, Section 4.6.35. +config BT_FRAME_SPACE_UPDATE + bool "Frame Space Update" + depends on (!HAS_BT_CTLR || BT_CTLR_FRAME_SPACE_UPDATE_SUPPORT) && BT_CONN && BT_LE_EXTENDED_FEAT_SET + help + Enable support for Bluetooth 6.0 Frame Space Update feature. + config BT_CHANNEL_SOUNDING bool "Channel Sounding [EXPERIMENTAL]" select EXPERIMENTAL diff --git a/subsys/bluetooth/audio/bap_unicast_client.c b/subsys/bluetooth/audio/bap_unicast_client.c index 1f081ee805b..3db8e8a7b9c 100644 --- a/subsys/bluetooth/audio/bap_unicast_client.c +++ b/subsys/bluetooth/audio/bap_unicast_client.c @@ -4456,14 +4456,13 @@ static void unicast_client_disconnected(struct bt_conn *conn, uint8_t reason) unicast_client_ep_reset(conn, reason); } -static struct bt_conn_cb conn_cbs = { +BT_CONN_CB_DEFINE(conn_cbs) = { .disconnected = unicast_client_disconnected, }; int bt_bap_unicast_client_discover(struct bt_conn *conn, enum bt_audio_dir dir) { struct unicast_client *client; - static bool conn_cb_registered; uint8_t role; int err; @@ -4496,11 +4495,6 @@ int bt_bap_unicast_client_discover(struct bt_conn *conn, enum bt_audio_dir dir) client->disc_params.start_handle = BT_ATT_FIRST_ATTRIBUTE_HANDLE; client->disc_params.end_handle = BT_ATT_LAST_ATTRIBUTE_HANDLE; - if (!conn_cb_registered) { - bt_conn_cb_register(&conn_cbs); - conn_cb_registered = true; - } - err = bt_gatt_discover(conn, &client->disc_params); if (err != 0) { atomic_clear_bit(client->flags, UNICAST_CLIENT_FLAG_BUSY); diff --git a/subsys/bluetooth/audio/csip_set_member.c b/subsys/bluetooth/audio/csip_set_member.c index d41230a1668..c38929846b4 100644 --- a/subsys/bluetooth/audio/csip_set_member.c +++ b/subsys/bluetooth/audio/csip_set_member.c @@ -647,7 +647,7 @@ static void csip_bond_deleted(uint8_t id, const bt_addr_le_t *peer) } } -static struct bt_conn_cb conn_callbacks = { +BT_CONN_CB_DEFINE(conn_callbacks) = { .disconnected = csip_disconnected, .security_changed = csip_security_changed, }; @@ -926,7 +926,6 @@ int bt_csip_set_member_register(const struct bt_csip_set_member_register_param * for (size_t i = 0U; i < ARRAY_SIZE(svc_insts); i++) { k_mutex_init(&svc_insts[i].mutex); } - bt_conn_cb_register(&conn_callbacks); bt_conn_auth_info_cb_register(&auth_callbacks); first_register = true; } diff --git a/subsys/bluetooth/common/Kconfig b/subsys/bluetooth/common/Kconfig index 2b7b698d8f8..60328a1dd35 100644 --- a/subsys/bluetooth/common/Kconfig +++ b/subsys/bluetooth/common/Kconfig @@ -119,7 +119,7 @@ config BT_BUF_ACL_RX_COUNT config BT_BUF_EVT_RX_SIZE int "Maximum supported HCI Event buffer length" - default $(UINT8_MAX) if (BT_EXT_ADV && BT_OBSERVER) || BT_PER_ADV_SYNC || BT_DF_CONNECTION_CTE_RX || BT_CLASSIC || BT_CHANNEL_SOUNDING + default $(UINT8_MAX) if (BT_EXT_ADV && BT_OBSERVER) || BT_PER_ADV_SYNC || BT_DF_CONNECTION_CTE_RX || BT_CLASSIC || BT_CHANNEL_SOUNDING || BT_LE_EXTENDED_FEAT_SET # LE Read Supported Commands command complete event. default 68 range 68 $(UINT8_MAX) diff --git a/subsys/bluetooth/controller/Kconfig b/subsys/bluetooth/controller/Kconfig index 60726163581..3b2c5beae80 100644 --- a/subsys/bluetooth/controller/Kconfig +++ b/subsys/bluetooth/controller/Kconfig @@ -125,10 +125,16 @@ config BT_CTLR_LE_PATH_LOSS_MONITORING_SUPPORT config BT_CTLR_SUBRATING_SUPPORT bool +config BT_CTLR_FRAME_SPACE_UPDATE_SUPPORT + bool + config BT_CTLR_CHANNEL_SOUNDING_SUPPORT bool -# Virtual option that all local LL implemenations should select +config BT_CTLR_EXTENDED_FEAT_SET_SUPPORT + bool + +# Virtual option that all local LL implementations should select config HAS_BT_CTLR bool @@ -1167,6 +1173,14 @@ config BT_CTLR_SUBRATING Enable support for Bluetooth v5.3 LE Connection Subrating in the Controller. +config BT_CTLR_FRAME_SPACE_UPDATE + bool "Frame Space Update" + depends on BT_CTLR_FRAME_SPACE_UPDATE_SUPPORT + default y if BT_FRAME_SPACE_UPDATE + help + Enable support for Bluetooth 6.0 Frame Space Update + in the Controller. + config BT_CTLR_CHANNEL_SOUNDING bool "Channel Sounding support" depends on BT_CTLR_CHANNEL_SOUNDING_SUPPORT @@ -1176,6 +1190,14 @@ config BT_CTLR_CHANNEL_SOUNDING Enable support for Bluetooth 6.0 Channel Sounding in the Controller. +config BT_CTLR_EXTENDED_FEAT_SET + bool "LL Extended Feature Set support" + depends on BT_CTLR_EXTENDED_FEAT_SET_SUPPORT + default y if BT_LE_EXTENDED_FEAT_SET + help + Enable support for Bluetooth 6.0 LL Extended Feature Set + in the Controller. + rsource "Kconfig.df" rsource "Kconfig.ll_sw_split" rsource "Kconfig.dtm" diff --git a/subsys/bluetooth/host/classic/Kconfig b/subsys/bluetooth/host/classic/Kconfig index 5d95a6375f5..beacfc31628 100644 --- a/subsys/bluetooth/host/classic/Kconfig +++ b/subsys/bluetooth/host/classic/Kconfig @@ -508,6 +508,12 @@ config BT_COD consult the following link: https://www.bluetooth.com/specifications/assigned-numbers +config BT_DEFAULT_ROLE_SWITCH_ENABLE + bool "Default Bluetooth Role Switch Enable/Disable State" + help + This option sets the controller's default link policy to + enable/disable the role switch. + endif # BT_CLASSIC endmenu diff --git a/subsys/bluetooth/host/classic/br.c b/subsys/bluetooth/host/classic/br.c index 994fcfbd22c..f9265dc948b 100644 --- a/subsys/bluetooth/host/classic/br.c +++ b/subsys/bluetooth/host/classic/br.c @@ -681,22 +681,22 @@ void bt_hci_role_change(struct net_buf *buf) LOG_DBG("status 0x%02x role %u addr %s", evt->status, evt->role, bt_addr_str(&evt->bdaddr)); - if (evt->status) { - return; - } - conn = bt_conn_lookup_addr_br(&evt->bdaddr); if (!conn) { LOG_ERR("Can't find conn for %s", bt_addr_str(&evt->bdaddr)); return; } - if (evt->role) { - conn->role = BT_CONN_ROLE_PERIPHERAL; - } else { - conn->role = BT_CONN_ROLE_CENTRAL; + if (evt->status == 0) { + if (evt->role == BT_HCI_ROLE_PERIPHERAL) { + conn->role = BT_CONN_ROLE_PERIPHERAL; + } else { + conn->role = BT_CONN_ROLE_CENTRAL; + } } + bt_conn_role_changed(conn, evt->status); + bt_conn_unref(conn); } @@ -800,7 +800,10 @@ int bt_br_init(void) struct bt_hci_cp_write_ssp_mode *ssp_cp; struct bt_hci_cp_write_inquiry_mode *inq_cp; struct bt_hci_write_local_name *name_cp; + struct bt_hci_rp_read_default_link_policy_settings *rp; + struct net_buf *rsp; int err; + uint16_t default_link_policy_settings; /* Read extended local features */ if (BT_FEAT_EXT_FEATURES(bt_dev.features)) { @@ -906,6 +909,38 @@ int bt_br_init(void) } } + err = bt_hci_cmd_send_sync(BT_HCI_OP_READ_DEFAULT_LINK_POLICY_SETTINGS, NULL, &rsp); + if (err) { + return err; + } + + rp = (void *)rsp->data; + default_link_policy_settings = rp->default_link_policy_settings; + + bool should_enable = IS_ENABLED(CONFIG_BT_DEFAULT_ROLE_SWITCH_ENABLE); + bool is_enabled = (default_link_policy_settings & + BT_HCI_LINK_POLICY_SETTINGS_ENABLE_ROLE_SWITCH); + + /* Enable/Disable the default role switch */ + if (should_enable != is_enabled) { + struct bt_hci_cp_write_default_link_policy_settings *policy_cp; + + default_link_policy_settings ^= BT_HCI_LINK_POLICY_SETTINGS_ENABLE_ROLE_SWITCH; + + buf = bt_hci_cmd_alloc(K_FOREVER); + if (!buf) { + return -ENOBUFS; + } + + policy_cp = net_buf_add(buf, sizeof(*policy_cp)); + policy_cp->default_link_policy_settings = default_link_policy_settings; + + err = bt_hci_cmd_send_sync(BT_HCI_OP_WRITE_DEFAULT_LINK_POLICY_SETTINGS, buf, NULL); + if (err) { + return err; + } + } + return 0; } diff --git a/subsys/bluetooth/host/classic/conn_br.c b/subsys/bluetooth/host/classic/conn_br.c index 582d560c4df..29cb2e2dfd4 100644 --- a/subsys/bluetooth/host/classic/conn_br.c +++ b/subsys/bluetooth/host/classic/conn_br.c @@ -170,3 +170,104 @@ void bt_br_acl_recv(struct bt_conn *conn, struct net_buf *buf, bool complete) net_buf_unref(buf); } + +int bt_conn_br_switch_role(const struct bt_conn *conn, uint8_t role) +{ + struct net_buf *buf; + struct bt_hci_cp_switch_role *cp; + + CHECKIF(conn == NULL) { + LOG_DBG("conn is NULL"); + return -EINVAL; + } + + if (!bt_conn_is_type(conn, BT_CONN_TYPE_BR)) { + LOG_DBG("Invalid connection type: %u for %p", conn->type, conn); + return -EINVAL; + } + + buf = bt_hci_cmd_alloc(K_FOREVER); + if (!buf) { + return -ENOBUFS; + } + + cp = net_buf_add(buf, sizeof(*cp)); + bt_addr_copy(&cp->bdaddr, &conn->br.dst); + cp->role = role; + + return bt_hci_cmd_send_sync(BT_HCI_OP_SWITCH_ROLE, buf, NULL); +} + +static int bt_conn_br_read_link_policy_settings(const struct bt_conn *conn, + uint16_t *link_policy_settings) +{ + int err; + struct net_buf *buf; + struct bt_hci_cp_read_link_policy_settings *cp; + struct bt_hci_rp_read_link_policy_settings *rp; + struct net_buf *rsp; + + buf = bt_hci_cmd_alloc(K_FOREVER); + if (!buf) { + return -ENOBUFS; + } + + cp = net_buf_add(buf, sizeof(*cp)); + cp->handle = sys_cpu_to_le16(conn->handle); + + err = bt_hci_cmd_send_sync(BT_HCI_OP_READ_LINK_POLICY_SETTINGS, buf, &rsp); + if (!err) { + rp = (void *)rsp->data; + *link_policy_settings = rp->link_policy_settings; + } + + return err; +} + +static int bt_conn_br_write_link_policy_settings(const struct bt_conn *conn, + uint16_t link_policy_settings) +{ + struct net_buf *buf; + struct bt_hci_cp_write_link_policy_settings *cp; + + buf = bt_hci_cmd_alloc(K_FOREVER); + if (!buf) { + return -ENOBUFS; + } + + cp = net_buf_add(buf, sizeof(*cp)); + cp->handle = sys_cpu_to_le16(conn->handle); + cp->link_policy_settings = link_policy_settings; + + return bt_hci_cmd_send_sync(BT_HCI_OP_WRITE_LINK_POLICY_SETTINGS, buf, NULL); +} + +int bt_conn_br_set_role_switch_enable(const struct bt_conn *conn, bool enable) +{ + int err; + uint16_t link_policy_settings; + bool is_enabled; + + CHECKIF(conn == NULL) { + LOG_DBG("conn is NULL"); + return -EINVAL; + } + + if (!bt_conn_is_type(conn, BT_CONN_TYPE_BR)) { + LOG_DBG("Invalid connection type: %u for %p", conn->type, conn); + return -EINVAL; + } + + err = bt_conn_br_read_link_policy_settings(conn, &link_policy_settings); + if (err) { + return err; + } + + is_enabled = (link_policy_settings & BT_HCI_LINK_POLICY_SETTINGS_ENABLE_ROLE_SWITCH); + if (enable == is_enabled) { + return 0; + } + + link_policy_settings ^= BT_HCI_LINK_POLICY_SETTINGS_ENABLE_ROLE_SWITCH; + return bt_conn_br_write_link_policy_settings(conn, link_policy_settings); +} diff --git a/subsys/bluetooth/host/classic/shell/bredr.c b/subsys/bluetooth/host/classic/shell/bredr.c index 8770d3acbd2..d5c1d09a082 100644 --- a/subsys/bluetooth/host/classic/shell/bredr.c +++ b/subsys/bluetooth/host/classic/shell/bredr.c @@ -1207,6 +1207,80 @@ static int cmd_info(const struct shell *sh, size_t argc, char *argv[]) return err; } +void role_changed(struct bt_conn *conn, uint8_t status) +{ + struct bt_conn_info info; + int err; + + bt_shell_print("Role changed (HCI status 0x%02x)", status); + + err = bt_conn_get_info(conn, &info); + if (err) { + bt_shell_print("Failed to get info"); + return; + } + + bt_shell_print("Current role is: %s", get_conn_role_str(info.role)); +} + +static int cmd_switch_role(const struct shell *sh, size_t argc, char *argv[]) +{ + int err; + const char *action; + uint8_t role; + + if (!default_conn) { + shell_print(sh, "Not connected"); + return -ENOEXEC; + } + + action = argv[1]; + + if (!strcmp(action, "central")) { + role = BT_HCI_ROLE_CENTRAL; + } else if (!strcmp(action, "peripheral")) { + role = BT_HCI_ROLE_PERIPHERAL; + } else { + shell_help(sh); + return SHELL_CMD_HELP_PRINTED; + } + + err = bt_conn_br_switch_role(default_conn, role); + + if (err) { + shell_error(sh, "fail to change role (err %d)", err); + } + + return 0; +} + +static int cmd_set_role_switchable(const struct shell *sh, size_t argc, char *argv[]) +{ + int err = 0; + bool enable; + + if (!default_conn) { + shell_print(sh, "Not connected"); + return -ENOEXEC; + } + + enable = shell_strtobool(argv[1], 10, &err); + if (err) { + shell_help(sh); + return SHELL_CMD_HELP_PRINTED; + } + + err = bt_conn_br_set_role_switch_enable(default_conn, enable); + + if (err) { + shell_error(sh, "fail to set role switchable (err %d)", err); + } else { + shell_print(sh, "success"); + } + + return 0; +} + static int cmd_default_handler(const struct shell *sh, size_t argc, char **argv) { if (argc == 1) { @@ -1270,6 +1344,9 @@ SHELL_STATIC_SUBCMD_SET_CREATE(br_cmds, SHELL_CMD_ARG(oob, NULL, NULL, cmd_oob, 1, 0), SHELL_CMD_ARG(pscan, NULL, "", cmd_connectable, 2, 0), SHELL_CMD_ARG(sdp-find, NULL, "", cmd_sdp_find_record, 2, 0), + SHELL_CMD_ARG(switch-role, NULL, "", cmd_switch_role, 2, 0), + SHELL_CMD_ARG(set-role-switchable, NULL, "", + cmd_set_role_switchable, 2, 0), SHELL_SUBCMD_SET_END ); diff --git a/subsys/bluetooth/host/classic/shell/bredr.h b/subsys/bluetooth/host/classic/shell/bredr.h new file mode 100644 index 00000000000..1cc3396c63f --- /dev/null +++ b/subsys/bluetooth/host/classic/shell/bredr.h @@ -0,0 +1,20 @@ +/** @file + * @brief Bluetooth shell functions + * + * This is not to be included by the application. + */ + +/* + * Copyright 2025 NXP + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef __BREDR_H +#define __BREDR_H +#include +#include + +void role_changed(struct bt_conn *conn, uint8_t status); + +#endif /* __BREDR_H */ diff --git a/subsys/bluetooth/host/conn.c b/subsys/bluetooth/host/conn.c index a74a0429527..10c11250727 100644 --- a/subsys/bluetooth/host/conn.c +++ b/subsys/bluetooth/host/conn.c @@ -1650,11 +1650,13 @@ static void tx_complete_work(struct k_work *work) static void notify_recycled_conn_slot(void) { #if defined(CONFIG_BT_CONN) - struct bt_conn_cb *callback; + if (IS_ENABLED(CONFIG_BT_CONN_DYNAMIC_CALLBACKS)) { + struct bt_conn_cb *callback; - SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { - if (callback->recycled) { - callback->recycled(); + SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { + if (callback->recycled) { + callback->recycled(); + } } } @@ -1826,6 +1828,27 @@ void bt_conn_connected(struct bt_conn *conn) notify_connected(conn); } +#if defined(CONFIG_BT_CLASSIC) +void bt_conn_role_changed(struct bt_conn *conn, uint8_t status) +{ + if (IS_ENABLED(CONFIG_BT_CONN_DYNAMIC_CALLBACKS)) { + struct bt_conn_cb *callback; + + SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { + if (callback->role_changed) { + callback->role_changed(conn, status); + } + } + } + + STRUCT_SECTION_FOREACH(bt_conn_cb, cb) { + if (cb->role_changed) { + cb->role_changed(conn, status); + } + } +} +#endif + static int conn_disconnect(struct bt_conn *conn, uint8_t reason) { int err; @@ -1889,12 +1912,14 @@ int bt_conn_disconnect(struct bt_conn *conn, uint8_t reason) static void notify_connected(struct bt_conn *conn) { - struct bt_conn_cb *callback; + if (IS_ENABLED(CONFIG_BT_CONN_DYNAMIC_CALLBACKS)) { + struct bt_conn_cb *callback; - SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { + SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { - if (callback->connected) { - callback->connected(conn, conn->err); + if (callback->connected) { + callback->connected(conn, conn->err); + } } } @@ -1907,11 +1932,13 @@ static void notify_connected(struct bt_conn *conn) static void notify_disconnected(struct bt_conn *conn) { - struct bt_conn_cb *callback; + if (IS_ENABLED(CONFIG_BT_CONN_DYNAMIC_CALLBACKS)) { + struct bt_conn_cb *callback; - SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { - if (callback->disconnected) { - callback->disconnected(conn, conn->err); + SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { + if (callback->disconnected) { + callback->disconnected(conn, conn->err); + } } } @@ -1934,11 +1961,13 @@ void notify_remote_info(struct bt_conn *conn) return; } - struct bt_conn_cb *callback; + if (IS_ENABLED(CONFIG_BT_CONN_DYNAMIC_CALLBACKS)) { + struct bt_conn_cb *callback; - SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { - if (callback->remote_info_available) { - callback->remote_info_available(conn, &remote_info); + SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { + if (callback->remote_info_available) { + callback->remote_info_available(conn, &remote_info); + } } } @@ -1963,13 +1992,14 @@ void notify_le_param_updated(struct bt_conn *conn) atomic_clear_bit(conn->flags, BT_CONN_PERIPHERAL_PARAM_SET); } - struct bt_conn_cb *callback; + if (IS_ENABLED(CONFIG_BT_CONN_DYNAMIC_CALLBACKS)) { + struct bt_conn_cb *callback; - SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { - if (callback->le_param_updated) { - callback->le_param_updated(conn, conn->le.interval, - conn->le.latency, - conn->le.timeout); + SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { + if (callback->le_param_updated) { + callback->le_param_updated(conn, conn->le.interval, + conn->le.latency, conn->le.timeout); + } } } @@ -1985,11 +2015,13 @@ void notify_le_param_updated(struct bt_conn *conn) #if defined(CONFIG_BT_USER_DATA_LEN_UPDATE) void notify_le_data_len_updated(struct bt_conn *conn) { - struct bt_conn_cb *callback; + if (IS_ENABLED(CONFIG_BT_CONN_DYNAMIC_CALLBACKS)) { + struct bt_conn_cb *callback; - SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { - if (callback->le_data_len_updated) { - callback->le_data_len_updated(conn, &conn->le.data_len); + SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { + if (callback->le_data_len_updated) { + callback->le_data_len_updated(conn, &conn->le.data_len); + } } } @@ -2004,11 +2036,13 @@ void notify_le_data_len_updated(struct bt_conn *conn) #if defined(CONFIG_BT_USER_PHY_UPDATE) void notify_le_phy_updated(struct bt_conn *conn) { - struct bt_conn_cb *callback; + if (IS_ENABLED(CONFIG_BT_CONN_DYNAMIC_CALLBACKS)) { + struct bt_conn_cb *callback; - SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { - if (callback->le_phy_updated) { - callback->le_phy_updated(conn, &conn->le.phy); + SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { + if (callback->le_phy_updated) { + callback->le_phy_updated(conn, &conn->le.phy); + } } } @@ -2026,22 +2060,24 @@ bool le_param_req(struct bt_conn *conn, struct bt_le_conn_param *param) return false; } - struct bt_conn_cb *callback; + if (IS_ENABLED(CONFIG_BT_CONN_DYNAMIC_CALLBACKS)) { + struct bt_conn_cb *callback; - SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { - if (!callback->le_param_req) { - continue; - } + SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { + if (!callback->le_param_req) { + continue; + } - if (!callback->le_param_req(conn, param)) { - return false; - } + if (!callback->le_param_req(conn, param)) { + return false; + } - /* The callback may modify the parameters so we need to - * double-check that it returned valid parameters. - */ - if (!bt_le_conn_params_valid(param)) { - return false; + /* The callback may modify the parameters so we need to + * double-check that it returned valid parameters. + */ + if (!bt_le_conn_params_valid(param)) { + return false; + } } } @@ -2428,12 +2464,13 @@ void bt_conn_identity_resolved(struct bt_conn *conn) rpa = &conn->le.init_addr; } + if (IS_ENABLED(CONFIG_BT_CONN_DYNAMIC_CALLBACKS)) { + struct bt_conn_cb *callback; - struct bt_conn_cb *callback; - - SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { - if (callback->identity_resolved) { - callback->identity_resolved(conn, rpa, &conn->le.dst); + SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { + if (callback->identity_resolved) { + callback->identity_resolved(conn, rpa, &conn->le.dst); + } } } @@ -2547,11 +2584,13 @@ void bt_conn_security_changed(struct bt_conn *conn, uint8_t hci_err, bt_iso_security_changed(conn, hci_err); } - struct bt_conn_cb *callback; + if (IS_ENABLED(CONFIG_BT_CONN_DYNAMIC_CALLBACKS)) { + struct bt_conn_cb *callback; - SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { - if (callback->security_changed) { - callback->security_changed(conn, conn->sec_level, err); + SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { + if (callback->security_changed) { + callback->security_changed(conn, conn->sec_level, err); + } } } @@ -2649,6 +2688,8 @@ bt_security_t bt_conn_get_security(const struct bt_conn *conn) } #endif /* CONFIG_BT_SMP */ +#if defined(CONFIG_BT_CONN_DYNAMIC_CALLBACKS) + int bt_conn_cb_register(struct bt_conn_cb *cb) { if (sys_slist_find(&conn_cbs, &cb->_node, NULL)) { @@ -2673,6 +2714,8 @@ int bt_conn_cb_unregister(struct bt_conn_cb *cb) return 0; } +#endif /* CONFIG_BT_CONN_DYNAMIC_CALLBACKS */ + bool bt_conn_exists_le(uint8_t id, const bt_addr_le_t *peer) { struct bt_conn *conn = bt_conn_lookup_addr_le(id, peer); @@ -2984,11 +3027,13 @@ static int bt_conn_get_tx_power_level(struct bt_conn *conn, uint8_t type, void notify_tx_power_report(struct bt_conn *conn, struct bt_conn_le_tx_power_report report) { - struct bt_conn_cb *callback; + if (IS_ENABLED(CONFIG_BT_CONN_DYNAMIC_CALLBACKS)) { + struct bt_conn_cb *callback; - SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { - if (callback->tx_power_report) { - callback->tx_power_report(conn, &report); + SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { + if (callback->tx_power_report) { + callback->tx_power_report(conn, &report); + } } } @@ -3129,11 +3174,13 @@ int bt_conn_le_get_tx_power_level(struct bt_conn *conn, void notify_path_loss_threshold_report(struct bt_conn *conn, struct bt_conn_le_path_loss_threshold_report report) { - struct bt_conn_cb *callback; + if (IS_ENABLED(CONFIG_BT_CONN_DYNAMIC_CALLBACKS)) { + struct bt_conn_cb *callback; - SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { - if (callback->path_loss_threshold_report) { - callback->path_loss_threshold_report(conn, &report); + SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { + if (callback->path_loss_threshold_report) { + callback->path_loss_threshold_report(conn, &report); + } } } @@ -3200,11 +3247,13 @@ int bt_conn_le_set_path_loss_mon_enable(struct bt_conn *conn, bool reporting_ena void notify_subrate_change(struct bt_conn *conn, const struct bt_conn_le_subrate_changed params) { - struct bt_conn_cb *callback; + if (IS_ENABLED(CONFIG_BT_CONN_DYNAMIC_CALLBACKS)) { + struct bt_conn_cb *callback; - SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { - if (callback->subrate_changed) { - callback->subrate_changed(conn, ¶ms); + SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { + if (callback->subrate_changed) { + callback->subrate_changed(conn, ¶ms); + } } } @@ -3304,15 +3353,139 @@ int bt_conn_le_subrate_request(struct bt_conn *conn, } #endif /* CONFIG_BT_SUBRATING */ +#if defined(CONFIG_BT_LE_EXTENDED_FEAT_SET) +void notify_read_all_remote_feat_complete(struct bt_conn *conn, + struct bt_conn_le_read_all_remote_feat_complete *params) +{ + if (IS_ENABLED(CONFIG_BT_CONN_DYNAMIC_CALLBACKS)) { + struct bt_conn_cb *callback; + + SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { + if (callback->read_all_remote_feat_complete != NULL) { + callback->read_all_remote_feat_complete(conn, params); + } + } + } + + STRUCT_SECTION_FOREACH(bt_conn_cb, cb) + { + if (cb->read_all_remote_feat_complete != NULL) { + cb->read_all_remote_feat_complete(conn, params); + } + } +} + +int bt_conn_le_read_all_remote_features(struct bt_conn *conn, uint8_t pages_requested) +{ + struct bt_hci_cp_le_read_all_remote_features *cp; + struct net_buf *buf; + + if (!bt_conn_is_type(conn, BT_CONN_TYPE_LE)) { + LOG_DBG("Invalid connection type: %u for %p", conn->type, conn); + return -EINVAL; + } + + if (pages_requested > BT_HCI_LE_FEATURE_PAGE_MAX) { + return -EINVAL; + } + + buf = bt_hci_cmd_alloc(K_FOREVER); + if (buf == NULL) { + return -ENOBUFS; + } + + cp = net_buf_add(buf, sizeof(*cp)); + cp->handle = sys_cpu_to_le16(conn->handle); + cp->pages_requested = pages_requested; + + return bt_hci_cmd_send_sync(BT_HCI_OP_LE_READ_ALL_REMOTE_FEATURES, buf, NULL); +} +#endif /* CONFIG_BT_LE_EXTENDED_FEAT_SET */ + +#if defined(CONFIG_BT_FRAME_SPACE_UPDATE) +void notify_frame_space_update_complete(struct bt_conn *conn, + struct bt_conn_le_frame_space_updated *params) +{ + if (IS_ENABLED(CONFIG_BT_CONN_DYNAMIC_CALLBACKS)) { + struct bt_conn_cb *callback; + + SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { + if (callback->frame_space_updated != NULL) { + callback->frame_space_updated(conn, params); + } + } + } + + STRUCT_SECTION_FOREACH(bt_conn_cb, cb) + { + if (cb->frame_space_updated != NULL) { + cb->frame_space_updated(conn, params); + } + } +} + +static bool frame_space_update_param_valid(const struct bt_conn_le_frame_space_update_param *param) +{ + if (param->frame_space_min > BT_CONN_LE_FRAME_SPACE_MAX || + param->frame_space_max > BT_CONN_LE_FRAME_SPACE_MAX || + param->frame_space_min > param->frame_space_max) { + return false; + } + + if (param->spacing_types == 0) { + return false; + } + + if (param->phys == 0) { + return false; + } + + return true; +} + +int bt_conn_le_frame_space_update(struct bt_conn *conn, + const struct bt_conn_le_frame_space_update_param *param) +{ + struct bt_hci_cp_le_frame_space_update *cp; + struct net_buf *buf; + + if (!bt_conn_is_type(conn, BT_CONN_TYPE_LE)) { + LOG_DBG("Invalid connection type: %u for %p", conn->type, conn); + return -EINVAL; + } + + if (!frame_space_update_param_valid(param)) { + return -EINVAL; + } + + buf = bt_hci_cmd_alloc(K_FOREVER); + if (buf == NULL) { + return -ENOBUFS; + } + + cp = net_buf_add(buf, sizeof(*cp)); + cp->handle = sys_cpu_to_le16(conn->handle); + cp->frame_space_min = sys_cpu_to_le16(param->frame_space_min); + cp->frame_space_max = sys_cpu_to_le16(param->frame_space_max); + cp->spacing_types = sys_cpu_to_le16(param->spacing_types); + cp->phys = param->phys; + + return bt_hci_cmd_send_sync(BT_HCI_OP_LE_FRAME_SPACE_UPDATE, buf, NULL); +} +#endif /* CONFIG_BT_FRAME_SPACE_UPDATE */ + #if defined(CONFIG_BT_CHANNEL_SOUNDING) void notify_remote_cs_capabilities(struct bt_conn *conn, uint8_t status, struct bt_conn_le_cs_capabilities *params) { - struct bt_conn_cb *callback; + if (IS_ENABLED(CONFIG_BT_CONN_DYNAMIC_CALLBACKS)) { + struct bt_conn_cb *callback; - SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { - if (callback->le_cs_read_remote_capabilities_complete) { - callback->le_cs_read_remote_capabilities_complete(conn, status, params); + SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { + if (callback->le_cs_read_remote_capabilities_complete) { + callback->le_cs_read_remote_capabilities_complete(conn, status, + params); + } } } @@ -3326,11 +3499,14 @@ void notify_remote_cs_capabilities(struct bt_conn *conn, uint8_t status, void notify_remote_cs_fae_table(struct bt_conn *conn, uint8_t status, struct bt_conn_le_cs_fae_table *params) { - struct bt_conn_cb *callback; + if (IS_ENABLED(CONFIG_BT_CONN_DYNAMIC_CALLBACKS)) { + struct bt_conn_cb *callback; - SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { - if (callback->le_cs_read_remote_fae_table_complete) { - callback->le_cs_read_remote_fae_table_complete(conn, status, params); + SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { + if (callback->le_cs_read_remote_fae_table_complete) { + callback->le_cs_read_remote_fae_table_complete(conn, status, + params); + } } } @@ -3344,11 +3520,13 @@ void notify_remote_cs_fae_table(struct bt_conn *conn, uint8_t status, void notify_cs_config_created(struct bt_conn *conn, uint8_t status, struct bt_conn_le_cs_config *params) { - struct bt_conn_cb *callback; + if (IS_ENABLED(CONFIG_BT_CONN_DYNAMIC_CALLBACKS)) { + struct bt_conn_cb *callback; - SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { - if (callback->le_cs_config_complete) { - callback->le_cs_config_complete(conn, status, params); + SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { + if (callback->le_cs_config_complete) { + callback->le_cs_config_complete(conn, status, params); + } } } @@ -3361,11 +3539,13 @@ void notify_cs_config_created(struct bt_conn *conn, uint8_t status, void notify_cs_config_removed(struct bt_conn *conn, uint8_t config_id) { - struct bt_conn_cb *callback; + if (IS_ENABLED(CONFIG_BT_CONN_DYNAMIC_CALLBACKS)) { + struct bt_conn_cb *callback; - SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { - if (callback->le_cs_config_removed) { - callback->le_cs_config_removed(conn, config_id); + SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { + if (callback->le_cs_config_removed) { + callback->le_cs_config_removed(conn, config_id); + } } } @@ -3378,11 +3558,13 @@ void notify_cs_config_removed(struct bt_conn *conn, uint8_t config_id) void notify_cs_security_enable_available(struct bt_conn *conn, uint8_t status) { - struct bt_conn_cb *callback; + if (IS_ENABLED(CONFIG_BT_CONN_DYNAMIC_CALLBACKS)) { + struct bt_conn_cb *callback; - SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { - if (callback->le_cs_security_enable_complete) { - callback->le_cs_security_enable_complete(conn, status); + SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { + if (callback->le_cs_security_enable_complete) { + callback->le_cs_security_enable_complete(conn, status); + } } } @@ -3396,11 +3578,13 @@ void notify_cs_security_enable_available(struct bt_conn *conn, uint8_t status) void notify_cs_procedure_enable_available(struct bt_conn *conn, uint8_t status, struct bt_conn_le_cs_procedure_enable_complete *params) { - struct bt_conn_cb *callback; + if (IS_ENABLED(CONFIG_BT_CONN_DYNAMIC_CALLBACKS)) { + struct bt_conn_cb *callback; - SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { - if (callback->le_cs_procedure_enable_complete) { - callback->le_cs_procedure_enable_complete(conn, status, params); + SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { + if (callback->le_cs_procedure_enable_complete) { + callback->le_cs_procedure_enable_complete(conn, status, params); + } } } @@ -3413,11 +3597,13 @@ void notify_cs_procedure_enable_available(struct bt_conn *conn, uint8_t status, void notify_cs_subevent_result(struct bt_conn *conn, struct bt_conn_le_cs_subevent_result *result) { - struct bt_conn_cb *callback; + if (IS_ENABLED(CONFIG_BT_CONN_DYNAMIC_CALLBACKS)) { + struct bt_conn_cb *callback; - SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { - if (callback->le_cs_subevent_data_available) { - callback->le_cs_subevent_data_available(conn, result); + SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { + if (callback->le_cs_subevent_data_available) { + callback->le_cs_subevent_data_available(conn, result); + } } } @@ -4199,11 +4385,13 @@ void bt_hci_le_df_connection_iq_report_common(uint8_t event, struct net_buf *buf return; } - struct bt_conn_cb *callback; + if (IS_ENABLED(CONFIG_BT_CONN_DYNAMIC_CALLBACKS)) { + struct bt_conn_cb *callback; - SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { - if (callback->cte_report_cb) { - callback->cte_report_cb(conn, &iq_report); + SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { + if (callback->cte_report_cb) { + callback->cte_report_cb(conn, &iq_report); + } } } @@ -4243,11 +4431,13 @@ void bt_hci_le_df_cte_req_failed(struct net_buf *buf) return; } - struct bt_conn_cb *callback; + if (IS_ENABLED(CONFIG_BT_CONN_DYNAMIC_CALLBACKS)) { + struct bt_conn_cb *callback; - SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { - if (callback->cte_report_cb) { - callback->cte_report_cb(conn, &iq_report); + SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, callback, _node) { + if (callback->cte_report_cb) { + callback->cte_report_cb(conn, &iq_report); + } } } diff --git a/subsys/bluetooth/host/conn_internal.h b/subsys/bluetooth/host/conn_internal.h index 909c0ebd22e..a31ca85c315 100644 --- a/subsys/bluetooth/host/conn_internal.h +++ b/subsys/bluetooth/host/conn_internal.h @@ -490,6 +490,8 @@ void bt_conn_set_state(struct bt_conn *conn, bt_conn_state_t state); void bt_conn_connected(struct bt_conn *conn); +void bt_conn_role_changed(struct bt_conn *conn, uint8_t status); + int bt_conn_le_conn_update(struct bt_conn *conn, const struct bt_le_conn_param *param); @@ -512,6 +514,12 @@ void notify_path_loss_threshold_report(struct bt_conn *conn, void notify_subrate_change(struct bt_conn *conn, struct bt_conn_le_subrate_changed params); +void notify_read_all_remote_feat_complete(struct bt_conn *conn, + struct bt_conn_le_read_all_remote_feat_complete *params); + +void notify_frame_space_update_complete(struct bt_conn *conn, + struct bt_conn_le_frame_space_updated *params); + void notify_remote_cs_capabilities(struct bt_conn *conn, uint8_t status, struct bt_conn_le_cs_capabilities *params); diff --git a/subsys/bluetooth/host/gatt.c b/subsys/bluetooth/host/gatt.c index be642fec9fe..12ec91c78e4 100644 --- a/subsys/bluetooth/host/gatt.c +++ b/subsys/bluetooth/host/gatt.c @@ -1511,6 +1511,17 @@ static void gatt_store_ccc_cf(uint8_t id, const bt_addr_le_t *peer_addr) } } +#if defined(CONFIG_BT_SETTINGS) && defined(CONFIG_BT_SMP) +BT_CONN_CB_DEFINE(gatt_conn_cb) = { + /* Also update the address of CCC or CF writes that happened before the + * identity resolution. Note that to increase security in the future, we + * might want to explicitly not do this and treat a bonded device as a + * brand-new peer. + */ + .identity_resolved = bt_gatt_identity_resolved, +}; +#endif /* CONFIG_BT_SETTINGS && CONFIG_BT_SMP */ + static void bt_gatt_service_init(void) { if (atomic_test_and_set_bit(gatt_flags, GATT_SERVICE_INITIALIZED)) { @@ -1567,17 +1578,6 @@ void bt_gatt_init(void) * and CF storage on pairing complete. */ bt_conn_auth_info_cb_register(&gatt_conn_auth_info_cb); - - static struct bt_conn_cb gatt_conn_cb = { - .identity_resolved = bt_gatt_identity_resolved, - }; - - /* Also update the address of CCC or CF writes that happened before the - * identity resolution. Note that to increase security in the future, we - * might want to explicitly not do this and treat a bonded device as a - * brand-new peer. - */ - bt_conn_cb_register(&gatt_conn_cb); #endif /* CONFIG_BT_SETTINGS && CONFIG_BT_SMP */ } diff --git a/subsys/bluetooth/host/hci_core.c b/subsys/bluetooth/host/hci_core.c index 7263bc39ed4..1f649689c7a 100644 --- a/subsys/bluetooth/host/hci_core.c +++ b/subsys/bluetooth/host/hci_core.c @@ -1792,13 +1792,72 @@ static void le_remote_feat_complete(struct net_buf *buf) atomic_set_bit(conn->flags, BT_CONN_LE_FEATURES_EXCHANGED); if (IS_ENABLED(CONFIG_BT_REMOTE_INFO) && - !IS_ENABLED(CONFIG_BT_REMOTE_VERSION)) { + (!IS_ENABLED(CONFIG_BT_REMOTE_VERSION) || + atomic_test_bit(conn->flags, BT_CONN_AUTO_VERSION_INFO))) { notify_remote_info(conn); } bt_conn_unref(conn); } +#if defined(CONFIG_BT_LE_EXTENDED_FEAT_SET) +static void le_read_all_remote_feat_complete(struct net_buf *buf) +{ + struct bt_hci_evt_le_read_all_remote_feat_complete *evt = (void *)buf->data; + struct bt_conn *conn; + struct bt_conn_le_read_all_remote_feat_complete params; + uint16_t handle = sys_le16_to_cpu(evt->handle); + + LOG_DBG("Read all remote feature complete: 0x%02x %s handle %u", evt->status, + bt_hci_err_to_str(evt->status), handle); + + conn = bt_conn_lookup_handle(handle, BT_CONN_TYPE_LE); + if (conn == NULL) { + LOG_ERR("Unknown conn handle 0x%04X", handle); + return; + } + + params.status = evt->status; + + if (params.status == BT_HCI_ERR_SUCCESS) { + params.max_remote_page = evt->max_remote_page; + params.max_valid_page = evt->max_valid_page; + params.features = evt->features; + } + + notify_read_all_remote_feat_complete(conn, ¶ms); + + bt_conn_unref(conn); +} +#endif /* CONFIG_BT_LE_EXTENDED_FEAT_SET */ + +#if defined(CONFIG_BT_FRAME_SPACE_UPDATE) +static void le_frame_space_update_complete(struct net_buf *buf) +{ + struct bt_hci_evt_le_frame_space_update_complete *evt = (void *)buf->data; + struct bt_conn *conn; + struct bt_conn_le_frame_space_updated params; + uint16_t handle = sys_le16_to_cpu(evt->handle); + + conn = bt_conn_lookup_handle(handle, BT_CONN_TYPE_LE); + if (conn == NULL) { + LOG_ERR("Unknown conn handle 0x%04X", handle); + return; + } + + params.status = evt->status; + + if (params.status == BT_HCI_ERR_SUCCESS) { + params.phys = evt->phys; + params.spacing_types = evt->spacing_types; + params.frame_space = evt->frame_space; + params.initiator = evt->initiator; + } + + notify_frame_space_update_complete(conn, ¶ms); +} +#endif /* CONFIG_BT_FRAME_SPACE_UPDATE */ + #if defined(CONFIG_BT_DATA_LEN_UPDATE) static void le_data_len_change(struct net_buf *buf) { @@ -2372,7 +2431,8 @@ static void bt_hci_evt_read_remote_version_complete(struct net_buf *buf) atomic_set_bit(conn->flags, BT_CONN_AUTO_VERSION_INFO); - if (IS_ENABLED(CONFIG_BT_REMOTE_INFO)) { + if (IS_ENABLED(CONFIG_BT_REMOTE_INFO) && + atomic_test_bit(conn->flags, BT_CONN_LE_FEATURES_EXCHANGED)) { /* Remote features is already present */ notify_remote_info(conn); } @@ -2920,6 +2980,16 @@ static const struct event_handler meta_events[] = { EVENT_HANDLER(BT_HCI_EVT_LE_ENH_CONN_COMPLETE_V2, le_enh_conn_complete_v2, sizeof(struct bt_hci_evt_le_enh_conn_complete_v2)), #endif /* CONFIG_BT_PER_ADV_RSP || CONFIG_BT_PER_ADV_SYNC_RSP */ +#if defined(CONFIG_BT_LE_EXTENDED_FEAT_SET) + EVENT_HANDLER(BT_HCI_EVT_LE_READ_ALL_REMOTE_FEAT_COMPLETE, + le_read_all_remote_feat_complete, + sizeof(struct bt_hci_evt_le_read_all_remote_feat_complete)), +#endif /* CONFIG_BT_LE_EXTENDED_FEAT_SET */ +#if defined(CONFIG_BT_FRAME_SPACE_UPDATE) + EVENT_HANDLER(BT_HCI_EVT_LE_FRAME_SPACE_UPDATE_COMPLETE, + le_frame_space_update_complete, + sizeof(struct bt_hci_evt_le_frame_space_update_complete)), +#endif /* CONFIG_BT_FRAME_SPACE_UPDATE */ #endif /* CONFIG_BT_CONN */ #if defined(CONFIG_BT_CHANNEL_SOUNDING) EVENT_HANDLER(BT_HCI_EVT_LE_CS_READ_REMOTE_SUPPORTED_CAPABILITIES_COMPLETE, @@ -3156,9 +3226,47 @@ static void read_le_features_complete(struct net_buf *buf) LOG_DBG("status 0x%02x %s", rp->status, bt_hci_err_to_str(rp->status)); + memcpy(bt_dev.le.features, rp->features, sizeof(rp->features)); +} + +static void read_le_all_supported_features_complete(struct net_buf *buf) +{ + struct bt_hci_rp_le_read_all_local_supported_features *rp = (void *)buf->data; + + LOG_DBG("status 0x%02x %s", rp->status, bt_hci_err_to_str(rp->status)); + memcpy(bt_dev.le.features, rp->features, sizeof(bt_dev.le.features)); } +static int read_le_local_supported_features(void) +{ + struct net_buf *rsp; + int err; + + /* Read Low Energy Supported Features */ + if (IS_ENABLED(CONFIG_BT_LE_EXTENDED_FEAT_SET) && + BT_READ_ALL_LOCAL_FEATURES_SUPPORTED(bt_dev.supported_commands)) { + err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_READ_ALL_LOCAL_SUPPORTED_FEATURES, NULL, + &rsp); + if (err != 0) { + return err; + } + + read_le_all_supported_features_complete(rsp); + } else { + err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_READ_LOCAL_FEATURES, NULL, + &rsp); + if (err != 0) { + return err; + } + + read_le_features_complete(rsp); + } + + net_buf_unref(rsp); + return 0; +} + #if defined(CONFIG_BT_CONN) #if !defined(CONFIG_BT_CLASSIC) static void read_buffer_size_complete(struct net_buf *buf) @@ -3443,6 +3551,16 @@ static int le_set_event_mask(void) BT_FEAT_LE_CONN_SUBRATING(bt_dev.le.features)) { mask |= BT_EVT_MASK_LE_SUBRATE_CHANGE; } + + if (IS_ENABLED(CONFIG_BT_LE_EXTENDED_FEAT_SET) && + BT_FEAT_LE_EXTENDED_FEAT_SET(bt_dev.le.features)) { + mask |= BT_EVT_MASK_LE_READ_ALL_REMOTE_FEAT_COMPLETE; + } + + if (IS_ENABLED(CONFIG_BT_FRAME_SPACE_UPDATE) && + BT_FEAT_LE_FRAME_SPACE_UPDATE_SET(bt_dev.le.features)) { + mask |= BT_EVT_MASK_LE_FRAME_SPACE_UPDATE_COMPLETE; + } } if (IS_ENABLED(CONFIG_BT_SMP) && @@ -3581,16 +3699,11 @@ static int le_init(void) return -ENODEV; } - /* Read Low Energy Supported Features */ - err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_READ_LOCAL_FEATURES, NULL, - &rsp); + err = read_le_local_supported_features(); if (err) { return err; } - read_le_features_complete(rsp); - net_buf_unref(rsp); - if (IS_ENABLED(CONFIG_BT_ISO) && BT_FEAT_LE_ISO(bt_dev.le.features)) { err = le_init_iso(); diff --git a/subsys/bluetooth/host/shell/bt.c b/subsys/bluetooth/host/shell/bt.c index 1550644018e..d9f7467104a 100644 --- a/subsys/bluetooth/host/shell/bt.c +++ b/subsys/bluetooth/host/shell/bt.c @@ -53,7 +53,9 @@ #include "controller/ll_sw/shell/ll.h" #endif /* CONFIG_BT_LL_SW_SPLIT */ #include "host/shell/bt.h" -#include "mesh/shell/hci.h" +#if defined(CONFIG_BT_CLASSIC) +#include "host/classic/shell/bredr.h" +#endif static bool no_settings_load; @@ -1008,6 +1010,69 @@ void subrate_changed(struct bt_conn *conn, } #endif +#if defined(CONFIG_BT_LE_EXTENDED_FEAT_SET) +void read_all_remote_feat_complete(struct bt_conn *conn, + const struct bt_conn_le_read_all_remote_feat_complete *params) +{ + if (params->status == BT_HCI_ERR_SUCCESS) { + uint8_t number_of_bytes = BT_HCI_LE_BYTES_PAGE_0_FEATURE_PAGE; + + if (params->max_valid_page > 0) { + number_of_bytes += + (params->max_valid_page * BT_HCI_LE_BYTES_PER_FEATURE_PAGE); + } + + bt_shell_fprintf_print( + "Read all remote features complete, Max Remote Page %d, LE Features: 0x", + params->max_remote_page); + + for (int i = number_of_bytes - 1; i >= 0; i--) { + uint8_t features = params->features[i]; + char features_str[(2 * sizeof(uint8_t)) + 1]; + + bin2hex(&features, sizeof(features), features_str, sizeof(features_str)); + bt_shell_fprintf_print("%s", features_str); + } + bt_shell_fprintf_print("\n"); + } else { + bt_shell_print("Read all remote features failed (HCI status 0x%02x)", + params->status); + } +} +#endif + +#if defined(CONFIG_BT_FRAME_SPACE_UPDATE) +static const char *frame_space_initiator_to_str( + enum bt_conn_le_frame_space_update_initiator initiator) +{ + switch (initiator) { + case BT_CONN_LE_FRAME_SPACE_UPDATE_INITIATOR_LOCAL_HOST: + return "Local Host"; + case BT_CONN_LE_FRAME_SPACE_UPDATE_INITIATOR_LOCAL_CONTROLLER: + return "Local Controller"; + case BT_CONN_LE_FRAME_SPACE_UPDATE_INITIATOR_PEER: + return "Peer"; + default: + return "Unknown"; + } +} + +void frame_space_updated(struct bt_conn *conn, + const struct bt_conn_le_frame_space_updated *params) +{ + if (params->status != BT_HCI_ERR_SUCCESS) { + bt_shell_print("Frame space update failed (HCI status 0x%02x)", + params->status); + return; + } + + bt_shell_print( + "Frame space updated: frame space %d us, PHYs 0x%04x, spacing types 0x%04x, initiator %s", + params->frame_space, params->phys, params->spacing_types, + frame_space_initiator_to_str(params->initiator)); +} +#endif + #if defined(CONFIG_BT_CHANNEL_SOUNDING) void print_remote_cs_capabilities(struct bt_conn *conn, uint8_t status, @@ -1158,7 +1223,7 @@ static void le_cs_config_removed(struct bt_conn *conn, uint8_t config_id) } #endif -static struct bt_conn_cb conn_callbacks = { +BT_CONN_CB_DEFINE(conn_callbacks) = { .connected = connected, .disconnected = disconnected, .le_param_req = le_param_req, @@ -1187,12 +1252,21 @@ static struct bt_conn_cb conn_callbacks = { #if defined(CONFIG_BT_SUBRATING) .subrate_changed = subrate_changed, #endif +#if defined(CONFIG_BT_LE_EXTENDED_FEAT_SET) + .read_all_remote_feat_complete = read_all_remote_feat_complete, +#endif +#if defined(CONFIG_BT_FRAME_SPACE_UPDATE) + .frame_space_updated = frame_space_updated, +#endif #if defined(CONFIG_BT_CHANNEL_SOUNDING) .le_cs_read_remote_capabilities_complete = print_remote_cs_capabilities, .le_cs_read_remote_fae_table_complete = print_remote_cs_fae_table, .le_cs_config_complete = le_cs_config_created, .le_cs_config_removed = le_cs_config_removed, #endif +#if defined(CONFIG_BT_CLASSIC) + .role_changed = role_changed, +#endif }; #endif /* CONFIG_BT_CONN */ @@ -1335,10 +1409,6 @@ static void bt_ready(int err) #if defined(CONFIG_BT_CONN) default_conn = NULL; - - /* Unregister to avoid register repeatedly */ - bt_conn_cb_unregister(&conn_callbacks); - bt_conn_cb_register(&conn_callbacks); #endif /* CONFIG_BT_CONN */ #if defined(CONFIG_BT_PER_ADV_SYNC) @@ -3280,6 +3350,83 @@ static int cmd_subrate_request(const struct shell *sh, size_t argc, char *argv[] } #endif +#if defined(CONFIG_BT_LE_EXTENDED_FEAT_SET) +static int cmd_read_all_remote_features(const struct shell *sh, size_t argc, char *argv[]) +{ + int err = 0; + + if (default_conn == NULL) { + shell_error(sh, "Conn handle error, at least one connection is required."); + return -ENOEXEC; + } + + uint8_t pages_requested = shell_strtoul(argv[1], 10, &err); + + if (err != 0) { + shell_help(sh); + shell_error(sh, "Could not parse input for pages_requested"); + return SHELL_CMD_HELP_PRINTED; + } + + err = bt_conn_le_read_all_remote_features(default_conn, pages_requested); + if (err != 0) { + shell_error(sh, "bt_conn_le_read_all_remote_features returned error %d", err); + return -ENOEXEC; + } + + return 0; +} +#endif + +#if defined(CONFIG_BT_FRAME_SPACE_UPDATE) +static int cmd_frame_space_update(const struct shell *sh, size_t argc, char *argv[]) +{ + int err = 0; + struct bt_conn_le_frame_space_update_param params; + + if (default_conn == NULL) { + shell_error(sh, "Conn handle error, at least one connection is required."); + return -ENOEXEC; + } + + params.frame_space_min = shell_strtoul(argv[1], 10, &err); + if (err) { + shell_help(sh); + shell_error(sh, "Could not parse frame_space_min input"); + return SHELL_CMD_HELP_PRINTED; + } + + params.frame_space_max = shell_strtoul(argv[2], 10, &err); + if (err) { + shell_help(sh); + shell_error(sh, "Could not parse frame_space_max input"); + return SHELL_CMD_HELP_PRINTED; + } + + params.phys = shell_strtoul(argv[3], 16, &err); + if (err) { + shell_help(sh); + shell_error(sh, "Could not parse phys input"); + return SHELL_CMD_HELP_PRINTED; + } + + params.spacing_types = shell_strtoul(argv[4], 16, &err); + if (err) { + shell_help(sh); + shell_error(sh, "Could not parse spacing_types input"); + return SHELL_CMD_HELP_PRINTED; + } + + err = bt_conn_le_frame_space_update(default_conn, ¶ms); + if (err != 0) { + shell_error(sh, "bt_conn_le_frame_space_update returned error %d", err); + return -ENOEXEC; + } + + return 0; +} +#endif + #if defined(CONFIG_BT_CONN) #if defined(CONFIG_BT_CENTRAL) static int bt_do_connect_le(int *ercd, size_t argc, char *argv[]) @@ -5031,6 +5178,16 @@ SHELL_STATIC_SUBCMD_SET_CREATE(bt_cmds, " ", cmd_subrate_request, 6, 0), #endif +#if defined(CONFIG_BT_LE_EXTENDED_FEAT_SET) + SHELL_CMD_ARG(read-all-remote-features, NULL, "", + cmd_read_all_remote_features, 2, 0), +#endif +#if defined(CONFIG_BT_FRAME_SPACE_UPDATE) + SHELL_CMD_ARG(frame-space-update, NULL, + "[frame_space_min ] [frame_space_max ] [phys ] " + "[spacing_types ]", + cmd_frame_space_update, 5, 0), +#endif #if defined(CONFIG_BT_BROADCASTER) SHELL_CMD_ARG(advertise, NULL, " [mode: discov, non_discov] " @@ -5176,9 +5333,6 @@ SHELL_STATIC_SUBCMD_SET_CREATE(bt_cmds, #endif #endif /* CONFIG_BT_SMP || CONFIG_BT_CLASSIC) */ #endif /* CONFIG_BT_CONN */ -#if defined(CONFIG_BT_HCI_MESH_EXT) - SHELL_CMD(mesh_adv, NULL, HELP_ONOFF, cmd_mesh_adv), -#endif /* CONFIG_BT_HCI_MESH_EXT */ #if defined(CONFIG_BT_LL_SW_SPLIT) SHELL_CMD(ll-addr, NULL, "", cmd_ll_addr_read), diff --git a/subsys/bluetooth/mesh/shell/CMakeLists.txt b/subsys/bluetooth/mesh/shell/CMakeLists.txt index 0a8e948fc43..e90e5542846 100644 --- a/subsys/bluetooth/mesh/shell/CMakeLists.txt +++ b/subsys/bluetooth/mesh/shell/CMakeLists.txt @@ -36,5 +36,3 @@ zephyr_library_sources_ifdef(CONFIG_BT_MESH_OD_PRIV_PROXY_CLI od_priv_proxy.c) zephyr_library_sources_ifdef(CONFIG_BT_MESH_SOL_PDU_RPL_CLI sol_pdu_rpl.c) zephyr_library_sources_ifdef(CONFIG_BT_MESH_SHELL_BRG_CFG_CLI brg_cfg.c) - -zephyr_library_sources_ifdef(CONFIG_BT_HCI_MESH_EXT hci.c) diff --git a/subsys/bluetooth/mesh/shell/hci.c b/subsys/bluetooth/mesh/shell/hci.c deleted file mode 100644 index 191a47c2411..00000000000 --- a/subsys/bluetooth/mesh/shell/hci.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2017-2018 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "../host/hci_core.h" - -#if defined(CONFIG_BT_HCI_MESH_EXT) -int cmd_mesh_adv(const struct shell *sh, size_t argc, char *argv[]) -{ - struct net_buf *buf; - int err; - - if (argc < 2) { - return -EINVAL; - } - - if (!strcmp(argv[1], "on")) { - struct bt_hci_cp_mesh_advertise *cp; - - buf = bt_hci_cmd_alloc(K_FOREVER); - if (!buf) { - return -ENOBUFS; - } - - net_buf_add_u8(buf, BT_HCI_OC_MESH_ADVERTISE); - - /* TODO: fetch and fill cmdline params */ - cp = net_buf_add(buf, sizeof(*cp)); - cp->adv_slot = 0U; - cp->own_addr_type = 0x01; - memset(&cp->random_addr, 0, sizeof(bt_addr_t)); - cp->ch_map = 0x07; - cp->tx_power = 0; - cp->min_tx_delay = 0U; - cp->max_tx_delay = 0x32; - cp->retx_count = 0x07; - cp->retx_interval = 0x00; - cp->scan_delay = 0x0a; - cp->scan_duration = sys_cpu_to_le16(0x0064); - cp->scan_filter = 0x00; - cp->data_len = 0U; - memset(cp->data, 0, sizeof(cp->data)); - } else if (!strcmp(argv[1], "off")) { - struct bt_hci_cp_mesh_advertise_cancel *cp; - - buf = bt_hci_cmd_alloc(K_FOREVER); - if (!buf) { - return -ENOBUFS; - } - - net_buf_add_u8(buf, BT_HCI_OC_MESH_ADVERTISE_CANCEL); - - cp = net_buf_add(buf, sizeof(*cp)); - cp->adv_slot = 0U; - } else { - return -EINVAL; - } - - err = bt_hci_cmd_send_sync(BT_HCI_OP_VS_MESH, buf, NULL); - - return err; -} -#endif /* CONFIG_BT_HCI_MESH_EXT */ diff --git a/subsys/bluetooth/mesh/shell/hci.h b/subsys/bluetooth/mesh/shell/hci.h deleted file mode 100644 index 81dcb0d892e..00000000000 --- a/subsys/bluetooth/mesh/shell/hci.h +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright (c) 2017 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -int cmd_mesh_adv(const struct shell *sh, size_t argc, char *argv[]); diff --git a/subsys/canbus/isotp/Kconfig b/subsys/canbus/isotp/Kconfig index 281692cf95e..c643f22ca18 100644 --- a/subsys/canbus/isotp/Kconfig +++ b/subsys/canbus/isotp/Kconfig @@ -87,7 +87,7 @@ config ISOTP_RX_SF_FF_BUF_COUNT default 4 help This buffer is used for first and single frames. It is extra because the - buffer has to be ready for the first reception in isr context and therefor + buffer has to be ready for the first reception in isr context and therefore is allocated when binding. Each buffer will occupy CAN_MAX_DLEN - 1 byte + header (sizeof(struct net_buf)) amount of data. diff --git a/subsys/debug/coredump/Kconfig b/subsys/debug/coredump/Kconfig index 1e763e522e1..c4e93605988 100644 --- a/subsys/debug/coredump/Kconfig +++ b/subsys/debug/coredump/Kconfig @@ -45,7 +45,7 @@ config DEBUG_COREDUMP_BACKEND_INTEL_ADSP_MEM_WINDOW help Core dump is done via memory window slot[1]. It is Intel ADSP memory region shared with xtensa DSP. - Window 2 slot [1] is reserved for debuging information. + Window 2 slot [1] is reserved for debugging information. config DEBUG_COREDUMP_BACKEND_OTHER bool "Backend subsystem for coredump defined out of tree" diff --git a/subsys/ipc/ipc_service/backends/Kconfig b/subsys/ipc/ipc_service/backends/Kconfig index 8230465e246..bb8b444898f 100644 --- a/subsys/ipc/ipc_service/backends/Kconfig +++ b/subsys/ipc/ipc_service/backends/Kconfig @@ -23,7 +23,7 @@ config IPC_SERVICE_BACKEND_ICMSG depends on DT_HAS_ZEPHYR_IPC_ICMSG_ENABLED select IPC_SERVICE_ICMSG help - Chosing this backend results in single endpoint implementation based + Choosing this backend results in single endpoint implementation based on circular packet buffer. config IPC_SERVICE_BACKEND_ICMSG_ME_INITIATOR @@ -33,8 +33,8 @@ config IPC_SERVICE_BACKEND_ICMSG_ME_INITIATOR depends on DT_HAS_ZEPHYR_IPC_ICMSG_ME_INITIATOR_ENABLED select IPC_SERVICE_ICMSG_ME help - Chosing this backend results in multi endpoint implementation based - on circular packet buffer. This enables enpoint discovery initiator + Choosing this backend results in multi endpoint implementation based + on circular packet buffer. This enables endpoint discovery initiator role. config IPC_SERVICE_BACKEND_ICMSG_ME_FOLLOWER @@ -44,8 +44,8 @@ config IPC_SERVICE_BACKEND_ICMSG_ME_FOLLOWER depends on DT_HAS_ZEPHYR_IPC_ICMSG_ME_FOLLOWER_ENABLED select IPC_SERVICE_ICMSG_ME help - Chosing this backend results in multi endpoint implementation based - on circular packet buffer. This enables enpoint discovery follower + Choosing this backend results in multi endpoint implementation based + on circular packet buffer. This enables endpoint discovery follower role. rsource "Kconfig.icmsg_me" diff --git a/subsys/logging/Kconfig.processing b/subsys/logging/Kconfig.processing index f354e8b5df6..c13c8a76a91 100644 --- a/subsys/logging/Kconfig.processing +++ b/subsys/logging/Kconfig.processing @@ -114,7 +114,7 @@ config LOG_PROCESS_THREAD_PRIORITY depends on LOG_PROCESS_THREAD_CUSTOM_PRIORITY help The priority of the log processing thread. - When not set the prority is set to K_LOWEST_APPLICATION_THREAD_PRIO. + When not set the priority is set to K_LOWEST_APPLICATION_THREAD_PRIO. endif # LOG_PROCESS_THREAD diff --git a/subsys/mgmt/ec_host_cmd/Kconfig.logging b/subsys/mgmt/ec_host_cmd/Kconfig.logging index 96de59e39cd..ca225309929 100644 --- a/subsys/mgmt/ec_host_cmd/Kconfig.logging +++ b/subsys/mgmt/ec_host_cmd/Kconfig.logging @@ -8,7 +8,7 @@ config EC_HOST_CMD_LOG_DBG_BUFFERS depends on EC_HC_LOG_LEVEL_DBG help Every command is logged with the debug logging level. Use this config - to decide, if full reqest and response buffers are logged alongside + to decide if full request and response buffers are logged alongside other command parameters. config EC_HOST_CMD_LOG_SUPPRESSED_NUMBER diff --git a/subsys/mgmt/mcumgr/smp/Kconfig b/subsys/mgmt/mcumgr/smp/Kconfig index b460067dd84..aab861fa9cf 100644 --- a/subsys/mgmt/mcumgr/smp/Kconfig +++ b/subsys/mgmt/mcumgr/smp/Kconfig @@ -31,7 +31,7 @@ config MCUMGR_SMP_CBOR_MIN_DECODING_LEVELS help Minimal decoding levels, map/list encapsulation, required to be supported by zcbor decoding of SMP responses - is auto genereated from MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_? options. + is auto generated from MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_? options. A group or command that adds additional maps/lists above the base map, which is already taken into account, should select one of the MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_?. @@ -87,7 +87,7 @@ config MCUMGR_SMP_CBOR_MIN_ENCODING_LEVELS help Minimal encoding levels, map/list encapsulation, required to be supported by zcbor encoding of SMP responses - is auto genereated from MCUMGR_SMP_CBOR_MIN_ENCODING_LEVEL_? options. + is auto generated from MCUMGR_SMP_CBOR_MIN_ENCODING_LEVEL_? options. A group or command that adds additional maps/lists above the base map, which is already taken into account, should select one of the MCUMGR_SMP_CBOR_MIN_ENCODING_LEVEL_?. diff --git a/tests/bluetooth/gatt/testcase.yaml b/tests/bluetooth/gatt/testcase.yaml index 37e14f0b968..ff18a0c663f 100644 --- a/tests/bluetooth/gatt/testcase.yaml +++ b/tests/bluetooth/gatt/testcase.yaml @@ -28,3 +28,17 @@ tests: tags: - bluetooth - gatt + bluetooth.gatt.no_bt_conn_dynamic_callbacks: + extra_args: + - EXTRA_DTC_OVERLAY_FILE="test.overlay" + - CONFIG_BT_CONN_DYNAMIC_CALLBACKS=n + platform_allow: + - native_sim + - native_sim/native/64 + - qemu_x86 + - qemu_cortex_m3 + integration_platforms: + - native_sim + tags: + - bluetooth + - gatt diff --git a/tests/bluetooth/shell/testcase.yaml b/tests/bluetooth/shell/testcase.yaml index 812aee24eeb..45812ca5132 100644 --- a/tests/bluetooth/shell/testcase.yaml +++ b/tests/bluetooth/shell/testcase.yaml @@ -34,6 +34,18 @@ tests: - CONFIG_BT_SUBRATING=y - CONFIG_BT_LL_SW_SPLIT=n build_only: true + bluetooth.shell.extended_feature_set: + extra_configs: + - CONFIG_BT_LE_MAX_LOCAL_SUPPORTED_FEATURE_PAGE=10 + - CONFIG_BT_LE_EXTENDED_FEAT_SET=y + - CONFIG_BT_LL_SW_SPLIT=n + build_only: true + bluetooth.shell.frame_space_update: + extra_configs: + - CONFIG_BT_FRAME_SPACE_UPDATE=y + - CONFIG_BT_LE_EXTENDED_FEAT_SET=y + - CONFIG_BT_LL_SW_SPLIT=n + build_only: true bluetooth.shell.channel_sounding: extra_configs: - CONFIG_BT_CHANNEL_SOUNDING=y @@ -86,6 +98,12 @@ tests: extra_args: CONF_FILE="audio.conf" build_only: true tags: bluetooth + bluetooth.shell.audio.no_bt_conn_dynamic_callbacks: + extra_args: + - CONF_FILE="audio.conf" + - CONFIG_BT_CONN_DYNAMIC_CALLBACKS=n + build_only: true + tags: bluetooth bluetooth.shell.audio.no_testing: extra_args: CONF_FILE="audio.conf" build_only: true diff --git a/tests/bsim/bluetooth/samples/central_hr_peripheral_hr/tests_scripts/central_hr_peripheral_hr_static_callbacks.sh b/tests/bsim/bluetooth/samples/central_hr_peripheral_hr/tests_scripts/central_hr_peripheral_hr_static_callbacks.sh new file mode 100755 index 00000000000..f6567efdc2a --- /dev/null +++ b/tests/bsim/bluetooth/samples/central_hr_peripheral_hr/tests_scripts/central_hr_peripheral_hr_static_callbacks.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +# Copyright 2025 Demant A/S +# SPDX-License-Identifier: Apache-2.0 + +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + +simulation_id="central_hr_peripheral_hr_static_callbacks_test" +test_long_name="$(guess_test_long_name)" +verbosity_level=2 +EXECUTE_TIMEOUT=60 + +cd ${BSIM_OUT_PATH}/bin + +Execute ./bs_${BOARD_TS}_samples_bluetooth_peripheral_hr_prj_conf_overlay-static_callbacks_conf \ + -v=${verbosity_level} -s=${simulation_id} -d=0 + +Execute ./bs_${BOARD_TS}_${test_long_name}_prj_conf_overlay-static_callbacks_conf \ + -v=${verbosity_level} -s=${simulation_id} -d=1 \ + -testid=central_hr_peripheral_hr + +Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \ + -D=2 -sim_length=12e6 $@ + +wait_for_background_jobs #Wait for all programs in background and return != 0 if any fails diff --git a/tests/bsim/bluetooth/samples/compile.sh b/tests/bsim/bluetooth/samples/compile.sh index f189445c36b..33a9827a300 100755 --- a/tests/bsim/bluetooth/samples/compile.sh +++ b/tests/bsim/bluetooth/samples/compile.sh @@ -37,6 +37,15 @@ app=tests/bsim/bluetooth/samples/central_hr_peripheral_hr \ extra_conf_file=${ZEPHYR_BASE}/samples/bluetooth/central_hr/prj.conf \ conf_overlay=${ZEPHYR_BASE}/samples/bluetooth/central_hr/overlay-phy_coded.conf \ compile +app=samples/bluetooth/peripheral_hr \ + sysbuild=1 \ + conf_overlay=overlay-static_callbacks.conf \ + compile +app=tests/bsim/bluetooth/samples/central_hr_peripheral_hr \ + sysbuild=1 \ + extra_conf_file=${ZEPHYR_BASE}/samples/bluetooth/central_hr/prj.conf \ + conf_overlay=${ZEPHYR_BASE}/samples/bluetooth/central_hr/overlay-static_callbacks.conf \ + compile if [ ${BOARD} == "nrf52_bsim/native" ]; then app=tests/bsim/bluetooth/samples/battery_service \ conf_file=prj.conf \