-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more configurable BLE characteristics
- Loading branch information
1 parent
3f51cc9
commit 884ddba
Showing
8 changed files
with
172 additions
and
23 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
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
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
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
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
49 changes: 49 additions & 0 deletions
49
examples/CharacteristicsConfiguration/CharacteristicsConfiguration.ino
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,49 @@ | ||
/* | ||
* Sets BLE characteristic options | ||
* Also shows how to set a custom MAC address | ||
* Use BLE Scanner etc on Android to see them | ||
*/ | ||
|
||
#include <Arduino.h> | ||
#include <BleGamepad.h> | ||
|
||
BleGamepad bleGamepad("Custom Contoller Name", "lemmingDev", 100); // Set custom device name, manufacturer and initial battery level | ||
BleGamepadConfiguration bleGamepadConfig; // Create a BleGamepadConfiguration object to store all of the options | ||
|
||
// Use the procedure below to set a custom Bluetooth MAC address | ||
// Compiler adds 0x02 to the last value of board's base MAC address to get the BT MAC address, so take 0x02 away from the value you actually want when setting | ||
// I've noticed the first number is a little picky and if set incorrectly don't work and will default to the board's embedded address | ||
// 0xAA definately works, so use that, or experiment | ||
uint8_t newMACAddress[] = {0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF - 0x02}; | ||
|
||
void setup() | ||
{ | ||
Serial.begin(115200); | ||
Serial.println("Starting BLE work!"); | ||
bleGamepadConfig.setAutoReport(false); | ||
bleGamepadConfig.setControllerType(CONTROLLER_TYPE_GAMEPAD); // CONTROLLER_TYPE_JOYSTICK, CONTROLLER_TYPE_GAMEPAD (DEFAULT), CONTROLLER_TYPE_MULTI_AXIS | ||
bleGamepadConfig.setVid(0xe502); | ||
bleGamepadConfig.setPid(0xabcd); | ||
|
||
bleGamepadConfig.setModelNumber("1.0"); | ||
bleGamepadConfig.setSoftwareRevision("Software Rev 1"); | ||
bleGamepadConfig.setSerialNumber("9876543210"); | ||
bleGamepadConfig.setFirmwareRevision("2.0"); | ||
bleGamepadConfig.setHardwareRevision("1.7"); | ||
|
||
// Some non-Windows operating systems and web based gamepad testers don't like min axis set below 0, so 0 is set by default | ||
//bleGamepadConfig.setAxesMin(0x8001); // -32767 --> int16_t - 16 bit signed integer - Can be in decimal or hexadecimal | ||
bleGamepadConfig.setAxesMin(0x0000); // 0 --> int16_t - 16 bit signed integer - Can be in decimal or hexadecimal | ||
bleGamepadConfig.setAxesMax(0x7FFF); // 32767 --> int16_t - 16 bit signed integer - Can be in decimal or hexadecimal | ||
|
||
bleGamepad.begin(&bleGamepadConfig); // Begin gamepad with configuration options | ||
esp_base_mac_addr_set(&newMACAddress[0]); // Set new MAC address | ||
} | ||
|
||
void loop() | ||
{ | ||
if (bleGamepad.isConnected()) | ||
{ | ||
|
||
} | ||
} |
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
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,10 +1,10 @@ | ||
name=ESP32-BLE-Gamepad | ||
version=0.5.1 | ||
version=0.5.2 | ||
author=lemmingDev | ||
maintainer=lemmingDev | ||
sentence=Bluetooth LE Gamepad library for the ESP32. | ||
paragraph=Bluetooth LE Gamepad library for the ESP32. | ||
category=Communication | ||
url=https://github.com/lemmingDev/ESP32-BLE-Gamepad | ||
architectures=esp32 | ||
depends=NimBLE-Arduino | ||
depends=NimBLE-Arduino |