-
-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3bed927
commit feb72c3
Showing
20 changed files
with
222 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Esp32 Bluetooth | ||
=============== | ||
|
||
All related libraries for Bluetooth support. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
COMPONENT_LIBNAME := | ||
|
||
COMPONENT_DEPENDS := esp32 | ||
|
||
EXTRA_LIBS += btdm_app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
ESP32 BLE Gamepad library | ||
========================== | ||
|
||
.. highlight:: c++ | ||
|
||
Introduction | ||
------------ | ||
This library allows you to make the ESP32 act as a Bluetooth gamepad and control what it does. | ||
The library uses :library:`NimBLE` for faster and lighter communication. | ||
|
||
Features | ||
-------- | ||
|
||
Using this library you can do the following: | ||
|
||
- Button press (128 buttons) | ||
- Button release (128 buttons) | ||
- Axes movement (6 axes (16 bit) (x, y, z, rZ, rX, rY) --> (Left Thumb X, Left Thumb Y, Right Thumb X, Right Thumb Y, Left Trigger, Right Trigger)) | ||
- 2 Sliders (16 bit) (Slider 1 and Slider 2) | ||
- 4 point of view hats (ie. d-pad plus 3 other hat switches) | ||
- Simulation controls (rudder, throttle, accelerator, brake, steering) | ||
- Configurable HID descriptor | ||
- Report optional battery level to host (basically works, but it doesn't show up in Android's status bar) | ||
- Customize Bluetooth device name/manufacturer | ||
- Uses efficient NimBLE bluetooth library | ||
- Compatible with Windows | ||
- Compatible with Android (Android OS maps default buttons / axes / hats slightly differently than Windows) | ||
- Compatible with Linux (limited testing) | ||
- Compatible with MacOS X (limited testing) | ||
|
||
Using | ||
----- | ||
|
||
1. Add ``COMPONENT_DEPENDS += BLEGamepad`` to your application componenent.mk file. | ||
2. Add these lines to your application:: | ||
|
||
#include <BleGamepad.h> | ||
namespace | ||
{ | ||
BleGamepad bleGamepad; | ||
// ... | ||
} // namespace | ||
void init() | ||
{ | ||
// ... | ||
bleGamepad.begin(); | ||
} | ||
|
||
|
||
Notes | ||
----- | ||
By default, reports are sent on every button press/release or axis/slider/hat/simulation movement, however this can be disabled, | ||
and then you manually call sendReport on the gamepad instance as shown in the IndividualAxes.ino example. | ||
|
||
There is also Bluetooth specific information that you can use (optional): | ||
|
||
Instead of `BleGamepad bleGamepad;` you can do `BleGamepad bleGamepad("Bluetooth Device Name", "Bluetooth Device Manufacturer", 100);`. | ||
The third parameter is the initial battery level of your device. | ||
Adjusting the battery level later on doesn't work. | ||
By default the battery level will be set to 100%, the device name will be `ESP32 BLE Gamepad` and the manufacturer will be `Espressif`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
COMPONENT_SUBMODULES := ESP32-BLE-Gamepad | ||
COMPONENT_SOC := esp32 | ||
COMPONENT_SOC := esp32* | ||
COMPONENT_DEPENDS := NimBLE | ||
|
||
COMPONENT_SRCDIRS := ESP32-BLE-Gamepad | ||
COMPONENT_INCDIRS := $(COMPONENT_SRCDIRS) | ||
|
||
COMPONENT_CPPFLAGS:= -DUSE_NIMBLE=1 | ||
APP_CFLAGS += -DUSE_NIMBLE=1 | ||
APP_CFLAGS += -DUSE_NIMBLE=1 |
25 changes: 12 additions & 13 deletions
25
Sming/Libraries/BLEGamepad/samples/Bluetooth_Gamepad/README.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
Basic Blink | ||
=========== | ||
Bluetooth Gamepad | ||
================= | ||
|
||
Simple blink example to confirm that the basic build system is working with your system. | ||
This sample turns the ESP32 into a Bluetooth LE gamepad that presses buttons and moves axis | ||
|
||
We use Timer instead of a loop because we want to allow WiFi communications to work in the background. | ||
See :doc:`/information/multitasking`. | ||
Possible buttons are: BUTTON_1 through to BUTTON_16 | ||
(16 buttons supported by default. Library can be configured to support up to 128) | ||
|
||
The LED on many development boards is connected to GPIO2, so this is the default. | ||
Possible DPAD/HAT switch position values are: | ||
DPAD_CENTERED, DPAD_UP, DPAD_UP_RIGHT, DPAD_RIGHT, DPAD_DOWN_RIGHT, DPAD_DOWN, DPAD_DOWN_LEFT, DPAD_LEFT, DPAD_UP_LEFT | ||
(or HAT_CENTERED, HAT_UP etc) | ||
|
||
If you get no response then check the documentation or schematic as your system | ||
may differ and change the LED_PIN definition accordingly. | ||
bleGamepad.setAxes takes the following int16_t parameters for the Left/Right Thumb X/Y, Left/Right Triggers plus slider1 and slider2, and hat switch position as above: | ||
(Left Thumb X, Left Thumb Y, Right Thumb X, Right Thumb Y, Left Trigger, Right Trigger, Hat switch position ^ (1 hat switch (dpad) supported by default. Library can be configured to support up to 4) | ||
|
||
For example, the NodeMCU ESP-C3 kits have an RGB LED connected to GPIO 3, 4 & 5. | ||
|
||
|
||
.. image:: blink.jpg | ||
:height: 192px | ||
Library can also be configured to support up to 5 simulation controls (can be set with setSimulationControls) | ||
(rudder, throttle, accelerator, brake, steering), but they are not enabled by default. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Sming/Libraries/BLEGamepad/samples/Bluetooth_Gamepad/component.mk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
COMPONENT_DEPENDS := BLEGamepad | ||
COMPONENT_DEPENDS := BLEGamepad |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
ESP32 BLE Keyboard library | ||
========================== | ||
|
||
.. highlight:: c++ | ||
|
||
Introduction | ||
------------ | ||
This library allows you to make the ESP32 act as a Bluetooth keyboard and control what it does. | ||
The library uses :library:`NimBLE` for faster and lighter communication. | ||
|
||
Features | ||
-------- | ||
|
||
Using this library you can do the following: | ||
|
||
- Send key strokes | ||
- Send text | ||
- Press/release individual keys | ||
- Media keys are supported | ||
- Set battery level (basically works, but doesn't show up in Android's status bar) | ||
- Compatible with Android | ||
- Compatible with Windows | ||
- Compatible with Linux | ||
- Compatible with MacOS X (not stable, some people have issues, doesn't work with old devices) | ||
- Compatible with iOS (not stable, some people have issues, doesn't work with old devices) | ||
|
||
Using | ||
----- | ||
|
||
1. Add ``COMPONENT_DEPENDS += BLEKeyboard`` to your application componenent.mk file. | ||
2. Add these lines to your application:: | ||
|
||
#include <BleKeyboard.h> | ||
|
||
namespace | ||
{ | ||
BleKeyboard bleKeyboard; | ||
// ... | ||
} // namespace | ||
void init() | ||
{ | ||
// ... | ||
bleKeyboard.begin(); | ||
} | ||
|
||
|
||
API documentation | ||
----------------- | ||
The BleKeyboard interface is almost identical to the Keyboard Interface, so you can use documentation right here: | ||
https://www.arduino.cc/reference/en/language/functions/usb/keyboard/ | ||
|
||
In addition to that you can send media keys (which is not possible with the USB keyboard library). Supported are the following: | ||
|
||
- KEY_MEDIA_NEXT_TRACK | ||
- KEY_MEDIA_PREVIOUS_TRACK | ||
- KEY_MEDIA_STOP | ||
- KEY_MEDIA_PLAY_PAUSE | ||
- KEY_MEDIA_MUTE | ||
- KEY_MEDIA_VOLUME_UP | ||
- KEY_MEDIA_VOLUME_DOWN | ||
- KEY_MEDIA_WWW_HOME | ||
- KEY_MEDIA_LOCAL_MACHINE_BROWSER // Opens "My Computer" on Windows | ||
- KEY_MEDIA_CALCULATOR | ||
- KEY_MEDIA_WWW_BOOKMARKS | ||
- KEY_MEDIA_WWW_SEARCH | ||
- KEY_MEDIA_WWW_STOP | ||
- KEY_MEDIA_WWW_BACK | ||
- KEY_MEDIA_CONSUMER_CONTROL_CONFIGURATION // Media Selection | ||
- KEY_MEDIA_EMAIL_READER | ||
|
||
There is also Bluetooth specific information that you can set (optional): | ||
Instead of `BleKeyboard bleKeyboard;` you can do `BleKeyboard bleKeyboard("Bluetooth Device Name", "Bluetooth Device Manufacturer", 100);`. (Max length is 15 characters, anything beyond that will be truncated.) | ||
The third parameter is the initial battery level of your device. To adjust the battery level later on you can simply call e.g. `bleKeyboard.setBatteryLevel(50)` (set battery level to 50%). | ||
By default the battery level will be set to 100%, the device name will be `ESP32 Bluetooth Keyboard` and the manufacturer will be `Espressif`. | ||
There is also a `setDelay` method to set a delay between each key event. E.g. `bleKeyboard.setDelay(10)` (10 milliseconds). The default is `8`. | ||
This feature is meant to compensate for some applications and devices that can't handle fast input and will skip letters if too many keys are sent in a small time frame. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
COMPONENT_SUBMODULES := ESP32-BLE-Keyboard | ||
COMPONENT_SOC := esp32 | ||
COMPONENT_SOC := esp32* | ||
COMPONENT_DEPENDS := NimBLE | ||
|
||
COMPONENT_SRCDIRS := ESP32-BLE-Keyboard | ||
COMPONENT_INCDIRS := $(COMPONENT_SRCDIRS) | ||
|
||
COMPONENT_CPPFLAGS:= -DUSE_NIMBLE=1 | ||
APP_CFLAGS += -DUSE_NIMBLE=1 | ||
APP_CFLAGS += -DUSE_NIMBLE=1 |
31 changes: 13 additions & 18 deletions
31
Sming/Libraries/BLEKeyboard/samples/Bluetooth_Keyboard/README.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,13 @@ | ||
Basic Blink | ||
=========== | ||
|
||
Simple blink example to confirm that the basic build system is working with your system. | ||
|
||
We use Timer instead of a loop because we want to allow WiFi communications to work in the background. | ||
See :doc:`/information/multitasking`. | ||
|
||
The LED on many development boards is connected to GPIO2, so this is the default. | ||
|
||
If you get no response then check the documentation or schematic as your system | ||
may differ and change the LED_PIN definition accordingly. | ||
|
||
For example, the NodeMCU ESP-C3 kits have an RGB LED connected to GPIO 3, 4 & 5. | ||
|
||
|
||
.. image:: blink.jpg | ||
:height: 192px | ||
Bluetooth Keyboard | ||
================== | ||
|
||
This sample demonstrates how to turn an Esp32 device into external keyboard. | ||
The "keyboard" and your PC will be communicating using Bluetooth Low Energy (BLE). | ||
The "keyboard" will write words, press Enter, press a media key and, if enabled in the sample code, Ctrl+Alt+Delete. | ||
|
||
Usage | ||
----- | ||
Once this sample is flashed and running on your ESP32 you can test it. | ||
Open a new text editor on your PC. Then search from your PC for new bluetooth devices. | ||
A device named "Sming BLE Keyboard" should show up. Connect to it and focus/open you text editor window. | ||
Be fast. Soon enough a "Hello World" text will start to be "magically" typed inside your text editor. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
Sming/Libraries/BLEKeyboard/samples/Bluetooth_Keyboard/component.mk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
COMPONENT_DEPENDS := BLEKeyboard | ||
COMPONENT_SOC := esp32* | ||
|
||
COMPONENT_DEPENDS := BLEKeyboard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
ESP32 NimBLE | ||
============ | ||
|
||
.. highlight:: c++ | ||
|
||
Introduction | ||
------------ | ||
NimBLE is a completely open source Bluetooth Low Energy (BLE) stack produced by `Apache <https://github.com/apache/mynewt-nimble>`_. | ||
It is more suited to resource constrained devices than bluedroid and has now been ported to the ESP32 by Espressif. | ||
|
||
Using | ||
----- | ||
|
||
1. Add ``COMPONENT_DEPENDS += NimBLE`` to your application componenent.mk file. | ||
2. Add these lines to your application:: | ||
|
||
#include <NimBLEDevice.h> | ||
void init() | ||
{ | ||
// ... | ||
BLEDevice::init(""); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
COMPONENT_SUBMODULES := esp-nimble-cpp | ||
COMPONENT_SOC := esp32 | ||
COMPONENT_SOC := esp32* | ||
|
||
COMPONENT_SRCDIRS := esp-nimble-cpp/src | ||
COMPONENT_INCDIRS := $(COMPONENT_SRCDIRS) |
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
Sming/Libraries/NimBLE/samples/Bluetooth_Client/README.rst
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
Sming/Libraries/NimBLE/samples/Bluetooth_Client/app/application.cpp
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.