Skip to content

Commit

Permalink
Merge branch 'bugfix/fix_esp_hid_host_compilation_v5.2' into 'release…
Browse files Browse the repository at this point in the history
…/v5.2'

fix(nimble): Fix compilation issue in esp_hid_host example (v5.2)

See merge request espressif/esp-idf!35309
  • Loading branch information
rahult-github committed Dec 2, 2024
2 parents 0b4e4f6 + f8ed8d8 commit 1c4a310
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions examples/bluetooth/esp_hid_host/main/esp_hid_host_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ static const char *TAG = "ESP_HIDH_DEMO";
static const char * remote_device_name = CONFIG_EXAMPLE_PEER_DEVICE_NAME;
#endif // CONFIG_BT_HID_HOST_ENABLED

static char *bda2str(esp_bd_addr_t bda, char *str, size_t size)
#if !CONFIG_BT_NIMBLE_ENABLED
static char *bda2str(uint8_t *bda, char *str, size_t size)
{
if (bda == NULL || str == NULL || size < 18) {
return NULL;
Expand All @@ -66,6 +67,7 @@ static char *bda2str(esp_bd_addr_t bda, char *str, size_t size)
p[0], p[1], p[2], p[3], p[4], p[5]);
return str;
}
#endif

void hidh_callback(void *handler_args, esp_event_base_t base, int32_t id, void *event_data)
{
Expand Down Expand Up @@ -191,7 +193,6 @@ void ble_store_config_init(void);
#endif
void app_main(void)
{
char bda_str[18] = {0};
esp_err_t ret;
#if HID_HOST_MODE == HIDH_IDLE_MODE
ESP_LOGE(TAG, "Please turn on BT HID host or BLE!");
Expand All @@ -215,7 +216,12 @@ void app_main(void)
};
ESP_ERROR_CHECK( esp_hidh_init(&config) );

#if !CONFIG_BT_NIMBLE_ENABLED
char bda_str[18] = {0};
ESP_LOGI(TAG, "Own address:[%s]", bda2str((uint8_t *)esp_bt_dev_get_address(), bda_str, sizeof(bda_str)));
#endif


#if CONFIG_BT_NIMBLE_ENABLED
/* XXX Need to have template for store */
ble_store_config_init();
Expand All @@ -226,6 +232,28 @@ void app_main(void)
if (ret) {
ESP_LOGE(TAG, "esp_nimble_enable failed: %d", ret);
}

vTaskDelay(200);

uint8_t own_addr_type = 0;
int rc;
uint8_t addr_val[6] = {0};

rc = ble_hs_id_copy_addr(BLE_ADDR_PUBLIC, NULL, NULL);

rc = ble_hs_id_infer_auto(0, &own_addr_type);

if (rc != 0) {
ESP_LOGI(TAG, "error determining address type; rc=%d\n", rc);
return;
}

rc = ble_hs_id_copy_addr(own_addr_type, addr_val, NULL);

ESP_LOGI(TAG, "Device Address: ");
ESP_LOGI(TAG, "%02x:%02x:%02x:%02x:%02x:%02x \n", addr_val[5], addr_val[4], addr_val[3],
addr_val[2], addr_val[1], addr_val[0]);

#endif
xTaskCreate(&hid_demo_task, "hid_task", 6 * 1024, NULL, 2, NULL);
}

0 comments on commit 1c4a310

Please sign in to comment.