Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fe67c72

Browse files
ci(pre-commit): Apply automatic fixes
1 parent 511c1d4 commit fe67c72

File tree

7 files changed

+40
-57
lines changed

7 files changed

+40
-57
lines changed

‎libraries/BLE/examples/Server_secure_static_passkey/Server_secure_static_passkey.ino

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,8 @@ void setup() {
8080
// Check the BLECharacteristic.h file for more information.
8181
secure_properties |= BLECharacteristic::PROPERTY_READ_ENC | BLECharacteristic::PROPERTY_WRITE_ENC;
8282

83-
BLECharacteristic *pSecureCharacteristic =
84-
pService->createCharacteristic(SECURE_CHARACTERISTIC_UUID, secure_properties);
85-
BLECharacteristic *pUnsecureCharacteristic =
86-
pService->createCharacteristic(UNSECURE_CHARACTERISTIC_UUID, unsecure_properties);
83+
BLECharacteristic *pSecureCharacteristic = pService->createCharacteristic(SECURE_CHARACTERISTIC_UUID, secure_properties);
84+
BLECharacteristic *pUnsecureCharacteristic = pService->createCharacteristic(UNSECURE_CHARACTERISTIC_UUID, unsecure_properties);
8785

8886
// Bluedroid uses permissions to secure characteristics.
8987
// This is the same as using the properties above.

‎libraries/BLE/src/BLECharacteristic.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -574,9 +574,7 @@ void BLECharacteristic::handleGATTServerEvent(esp_gatts_cb_event_t event, esp_ga
574574

575575
if (BLEDevice::m_securityCallbacks != nullptr) {
576576
log_i("Authorization required for write operation. Checking authorization...");
577-
authorized = BLEDevice::m_securityCallbacks->onAuthorizationRequest(
578-
param->write.conn_id, m_handle, false
579-
);
577+
authorized = BLEDevice::m_securityCallbacks->onAuthorizationRequest(param->write.conn_id, m_handle, false);
580578
} else {
581579
log_w("onAuthorizationRequest not implemented. Rejecting write authorization request");
582580
}
@@ -656,9 +654,7 @@ void BLECharacteristic::handleGATTServerEvent(esp_gatts_cb_event_t event, esp_ga
656654

657655
if (BLEDevice::m_securityCallbacks != nullptr) {
658656
log_i("Authorization required for read operation. Checking authorization...");
659-
authorized = BLEDevice::m_securityCallbacks->onAuthorizationRequest(
660-
param->read.conn_id, m_handle, true
661-
);
657+
authorized = BLEDevice::m_securityCallbacks->onAuthorizationRequest(param->read.conn_id, m_handle, true);
662658
} else {
663659
log_w("onAuthorizationRequest not implemented. Rejecting read authorization request");
664660
}

‎libraries/BLE/src/BLECharacteristic.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,14 @@ class BLECharacteristic {
140140

141141
#if defined(CONFIG_BLUEDROID_ENABLED)
142142
static const uint32_t PROPERTY_READ = 1 << 0;
143-
static const uint32_t PROPERTY_READ_ENC = 0; // Not supported by Bluedroid. Use setAccessPermissions() instead.
144-
static const uint32_t PROPERTY_READ_AUTHEN = 0; // Not supported by Bluedroid. Use setAccessPermissions() instead.
145-
static const uint32_t PROPERTY_READ_AUTHOR = 0; // Not supported by Bluedroid. Use setAccessPermissions() instead.
143+
static const uint32_t PROPERTY_READ_ENC = 0; // Not supported by Bluedroid. Use setAccessPermissions() instead.
144+
static const uint32_t PROPERTY_READ_AUTHEN = 0; // Not supported by Bluedroid. Use setAccessPermissions() instead.
145+
static const uint32_t PROPERTY_READ_AUTHOR = 0; // Not supported by Bluedroid. Use setAccessPermissions() instead.
146146
static const uint32_t PROPERTY_WRITE = 1 << 1;
147147
static const uint32_t PROPERTY_WRITE_NR = 1 << 5;
148-
static const uint32_t PROPERTY_WRITE_ENC = 0; // Not supported by Bluedroid. Use setAccessPermissions() instead.
149-
static const uint32_t PROPERTY_WRITE_AUTHEN = 0; // Not supported by Bluedroid. Use setAccessPermissions() instead.
150-
static const uint32_t PROPERTY_WRITE_AUTHOR = 0; // Not supported by Bluedroid. Use setAccessPermissions() instead.
148+
static const uint32_t PROPERTY_WRITE_ENC = 0; // Not supported by Bluedroid. Use setAccessPermissions() instead.
149+
static const uint32_t PROPERTY_WRITE_AUTHEN = 0; // Not supported by Bluedroid. Use setAccessPermissions() instead.
150+
static const uint32_t PROPERTY_WRITE_AUTHOR = 0; // Not supported by Bluedroid. Use setAccessPermissions() instead.
151151
static const uint32_t PROPERTY_NOTIFY = 1 << 2;
152152
static const uint32_t PROPERTY_BROADCAST = 1 << 3;
153153
static const uint32_t PROPERTY_INDICATE = 1 << 4;

‎libraries/BLE/src/BLEClient.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,7 @@ int BLEClient::handleGAPEvent(struct ble_gap_event *event, void *arg) {
10081008
break;
10091009
}
10101010

1011-
if(BLESecurity::m_securityEnabled) {
1011+
if(BLESecurity::m_securityEnabled) {
10121012
BLESecurity::startSecurity(client->m_conn_id);
10131013
}
10141014

@@ -1174,7 +1174,7 @@ int BLEClient::handleGAPEvent(struct ble_gap_event *event, void *arg) {
11741174
pkey.action = event->passkey.params.action;
11751175
pkey.passkey = BLESecurity::getPassKey(); // This is the passkey to be entered on peer
11761176

1177-
if(!BLESecurity::m_passkeySet) {
1177+
if(!BLESecurity::m_passkeySet) {
11781178
log_w("No passkey set");
11791179
}
11801180

‎libraries/BLE/src/BLEDevice.cpp

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -723,13 +723,10 @@ BLEStack BLEDevice::getBLEStack() {
723723

724724
String BLEDevice::getBLEStackString() {
725725
switch (getBLEStack()) {
726-
case BLEStack::BLUEDROID:
727-
return "Bluedroid";
728-
case BLEStack::NIMBLE:
729-
return "NimBLE";
726+
case BLEStack::BLUEDROID: return "Bluedroid";
727+
case BLEStack::NIMBLE: return "NimBLE";
730728
case BLEStack::UNKNOWN:
731-
default:
732-
return "Unknown";
729+
default: return "Unknown";
733730
}
734731
}
735732

@@ -829,7 +826,7 @@ void BLEDevice::gapEventHandler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_par
829826
case ESP_GAP_BLE_OOB_REQ_EVT: /* OOB request event */ log_i("ESP_GAP_BLE_OOB_REQ_EVT"); break;
830827
case ESP_GAP_BLE_LOCAL_IR_EVT: /* BLE local IR event */ log_i("ESP_GAP_BLE_LOCAL_IR_EVT"); break;
831828
case ESP_GAP_BLE_LOCAL_ER_EVT: /* BLE local ER event */ log_i("ESP_GAP_BLE_LOCAL_ER_EVT"); break;
832-
case ESP_GAP_BLE_NC_REQ_EVT: /* NUMERIC CONFIRMATION */
829+
case ESP_GAP_BLE_NC_REQ_EVT: /* NUMERIC CONFIRMATION */
833830
{
834831
log_i("ESP_GAP_BLE_NC_REQ_EVT");
835832
#ifdef CONFIG_BLE_SMP_ENABLE // Check that BLE SMP (security) is configured in make menuconfig
@@ -840,8 +837,7 @@ void BLEDevice::gapEventHandler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_par
840837
esp_ble_confirm_reply(param->ble_security.ble_req.bd_addr, false);
841838
}
842839
#endif // CONFIG_BLE_SMP_ENABLE
843-
}
844-
break;
840+
} break;
845841
case ESP_GAP_BLE_PASSKEY_REQ_EVT: /* passkey request event */
846842
{
847843
log_i("ESP_GAP_BLE_PASSKEY_REQ_EVT: ");
@@ -867,8 +863,7 @@ void BLEDevice::gapEventHandler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_par
867863

868864
esp_ble_passkey_reply(param->ble_security.ble_req.bd_addr, true, passkey);
869865
#endif // CONFIG_BLE_SMP_ENABLE
870-
}
871-
break;
866+
} break;
872867
/*
873868
* TODO should we add white/black list comparison?
874869
*/
@@ -885,8 +880,7 @@ void BLEDevice::gapEventHandler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_par
885880
esp_ble_gap_security_rsp(param->ble_security.ble_req.bd_addr, true);
886881
}
887882
#endif // CONFIG_BLE_SMP_ENABLE
888-
}
889-
break;
883+
} break;
890884
/*
891885
*
892886
*/
@@ -897,7 +891,7 @@ void BLEDevice::gapEventHandler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_par
897891
#ifdef CONFIG_BLE_SMP_ENABLE // Check that BLE SMP (security) is configured in make menuconfig
898892
uint32_t passkey = param->ble_security.key_notif.passkey;
899893

900-
if(!BLESecurity::m_passkeySet) {
894+
if(!BLESecurity::m_passkeySet) {
901895
log_w("No passkey set");
902896
}
903897

@@ -912,17 +906,15 @@ void BLEDevice::gapEventHandler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_par
912906
BLEDevice::m_securityCallbacks->onPassKeyNotify(passkey);
913907
}
914908
#endif // CONFIG_BLE_SMP_ENABLE
915-
}
916-
break;
909+
} break;
917910
case ESP_GAP_BLE_KEY_EVT:
918911
{
919912
//shows the ble key type info share with peer device to the user.
920913
log_d("ESP_GAP_BLE_KEY_EVT");
921914
#ifdef CONFIG_BLE_SMP_ENABLE // Check that BLE SMP (security) is configured in make menuconfig
922915
log_i("key type = %s", BLESecurity::esp_key_type_to_str(param->ble_security.ble_key.key_type));
923916
#endif // CONFIG_BLE_SMP_ENABLE
924-
}
925-
break;
917+
} break;
926918
case ESP_GAP_BLE_AUTH_CMPL_EVT:
927919
{
928920
log_i("ESP_GAP_BLE_AUTH_CMPL_EVT");
@@ -931,8 +923,7 @@ void BLEDevice::gapEventHandler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_par
931923
BLEDevice::m_securityCallbacks->onAuthenticationComplete(param->ble_security.auth_cmpl);
932924
}
933925
#endif // CONFIG_BLE_SMP_ENABLE
934-
}
935-
break;
926+
} break;
936927
default:
937928
{
938929
break;
@@ -964,8 +955,6 @@ void BLEDevice::setCustomGattsHandler(gatts_event_handler handler) {
964955
m_customGattsHandler = handler;
965956
}
966957

967-
968-
969958
#endif
970959

971960
/***************************************************************************

‎libraries/BLE/src/BLESecurity.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ uint32_t BLESecurity::setPassKey(bool staticPasskey, uint32_t passkey) {
149149
log_d("setPassKey: staticPasskey=%d, passkey=%d", staticPasskey, passkey);
150150
m_staticPasskey = staticPasskey;
151151

152-
if(m_staticPasskey) {
152+
if(m_staticPasskey) {
153153
m_passkey = passkey;
154-
if(m_passkey == BLE_SM_DEFAULT_PASSKEY) {
154+
if(m_passkey == BLE_SM_DEFAULT_PASSKEY) {
155155
log_w("*WARNING* Using default passkey: %06d", BLE_SM_DEFAULT_PASSKEY);
156156
log_w("*WARNING* Please use a random passkey or set a different static passkey");
157157
}
@@ -174,7 +174,7 @@ uint32_t BLESecurity::setPassKey(bool staticPasskey, uint32_t passkey) {
174174
// If using a random passkey, it will generate a new random passkey if m_regenOnConnect is true.
175175
// Otherwise, it will return the current passkey being used.
176176
uint32_t BLESecurity::getPassKey() {
177-
if(m_passkeySet && !m_staticPasskey && m_regenOnConnect) {
177+
if(m_passkeySet && !m_staticPasskey && m_regenOnConnect) {
178178
m_passkey = generateRandomPassKey();
179179
#if defined(CONFIG_BLUEDROID_ENABLED)
180180
esp_ble_gap_set_security_param(ESP_BLE_SM_SET_STATIC_PASSKEY, &m_passkey, sizeof(uint32_t));
@@ -197,8 +197,8 @@ void BLESecurity::setAuthenticationMode(bool bonding, bool mitm, bool sc) {
197197
m_securityEnabled = (m_authReq != 0);
198198
#if defined(CONFIG_BLUEDROID_ENABLED)
199199
esp_ble_gap_set_security_param(ESP_BLE_SM_AUTHEN_REQ_MODE, &m_authReq, sizeof(uint8_t));
200-
if(sc) {
201-
if(mitm) {
200+
if(sc) {
201+
if(mitm) {
202202
setEncryptionLevel(ESP_BLE_SEC_ENCRYPT_MITM);
203203
} else {
204204
setEncryptionLevel(ESP_BLE_SEC_ENCRYPT_NO_MITM);
@@ -252,7 +252,9 @@ bool BLESecurityCallbacks::onConfirmPIN(uint32_t pin) {
252252
// It should return true if the authorization is granted, false otherwise.
253253
bool BLESecurityCallbacks::onAuthorizationRequest(uint16_t connHandle, uint16_t attrHandle, bool isRead) {
254254
Serial.println("BLESecurityCallbacks: *ATTENTION* Using unsecure onAuthorizationRequest. It will accept any authorization request.");
255-
Serial.println("BLESecurityCallbacks: *ATTENTION* Please implement onAuthorizationRequest with a suitable authorization logic in your BLESecurityCallbacks class");
255+
Serial.println(
256+
"BLESecurityCallbacks: *ATTENTION* Please implement onAuthorizationRequest with a suitable authorization logic in your BLESecurityCallbacks class"
257+
);
256258
return true;
257259
}
258260

@@ -268,7 +270,7 @@ void BLESecurity::setEncryptionLevel(esp_ble_sec_act_t level) {
268270

269271
bool BLESecurity::startSecurity(esp_bd_addr_t bd_addr, int *rcPtr) {
270272
#ifdef CONFIG_BLE_SMP_ENABLE
271-
if(m_securityStarted) {
273+
if(m_securityStarted) {
272274
log_w("Security already started for bd_addr=%s", BLEAddress(bd_addr).toString().c_str());
273275
return true;
274276
}
@@ -320,7 +322,7 @@ void BLESecurityCallbacks::onAuthenticationComplete(esp_ble_auth_cmpl_t param) {
320322
#if defined(CONFIG_NIMBLE_ENABLED)
321323
// This function initiates security for a given connection handle.
322324
bool BLESecurity::startSecurity(uint16_t connHandle, int *rcPtr) {
323-
if(m_securityStarted) {
325+
if(m_securityStarted) {
324326
log_w("Security already started for connHandle=%d", connHandle);
325327
return true;
326328
}

‎libraries/BLE/src/BLEServer.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ int BLEServer::handleGATTServerEvent(struct ble_gap_event *event, void *arg) {
638638
server->m_pServerCallbacks->onConnect(server, &desc);
639639
}
640640

641-
if(BLESecurity::m_securityEnabled && BLESecurity::m_forceSecurity) {
641+
if(BLESecurity::m_securityEnabled && BLESecurity::m_forceSecurity) {
642642
BLESecurity::startSecurity(event->connect.conn_handle);
643643
}
644644

@@ -828,7 +828,7 @@ int BLEServer::handleGATTServerEvent(struct ble_gap_event *event, void *arg) {
828828
pkey.action = event->passkey.params.action;
829829
pkey.passkey = BLESecurity::getPassKey();
830830

831-
if(!BLESecurity::m_passkeySet) {
831+
if(!BLESecurity::m_passkeySet) {
832832
log_w("No passkey set");
833833
}
834834

@@ -915,18 +915,16 @@ int BLEServer::handleGATTServerEvent(struct ble_gap_event *event, void *arg) {
915915
{
916916
log_d("BLE_GAP_EVENT_AUTHORIZE");
917917

918-
log_i("Authorization request: conn_handle=%d attr_handle=%d is_read=%d",
919-
event->authorize.conn_handle,
920-
event->authorize.attr_handle,
921-
event->authorize.is_read);
918+
log_i(
919+
"Authorization request: conn_handle=%d attr_handle=%d is_read=%d", event->authorize.conn_handle, event->authorize.attr_handle, event->authorize.is_read
920+
);
922921

923922
bool authorized = false;
924923

925924
if (BLEDevice::m_securityCallbacks != nullptr) {
926925
log_i("Asking for authorization from onAuthorizationRequest");
927-
authorized = BLEDevice::m_securityCallbacks->onAuthorizationRequest(
928-
event->authorize.conn_handle, event->authorize.attr_handle, event->authorize.is_read
929-
);
926+
authorized =
927+
BLEDevice::m_securityCallbacks->onAuthorizationRequest(event->authorize.conn_handle, event->authorize.attr_handle, event->authorize.is_read);
930928
} else {
931929
log_w("onAuthorizationRequest not implemented. Rejecting authorization request");
932930
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /