Skip to content

Commit 76b28d8

Browse files
committed
Merge branch 'feat/support_blecrt_489' into 'master'
feat(ble/bluedroid): Added API to set channel map for scanning Closes BLERP-2204 See merge request espressif/esp-idf!41681
2 parents 9fe5195 + fd4bb69 commit 76b28d8

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

components/bt/host/bluedroid/api/esp_gap_ble_api.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,6 +1795,24 @@ esp_err_t esp_ble_gap_set_sch_len(uint8_t role, uint32_t len)
17951795
return esp_ble_gap_vendor_command_send(&vs_cmd);
17961796
}
17971797
#endif // CONFIG_SOC_BLE_MULTI_CONN_OPTIMIZATION
1798+
1799+
esp_err_t esp_ble_gap_set_scan_chan_map(uint8_t state, uint8_t chan_map[5])
1800+
{
1801+
esp_ble_vendor_cmd_params_t vs_cmd;
1802+
uint8_t cmd_param[6];
1803+
1804+
if (chan_map == NULL) {
1805+
return ESP_ERR_INVALID_ARG;
1806+
}
1807+
1808+
cmd_param[0] = state;
1809+
memcpy(&cmd_param[1], chan_map, 5);
1810+
vs_cmd.opcode = 0xFD19;
1811+
vs_cmd.param_len = 6;
1812+
vs_cmd.p_param_buf = cmd_param;
1813+
1814+
return esp_ble_gap_vendor_command_send(&vs_cmd);
1815+
}
17981816
#endif // (BLE_VENDOR_HCI_EN == TRUE)
17991817

18001818
#if (BLE_FEAT_POWER_CONTROL_EN == TRUE)

components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ typedef enum {
248248
ESP_GAP_BLE_READ_CHANNEL_MAP_COMPLETE_EVT, /*!< When BLE channel map result is received, the event comes */
249249
ESP_GAP_BLE_SET_COMMON_FACTOR_CMPL_EVT, /*!< When set the common factor complete, the event comes */
250250
ESP_GAP_BLE_SET_SCH_LEN_CMPL_EVT, /*!< When set the scheduling length complete, the event comes */
251+
ESP_GAP_BLE_SET_SCAN_CHAN_MAP_CMPL_EVT, /*!< When set the channel map for scanning complete, the event comes */
251252
ESP_GAP_BLE_EVT_MAX, /*!< when maximum advertising event complete, the event comes */
252253
} esp_gap_ble_cb_event_t;
253254

@@ -1762,6 +1763,12 @@ typedef union {
17621763
struct ble_set_sch_len_cmpl_evt_param {
17631764
esp_bt_status_t status; /*!< Indicate scheduling length set operation success status */
17641765
} set_sch_len_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_SCH_LEN_CMPL_EVT */
1766+
/**
1767+
* @brief ESP_GAP_BLE_SET_SCAN_CHAN_MAP_CMPL_EVT
1768+
*/
1769+
struct ble_set_scan_chan_map_cmpl_evt_param {
1770+
esp_bt_status_t status; /*!< Indicate channel map for scanning set operation success status */
1771+
} set_scan_chan_map_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_SCAN_CHAN_MAP_CMPL_EVT */
17651772
#endif // #if (BLE_VENDOR_HCI_EN == TRUE)
17661773
#if (BLE_FEAT_POWER_CONTROL_EN == TRUE)
17671774
/**
@@ -3144,6 +3151,28 @@ esp_err_t esp_ble_gap_set_common_factor(uint32_t common_factor);
31443151
*/
31453152
esp_err_t esp_ble_gap_set_sch_len(uint8_t role, uint32_t len);
31463153

3154+
/**
3155+
* @brief This function is used to Set the channel map for LE scanning or initiating state.
3156+
*
3157+
* @note - This function must be called before starting scanning or initiating.
3158+
* - At least one channel should be marked as used.
3159+
*
3160+
* @param[in] state: The LE state for which the channel map is applied.
3161+
* - 0 : Scanning state
3162+
* - 1 : Initiating state
3163+
* @param[in] chan_map: A 5-byte array representing the channel usage bit mask.
3164+
* Each bit corresponds to one channel from channel 0 to channel 39.
3165+
* The least significant bit of chan_map[0] corresponds to channel 0.
3166+
* The most significant bit of chan_map[4] corresponds to channel 39.
3167+
* - Bit = 1 : channel is used
3168+
* - Bit = 0 : channel is not used
3169+
*
3170+
* @return
3171+
* - ESP_OK : success
3172+
* - other : failed
3173+
*/
3174+
esp_err_t esp_ble_gap_set_scan_chan_map(uint8_t state, uint8_t chan_map[5]);
3175+
31473176
/**
31483177
* @brief This function is used to read the current and maximum transmit power levels of the local Controller.
31493178
*

components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,6 +1452,10 @@ static void btc_ble_vendor_hci_cmd_complete_callback(tBTA_VSC_CMPL *p_param)
14521452
msg.act = ESP_GAP_BLE_SET_SCH_LEN_CMPL_EVT;
14531453
param.set_sch_len_cmpl.status = p_param->p_param_buf[0];
14541454
break;
1455+
case 0xFD19:
1456+
msg.act = ESP_GAP_BLE_SET_SCAN_CHAN_MAP_CMPL_EVT;
1457+
param.set_scan_chan_map_cmpl.status = btc_hci_to_esp_status(p_param->p_param_buf[0]);
1458+
break;
14551459
default:
14561460
param.vendor_cmd_cmpl.opcode = p_param->opcode;
14571461
param.vendor_cmd_cmpl.param_len = p_param->param_len;

0 commit comments

Comments
 (0)