bigjbehr / esp32-bluetooth-ble-remote-control Goto Github PK
View Code? Open in Web Editor NEWAn Example of using a BLE Remote Controller with an ESP32
An Example of using a BLE Remote Controller with an ESP32
I want to use this code in another opensource project under MIT license. Do you think it is possible to put a license file in so I do not have to rewrite the thing?
Hello,
I would like to thank you so much for your awesome work. It is very clear and well documented. Thanks to your code, I managed to create a connection between my esp32 dev board and my VR Box controller. Triggers and joystick are working perfectly. But the "B" buttons is not showing on the serial monitor. About the A, C and D, I let you see this pdf that shows my serial monitor : https://www.dropbox.com/s/9yv8pdn48ai4nl9/VRBOX%20buttons%20not%20working.pdf?dl=0
Could you help me to make the serial monitor displays the right buttons please ?
Again, thank you for your work, it helps me a lot !
Hi there! First of all, thank you for offering us this great contribution to connect an external controller!
I am facing an issue where my esp32 (Air mouse gyro) hangs every so often for about 10-20 seconds if I have the "vr-box"(is other different model but similar) paired to the esp32, even if I have commented out all the buttons on the vr-box so that they don't send nothing.
The blocking that I comment is similar to as if it had a delay in the movements and the Hz will drop in turn, do you have any idea why this could be happening, something like a buffer?
Another thing, do you think there would be a way to pair us for bt to the PlayStation?
Thank you very much dear friend!
Hi there,
I am trying to run your code (very useful by the way) with another gamepad, which of course uses the same HID service and similar layout (one joystick and 4 buttons). I run it on ESP32C3.
For some reason it does crash after the 4th notify callback is registered, does anyone have an idea of what the problem could be?I increased the stack size by 1024 bytes but it did not change anything.
Joystick Task Created
AB Button Task Created
CD Button Task Created
Starting ESP32 BLE Client...
BLE Advertised Device found: Name: , Address: 71:a0:e4:31:92:d5, manufacturer data: 060001092002f56b465dc6a555271d24da5e0085cdb558005eec8faca8
Server name does not match, not our server
BLE Advertised Device found: Name: BLE-M3, Address: 22:03:d7:00:24:00, appearance: 961, serviceUUID: 00001812-0000-1000-8000-00805f9b34fb
Found VRBOX Server
Server has HID service
Offline, start a scan
Forming a connection to 22:03:d7:00:24:00
- Created client
onConnect event
- Connected to server
- Found HID service
Characteristic UUID: 00002a4b-0000-1000-8000-00805f9b34fb
Found Characteristic UUID: 00002a4b-0000-1000-8000-00805f9b34fb
Characteristic UUID: 00002a4a-0000-1000-8000-00805f9b34fb
Found Characteristic UUID: 00002a4a-0000-1000-8000-00805f9b34fb
Characteristic UUID: 00002a4c-0000-1000-8000-00805f9b34fb
Found Characteristic UUID: 00002a4c-0000-1000-8000-00805f9b34fb
Characteristic UUID: 00002a4e-0000-1000-8000-00805f9b34fb
Found Characteristic UUID: 00002a4e-0000-1000-8000-00805f9b34fb
Characteristic UUID: 00002a4d-0000-1000-8000-00805f9b34fb
Found a report characteristic
Can notify
Notify callback for characteristic 00002a4d-0000-1000-8000-00805f9b34fb of data length 9
data: 00 93 00 C8 00 8E 03 8E 03
Callback registered for: Handle: 0x00000020, 32
Characteristic UUID: 00002a4d-0000-1000-8000-00805f9b34fb
Found a report characteristic
Can notify
Notify callback for characteristic 00002a4d-0000-1000-8000-00805f9b34fb of data length 9
data: 00 93 00 C8 00 8E 03 8E 03
Callback registered for: Handle: 0x00000026, 38
Characteristic UUID: 00002a4d-0000-1000-8000-00805f9b34fb
Found a report characteristic
Can notify
Notify callback for characteristic 00002a4d-0000-1000-8000-00805f9b34fb of data length 9
data: 00 93 00 C8 00 8E 03 8E 03
Callback registered for: Handle: 0x0000002C, 44
Characteristic UUID: 00002a4d-0000-1000-8000-00805f9b34fb
Found a report characteristic
Can notify
Notify callback for characteristic 00002a4d-0000-1000-8000-00805f9b34fb of data length 9
data: 00 93 00 C8 00 8E 03 8E 03
Callback registered for: Handle: 0x00000032, 50
/* crash occurs here*/ ESP-ROM:esp32c3-api1-20210207
Not sure what the cause is. Sadly on the C3 there is no exception decoder (yet) so i cannot see the exact cause of the issue.
If anyone has an idea on what the problem could be, it will be very welcome.
Thanks
Greetings and thank you - it's a tremendous amount of work. I'm experiencing a constant reboot after successfully connecting to the server, in my case VR-PARK. The ESP32 reboots with the error:
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x40090653 PS : 0x00060e30 A0 : 0x800d4a20 A1 : 0x3ffc90a0
A2 : 0x3ffc90db A3 : 0x00000001 A4 : 0x00000013 A5 : 0x3ffc90db
A6 : 0x00000057 A7 : 0x3ffc8f10 A8 : 0x800d7e38 A9 : 0x3ffc9070
A10 : 0x00000002 A11 : 0x3f403dff A12 : 0x00000057 A13 : 0x0000ff00
A14 : 0x00ff0000 A15 : 0xff000000 SAR : 0x00000020 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000001 LBEG : 0x40090d2d LEND : 0x40090d3d LCOUNT : 0xffffffff
Backtrace: 0x40090650:0x3ffc90a0 0x400d4a1d:0x3ffc90b0 0x400d2002:0x3ffc90d0 0x400d236d:0x3ffc9150 0x400d2746:0x3ffc91a0 0x400d8bdd:0x3ffc91e0
It rescans, reconnects, and then goes into a reboot. As you advised, I tried increasing #define TaskStackSize by 1024, but I've reached the maximum of 288KB, and the errors have not stopped. The SDK, BLE lib has current versions, please help?
sorry, maybe a bit of a noob question but i'm trying to compile the code and i'm getting this on my Arduino IDE:
am I missing something? is it possible I just need to update my esp32 Arduino IDE libraries?
I get the following error messages when compiling ...
"/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/xtensa-esp32-elf/bin/xtensa-esp32-elf-g++" -DESP_PLATFORM -DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h" -DHAVE_CONFIG_H "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/config" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/bluedroid" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/app_trace" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/app_update" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/bootloader_support" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/bt" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/driver" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/esp32" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/esp_adc_cal" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/ethernet" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/fatfs" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/freertos" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/heap" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/jsmn" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/log" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/mdns" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/mbedtls" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/mbedtls_port" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/newlib" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/nvs_flash" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/openssl" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/spi_flash" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/sdmmc" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/spiffs" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/tcpip_adapter" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/ulp" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/vfs" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/wear_levelling" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/xtensa-debug-module" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/coap" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/console" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/expat" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/json" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/lwip" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/newlib" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/nghttp" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/soc" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/tools/sdk/include/wpa_supplicant" -std=gnu++11 -fno-exceptions -Os -g3 -Wpointer-arith -fexceptions -fstack-protector -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -mlongcalls -nostdlib -w -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -fno-rtti -MMD -c -DF_CPU=240000000L -DARDUINO=10805 -DARDUINO_LOLIN32 -DARDUINO_ARCH_ESP32 -DARDUINO_BOARD="LOLIN32" -DARDUINO_VARIANT="lolin32" -DESP32 -DCORE_DEBUG_LEVEL=0 "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/cores/esp32" "-I/home/heikoch/bin/arduino-1.8.5/hardware/espressif/esp32/variants/lolin32" "/tmp/arduino_build_568207/sketch/Gatt-VRBOX-Tasks.ino.cpp" -o "/tmp/arduino_build_568207/sketch/Gatt-VRBOX-Tasks.ino.cpp.o"
/home/heikoch/Arduino/ESP32-Bluetooth-BLE-Remote-Control/Gatt-VRBOX-Tasks/Gatt-VRBOX-Tasks.ino: In function 'void gattc_profile_event_handler(esp_gattc_cb_event_t, esp_gatt_if_t, esp_ble_gattc_cb_param_t*, int)':
Gatt-VRBOX-Tasks:415: error: cannot convert 'bool' to 'esp_ble_addr_type_t' for argument '3' to 'esp_err_t esp_ble_gattc_open(esp_gatt_if_t, uint8_t*, esp_ble_addr_type_t, bool)'
esp_ble_gattc_open(profiles[BATTERY_PROFILE].gattc_if, profiles[BATTERY_PROFILE].remote_bda, true);
^
/home/heikoch/Arduino/ESP32-Bluetooth-BLE-Remote-Control/Gatt-VRBOX-Tasks/Gatt-VRBOX-Tasks.ino: In function 'void esp_gap_cb(esp_gap_ble_cb_event_t, esp_ble_gap_cb_param_t*)':
Gatt-VRBOX-Tasks:582: error: cannot convert 'bool' to 'esp_ble_addr_type_t' for argument '3' to 'esp_err_t esp_ble_gattc_open(esp_gatt_if_t, uint8_t*, esp_ble_addr_type_t, bool)'
esp_ble_gattc_open(profiles[HID_PROFILE].gattc_if, scan_result->scan_rst.bda, true);
^
exit status 1
cannot convert 'bool' to 'esp_ble_addr_type_t' for argument '3' to 'esp_err_t esp_ble_gattc_open(esp_gatt_if_t, uint8_t*, esp_ble_addr_type_t, bool)'
Does somebody has any idea?
Thanks Heiko
Hi, thanks for this great work. I want to test it with a different joystick, but when I upload the code BLE-VRBOX.ino, I get a compilation error:
sketch\Test_BLE_joystick.ino.cpp.o:(.literal._Z20setupCharacteristicsP16BLERemoteServicePFvP23BLERemoteCharacteristicPhjbE+0x28): undefined reference to `BLERemoteService::getCharacteristicsByHandle()'
sketch\Test_BLE_joystick.ino.cpp.o: In function `setupCharacteristics(BLERemoteService*, void (*)(BLERemoteCharacteristic*, unsigned char*, unsigned int, bool))':
C:\Users\fa125436\Documents\Arduino\Test_BLE_joystick/Test_BLE_joystick.ino:256: undefined reference to `BLERemoteService::getCharacteristicsByHandle()'
collect2.exe: error: ld returned 1 exit status
Plusieurs bibliothèque trouvées pour "BLEDevice.h"
Utilisé : C:\Users\xxx\Documents\Arduino\libraries\ESP32_BLE_Arduino
Non utilisé : C:\Users\xxx\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5\libraries\BLE
exit status 1
Erreur de compilation pour la carte ESP32 Dev Module
Do you know what is wrong?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.