Increased readability in onResult

Improved IF-syntaxis
This commit is contained in:
RobertoHE 2022-06-21 18:53:46 +02:00 committed by GitHub
parent 53e01392be
commit 39c16474b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 24 deletions

View File

@ -196,32 +196,34 @@ public:
protected:
void onResult(NimBLEAdvertisedDevice *advertisedDevice)
{
if (enableConnection) //not begin() or end()
if (!enableConnection) // not begin() or end()
{
DEBUGCLIENT("Advertised Device found: ");
DEBUGCLIENT(advertisedDevice->toString().c_str());
if (advertisedDevice->isAdvertisingService(NimBLEUUID(SERVICE_UUID)))
{
DEBUGCLIENT("Found MIDI Service");
if (!specificTarget || (advertisedDevice->getName() == nameTarget.c_str() || advertisedDevice->getAddress() == nameTarget))
{
/** Ready to connect now */
doConnect = true;
/** Save the device reference in a public variable that the client can use*/
advDevice = *advertisedDevice;
/** stop scan before connecting */
NimBLEDevice::getScan()->stop();
}
else
{
DEBUGCLIENT("Name error");
}
}
else
{
doConnect = false;
}
return;
}
DEBUGCLIENT("Advertised Device found: ");
DEBUGCLIENT(advertisedDevice->toString().c_str());
if (!advertisedDevice->isAdvertisingService(NimBLEUUID(SERVICE_UUID)))
{
doConnect = false;
return;
}
DEBUGCLIENT("Found MIDI Service");
if (!(!specificTarget || (advertisedDevice->getName() == nameTarget.c_str() || advertisedDevice->getAddress() == nameTarget)))
{
DEBUGCLIENT("Name error");
return;
}
/** Ready to connect now */
doConnect = true;
/** Save the device reference in a public variable that the client can use*/
advDevice = *advertisedDevice;
/** stop scan before connecting */
NimBLEDevice::getScan()->stop();
return;
};
};