Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ESP32 BLE libraries, apply fixes #2847

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 112 additions & 2 deletions Sming/Libraries/BLEGamepad/ESP32-BLE-Gamepad.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/BleGamepad.cpp b/BleGamepad.cpp
index 212e6d7..f7fc502 100644
index 4df4796..e0cbf0c 100644
--- a/BleGamepad.cpp
+++ b/BleGamepad.cpp
@@ -834,8 +834,7 @@ void BleGamepad::release(uint8_t b)
@@ -843,8 +843,7 @@ void BleGamepad::release(uint8_t b)

uint8_t BleGamepad::specialButtonBitPosition(uint8_t b)
{
Expand All @@ -12,3 +12,113 @@ index 212e6d7..f7fc502 100644
uint8_t bit = 0;
for (int i = 0; i < b; i++)
{
diff --git a/BleGamepad.h b/BleGamepad.h
index ab17740..28752e5 100644
--- a/BleGamepad.h
+++ b/BleGamepad.h
@@ -107,7 +107,7 @@ public:
std::string deviceName;

protected:
- virtual void onStarted(NimBLEServer *pServer){};
+ virtual void onStarted(NimBLEServer *){};
};

#endif // CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
diff --git a/BleConnectionStatus.cpp b/BleConnectionStatus.cpp
index 5d11694..f2fa751 100644
--- a/BleConnectionStatus.cpp
+++ b/BleConnectionStatus.cpp
@@ -4,13 +4,13 @@ BleConnectionStatus::BleConnectionStatus(void)
{
}

-void BleConnectionStatus::onConnect(NimBLEServer *pServer, ble_gap_conn_desc* desc)
+void BleConnectionStatus::onConnect(NimBLEServer* pServer, NimBLEConnInfo& connInfo)
{
- pServer->updateConnParams(desc->conn_handle, 6, 7, 0, 600);
- this->connected = true;
+ pServer->updateConnParams(connInfo.getConnHandle(), 6, 7, 0, 600);
+ this->connected = true;
}

-void BleConnectionStatus::onDisconnect(NimBLEServer *pServer)
+void BleConnectionStatus::onDisconnect(NimBLEServer*, NimBLEConnInfo&, int)
{
- this->connected = false;
+ this->connected = false;
}
diff --git a/BleConnectionStatus.h b/BleConnectionStatus.h
index 15997f4..b99fd6f 100644
--- a/BleConnectionStatus.h
+++ b/BleConnectionStatus.h
@@ -14,8 +14,8 @@ class BleConnectionStatus : public NimBLEServerCallbacks
public:
BleConnectionStatus(void);
bool connected = false;
- void onConnect(NimBLEServer *pServer, ble_gap_conn_desc* desc);
- void onDisconnect(NimBLEServer *pServer);
+ void onConnect(NimBLEServer* pServer, NimBLEConnInfo& connInfo) override;
+ void onDisconnect(NimBLEServer* pServer, NimBLEConnInfo& connInfo, int reason) override;
NimBLECharacteristic *inputGamepad;
};

diff --git a/BleGamepadConfiguration.cpp b/BleGamepadConfiguration.cpp
index 87f50ee..5004ee6 100644
--- a/BleGamepadConfiguration.cpp
+++ b/BleGamepadConfiguration.cpp
@@ -114,11 +114,11 @@ bool BleGamepadConfiguration::getIncludeAccelerator() { return _whichSimulationC
bool BleGamepadConfiguration::getIncludeBrake() { return _whichSimulationControls[BRAKE]; }
bool BleGamepadConfiguration::getIncludeSteering() { return _whichSimulationControls[STEERING]; }
const bool *BleGamepadConfiguration::getWhichSimulationControls() const { return _whichSimulationControls; }
-char *BleGamepadConfiguration::getModelNumber(){ return _modelNumber; }
-char *BleGamepadConfiguration::getSoftwareRevision(){ return _softwareRevision; }
-char *BleGamepadConfiguration::getSerialNumber(){ return _serialNumber; }
-char *BleGamepadConfiguration::getFirmwareRevision(){ return _firmwareRevision; }
-char *BleGamepadConfiguration::getHardwareRevision(){ return _hardwareRevision; }
+const char *BleGamepadConfiguration::getModelNumber(){ return _modelNumber; }
+const char *BleGamepadConfiguration::getSoftwareRevision(){ return _softwareRevision; }
+const char *BleGamepadConfiguration::getSerialNumber(){ return _serialNumber; }
+const char *BleGamepadConfiguration::getFirmwareRevision(){ return _firmwareRevision; }
+const char *BleGamepadConfiguration::getHardwareRevision(){ return _hardwareRevision; }

void BleGamepadConfiguration::setWhichSpecialButtons(bool start, bool select, bool menu, bool home, bool back, bool volumeInc, bool volumeDec, bool volumeMute)
{
diff --git a/BleGamepadConfiguration.h b/BleGamepadConfiguration.h
index 598543f..daf4d03 100644
--- a/BleGamepadConfiguration.h
+++ b/BleGamepadConfiguration.h
@@ -217,11 +217,11 @@ private:
int16_t _axesMax;
int16_t _simulationMin;
int16_t _simulationMax;
- char *_modelNumber;
- char *_softwareRevision;
- char *_serialNumber;
- char *_firmwareRevision;
- char *_hardwareRevision;
+ const char *_modelNumber;
+ const char *_softwareRevision;
+ const char *_serialNumber;
+ const char *_firmwareRevision;
+ const char *_hardwareRevision;

public:
BleGamepadConfiguration();
@@ -267,11 +267,11 @@ public:
int16_t getAxesMax();
int16_t getSimulationMin();
int16_t getSimulationMax();
- char *getModelNumber();
- char *getSoftwareRevision();
- char *getSerialNumber();
- char *getFirmwareRevision();
- char *getHardwareRevision();
+ const char *getModelNumber();
+ const char *getSoftwareRevision();
+ const char *getSerialNumber();
+ const char *getFirmwareRevision();
+ const char *getHardwareRevision();

void setControllerType(uint8_t controllerType);
void setAutoReport(bool value);
2 changes: 2 additions & 0 deletions Sming/Libraries/BLEGamepad/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ COMPONENT_INCDIRS := $(COMPONENT_SRCDIRS)

COMPONENT_CPPFLAGS:= -DUSE_NIMBLE=1
APP_CFLAGS += -DUSE_NIMBLE=1

COMPONENT_CXXFLAGS := -Wno-unused-parameter
2 changes: 1 addition & 1 deletion Sming/Libraries/BLEKeyboard/ESP32-BLE-Keyboard
25 changes: 13 additions & 12 deletions Sming/Libraries/BLEKeyboard/ESP32-BLE-Keyboard.patch
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
diff --git a/BleKeyboard.cpp b/BleKeyboard.cpp
index 0d043f4..d317e83 100644
index 48a8930..72b0253 100644
--- a/BleKeyboard.cpp
+++ b/BleKeyboard.cpp
@@ -499,7 +499,7 @@ size_t BleKeyboard::write(const uint8_t *buffer, size_t size) {
@@ -500,7 +500,7 @@ size_t BleKeyboard::write(const uint8_t *buffer, size_t size) {
return n;
}

-void BleKeyboard::onConnect(BLEServer* pServer) {
+void BleKeyboard::onConnect(BLEServer* pServer, BLEConnInfo& connInfo) {
+void BleKeyboard::onConnect(BLEServer*, BLEConnInfo&) {
this->connected = true;

#if !defined(USE_NIMBLE)
@@ -513,7 +513,7 @@ void BleKeyboard::onConnect(BLEServer* pServer) {
@@ -514,7 +514,7 @@ void BleKeyboard::onConnect(BLEServer* pServer) {

}

-void BleKeyboard::onDisconnect(BLEServer* pServer) {
+void BleKeyboard::onDisconnect(BLEServer* pServer, BLEConnInfo& connInfo, int reason) {
+void BleKeyboard::onDisconnect(BLEServer*, BLEConnInfo&, int) {
this->connected = false;

#if !defined(USE_NIMBLE)
@@ -528,7 +528,7 @@ void BleKeyboard::onDisconnect(BLEServer* pServer) {
@@ -529,7 +529,7 @@ void BleKeyboard::onDisconnect(BLEServer* pServer) {
#endif // !USE_NIMBLE
}

-void BleKeyboard::onWrite(BLECharacteristic* me) {
+void BleKeyboard::onWrite(BLECharacteristic* me, BLEConnInfo& connInfo) {
+void BleKeyboard::onWrite(BLECharacteristic* me, BLEConnInfo&) {
uint8_t* value = (uint8_t*)(me->getValue().c_str());
(void)value;
ESP_LOGI(LOG_TAG, "special keys: %d", *value);
@@ -539,8 +539,8 @@ void BleKeyboard::delay_ms(uint64_t ms) {
@@ -540,8 +540,8 @@ void BleKeyboard::delay_ms(uint64_t ms) {
if(ms){
uint64_t e = (m + (ms * 1000));
if(m > e){ //overflow
Expand All @@ -40,9 +40,8 @@ index 0d043f4..d317e83 100644
+ while(uint64_t(esp_timer_get_time()) < e) {}
}
}
\ No newline at end of file
diff --git a/BleKeyboard.h b/BleKeyboard.h
index 0736a02..e72216d 100644
index 0736a02..9299394 100644
--- a/BleKeyboard.h
+++ b/BleKeyboard.h
@@ -11,6 +11,7 @@
Expand All @@ -53,13 +52,15 @@ index 0736a02..e72216d 100644
#define BLEDevice NimBLEDevice
#define BLEServerCallbacks NimBLEServerCallbacks
#define BLECharacteristicCallbacks NimBLECharacteristicCallbacks
@@ -173,9 +174,9 @@ public:
@@ -172,10 +173,10 @@ public:
void set_product_id(uint16_t pid);
void set_version(uint16_t version);
protected:
virtual void onStarted(BLEServer *pServer) { };
- virtual void onStarted(BLEServer *pServer) { };
- virtual void onConnect(BLEServer* pServer) override;
- virtual void onDisconnect(BLEServer* pServer) override;
- virtual void onWrite(BLECharacteristic* me) override;
+ virtual void onStarted(BLEServer*) { };
+ virtual void onConnect(BLEServer* pServer, BLEConnInfo& connInfo) override;
+ virtual void onDisconnect(BLEServer* pServer, BLEConnInfo& connInfo, int reason) override;
+ virtual void onWrite(BLECharacteristic* me, BLEConnInfo& connInfo) override;
Expand Down
2 changes: 2 additions & 0 deletions Sming/Libraries/BLEKeyboard/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ COMPONENT_INCDIRS := $(COMPONENT_SRCDIRS)

COMPONENT_CPPFLAGS:= -DUSE_NIMBLE=1
APP_CFLAGS += -DUSE_NIMBLE=1

COMPONENT_CXXFLAGS := -Wno-unused-parameter
2 changes: 2 additions & 0 deletions Sming/Libraries/NimBLE/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ COMPONENT_SOC := esp32 esp32c3 esp32s3

COMPONENT_SRCDIRS := esp-nimble-cpp/src
COMPONENT_INCDIRS := $(COMPONENT_SRCDIRS)

COMPONENT_CXXFLAGS := -Wno-unused-parameter
2 changes: 1 addition & 1 deletion Sming/Libraries/NimBLE/esp-nimble-cpp
Submodule esp-nimble-cpp updated 41 files
+15 −6 .github/workflows/build.yml
+8 −0 CMakeLists.txt
+280 −172 docs/Doxyfile
+1 −1 docs/Improvements_and_updates.md
+12 −7 docs/Migration_guide.md
+86 −84 examples/Advanced/NimBLE_Client/main/main.cpp
+34 −34 examples/Advanced/NimBLE_Server/main/main.cpp
+1 −1 examples/Bluetooth_5/NimBLE_extended_client/main/main.cpp
+2 −2 examples/Bluetooth_5/NimBLE_extended_server/main/main.cpp
+2 −2 examples/Bluetooth_5/NimBLE_multi_advertiser/main/main.cpp
+33 −21 examples/basic/BLE_client/main/main.cpp
+35 −26 examples/basic/BLE_notify/main/main.cpp
+38 −28 examples/basic/BLE_uart/main/main.cpp
+17 −0 package.json
+0 −4 src/NimBLE2904.cpp
+0 −3 src/NimBLE2904.h
+9 −0 src/NimBLEAddress.cpp
+1 −0 src/NimBLEAddress.h
+60 −4 src/NimBLEAdvertisedDevice.cpp
+6 −2 src/NimBLEAdvertisedDevice.h
+69 −17 src/NimBLEAdvertising.cpp
+11 −2 src/NimBLEAdvertising.h
+1 −0 src/NimBLEAttValue.h
+9 −4 src/NimBLECharacteristic.cpp
+105 −27 src/NimBLEClient.cpp
+14 −5 src/NimBLEClient.h
+17 −17 src/NimBLEConnInfo.h
+70 −15 src/NimBLEDevice.cpp
+5 −1 src/NimBLEDevice.h
+2 −2 src/NimBLEEddystoneTLM.cpp
+0 −3 src/NimBLEExtAdvertising.cpp
+47 −30 src/NimBLEHIDDevice.cpp
+1 −0 src/NimBLEHIDDevice.h
+9 −7 src/NimBLERemoteCharacteristic.cpp
+4 −3 src/NimBLERemoteCharacteristic.h
+10 −15 src/NimBLEScan.cpp
+14 −4 src/NimBLEScan.h
+42 −23 src/NimBLEServer.cpp
+16 −7 src/NimBLEServer.h
+13 −2 src/NimBLEService.cpp
+1 −1 src/NimBLEService.h
28 changes: 28 additions & 0 deletions Sming/Libraries/NimBLE/esp-nimble-cpp.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
diff --git a/src/NimBLEAttValue.h b/src/NimBLEAttValue.h
index 786bc8b..08b7e16 100644
--- a/src/NimBLEAttValue.h
+++ b/src/NimBLEAttValue.h
@@ -178,7 +178,7 @@ public:
#else
time_t getTimeStamp() const { return 0; }
void setTimeStamp() { }
- void setTimeStamp(time_t t) { }
+ void setTimeStamp(time_t) { }
#endif

/**
diff --git a/src/NimBLEUtils.h b/src/NimBLEUtils.h
index 006d935..8c8926e 100644
--- a/src/NimBLEUtils.h
+++ b/src/NimBLEUtils.h
@@ -13,7 +13,10 @@
#if defined(CONFIG_BT_ENABLED)

#if defined(CONFIG_NIMBLE_CPP_IDF)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
#include "host/ble_gap.h"
+#pragma GCC diagnostic pop
#else
#include "nimble/nimble/host/include/host/ble_gap.h"
#endif
Loading