dmamontov / esphome-blekeyboard

ESPHome BLE Keyboard
https://community.home-assistant.io/t/esphome-ble-keyboard/
84 stars 16 forks source link

Doesn't compile on latest ESPHome #3

Closed ThisIsTheOnlyUsernameAvailable closed 2 years ago

ThisIsTheOnlyUsernameAvailable commented 2 years ago

Hi!

Thanks for this library. It's a fantastic idea.

It doesn't look like it compiles on the latest ESPHome. I've tried with both Arduino and Espressif frameworks without success.

My basic YAML:

esphome:
  name: bt-test
  platformio_options: # Delete if you don't want to use NimBLE mode. More details: https://github.com/T-vK/ESP32-BLE-Keyboard#nimble-mode
    build_flags: -D USE_NIMBLE
  includes:
    - libraries/ble-2/keyboard.h
    - libraries/ble-2/keymap.h

  libraries:
    - ESP32 BLE Arduino@>=1.0.1
    - https://github.com/h2zero/NimBLE-Arduino/archive/refs/tags/1.3.2.zip
    - https://github.com/T-vK/ESP32-BLE-Keyboard/releases/download/0.3.1-beta/ESP32-BLE-Keyboard.zip

esp32:
  board: tinypico
  framework:
    type: arduino
    version: recommended

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: "<removed>"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Bt-Test Fallback Hotspot"
    password: "<removed>"

# captive_portal:

Compiling under Arduino does the following:

INFO Reading configuration /config/bt-test.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing bt-test (board: tinypico; framework: arduino; platform: platformio/espressif32 @ 3.5.0)
--------------------------------------------------------------------------------
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
Library Manager: Installing https://github.com/h2zero/NimBLE-Arduino/archive/refs/tags/1.3.2.zip

Unpacking  [####################################]  100%
Library Manager: NimBLE-Arduino @ 1.3.1 has been installed!
Library Manager: Installing https://github.com/T-vK/ESP32-BLE-Keyboard/releases/download/0.3.1-beta/ESP32-BLE-Keyboard.zip

Unpacking  [####################################]  100%
Library Manager: ESP32 BLE Keyboard @ 0.3.1 has been installed!
Dependency Graph
|-- <ESP32 BLE Arduino> 1.0.1
|-- <NimBLE-Arduino> 1.3.1
|-- <ESP32 BLE Keyboard> 0.3.1
|-- <WiFi> 1.0
|-- <ESPmDNS> 1.0
|-- <Update> 1.0
Compiling .pioenvs/bt-test/src/esphome/components/api/api_connection.cpp.o
Compiling .pioenvs/bt-test/src/esphome/components/api/api_frame_helper.cpp.o
Compiling .pioenvs/bt-test/src/esphome/components/api/api_pb2.cpp.o
Compiling .pioenvs/bt-test/src/esphome/components/api/api_pb2_service.cpp.o
Compiling .pioenvs/bt-test/src/esphome/components/api/api_server.cpp.o
Compiling .pioenvs/bt-test/src/esphome/components/api/list_entities.cpp.o
Compiling .pioenvs/bt-test/src/esphome/components/api/proto.cpp.o
Compiling .pioenvs/bt-test/src/esphome/components/api/subscribe_state.cpp.o
Compiling .pioenvs/bt-test/src/esphome/components/api/user_services.cpp.o
Compiling .pioenvs/bt-test/src/esphome/components/esp32/core.cpp.o
Compiling .pioenvs/bt-test/src/esphome/components/esp32/gpio_arduino.cpp.o
Compiling .pioenvs/bt-test/src/esphome/components/esp32/gpio_idf.cpp.o
Compiling .pioenvs/bt-test/src/esphome/components/esp32/preferences.cpp.o
Compiling .pioenvs/bt-test/src/esphome/components/logger/logger.cpp.o
Compiling .pioenvs/bt-test/src/esphome/components/md5/md5.cpp.o
Compiling .pioenvs/bt-test/src/esphome/components/mdns/mdns_component.cpp.o
Compiling .pioenvs/bt-test/src/esphome/components/mdns/mdns_esp32_arduino.cpp.o
Compiling .pioenvs/bt-test/src/esphome/components/mdns/mdns_esp8266.cpp.o
Compiling .pioenvs/bt-test/src/esphome/components/mdns/mdns_esp_idf.cpp.o
Compiling .pioenvs/bt-test/src/esphome/components/network/util.cpp.o
Compiling .pioenvs/bt-test/src/esphome/components/ota/ota_backend_arduino_esp32.cpp.o
Compiling .pioenvs/bt-test/src/esphome/components/ota/ota_backend_arduino_esp8266.cpp.o
Compiling .pioenvs/bt-test/src/esphome/components/ota/ota_backend_esp_idf.cpp.o
Compiling .pioenvs/bt-test/src/esphome/components/ota/ota_component.cpp.o
Compiling .pioenvs/bt-test/src/esphome/components/socket/bsd_sockets_impl.cpp.o
Compiling .pioenvs/bt-test/src/esphome/components/socket/lwip_raw_tcp_impl.cpp.o
Compiling .pioenvs/bt-test/src/esphome/components/socket/socket.cpp.o
Compiling .pioenvs/bt-test/src/esphome/components/wifi/wifi_component.cpp.o
Compiling .pioenvs/bt-test/src/esphome/components/wifi/wifi_component_esp32_arduino.cpp.o
Compiling .pioenvs/bt-test/src/esphome/components/wifi/wifi_component_esp8266.cpp.o
Compiling .pioenvs/bt-test/src/esphome/components/wifi/wifi_component_esp_idf.cpp.o
Compiling .pioenvs/bt-test/src/esphome/core/application.cpp.o
Compiling .pioenvs/bt-test/src/esphome/core/color.cpp.o
Compiling .pioenvs/bt-test/src/esphome/core/component.cpp.o
Compiling .pioenvs/bt-test/src/esphome/core/component_iterator.cpp.o
Compiling .pioenvs/bt-test/src/esphome/core/controller.cpp.o
Compiling .pioenvs/bt-test/src/esphome/core/entity_base.cpp.o
Compiling .pioenvs/bt-test/src/esphome/core/helpers.cpp.o
Compiling .pioenvs/bt-test/src/esphome/core/log.cpp.o
Compiling .pioenvs/bt-test/src/esphome/core/scheduler.cpp.o
Compiling .pioenvs/bt-test/src/esphome/core/util.cpp.o
Compiling .pioenvs/bt-test/src/main.cpp.o
Generating partitions .pioenvs/bt-test/partitions.bin
Compiling .pioenvs/bt-test/lib1c8/BLE/BLE2902.cpp.o
Compiling .pioenvs/bt-test/lib1c8/BLE/BLE2904.cpp.o
Compiling .pioenvs/bt-test/lib1c8/BLE/BLEAddress.cpp.o
Compiling .pioenvs/bt-test/lib1c8/BLE/BLEAdvertisedDevice.cpp.o
Compiling .pioenvs/bt-test/lib1c8/BLE/BLEAdvertising.cpp.o
Compiling .pioenvs/bt-test/lib1c8/BLE/BLEBeacon.cpp.o
In file included from src/main.cpp:20:0:
src/keyboard.h:45:5: error: 'BinarySensor' does not name a type
     BinarySensor *connected_binarysensor = new BinarySensor();
     ^
src/keyboard.h:46:5: error: 'Sensor' does not name a type
     Sensor *delay_sensor = new Sensor();
     ^
In file included from src/main.cpp:20:0:
src/keyboard.h: In member function 'virtual void Esp32BLEKeyboard::setup()':
src/keyboard.h:56:9: error: 'delay_sensor' was not declared in this scope
         delay_sensor->publish_state(8);
         ^
src/keyboard.h: In member function 'virtual void Esp32BLEKeyboard::update()':
src/keyboard.h:60:9: error: 'connected_binarysensor' was not declared in this scope
         connected_binarysensor->publish_state(bleKeyboard.isConnected());
         ^
src/keyboard.h: In member function 'void Esp32BLEKeyboard::release(std::__cxx11::string, uint32_t)':
src/keyboard.h:73:9: error: 'delay_sensor' was not declared in this scope
         delay_sensor->publish_state(delay_ms);
         ^
Compiling .pioenvs/bt-test/lib1c8/BLE/BLECharacteristic.cpp.o
*** [.pioenvs/bt-test/src/main.cpp.o] Error 1
========================== [FAILED] Took 5.76 seconds ==========================

Compiling under Esspresif:

INFO Reading configuration /config/bt-test.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing bt-test (board: tinypico; framework: espidf; platform: platformio/espressif32 @ 3.5.0)
--------------------------------------------------------------------------------
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
 - framework-espidf 3.40302.0 (4.3.2) 
 - tool-cmake 3.16.4 
 - tool-ninja 1.7.1 
 - toolchain-riscv32-esp 8.4.0+2021r2-patch2 
 - toolchain-xtensa-esp32 8.4.0+2021r2-patch2 
 - toolchain-xtensa-esp32s2 8.4.0+2021r2-patch2
Reading CMake configuration...
Library Manager: Installing ESP32 BLE Arduino @ >=1.0.1

Unpacking  [####################################]  100%
Library Manager: ESP32 BLE Arduino @ 1.0.1 has been installed!
Library Manager: Installing https://github.com/h2zero/NimBLE-Arduino/archive/refs/tags/1.3.2.zip

Unpacking  [####################################]  100%
Library Manager: NimBLE-Arduino @ 1.3.1 has been installed!
Library Manager: Installing https://github.com/T-vK/ESP32-BLE-Keyboard/releases/download/0.3.1-beta/ESP32-BLE-Keyboard.zip

Unpacking  [####################################]  100%
Library Manager: ESP32 BLE Keyboard @ 0.3.1 has been installed!
Generating assembly for certificate bundle...
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
No dependencies
Compiling .pioenvs/bt-test/src/esphome/components/api/api_connection.o
Compiling .pioenvs/bt-test/src/esphome/components/api/api_frame_helper.o
Compiling .pioenvs/bt-test/src/esphome/components/api/api_pb2.o
Compiling .pioenvs/bt-test/src/esphome/components/api/api_pb2_service.o
Compiling .pioenvs/bt-test/src/esphome/components/api/api_server.o
Compiling .pioenvs/bt-test/src/esphome/components/api/list_entities.o
Compiling .pioenvs/bt-test/src/esphome/components/api/proto.o
Compiling .pioenvs/bt-test/src/esphome/components/api/subscribe_state.o
Compiling .pioenvs/bt-test/src/esphome/components/api/user_services.o
Compiling .pioenvs/bt-test/src/esphome/components/esp32/core.o
Compiling .pioenvs/bt-test/src/esphome/components/esp32/gpio_arduino.o
Compiling .pioenvs/bt-test/src/esphome/components/esp32/gpio_idf.o
Compiling .pioenvs/bt-test/src/esphome/components/esp32/preferences.o
Compiling .pioenvs/bt-test/src/esphome/components/logger/logger.o
Compiling .pioenvs/bt-test/src/esphome/components/md5/md5.o
Compiling .pioenvs/bt-test/src/esphome/components/mdns/mdns_component.o
Compiling .pioenvs/bt-test/src/esphome/components/mdns/mdns_esp32_arduino.o
Compiling .pioenvs/bt-test/src/esphome/components/mdns/mdns_esp8266.o
Compiling .pioenvs/bt-test/src/esphome/components/mdns/mdns_esp_idf.o
Compiling .pioenvs/bt-test/src/esphome/components/network/util.o
Compiling .pioenvs/bt-test/src/esphome/components/ota/ota_backend_arduino_esp32.o
Compiling .pioenvs/bt-test/src/esphome/components/ota/ota_backend_arduino_esp8266.o
Compiling .pioenvs/bt-test/src/esphome/components/ota/ota_backend_esp_idf.o
Compiling .pioenvs/bt-test/src/esphome/components/ota/ota_component.o
Compiling .pioenvs/bt-test/src/esphome/components/socket/bsd_sockets_impl.o
Compiling .pioenvs/bt-test/src/esphome/components/socket/lwip_raw_tcp_impl.o
Compiling .pioenvs/bt-test/src/esphome/components/socket/socket.o
Compiling .pioenvs/bt-test/src/esphome/components/wifi/wifi_component.o
Compiling .pioenvs/bt-test/src/esphome/components/wifi/wifi_component_esp32_arduino.o
Compiling .pioenvs/bt-test/src/esphome/components/wifi/wifi_component_esp8266.o
Compiling .pioenvs/bt-test/src/esphome/components/wifi/wifi_component_esp_idf.o
Compiling .pioenvs/bt-test/src/esphome/core/application.o
Compiling .pioenvs/bt-test/src/esphome/core/color.o
Compiling .pioenvs/bt-test/src/esphome/core/component.o
Compiling .pioenvs/bt-test/src/esphome/core/component_iterator.o
Compiling .pioenvs/bt-test/src/esphome/core/controller.o
Compiling .pioenvs/bt-test/src/esphome/core/entity_base.o
Compiling .pioenvs/bt-test/src/esphome/core/helpers.o
Compiling .pioenvs/bt-test/src/esphome/core/log.o
Compiling .pioenvs/bt-test/src/esphome/core/scheduler.o
Compiling .pioenvs/bt-test/src/esphome/core/util.o
Compiling .pioenvs/bt-test/src/main.o
Generating LD script .pioenvs/bt-test/esp32_out.ld
In file included from src/main.cpp:15:
src/keyboard.h:4:10: fatal error: BleKeyboard.h: No such file or directory

*********************************************************************
* Looking for BleKeyboard.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:BleKeyboard.h"
* Web  > https://registry.platformio.org/search?q=header:BleKeyboard.h
*
*********************************************************************

 #include <BleKeyboard.h>
          ^~~~~~~~~~~~~~~
compilation terminated.
*** [.pioenvs/bt-test/src/main.o] Error 1
========================= [FAILED] Took 10.01 seconds =========================

Trying to meet the dependency just goes around in circles.

Any suggestions?

TIA.

jonathanrobichaud4 commented 2 years ago

Try using the latest version of nimble and blekeyboard (the links are in the readme) I was having issues with my esp constantly crashing and using the latest versions fixed that so maybe it will help.

dmamontov commented 2 years ago

@ThisIsTheOnlyUsernameAvailable I haven't had time to check yet. I'll try to update this week.

ThisIsTheOnlyUsernameAvailable commented 2 years ago

Try using the latest version of nimble and blekeyboard (the links are in the readme) I was having issues with my esp constantly crashing and using the latest versions fixed that so maybe it will help.

Thanks for the suggestion, but the issue remains with the latest releases of both libraries.

dmamontov commented 2 years ago

@ThisIsTheOnlyUsernameAvailable I tried on version 2022.4.0 everything compiles correctly. Maybe your esphome itself has not been updated correctly? build.log clean_build.log

ThisIsTheOnlyUsernameAvailable commented 2 years ago

I'm really sorry to have wasted your time, @dmamontov. I'll try to work out why my setup doesn't work and will post it here, in case anyone else has the same issue.

dmamontov commented 2 years ago

Not relevant. A new version has been released.