Skip to content

Commit 0eca1c6

Browse files
ci(pre-commit): Apply automatic fixes
1 parent 6100cb5 commit 0eca1c6

23 files changed

+141
-163
lines changed

cores/esp32/esp32-hal-misc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
#endif
3131
#include <sys/time.h>
3232
#include "soc/rtc.h"
33-
#if !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6) && !defined(CONFIG_IDF_TARGET_ESP32H2) && !defined(CONFIG_IDF_TARGET_ESP32P4) && !defined(CONFIG_IDF_TARGET_ESP32C5)
33+
#if !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6) && !defined(CONFIG_IDF_TARGET_ESP32H2) && !defined(CONFIG_IDF_TARGET_ESP32P4) \
34+
&& !defined(CONFIG_IDF_TARGET_ESP32C5)
3435
#include "soc/rtc_cntl_reg.h"
3536
#include "soc/syscon_reg.h"
3637
#endif

libraries/BLE/src/BLE2902.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,26 @@ class BLE2902 : public BLEDescriptor {
4040

4141
// Class declaration for NimBLE (deprecated)
4242
#if defined(CONFIG_NIMBLE_ENABLED)
43-
class [[deprecated("NimBLE does not support manually adding 2902 descriptors as they \
43+
class [[deprecated("NimBLE does not support manually adding 2902 descriptors as they \
4444
are automatically added when the characteristic has notifications or indications enabled. \
4545
Get/Set the notifications/indications properties of the characteristic instead. \
4646
This class will be removed in a future version.")]] BLE2902 : public BLEDescriptor {
4747
#endif
4848

49-
public:
50-
/***************************************************************************
49+
public:
50+
/***************************************************************************
5151
* Common public functions *
5252
***************************************************************************/
5353

54-
BLE2902();
55-
bool getNotifications();
56-
bool getIndications();
57-
void setNotifications(bool flag);
58-
void setIndications(bool flag);
54+
BLE2902();
55+
bool getNotifications();
56+
bool getIndications();
57+
void setNotifications(bool flag);
58+
void setIndications(bool flag);
5959

60-
private:
61-
friend class BLECharacteristic;
62-
}; // BLE2902
60+
private:
61+
friend class BLECharacteristic;
62+
}; // BLE2902
6363

6464
#endif /* CONFIG_BLUEDROID_ENABLED || CONFIG_NIMBLE_ENABLED */
6565
#endif /* SOC_BLE_SUPPORTED */

libraries/BLE/src/BLE2904.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525

2626
#include "BLE2904.h"
2727

28-
#define BLE2904_UUID 0x2904
29-
#define BLE2904_DEFAULT_NAMESPACE 1 // 1 = Bluetooth SIG Assigned Numbers
30-
#define BLE2904_DEFAULT_UNIT 0x2700 // 0x2700 = Unitless
28+
#define BLE2904_UUID 0x2904
29+
#define BLE2904_DEFAULT_NAMESPACE 1 // 1 = Bluetooth SIG Assigned Numbers
30+
#define BLE2904_DEFAULT_UNIT 0x2700 // 0x2700 = Unitless
3131

3232
/***************************************************************************
3333
* Common functions *

libraries/BLE/src/BLEAdvertisedDevice.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
* Common includes *
2525
***************************************************************************/
2626

27-
2827
#include <sstream>
2928
#include "BLEAdvertisedDevice.h"
3029
#include "BLEUtils.h"
@@ -328,32 +327,32 @@ void BLEAdvertisedDevice::parseAdvertisement(uint8_t *payload, size_t total_len)
328327

329328
switch (ad_type) {
330329
case ESP_BLE_AD_TYPE_NAME_CMPL: // 0x09
331-
{ // Adv Data Type: ESP_BLE_AD_TYPE_NAME_CMPL
330+
{ // Adv Data Type: ESP_BLE_AD_TYPE_NAME_CMPL
332331
setName(String(reinterpret_cast<char *>(payload), length));
333332
break;
334333
} // 0x09
335334

336335
case ESP_BLE_AD_TYPE_TX_PWR: // 0x0A
337-
{ // Adv Data Type: ESP_BLE_AD_TYPE_TX_PWR
336+
{ // Adv Data Type: ESP_BLE_AD_TYPE_TX_PWR
338337
setTXPower(*payload);
339338
break;
340339
} // 0x0A
341340

342341
case ESP_BLE_AD_TYPE_APPEARANCE: // 0x19
343-
{ // Adv Data Type: ESP_BLE_AD_TYPE_APPEARANCE
342+
{ // Adv Data Type: ESP_BLE_AD_TYPE_APPEARANCE
344343
setAppearance(*reinterpret_cast<uint16_t *>(payload));
345344
break;
346345
} // 0x19
347346

348347
case ESP_BLE_AD_TYPE_FLAG: // 0x01
349-
{ // Adv Data Type: ESP_BLE_AD_TYPE_FLAG
348+
{ // Adv Data Type: ESP_BLE_AD_TYPE_FLAG
350349
setAdFlag(*payload);
351350
break;
352351
} // 0x01
353352

354353
case ESP_BLE_AD_TYPE_16SRV_PART: // 0x02
355354
case ESP_BLE_AD_TYPE_16SRV_CMPL: // 0x03
356-
{ // Adv Data Type: ESP_BLE_AD_TYPE_16SRV_PART/CMPL
355+
{ // Adv Data Type: ESP_BLE_AD_TYPE_16SRV_PART/CMPL
357356
for (int var = 0; var < length / 2; ++var) {
358357
setServiceUUID(BLEUUID(*reinterpret_cast<uint16_t *>(payload + var * 2)));
359358
}
@@ -362,21 +361,21 @@ void BLEAdvertisedDevice::parseAdvertisement(uint8_t *payload, size_t total_len)
362361

363362
case ESP_BLE_AD_TYPE_32SRV_PART: // 0x04
364363
case ESP_BLE_AD_TYPE_32SRV_CMPL: // 0x05
365-
{ // Adv Data Type: ESP_BLE_AD_TYPE_32SRV_PART/CMPL
364+
{ // Adv Data Type: ESP_BLE_AD_TYPE_32SRV_PART/CMPL
366365
for (int var = 0; var < length / 4; ++var) {
367366
setServiceUUID(BLEUUID(*reinterpret_cast<uint32_t *>(payload + var * 4)));
368367
}
369368
break;
370369
} // 0x04, 0x05
371370

372371
case ESP_BLE_AD_TYPE_128SRV_CMPL: // 0x07
373-
{ // Adv Data Type: ESP_BLE_AD_TYPE_128SRV_CMPL
372+
{ // Adv Data Type: ESP_BLE_AD_TYPE_128SRV_CMPL
374373
setServiceUUID(BLEUUID(payload, 16, false));
375374
break;
376375
} // 0x07
377376

378377
case ESP_BLE_AD_TYPE_128SRV_PART: // 0x06
379-
{ // Adv Data Type: ESP_BLE_AD_TYPE_128SRV_PART
378+
{ // Adv Data Type: ESP_BLE_AD_TYPE_128SRV_PART
380379
setServiceUUID(BLEUUID(payload, 16, false));
381380
break;
382381
} // 0x06
@@ -389,7 +388,7 @@ void BLEAdvertisedDevice::parseAdvertisement(uint8_t *payload, size_t total_len)
389388
} // 0xFF
390389

391390
case ESP_BLE_AD_TYPE_SERVICE_DATA: // 0x16
392-
{ // Adv Data Type: ESP_BLE_AD_TYPE_SERVICE_DATA - 2 byte UUID
391+
{ // Adv Data Type: ESP_BLE_AD_TYPE_SERVICE_DATA - 2 byte UUID
393392
if (length < 2) {
394393
log_e("Length too small for SERVICE_DATA");
395394
break;
@@ -403,7 +402,7 @@ void BLEAdvertisedDevice::parseAdvertisement(uint8_t *payload, size_t total_len)
403402
} // 0x16
404403

405404
case ESP_BLE_AD_TYPE_32SERVICE_DATA: // 0x20
406-
{ // Adv Data Type: ESP_BLE_AD_TYPE_32SERVICE_DATA - 4 byte UUID
405+
{ // Adv Data Type: ESP_BLE_AD_TYPE_32SERVICE_DATA - 4 byte UUID
407406
if (length < 4) {
408407
log_e("Length too small for 32SERVICE_DATA");
409408
break;
@@ -417,7 +416,7 @@ void BLEAdvertisedDevice::parseAdvertisement(uint8_t *payload, size_t total_len)
417416
} // 0x20
418417

419418
case ESP_BLE_AD_TYPE_128SERVICE_DATA: // 0x21
420-
{ // Adv Data Type: ESP_BLE_AD_TYPE_128SERVICE_DATA - 16 byte UUID
419+
{ // Adv Data Type: ESP_BLE_AD_TYPE_128SERVICE_DATA - 16 byte UUID
421420
if (length < 16) {
422421
log_e("Length too small for 128SERVICE_DATA");
423422
break;

libraries/BLE/src/BLECharacteristic.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* Common definitions *
3838
***************************************************************************/
3939

40-
#define NULL_HANDLE (0xffff)
40+
#define NULL_HANDLE (0xffff)
4141

4242
/***************************************************************************
4343
* NimBLE definitions *
@@ -927,8 +927,7 @@ int BLECharacteristic::handleGATTServerEvent(uint16_t conn_handle, uint16_t attr
927927
return 0;
928928
}
929929

930-
default:
931-
break;
930+
default: break;
932931
}
933932
}
934933

@@ -943,38 +942,38 @@ int BLECharacteristic::handleGATTServerEvent(uint16_t conn_handle, uint16_t attr
943942
*/
944943
void BLECharacteristic::setSubscribe(struct ble_gap_event *event) {
945944
ble_gap_conn_desc desc;
946-
if(ble_gap_conn_find(event->subscribe.conn_handle, &desc) != 0) {
945+
if (ble_gap_conn_find(event->subscribe.conn_handle, &desc) != 0) {
947946
return;
948947
}
949948

950949
uint16_t subVal = 0;
951-
if(event->subscribe.cur_notify > 0 && (m_properties & BLECharacteristic::PROPERTY_NOTIFY)) {
950+
if (event->subscribe.cur_notify > 0 && (m_properties & BLECharacteristic::PROPERTY_NOTIFY)) {
952951
subVal |= NIMBLE_SUB_NOTIFY;
953952
}
954-
if(event->subscribe.cur_indicate && (m_properties & BLECharacteristic::PROPERTY_INDICATE)) {
953+
if (event->subscribe.cur_indicate && (m_properties & BLECharacteristic::PROPERTY_INDICATE)) {
955954
subVal |= NIMBLE_SUB_INDICATE;
956955
}
957956

958957
log_i("New subscribe value for conn: %d val: %d", event->subscribe.conn_handle, subVal);
959958

960-
if(!event->subscribe.cur_indicate && event->subscribe.prev_indicate) {
959+
if (!event->subscribe.cur_indicate && event->subscribe.prev_indicate) {
961960
BLEDevice::getServer()->clearIndicateWait(event->subscribe.conn_handle);
962961
}
963962

964963
auto it = m_subscribedVec.begin();
965-
for(; it != m_subscribedVec.end(); ++it) {
966-
if((*it).first == event->subscribe.conn_handle) {
964+
for (; it != m_subscribedVec.end(); ++it) {
965+
if ((*it).first == event->subscribe.conn_handle) {
967966
break;
968967
}
969968
}
970969

971-
if(subVal > 0) {
972-
if(it == m_subscribedVec.end()) {
970+
if (subVal > 0) {
971+
if (it == m_subscribedVec.end()) {
973972
m_subscribedVec.push_back({event->subscribe.conn_handle, subVal});
974973
} else {
975974
(*it).second = subVal;
976975
}
977-
} else if(it != m_subscribedVec.end()) {
976+
} else if (it != m_subscribedVec.end()) {
978977
m_subscribedVec.erase(it);
979978
}
980979

@@ -1062,12 +1061,12 @@ void BLECharacteristic::notify(bool is_notification) {
10621061
log_w("- Truncating to %d bytes (maximum notify size)", _mtu - 3);
10631062
}
10641063

1065-
if(is_notification && (!(myPair.second & NIMBLE_SUB_NOTIFY))) {
1064+
if (is_notification && (!(myPair.second & NIMBLE_SUB_NOTIFY))) {
10661065
log_w("Sending notification to client subscribed to indications, sending indication instead");
10671066
is_notification = false;
10681067
}
10691068

1070-
if(!is_notification && (!(myPair.second & NIMBLE_SUB_INDICATE))) {
1069+
if (!is_notification && (!(myPair.second & NIMBLE_SUB_INDICATE))) {
10711070
log_w("Sending indication to client subscribed to notification, sending notification instead");
10721071
is_notification = true;
10731072
}
@@ -1129,7 +1128,7 @@ void BLECharacteristicCallbacks::onWrite(BLECharacteristic *pCharacteristic, ble
11291128
onWrite(pCharacteristic);
11301129
} // onWrite
11311130

1132-
void BLECharacteristicCallbacks::onSubscribe(BLECharacteristic* pCharacteristic, ble_gap_conn_desc* desc, uint16_t subValue) {
1131+
void BLECharacteristicCallbacks::onSubscribe(BLECharacteristic *pCharacteristic, ble_gap_conn_desc *desc, uint16_t subValue) {
11331132
log_d(">> onSubscribe: default");
11341133
log_d("<< onSubscribe");
11351134
} // onSubscribe

libraries/BLE/src/BLEClient.cpp

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ bool BLEClient::secureConnection() {
181181

182182
#if defined(CONFIG_NIMBLE_ENABLED)
183183
int retryCount = 1;
184-
BLETaskData taskData(const_cast<BLEClient*>(this), BLE_HS_ENOTCONN);
184+
BLETaskData taskData(const_cast<BLEClient *>(this), BLE_HS_ENOTCONN);
185185
m_pTaskData = &taskData;
186186

187187
do {
@@ -452,8 +452,8 @@ bool BLEClient::connect(BLEAddress address, uint8_t type, uint32_t timeoutMs) {
452452
errRc = ::esp_ble_gattc_open(
453453
m_gattc_if,
454454
getPeerAddress().getNative(), // address
455-
(esp_ble_addr_type_t)type, // Note: This was added on 2018-04-03 when the latest ESP-IDF was detected to have changed the signature.
456-
1 // direct connection <-- maybe needs to be changed in case of direct indirect connection???
455+
(esp_ble_addr_type_t)type, // Note: This was added on 2018-04-03 when the latest ESP-IDF was detected to have changed the signature.
456+
1 // direct connection <-- maybe needs to be changed in case of direct indirect connection???
457457
);
458458
if (errRc != ESP_OK) {
459459
log_e("esp_ble_gattc_open: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
@@ -866,12 +866,11 @@ bool BLEClient::connect(BLEAddress address, uint8_t type, uint32_t timeoutMs) {
866866
* When a service is found or there is none left or there was an error
867867
* the API will call this and report findings.
868868
*/
869-
int BLEClient::serviceDiscoveredCB(uint16_t conn_handle, const struct ble_gatt_error *error, const struct ble_gatt_svc *service, void *arg)
870-
{
869+
int BLEClient::serviceDiscoveredCB(uint16_t conn_handle, const struct ble_gatt_error *error, const struct ble_gatt_svc *service, void *arg) {
871870
log_d("Service Discovered >> status: %d handle: %d", error->status, (error->status == 0) ? service->start_handle : -1);
872871

873-
BLETaskData *pTaskData = (BLETaskData*)arg;
874-
BLEClient *client = (BLEClient*)pTaskData->m_pInstance;
872+
BLETaskData *pTaskData = (BLETaskData *)arg;
873+
BLEClient *client = (BLEClient *)pTaskData->m_pInstance;
875874

876875
if (error->status == BLE_HS_ENOTCONN) {
877876
log_e("<< Service Discovered; Disconnected");
@@ -880,13 +879,13 @@ int BLEClient::serviceDiscoveredCB(uint16_t conn_handle, const struct ble_gatt_e
880879
}
881880

882881
// Make sure the service discovery is for this device
883-
if(client->getConnId() != conn_handle){
882+
if (client->getConnId() != conn_handle) {
884883
return 0;
885884
}
886885

887-
if(error->status == 0) {
886+
if (error->status == 0) {
888887
// Found a service - add it to the vector
889-
BLERemoteService* pRemoteService = new BLERemoteService(client, service);
888+
BLERemoteService *pRemoteService = new BLERemoteService(client, service);
890889
client->m_servicesMap.insert(std::pair<std::string, BLERemoteService *>(pRemoteService->getUUID().toString().c_str(), pRemoteService));
891890
client->m_servicesMapByInstID.insert(std::pair<BLERemoteService *, uint16_t>(pRemoteService, service->start_handle));
892891
return 0;
@@ -1018,7 +1017,8 @@ int BLEClient::handleGAPEvent(struct ble_gap_event *event, void *arg) {
10181017
return 0;
10191018
} // BLE_GAP_EVENT_CONNECT
10201019

1021-
case BLE_GAP_EVENT_TERM_FAILURE: {
1020+
case BLE_GAP_EVENT_TERM_FAILURE:
1021+
{
10221022
if (client->m_conn_id != event->term_failure.conn_handle) {
10231023
return 0;
10241024
}
@@ -1030,7 +1030,7 @@ int BLEClient::handleGAPEvent(struct ble_gap_event *event, void *arg) {
10301030
ble_gap_terminate(event->term_failure.conn_handle, BLE_ERR_REM_USER_CONN_TERM);
10311031
}
10321032
return 0;
1033-
} // BLE_GAP_EVENT_TERM_FAILURE
1033+
} // BLE_GAP_EVENT_TERM_FAILURE
10341034

10351035
case BLE_GAP_EVENT_NOTIFY_RX:
10361036
{
@@ -1071,7 +1071,9 @@ int BLEClient::handleGAPEvent(struct ble_gap_event *event, void *arg) {
10711071

10721072
if (characteristic->second->m_notifyCallback != nullptr) {
10731073
log_d("Invoking callback for notification on characteristic %s", characteristic->second->toString().c_str());
1074-
characteristic->second->m_notifyCallback(characteristic->second, event->notify_rx.om->om_data, event->notify_rx.om->om_len, !event->notify_rx.indication);
1074+
characteristic->second->m_notifyCallback(
1075+
characteristic->second, event->notify_rx.om->om_data, event->notify_rx.om->om_len, !event->notify_rx.indication
1076+
);
10751077
}
10761078
break;
10771079
}
@@ -1234,7 +1236,7 @@ int BLEClient::disconnect(uint8_t reason) {
12341236
log_d(">> disconnect()");
12351237
int rc = 0;
12361238

1237-
if(isConnected()) {
1239+
if (isConnected()) {
12381240
rc = ble_gap_terminate(m_conn_id, reason);
12391241
if (rc != 0 && rc != BLE_HS_ENOTCONN && rc != BLE_HS_EALREADY) {
12401242
m_lastErr = rc;
@@ -1246,23 +1248,23 @@ int BLEClient::disconnect(uint8_t reason) {
12461248

12471249
log_d("<< disconnect()");
12481250
return rc;
1249-
} // disconnect
1251+
} // disconnect
12501252

12511253
bool BLEClientCallbacks::onConnParamsUpdateRequest(BLEClient *pClient, const ble_gap_upd_params *params) {
12521254
log_d("BLEClientCallbacks", "onConnParamsUpdateRequest: default");
12531255
return true;
12541256
}
12551257

1256-
uint32_t BLEClientCallbacks::onPassKeyRequest(){
1258+
uint32_t BLEClientCallbacks::onPassKeyRequest() {
12571259
log_d("onPassKeyRequest: default: 123456");
12581260
return 123456;
12591261
}
12601262

1261-
void BLEClientCallbacks::onAuthenticationComplete(ble_gap_conn_desc* desc){
1263+
void BLEClientCallbacks::onAuthenticationComplete(ble_gap_conn_desc *desc) {
12621264
log_d("onAuthenticationComplete: default");
12631265
}
12641266

1265-
bool BLEClientCallbacks::onConfirmPIN(uint32_t pin){
1267+
bool BLEClientCallbacks::onConfirmPIN(uint32_t pin) {
12661268
log_d("onConfirmPIN: default: true");
12671269
return true;
12681270
}

libraries/BLE/src/BLEClient.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,7 @@ class BLEClient {
121121

122122
#if defined(CONFIG_NIMBLE_ENABLED)
123123
static int handleGAPEvent(struct ble_gap_event *event, void *arg);
124-
static int serviceDiscoveredCB(uint16_t conn_handle,
125-
const struct ble_gatt_error *error,
126-
const struct ble_gatt_svc *service,
127-
void *arg);
124+
static int serviceDiscoveredCB(uint16_t conn_handle, const struct ble_gatt_error *error, const struct ble_gatt_svc *service, void *arg);
128125
#endif
129126

130127
private:
@@ -213,7 +210,7 @@ class BLEClientCallbacks {
213210
#if defined(CONFIG_NIMBLE_ENABLED)
214211
virtual bool onConnParamsUpdateRequest(BLEClient *pClient, const ble_gap_upd_params *params);
215212
virtual uint32_t onPassKeyRequest();
216-
virtual void onAuthenticationComplete(ble_gap_conn_desc* desc);
213+
virtual void onAuthenticationComplete(ble_gap_conn_desc *desc);
217214
virtual bool onConfirmPIN(uint32_t pin);
218215
#endif
219216
};

libraries/BLE/src/BLEDescriptorMap.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ String BLEDescriptorMap::toString() {
149149
return res;
150150
} // toString
151151

152-
153152
/**
154153
* @brief Get the first descriptor in the map.
155154
* @return The first descriptor in the map.

0 commit comments

Comments
 (0)