mirror of
https://github.com/espressif/esp-idf
synced 2025-03-10 09:39:10 -04:00
fix(nimble): Fix compilation issue in esp_hid_host example
This commit is contained in:
parent
3341e73852
commit
f8ed8d8e25
@ -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;
|
||||
@ -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)
|
||||
{
|
||||
@ -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!");
|
||||
@ -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();
|
||||
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user