Skip to content

Commit

Permalink
feat(bt/bluedroid): Added definition of minor class of COD for periph…
Browse files Browse the repository at this point in the history
…eral major class

Closes #13622
  • Loading branch information
boblane1 authored and espressif-bot committed Sep 26, 2024
1 parent c467c8e commit 4459865
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
22 changes: 22 additions & 0 deletions components/bt/host/bluedroid/api/include/api/esp_gap_bt_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,9 @@ void app_main(void)
esp_bt_gap_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);
Expand All @@ -451,7 +452,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;

Expand Down
3 changes: 2 additions & 1 deletion examples/bluetooth/esp_hid_device/main/esp_hid_device_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -903,8 +903,9 @@ void app_main(void)
ESP_LOGI(TAG, "setting device name");
esp_bt_gap_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");
Expand Down

0 comments on commit 4459865

Please sign in to comment.