espressif / arduino-esp32

Arduino core for the ESP32
GNU Lesser General Public License v2.1
13.77k stars 7.44k forks source link

I tried to use "esp_hid_host_API" in Arduino, but compilation failed. How should I use this publicly available API #9371

Open hotbinz opened 8 months ago

hotbinz commented 8 months ago

Board

esp32wroom

Device Description

淘宝买的开发板

Hardware Configuration

None

Version

v2.0.14

IDE Name

arduino

Operating System

windows11

Flash frequency

40mhz

PSRAM enabled

yes

Upload speed

115200

Description

Compilation error occurred

Sketch

#include "testjoy.h"
#include "esp_hidh_api.h"
#include "esp_err.h"

bool TestJoy::begin() {
  if (!btStarted() && !btStart()) {
    printf("btStart failed");
    return false;
  }
  ESP_ERROR_CHECK(esp_bt_hid_host_deinit());
  printf("hid init!");
}

Debug Message

c: /users/huayu/appdata/local/arduino15/packages/esp32/tools/xtensa esp32 elf gcc/esp-2021r2 patch5-8.4.0/bin// Lib/gcc/xtensa esp32 elf/8.40/../../../..// Xtensa esp32 elf/bin/ld. exe: C: \ Users \ huayu \ AppData \ Local \ Temparaduino \ sketches \ E4CD6881C5474732B66C7D8A5C4328B5 \ sketches \ testjoy. cpp. o: (. literal. _ZN7TestJoy5beginEv+0x14): undefined reference to ` esp_bt_hid_host_deit '
c: /users/huayu/appdata/local/arduino15/packages/esp32/tools/xtensa esp32 elf gcc/esp-2021r2 patch5-8.4.0/bin// Lib/gcc/xtensa esp32 elf/8.40/../../../..// Xtensa-esp32 elf/bin/ld. exe: C: \ Users \ huayu \ AppData \ Local \ Temparaduino \ sketches \ E4CD6881C5474732B66C7D8A5C4328B5 \ sketches \ testjoy. cpp. o: in function ` TestJoy:: begin() ':
C: \ Users \ huayu \ Documents \ Arduino \ statelite/testjoy. cpp: 7: undefined reference to ` esp_bt_hid_host_deit '
Collect2. exe: error: ld returned 1 exit status
Exit status 1
Compilation error: exit status 1

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

me-no-dev commented 8 months ago

looks like you misspelled esp_bt_hid_host_deit and should be esp_bt_hid_host_deinit