Skip to content

Commit

Permalink
ESP IDF 5.3 compatibility (#487)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmarkov authored Sep 19, 2024
1 parent ead9b6f commit 95d6cf0
Showing 1 changed file with 69 additions and 20 deletions.
89 changes: 69 additions & 20 deletions src/bt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,10 +492,10 @@ where
..Default::default()
};

#[cfg(esp32c3)]
#[cfg(esp32s3)]
let mut bt_cfg = esp_bt_controller_config_t {
magic: crate::sys::ESP_BT_CTRL_CONFIG_MAGIC_VAL,
version: crate::sys::ESP_BT_CTRL_CONFIG_VERSION,
magic: crate::sys::ESP_BT_CTRL_CONFIG_MAGIC_VAL as _,
version: crate::sys::ESP_BT_CTRL_CONFIG_VERSION as _,
controller_task_stack_size: crate::sys::ESP_TASK_BT_CONTROLLER_STACK as _,
controller_task_prio: crate::sys::ESP_TASK_BT_CONTROLLER_PRIO as _,
controller_task_run_cpu: crate::sys::CONFIG_BT_CTRL_PINNED_TO_CORE as _,
Expand All @@ -506,13 +506,15 @@ where
ble_st_acl_tx_buf_nb: crate::sys::CONFIG_BT_CTRL_BLE_STATIC_ACL_TX_BUF_NB as _,
ble_hw_cca_check: crate::sys::CONFIG_BT_CTRL_HW_CCA_EFF as _,
ble_adv_dup_filt_max: crate::sys::CONFIG_BT_CTRL_ADV_DUP_FILT_MAX as _,
coex_param_en: false,
ce_len_type: crate::sys::CONFIG_BT_CTRL_CE_LENGTH_TYPE_EFF as _,
coex_use_hooks: false,
hci_tl_type: crate::sys::CONFIG_BT_CTRL_HCI_TL_EFF as _,
hci_tl_funcs: core::ptr::null_mut(),
txant_dft: crate::sys::CONFIG_BT_CTRL_TX_ANTENNA_INDEX_EFF as _,
rxant_dft: crate::sys::CONFIG_BT_CTRL_RX_ANTENNA_INDEX_EFF as _,
txpwr_dft: crate::sys::CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_EFF as _,
cfg_mask: crate::sys::CFG_MASK,
cfg_mask: crate::sys::CFG_MASK as _,
scan_duplicate_mode: crate::sys::SCAN_DUPLICATE_MODE as _,
scan_duplicate_type: crate::sys::SCAN_DUPLICATE_TYPE_VALUE as _,
normal_adv_size: crate::sys::NORMAL_SCAN_DUPLICATE_CACHE_SIZE as _,
Expand All @@ -523,18 +525,16 @@ where
slave_ce_len_min: crate::sys::SLAVE_CE_LEN_MIN_DEFAULT as _,
hw_recorrect_en: crate::sys::AGC_RECORRECT_EN as _,
cca_thresh: crate::sys::CONFIG_BT_CTRL_HW_CCA_VAL as _,
coex_param_en: false,
coex_use_hooks: false,
ble_50_feat_supp: crate::sys::BT_CTRL_50_FEATURE_SUPPORT != 0,
dup_list_refresh_period: crate::sys::DUPL_SCAN_CACHE_REFRESH_PERIOD as _,
scan_backoff_upperlimitmax: crate::sys::BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX as _,
..Default::default()
..Default::default() // TODO
// ble_50_feat_supp: crate::sys::BT_CTRL_50_FEATURE_SUPPORT != 0,
// dup_list_refresh_period: crate::sys::DUPL_SCAN_CACHE_REFRESH_PERIOD as _,
// scan_backoff_upperlimitmax: crate::sys::BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX as _
};

#[cfg(esp32s3)]
#[cfg(esp32c3)]
let mut bt_cfg = esp_bt_controller_config_t {
magic: crate::sys::ESP_BT_CTRL_CONFIG_MAGIC_VAL as _,
version: crate::sys::ESP_BT_CTRL_CONFIG_VERSION as _,
magic: crate::sys::ESP_BT_CTRL_CONFIG_MAGIC_VAL,
version: crate::sys::ESP_BT_CTRL_CONFIG_VERSION,
controller_task_stack_size: crate::sys::ESP_TASK_BT_CONTROLLER_STACK as _,
controller_task_prio: crate::sys::ESP_TASK_BT_CONTROLLER_PRIO as _,
controller_task_run_cpu: crate::sys::CONFIG_BT_CTRL_PINNED_TO_CORE as _,
Expand All @@ -545,15 +545,13 @@ where
ble_st_acl_tx_buf_nb: crate::sys::CONFIG_BT_CTRL_BLE_STATIC_ACL_TX_BUF_NB as _,
ble_hw_cca_check: crate::sys::CONFIG_BT_CTRL_HW_CCA_EFF as _,
ble_adv_dup_filt_max: crate::sys::CONFIG_BT_CTRL_ADV_DUP_FILT_MAX as _,
coex_param_en: false,
ce_len_type: crate::sys::CONFIG_BT_CTRL_CE_LENGTH_TYPE_EFF as _,
coex_use_hooks: false,
hci_tl_type: crate::sys::CONFIG_BT_CTRL_HCI_TL_EFF as _,
hci_tl_funcs: core::ptr::null_mut(),
txant_dft: crate::sys::CONFIG_BT_CTRL_TX_ANTENNA_INDEX_EFF as _,
rxant_dft: crate::sys::CONFIG_BT_CTRL_RX_ANTENNA_INDEX_EFF as _,
txpwr_dft: crate::sys::CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_EFF as _,
cfg_mask: crate::sys::CFG_MASK as _,
cfg_mask: crate::sys::CFG_MASK,
scan_duplicate_mode: crate::sys::SCAN_DUPLICATE_MODE as _,
scan_duplicate_type: crate::sys::SCAN_DUPLICATE_TYPE_VALUE as _,
normal_adv_size: crate::sys::NORMAL_SCAN_DUPLICATE_CACHE_SIZE as _,
Expand All @@ -564,10 +562,12 @@ where
slave_ce_len_min: crate::sys::SLAVE_CE_LEN_MIN_DEFAULT as _,
hw_recorrect_en: crate::sys::AGC_RECORRECT_EN as _,
cca_thresh: crate::sys::CONFIG_BT_CTRL_HW_CCA_VAL as _,
..Default::default() // TODO
// ble_50_feat_supp: crate::sys::BT_CTRL_50_FEATURE_SUPPORT != 0,
// dup_list_refresh_period: crate::sys::DUPL_SCAN_CACHE_REFRESH_PERIOD as _,
// scan_backoff_upperlimitmax: crate::sys::BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX as _
coex_param_en: false,
coex_use_hooks: false,
ble_50_feat_supp: crate::sys::BT_CTRL_50_FEATURE_SUPPORT != 0,
dup_list_refresh_period: crate::sys::DUPL_SCAN_CACHE_REFRESH_PERIOD as _,
scan_backoff_upperlimitmax: crate::sys::BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX as _,
..Default::default()
};

#[cfg(not(any(esp32, esp32s3, esp32c3)))]
Expand Down Expand Up @@ -604,12 +604,61 @@ where
controller_run_cpu: 0,
enable_qa_test: crate::sys::RUN_QA_TEST as _,
enable_bqb_test: crate::sys::RUN_BQB_TEST as _,
#[cfg(any(
esp_idf_version_major = "4",
esp_idf_version = "5.0",
esp_idf_version = "5.1",
esp_idf_version = "5.2",
not(any(esp32c6, esp32h2))
))]
enable_uart_hci: crate::sys::HCI_UART_EN as _,
#[cfg(any(
esp_idf_version_major = "4",
esp_idf_version = "5.0",
esp_idf_version = "5.1",
esp_idf_version = "5.2",
not(any(esp32c6, esp32h2))
))]
ble_hci_uart_port: crate::sys::DEFAULT_BT_LE_HCI_UART_PORT as _,
#[cfg(any(
esp_idf_version_major = "4",
esp_idf_version = "5.0",
esp_idf_version = "5.1",
esp_idf_version = "5.2",
not(any(esp32c6, esp32h2))
))]
ble_hci_uart_baud: crate::sys::DEFAULT_BT_LE_HCI_UART_BAUD,
#[cfg(any(
esp_idf_version_major = "4",
esp_idf_version = "5.0",
esp_idf_version = "5.1",
esp_idf_version = "5.2",
not(any(esp32c6, esp32h2))
))]
ble_hci_uart_data_bits: crate::sys::DEFAULT_BT_LE_HCI_UART_DATA_BITS as _,
#[cfg(any(
esp_idf_version_major = "4",
esp_idf_version = "5.0",
esp_idf_version = "5.1",
esp_idf_version = "5.2",
not(any(esp32c6, esp32h2))
))]
ble_hci_uart_stop_bits: crate::sys::DEFAULT_BT_LE_HCI_UART_STOP_BITS as _,
#[cfg(any(
esp_idf_version_major = "4",
esp_idf_version = "5.0",
esp_idf_version = "5.1",
esp_idf_version = "5.2",
not(any(esp32c6, esp32h2))
))]
ble_hci_uart_flow_ctrl: crate::sys::DEFAULT_BT_LE_HCI_UART_FLOW_CTRL as _,
#[cfg(any(
esp_idf_version_major = "4",
esp_idf_version = "5.0",
esp_idf_version = "5.1",
esp_idf_version = "5.2",
not(any(esp32c6, esp32h2))
))]
ble_hci_uart_uart_parity: crate::sys::DEFAULT_BT_LE_HCI_UART_PARITY as _,
enable_tx_cca: crate::sys::DEFAULT_BT_LE_TX_CCA_ENABLED as _,
cca_rssi_thresh: (256 - crate::sys::DEFAULT_BT_LE_CCA_RSSI_THRESH) as _,
Expand Down

0 comments on commit 95d6cf0

Please sign in to comment.