Compare commits

...

7 Commits

Author SHA1 Message Date
Wang Meng Yang
871d0c8c9a Merge branch 'bugfix/fix_hid_cod_setting_v5.0' into 'release/v5.0'
Some checks failed
docker / docker (push) Has been cancelled
Bugfix/fix hid cod setting[backport 5.0]

See merge request espressif/esp-idf!33340
2024-09-12 09:34:22 +08:00
Wang Meng Yang
02e0c7a2b8 Merge branch 'bugfix/exit_sniff_immed_enter_sniff_v5.0' into 'release/v5.0'
fix(bt/bluedroid): Fix the protocol stack to exit sniff mode(v5.0)

See merge request espressif/esp-idf!33400
2024-09-11 15:32:43 +08:00
Rahul Tank
26a300b668 Merge branch 'bugfix/bidirectioanl_data_transfer_ble_spp_v5.0' into 'release/v5.0'
fix(nimble): Added support for bidirectional data trasfer (v5.0)

See merge request espressif/esp-idf!33415
2024-09-11 14:05:09 +08:00
xiongweichao
dc937198c9 fix(bt/bluedroid): Fix the protocol stack to exit sniff mode
- Already in result mode but request change indication has not been cleared
2024-09-10 11:42:25 +08:00
Astha Verma
bb9134aaf8 fix(nimble): Added support for bidirectional data trasfer 2024-09-09 18:41:37 +05:30
liqigan
195f08112b fix(esp_hid): Fixed protocol mode mapping bug
Closes https://github.com/espressif/esp-idf/issues/14232
2024-09-05 14:28:02 +08:00
liqigan
9545b5480f feat(bt/bluedroid): Added definition of minor class of COD for peripheral major class
Closes https://github.com/espressif/esp-idf/issues/13622
2024-09-05 14:27:55 +08:00
6 changed files with 76 additions and 11 deletions

View File

@ -206,6 +206,28 @@ typedef enum {
ESP_BT_COD_MAJOR_DEV_UNCATEGORIZED = 31, /*!< Uncategorized: device not specified */
} esp_bt_cod_major_dev_t;
/// Minor device class field of Class of Device for Peripheral Major Class
typedef enum {
ESP_BT_COD_MINOR_PERIPHERAL_KEYBOARD = 0x10, /*!< Keyboard */
ESP_BT_COD_MINOR_PERIPHERAL_POINTING = 0x20, /*!< Pointing */
ESP_BT_COD_MINOR_PERIPHERAL_COMBO = 0x30, /*!< Combo
ESP_BT_COD_MINOR_PERIPHERAL_KEYBOARD, ESP_BT_COD_MINOR_PERIPHERAL_POINTING
and ESP_BT_COD_MINOR_PERIPHERAL_COMBO can be OR'd with one of the
following values to identify a multifunctional device. e.g.
ESP_BT_COD_MINOR_PERIPHERAL_KEYBOARD | ESP_BT_COD_MINOR_PERIPHERAL_GAMEPAD
ESP_BT_COD_MINOR_PERIPHERAL_POINTING | ESP_BT_COD_MINOR_PERIPHERAL_SENSING_DEVICE
*/
ESP_BT_COD_MINOR_PERIPHERAL_JOYSTICK = 0x01, /*!< Joystick */
ESP_BT_COD_MINOR_PERIPHERAL_GAMEPAD = 0x02, /*!< Gamepad */
ESP_BT_COD_MINOR_PERIPHERAL_REMOTE_CONTROL = 0x03, /*!< Remote Control */
ESP_BT_COD_MINOR_PERIPHERAL_SENSING_DEVICE = 0x04, /*!< Sensing Device */
ESP_BT_COD_MINOR_PERIPHERAL_DIGITIZING_TABLET = 0x05, /*!< Digitizing Tablet */
ESP_BT_COD_MINOR_PERIPHERAL_CARD_READER = 0x06, /*!< Card Reader */
ESP_BT_COD_MINOR_PERIPHERAL_DIGITAL_PAN = 0x07, /*!< Digital Pan */
ESP_BT_COD_MINOR_PERIPHERAL_HAND_SCANNER = 0x08, /*!< Hand Scanner */
ESP_BT_COD_MINOR_PERIPHERAL_HAND_GESTURAL_INPUT = 0x09, /*!< Hand Gestural Input */
} esp_bt_cod_minor_peripheral_t;
/// Bits of major device class field
#define ESP_BT_COD_MAJOR_DEV_BIT_MASK (0x1f00) /*!< Major device bit mask */
#define ESP_BT_COD_MAJOR_DEV_BIT_OFFSET (8) /*!< Major device bit offset */

View File

@ -543,7 +543,7 @@ static tBTM_PM_MODE btm_pm_get_set_mode(UINT8 pm_id, tBTM_PM_MCB *p_cb, tBTM_PM_
** Function btm_pm_snd_md_req
** Description get the resulting mode and send the resuest to host controller
** Returns tBTM_STATUS
**, BOOLEAN *p_chg_ind
**
*******************************************************************************/
static tBTM_STATUS btm_pm_snd_md_req(UINT8 pm_id, UINT16 link_hdl, tBTM_PM_PWR_MD *p_mode)
{
@ -565,6 +565,8 @@ static tBTM_STATUS btm_pm_snd_md_req(UINT8 pm_id, UINT16 link_hdl, tBTM_PM_PWR_M
/* already in the resulting mode */
if ( (mode == BTM_PM_MD_ACTIVE) ||
((md_res.max >= p_cb->interval) && (md_res.min <= p_cb->interval)) ) {
// Clear request change indication because already in result mode
p_cb->chg_ind = FALSE;
return BTM_CMD_STORED;
}
/* Otherwise, needs to wake, then sleep */
@ -689,7 +691,7 @@ static void btm_pm_check_stored(void)
** Description This function is called when an HCI command status event occurs
** for power manager related commands.
**
** Input Parms status - status of the event (HCI_SUCCESS if no errors)
** Input Params status - status of the event (HCI_SUCCESS if no errors)
**
** Returns none.
**
@ -717,7 +719,7 @@ void btm_pm_proc_cmd_status(UINT8 status)
#if BTM_PM_DEBUG == TRUE
BTM_TRACE_DEBUG( "btm_pm_proc_cmd_status new state:0x%x", p_cb->state);
#endif // BTM_PM_DEBUG
} else { /* the command was not successfull. Stay in the same state */
} else { /* the command was not successful. Stay in the same state */
pm_status = BTM_PM_STS_ERROR;
}
@ -743,7 +745,7 @@ void btm_pm_proc_cmd_status(UINT8 status)
**
** Description This function is called when an HCI mode change event occurs.
**
** Input Parms hci_status - status of the event (HCI_SUCCESS if no errors)
** Input Params hci_status - status of the event (HCI_SUCCESS if no errors)
** hci_handle - connection handle associated with the change
** mode - HCI_MODE_ACTIVE, HCI_MODE_HOLD, HCI_MODE_SNIFF, or HCI_MODE_PARK
** interval - number of baseband slots (meaning depends on mode)

View File

@ -717,11 +717,9 @@ void bt_hidd_cb(esp_hidd_cb_event_t event, esp_hidd_cb_param_t *param)
}
case ESP_HIDD_SET_PROTOCOL_EVT: {
if (param->set_protocol.protocol_mode != ESP_HIDD_UNSUPPORTED_MODE) {
if (s_hidd_param.dev->protocol_mode == param->set_protocol.protocol_mode) {
break;
}
osi_mutex_lock(&s_hidd_param.mutex, OSI_MUTEX_MAX_TIMEOUT);
s_hidd_param.dev->protocol_mode = param->set_protocol.protocol_mode;
s_hidd_param.dev->protocol_mode =
param->set_protocol.protocol_mode ? ESP_HID_PROTOCOL_MODE_BOOT : ESP_HID_PROTOCOL_MODE_REPORT;
osi_mutex_unlock(&s_hidd_param.mutex);
cb_param.protocol_mode.dev = s_hidd_param.dev->dev;
cb_param.protocol_mode.protocol_mode = s_hidd_param.dev->protocol_mode;

View File

@ -435,8 +435,9 @@ void app_main(void)
esp_bt_dev_set_device_name(local_device_name);
ESP_LOGI(TAG, "setting cod major, peripheral");
esp_bt_cod_t cod;
esp_bt_cod_t cod = {0};
cod.major = ESP_BT_COD_MAJOR_DEV_PERIPHERAL;
cod.minor = ESP_BT_COD_MINOR_PERIPHERAL_POINTING;
esp_bt_gap_set_cod(cod, ESP_BT_SET_COD_MAJOR_MINOR);
vTaskDelay(2000 / portTICK_PERIOD_MS);
@ -447,7 +448,7 @@ void app_main(void)
s_local_param.app_param.name = "Mouse";
s_local_param.app_param.description = "Mouse Example";
s_local_param.app_param.provider = "ESP32";
s_local_param.app_param.subclass = ESP_HID_CLASS_MIC;
s_local_param.app_param.subclass = ESP_HID_CLASS_MIC; // keep same with minor class of COD
s_local_param.app_param.desc_list = hid_mouse_descriptor;
s_local_param.app_param.desc_list_len = hid_mouse_descriptor_len;

View File

@ -592,8 +592,9 @@ void app_main(void)
ESP_LOGI(TAG, "setting device name");
esp_bt_dev_set_device_name(bt_hid_config.device_name);
ESP_LOGI(TAG, "setting cod major, peripheral");
esp_bt_cod_t cod;
esp_bt_cod_t cod = {0};
cod.major = ESP_BT_COD_MAJOR_DEV_PERIPHERAL;
cod.minor = ESP_BT_COD_MINOR_PERIPHERAL_POINTING;
esp_bt_gap_set_cod(cod, ESP_BT_SET_COD_MAJOR_MINOR);
vTaskDelay(1000 / portTICK_PERIOD_MS);
ESP_LOGI(TAG, "setting bt device");

View File

@ -26,6 +26,43 @@ uint16_t attribute_handle[CONFIG_BT_NIMBLE_MAX_CONNECTIONS + 1];
static void ble_spp_client_scan(void);
static ble_addr_t connected_addr[CONFIG_BT_NIMBLE_MAX_CONNECTIONS + 1];
static void ble_spp_client_write_subscribe(const struct peer *peer)
{
uint8_t value[2];
int rc;
const struct peer_dsc *dsc;
/* Subscribe to notifications for the SPP characteristic.
* A central enables notifications by writing two bytes (1, 0) to the
* characteristic's client-characteristic-configuration-descriptor (CCCD).
*/
dsc = peer_dsc_find_uuid(peer,
BLE_UUID16_DECLARE(GATT_SPP_SVC_UUID),
BLE_UUID16_DECLARE(GATT_SPP_CHR_UUID),
BLE_UUID16_DECLARE(BLE_GATT_DSC_CLT_CFG_UUID16));
if (dsc == NULL) {
MODLOG_DFLT(ERROR, "Error: Peer lacks a CCCD for the Unread Alert "
"Status characteristic\n");
goto err;
}
value[0] = 1;
value[1] = 0;
rc = ble_gattc_write_flat(peer->conn_handle, dsc->dsc.handle,
value, sizeof value, NULL, NULL);
if (rc != 0) {
MODLOG_DFLT(ERROR, "Error: Failed to subscribe to characteristic; "
"rc=%d\n", rc);
goto err;
}
return;
err:
/* Terminate the connection. */
ble_gap_terminate(peer->conn_handle, BLE_ERR_REM_USER_CONN_TERM);
}
static void
ble_spp_client_set_handle(const struct peer *peer)
{
@ -34,8 +71,10 @@ ble_spp_client_set_handle(const struct peer *peer)
BLE_UUID16_DECLARE(GATT_SPP_SVC_UUID),
BLE_UUID16_DECLARE(GATT_SPP_CHR_UUID));
attribute_handle[peer->conn_handle] = chr->chr.val_handle;
}
/**
* Called when service discovery of the specified peer has completed.
*/
@ -58,6 +97,8 @@ ble_spp_client_on_disc_complete(const struct peer *peer, int status, void *arg)
"conn_handle=%d\n", status, peer->conn_handle);
ble_spp_client_set_handle(peer);
ble_spp_client_write_subscribe(peer);
#if CONFIG_BT_NIMBLE_MAX_CONNECTIONS > 1
ble_spp_client_scan();
#endif